23 #include <QAbstractItemDelegate>
28 #include "../vfileproperty_p.h"
30 #include "../vproperty_p.h"
58 d_ptr->VariantValue.setValue(file);
64 return d_ptr->VariantValue.toString();
70 if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
72 QFileInfo tmpFile(d_ptr->VariantValue.toString());
73 return tmpFile.fileName();
81 const QAbstractItemDelegate* delegate)
88 VFileEditWidget::connect(tmpWidget, SIGNAL(commitData(QWidget*)), delegate, SIGNAL(commitData(QWidget*)));
91 tmpWidget->setLocale(parent->locale());
93 tmpWidget->
setFile(d_ptr->VariantValue.toString());
104 tmpWidget->
setFile(d_ptr->VariantValue.toString());
115 const VFileEditWidget* tmpWidget = qobject_cast<const VFileEditWidget*>(editor);
126 if (key ==
"FileFilters")
128 setFileFilters(value.toString());
130 else if (key ==
"Directory")
132 setDirectory(value.toBool());
138 if (key ==
"FileFilters")
140 return getFileFilters();
142 else if (key ==
"Directory")
144 return isDirectory();
152 return QStringList(
"FileFilters") <<
"Directory";
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &options, const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE
Returns an editor widget, or NULL if it doesn't supply one.
virtual QString getFileFilters() const
Returns the current file filters as a string.
virtual bool isDirectory() const
Returns whether this is a file (false) or a directory (true)
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
virtual ~VFileProperty() Q_DECL_OVERRIDE
The destructor.
VFileProperty(const QString &name)
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Get the data how it should be displayed.
virtual QVariant getSetting(const QString &key) const Q_DECL_OVERRIDE
Get the settings. This function has to be implemented in a subclass in order to have an effect.
virtual void setDirectory(bool is_directory)
Sets whether this is a file (false) or a directory (true)
virtual bool setEditorData(QWidget *editor) Q_DECL_OVERRIDE
Sets the property's data to the editor (returns false, if the standard delegate should do that)
virtual void setFile(const QString &file)
Set file.
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE
Sets the settings. Available settings:
virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE
Returns the list of keys of the property's settings.
virtual void setFileFilters(const QString &filefilters)
Sets the file filters. The file filters have to be like the ones passed a QFileOpenDialog.
virtual QString getFile() const
Get file.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const
Clones this property.
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const
Get the data how it should be displayed.
virtual QVariant getSetting(const QString &key) const
Get the settings. This function has to be implemented in a subclass in order to have an effect.