VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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. More...

Inheritance diagram for makVrv::DtFileWidgetDelegate:
Inheritance graph
[legend]

Public Member Functions

 DtFileWidgetDelegate (DtDe &de, QObject *parent=NULL)
 Default CTOR.
virtual ~DtFileWidgetDelegate ()
 Virtual DTOR.
void setCaption (const QString &cap=QString(""))
 Set the caption for the file browser.
void addFileTypeFilter (const QString &name, const QString &ext)
 Add a file-type filter.
QString fileTypeFilterString () const
 Get the full file-type filter string.

Static Public Member Functions

static QString generateFileFilterItem (const QString &name, const QString &ext)
 Helper function to create a single filter item to be included in a file-type filter string.
static std::string rootDirectory ()
 Get the root directory (where the application runs from).
static std::string lastDirectory (const std::string &ext="")
 Get the last directory visited.
static void setDataDirectory (const std::string &ext, const std::string &dir)
 Register a data keyed from an extension.

Protected Types

typedef std::map< std::string,
std::string > 
ExtDirMap
 Map of absolute data directories keyed off of extensions.

Protected Member Functions

virtual QWidgetcreateEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
 Create the editor for this delegate.
virtual QString displayText (const QVariant &value, const QLocale &locale) const
 Display an empty string as "<none>" meaning no file selected.

Protected Attributes

DtDemyDe
 The display engine.
QString myCaption
 The caption for the browser dialog.
QMap< QString, QString > myFilters
 The map of file filter strings keyed off the file-type name.

Static Protected Attributes

static std::string RootPath
 The absolute root (were the application was run from).
static std::string LastDirectory
 The absolute data directory (were the data files are stored).
static ExtDirMap LastDirectories

Detailed Description

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.

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 Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)