Seamly2D
Code documentation
venumproperty.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file venumproperty.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 VENUMPROPERTY_H
22 #define VENUMPROPERTY_H
23 
24 #include <qcompilerdetection.h>
25 #include <QMetaObject>
26 #include <QObject>
27 #include <QString>
28 #include <QStringList>
29 #include <QStyleOptionViewItem>
30 #include <QVariant>
31 #include <Qt>
32 #include <QtGlobal>
33 
34 #include "../vproperty.h"
35 
36 namespace VPE
37 {
38 
39 class VEnumProperty : public VProperty
40 {
41  Q_OBJECT
42 public:
43  //! Constructor
44  explicit VEnumProperty(const QString& name);
45 
46  //! Destructor
47  virtual ~VEnumProperty() Q_DECL_OVERRIDE {}
48 
49  //! Get the data how it should be displayed
50  virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
51 
52  //! Returns an editor widget, or NULL if it doesn't supply one
53  //! \param parent The widget to which the editor will be added as a child
54  //! \options Render options
55  //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
56  //! slots.
57  virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
58  const QAbstractItemDelegate* delegate) Q_DECL_OVERRIDE;
59 
60  //! Gets the data from the widget
61  virtual QVariant getEditorData(const QWidget* editor) const Q_DECL_OVERRIDE;
62 
63  //! Sets the enumeration literals
64  virtual void setLiterals(const QStringList &literals);
65 
66  //! Get the settings. This function has to be implemented in a subclass in order to have an effect
67  virtual QStringList getLiterals() const;
68 
69  //! Sets the value of the property
70  virtual void setValue(const QVariant& value) Q_DECL_OVERRIDE;
71 
72  //! Returns a string containing the type of the property
73  virtual QString type() const Q_DECL_OVERRIDE;
74 
75  //! Clones this property
76  //! \param include_children Indicates whether to also clone the children
77  //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
78  //! to fill all the data into container. This can also be used when subclassing this function.
79  //! \return Returns the newly created property (or container, if it was not NULL)
80  Q_REQUIRED_RESULT virtual VProperty* clone(bool include_children = true,
81  VProperty* container = nullptr) const Q_DECL_OVERRIDE;
82 
83  //! Sets the settings. Available settings:
84  //!
85  //! key: "literals" - value: "item1;;item2;;item3"
86  virtual void setSetting(const QString& key, const QVariant& value) Q_DECL_OVERRIDE;
87 
88  //! Get the settings. This function has to be implemented in a subclass in order to have an effect
89  virtual QVariant getSetting(const QString& key) const Q_DECL_OVERRIDE;
90 
91  //! Returns the list of keys of the property's settings
92  virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE;
93 
94 public slots:
95  void currentIndexChanged(int index);
96 
97 protected:
98  //! The list of possible options to choose from
99  QStringList EnumerationLiterals;
100  // No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other
101  //members by reimplementing the VPropertyPrivate class without touching this header file.
102 private:
103  Q_DISABLE_COPY(VEnumProperty)
104 };
105 
106 }
107 
108 #endif // VENUMPROPERTY_H
void currentIndexChanged(int index)
virtual QStringList getLiterals() const
Get the settings. This function has to be implemented in a subclass in order to have an effect.
virtual ~VEnumProperty() Q_DECL_OVERRIDE
Destructor.
Definition: venumproperty.h:47
virtual void setValue(const QVariant &value) Q_DECL_OVERRIDE
Sets the value of the property.
virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE
Returns the list of keys of the property's settings.
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Get the data how it should be displayed.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE
Sets the settings. Available settings:
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
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 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.
VEnumProperty(const QString &name)
Constructor.
QStringList EnumerationLiterals
The list of possible options to choose from.
Definition: venumproperty.h:99
virtual void setLiterals(const QStringList &literals)
Sets the enumeration literals.