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.
|
typedef std::map< std::string,
std::string > | ExtDirMap |
| |
|
| virtual QWidget * | createEditor (QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const |
| |
| virtual QString | displayText (const QVariant &value, const QLocale &locale) const |
| |
Map of absolute data directories keyed off of extensions.
| 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 |
| 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. |
| 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: