VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes
makVrv::DtFileWidgetDelegate Class Reference

A custom delegate for the file field to allow editing with the use of a file browser in a Qt item view (e.g. a QTableView or QTreeView).

Note
Do not share instances of delegates between widgets.
Inheritance diagram for makVrv::DtFileWidgetDelegate:
Inheritance graph
[legend]

Public Member Functions

 DtFileWidgetDelegate (DtDe &de, QObject *parent=NULL)
 
virtual ~DtFileWidgetDelegate ()
 
void setCaption (const QString &cap=QString(""))
 
void addFileTypeFilter (const QString &name, const QString &ext)
 
QString fileTypeFilterString () const
 

Static Public Member Functions

static QString generateFileFilterItem (const QString &name, const QString &ext)
 
static std::string rootDirectory ()
 
static std::string lastDirectory (const std::string &ext="")
 
static void setDataDirectory (const std::string &ext, const std::string &dir)
 

Protected Types

typedef std::map< std::string,
std::string > 
ExtDirMap
 

Protected Member Functions

virtual QWidget * createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
 
virtual QString displayText (const QVariant &value, const QLocale &locale) const
 

Protected Attributes

DtDemyDe
 
QString myCaption
 
QMap< QString, QString > myFilters
 

Static Protected Attributes

static std::string RootPath
 
static std::string LastDirectory
 
static ExtDirMap LastDirectories
 

Member Typedef Documentation

typedef std::map<std::string, std::string> makVrv::DtFileWidgetDelegate::ExtDirMap
protected

Map of absolute data directories keyed off of extensions.

Constructor & Destructor Documentation

makVrv::DtFileWidgetDelegate::DtFileWidgetDelegate ( DtDe de,
QObject parent = NULL 
)

Default CTOR.

Parameters
[in]deis the display engine.
[in]parentis the owner of this delegate.
virtual makVrv::DtFileWidgetDelegate::~DtFileWidgetDelegate ( )
virtual

Virtual DTOR.

Member Function Documentation

void makVrv::DtFileWidgetDelegate::setCaption ( const QString &  cap = QString(""))

Set the caption for the file browser.

Parameters
[in]capis the caption, default is "Open File".
Note
Passing an empty string will reset the caption to the default.
void makVrv::DtFileWidgetDelegate::addFileTypeFilter ( const QString &  name,
const QString &  ext 
)

Add a file-type filter.

Parameters
[in]nameis the name of the type of file to filter on, e.g. "Image File" or "Sound File".
[in]extis the file-type extension to filter on, e.g. "rgb" or "wav".
QString makVrv::DtFileWidgetDelegate::fileTypeFilterString ( ) const

Get the full file-type filter string.

Returns
The fully constructed filter string.
static QString makVrv::DtFileWidgetDelegate::generateFileFilterItem ( const QString &  name,
const QString &  ext 
)
static

Helper function to create a single filter item to be included in a file-type filter string.

ex. generateFileFilterItem( "Image File", "rgb" ); returns "Image File (*.rgb)"

Parameters
[in]nameis the name of the type of file to filter on, e.g. "Image File" or "Sound File".
[in]extis the file-type extension to filter on, e.g. "rgb" or "wav".
Note
If either value is empty an empty string is returned.
static std::string makVrv::DtFileWidgetDelegate::rootDirectory ( )
static

Get the root directory (where the application runs from).

Returns
the root directory.
static std::string makVrv::DtFileWidgetDelegate::lastDirectory ( const std::string &  ext = "")
static

Get the last directory visited.

Parameters
[in]extis the file extension to search for the last directory. If ext is an empty string, or the extension was never used the last directory from any browser is returned.
Returns
the last director for the given extension or the last directory from any browser.
static void makVrv::DtFileWidgetDelegate::setDataDirectory ( const std::string &  ext,
const std::string &  dir 
)
static

Register a data keyed from an extension.

Parameters
[in]extis the file extension to register the data directory.
[in]diris the directory to register.
Note
If extension or directory are invalid, or directory does not exist, the directory will not be registered.
virtual QWidget* makVrv::DtFileWidgetDelegate::createEditor ( QWidget *  parent,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const
protectedvirtual

Create the editor for this delegate. Reimplemented from QStyledItemDelegate::createEditor().

Parameters
[in]parentis the parent widget for this delegate.
[in]optionis the display options (not used).
[in]indexis the model index to the view.
Returns
The editor for editing the data (a file-browser).
virtual QString makVrv::DtFileWidgetDelegate::displayText ( const QVariant &  value,
const QLocale &  locale 
) const
protectedvirtual

Display an empty string as "<none>" meaning no file selected. Reimplemented from QStyledItemDelegate::displayText().

Parameters
[in]valueis the value to be displayed (a QString).
[in]localeis a regional converter between string and numbers.

Member Data Documentation

std::string makVrv::DtFileWidgetDelegate::RootPath
staticprotected

The absolute root (were the application was run from).

std::string makVrv::DtFileWidgetDelegate::LastDirectory
staticprotected

The absolute data directory (were the data files are stored).

ExtDirMap makVrv::DtFileWidgetDelegate::LastDirectories
staticprotected
DtDe& makVrv::DtFileWidgetDelegate::myDe
protected

The display engine.

QString makVrv::DtFileWidgetDelegate::myCaption
protected

The caption for the browser dialog.

QMap<QString, QString> makVrv::DtFileWidgetDelegate::myFilters
protected

The map of file filter strings keyed off the file-type name.


The documentation for this class was generated from the following file:

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)