Seamly2D
Code documentation
vstringproperty.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vstringproperty.h
4  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
5  ** @date 27 8, 2014
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 VSTRINGPROPERTY_H
22 #define VSTRINGPROPERTY_H
23 
24 #include <qcompilerdetection.h>
25 #include <QMap>
26 #include <QMetaObject>
27 #include <QObject>
28 #include <QString>
29 #include <QStringList>
30 #include <QStyleOptionViewItem>
31 #include <QVariant>
32 #include <QtGlobal>
33 
34 #include "../vproperty.h"
35 
36 namespace VPE
37 {
38 
39 
40 //! Class for holding a string property
41 class VStringProperty : public VProperty
42 {
43  Q_OBJECT
44 public:
45  VStringProperty(const QString &name, const QMap<QString, QVariant> &settings);
46 
47  explicit VStringProperty(const QString &name);
48 
49  //! Returns an editor widget, or NULL if it doesn't supply one
50  //! \param parent The widget to which the editor will be added as a child
51  //! \options Render options
52  //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
53  //! slots.
54  virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &options,
55  const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE;
56 
57  //! Gets the data from the widget
58  virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE;
59 
60  void setReadOnly(bool readOnly);
61  void setOsSeparator(bool separator);
62  void setClearButtonEnable(bool value);
63 
64  //! Sets the settings.
65  virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE;
66 
67  //! Get the settings. This function has to be implemented in a subclass in order to have an effect
68  virtual QVariant getSetting(const QString &key) const Q_DECL_OVERRIDE;
69 
70  //! Returns the list of keys of the property's settings
71  virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE;
72 
73  //! Returns a string containing the type of the property
74  virtual QString type() const Q_DECL_OVERRIDE;
75 
76  //! Clones this property
77  //! \param include_children Indicates whether to also clone the children
78  //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
79  //! to fill all the data into container. This can also be used when subclassing this function.
80  //! \return Returns the newly created property (or container, if it was not NULL)
81  Q_REQUIRED_RESULT virtual VProperty *clone(bool include_children = true,
82  VProperty *container = nullptr) const Q_DECL_OVERRIDE;
83 
84  virtual void updateParent(const QVariant &value) Q_DECL_OVERRIDE;
85 
86  int getTypeForParent() const;
87  void setTypeForParent(int value);
88 
89 protected:
90  bool readOnly;
94 
95  virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
96 
97 private:
98  Q_DISABLE_COPY(VStringProperty)
99 };
100 
101 }
102 #endif // VSTRINGPROPERTY_H
Class for holding a string property.
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
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.
void setTypeForParent(int value)
void setReadOnly(bool readOnly)
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.
void setOsSeparator(bool separator)
virtual void updateParent(const QVariant &value) Q_DECL_OVERRIDE
virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE
Returns the list of keys of the property's settings.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
void setClearButtonEnable(bool value)
virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE
Sets the settings.
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE
VStringProperty(const QString &name, const QMap< QString, QVariant > &settings)