Seamly2D
Code documentation
vboolproperty.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vboolproperty.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 VBOOLPROPERTY_H
22 #define VBOOLPROPERTY_H
23 
24 #include <qcompilerdetection.h>
25 #include <stddef.h>
26 #include <QMetaObject>
27 #include <QObject>
28 #include <QString>
29 #include <QVariant>
30 #include <Qt>
31 #include <QtGlobal>
32 
33 #include "../vproperty.h"
34 
35 namespace VPE
36 {
37 
38 //! The VBoolProperty can take two states: True or False.
39 class VBoolProperty : public VProperty
40 {
41  Q_OBJECT
42 public:
43  //! Default constructor
44  explicit VBoolProperty(const QString& name);
45 
46  //! Destructor
47  virtual ~VBoolProperty() 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  //! This is used by the model to set the data
53  //! \param data The data to set
54  //! \param role The role. Default is Qt::EditRole
55  //! \return Returns true, if the data was changed, false if not.
56  virtual bool setData (const QVariant& data, int role = Qt::EditRole) Q_DECL_OVERRIDE;
57 
58  //! Returns item flags
59  virtual Qt::ItemFlags flags(int column = DPC_Name) const Q_DECL_OVERRIDE;
60 
61  //! Returns a string containing the type of the property
62  virtual QString type() const Q_DECL_OVERRIDE;
63 
64  //! Clones this property
65  //! \param include_children Indicates whether to also clone the children
66  //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
67  //! to fill all the data into container. This can also be used when subclassing this function.
68  //! \return Returns the newly created property (or container, if it was not NULL)
69  virtual VProperty* clone(bool include_children = true, VProperty* container = NULL) const Q_DECL_OVERRIDE;
70 
71 protected:
72  //! The (translatable) text displayed when the property is set to true (default: "True")
73  static QVariant TrueText;
74 
75  //! The (translatable) text displayed when the property is set to false (default: "False")
76  static QVariant FalseText;
77 
78 private:
79  Q_DISABLE_COPY(VBoolProperty)
80 };
81 
82 }
83 
84 #endif // VBOOLPROPERTY_H
The VBoolProperty can take two states: True or False.
Definition: vboolproperty.h:40
virtual bool setData(const QVariant &data, int role=Qt::EditRole) Q_DECL_OVERRIDE
This is used by the model to set the data.
virtual ~VBoolProperty() Q_DECL_OVERRIDE
Destructor.
Definition: vboolproperty.h:47
virtual VProperty * clone(bool include_children=true, VProperty *container=NULL) const Q_DECL_OVERRIDE
Clones this property.
virtual Qt::ItemFlags flags(int column=DPC_Name) const Q_DECL_OVERRIDE
Returns item flags.
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
static QVariant FalseText
The (translatable) text displayed when the property is set to false (default: "False")
Definition: vboolproperty.h:76
VBoolProperty(const QString &name)
Default constructor.
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Get the data how it should be displayed.
static QVariant TrueText
The (translatable) text displayed when the property is set to true (default: "True")
Definition: vboolproperty.h:73