Seamly2D
Code documentation
vfileproperty.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vfileproperty.h
4  ** @author hedgeware <internal(at)hedgeware.net>
5  ** @date
6  **
7  ** @brief
8  ** @copyright
9  ** All rights reserved. This program and the accompanying materials
10  ** are made available under the terms of the GNU Lesser General Public License
11  ** (LGPL) version 2.1 which accompanies this distribution, and is available at
12  ** http://www.gnu.org/licenses/lgpl-2.1.html
13  **
14  ** This library is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  ** Lesser General Public License for more details.
18  **
19  *************************************************************************/
20 
21 #ifndef VFILEPROPERTY_H
22 #define VFILEPROPERTY_H
23 
24 #include <qcompilerdetection.h>
25 #include <QMetaObject>
26 #include <QObject>
27 #include <QPointer>
28 #include <QString>
29 #include <QStringList>
30 #include <QStyleOptionViewItem>
31 #include <QVariant>
32 #include <Qt>
33 #include <QtGlobal>
34 
35 #include "../vproperty.h"
36 
37 namespace VPE
38 {
39 
40 class VFileProperty : public VProperty
41 {
42  Q_OBJECT
43 public:
44  explicit VFileProperty(const QString &name);
45 
46  //! The destructor
47  virtual ~VFileProperty() Q_DECL_OVERRIDE;
48 
49  //! Sets the file filters. The file filters have to be like the ones passed a QFileOpenDialog.
50  virtual void setFileFilters(const QString& filefilters);
51 
52  //! Returns the current file filters as a string
53  virtual QString getFileFilters() const;
54 
55  //! Set file
56  virtual void setFile(const QString& file);
57 
58  //! Get file
59  virtual QString getFile() const;
60 
61  //! Get the data how it should be displayed
62  virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
63 
64  //! Returns an editor widget, or NULL if it doesn't supply one
65  //! \param parent The widget to which the editor will be added as a child
66  //! \options Render options
67  //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
68  //! slots.
69  virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
70  const QAbstractItemDelegate* delegate) Q_DECL_OVERRIDE;
71 
72  //! Sets the property's data to the editor (returns false, if the standard delegate should do that)
73  virtual bool setEditorData(QWidget* editor) Q_DECL_OVERRIDE;
74 
75  //! Gets the data from the widget
76  virtual QVariant getEditorData(const QWidget* editor) const Q_DECL_OVERRIDE;
77 
78  //! Sets the settings. Available settings:
79  //!
80  //! key: "FileFilters" - value: File filters in the same format the QFileDialog expects it
81  virtual void setSetting(const QString& key, const QVariant& value) Q_DECL_OVERRIDE;
82 
83  //! Get the settings. This function has to be implemented in a subclass in order to have an effect
84  virtual QVariant getSetting(const QString& key) const Q_DECL_OVERRIDE;
85 
86  //! Returns the list of keys of the property's settings
87  virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE;
88 
89  //! Returns a string containing the type of the property
90  virtual QString type() const Q_DECL_OVERRIDE;
91 
92  //! Clones this property
93  //! \param include_children Indicates whether to also clone the children
94  //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
95  //! to fill all the data into container. This can also be used when subclassing this function.
96  //! \return Returns the newly created property (or container, if it was not NULL)
97  Q_REQUIRED_RESULT virtual VProperty* clone(bool include_children = true,
98  VProperty* container = nullptr) const Q_DECL_OVERRIDE;
99 
100  //! Returns whether this is a file (false) or a directory (true)
101  virtual bool isDirectory() const;
102 
103  //! Sets whether this is a file (false) or a directory (true)
104  virtual void setDirectory(bool is_directory);
105 
106 private:
107  Q_DISABLE_COPY(VFileProperty)
108 };
109 
110 }
111 
112 #endif // VFILEPROPERTY_H
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.