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...
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 QWidget * | createEditor (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 |
| DtDe & | myDe |
| | 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
Map of absolute data directories keyed off of extensions.
Constructor & Destructor Documentation
| makVrv::DtFileWidgetDelegate::DtFileWidgetDelegate |
( |
DtDe & |
de, |
|
|
QObject * |
parent = NULL |
|
) |
| |
Default CTOR.
- Parameters
-
| [in] | de | is the display engine. |
| [in] | parent | is the owner of this delegate. |
| virtual makVrv::DtFileWidgetDelegate::~DtFileWidgetDelegate |
( |
| ) |
|
|
virtual |
Member Function Documentation
| void makVrv::DtFileWidgetDelegate::setCaption |
( |
const QString & |
cap = QString("") | ) |
|
Set the caption for the file browser.
- Parameters
-
| [in] | cap | is 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] | name | is the name of the type of file to filter on, e.g. "Image File" or "Sound File". |
| [in] | ext | is 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] | name | is the name of the type of file to filter on, e.g. "Image File" or "Sound File". |
| [in] | ext | is 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] | ext | is 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] | ext | is the file extension to register the data directory. |
| [in] | dir | is 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] | parent | is the parent widget for this delegate. |
| [in] | option | is the display options (not used). |
| [in] | index | is 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] | value | is the value to be displayed (a QString). |
| [in] | locale | is 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 |
| 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: