Seamly2D
Code documentation
vlabelproperty.h
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D 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
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file vlabelproperty.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 18 3, 2017
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2017 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #ifndef VLABELPROPERTY_H
53 #define VLABELPROPERTY_H
54 
55 #include <qcompilerdetection.h>
56 #include <QMap>
57 #include <QMetaObject>
58 #include <QObject>
59 #include <QString>
60 #include <QStringList>
61 #include <QStyleOptionViewItem>
62 #include <QVariant>
63 #include <QtGlobal>
64 
65 #include "../vproperty.h"
66 
67 namespace VPE
68 {
69 
70 
71 //! Class for holding a string property
72 class VLabelProperty : public VProperty
73 {
74  Q_OBJECT
75 public:
76  VLabelProperty(const QString &name, const QMap<QString, QVariant> &settings);
77 
78  explicit VLabelProperty(const QString &name);
79 
80  //! Returns an editor widget, or NULL if it doesn't supply one
81  //! \param parent The widget to which the editor will be added as a child
82  //! \options Render options
83  //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
84  //! slots.
85  virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &options,
86  const QAbstractItemDelegate *delegate) Q_DECL_OVERRIDE;
87 
88  //! Gets the data from the widget
89  virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE;
90 
91  //! Sets the settings.
92  virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE;
93 
94  //! Get the settings. This function has to be implemented in a subclass in order to have an effect
95  virtual QVariant getSetting(const QString &key) const Q_DECL_OVERRIDE;
96 
97  //! Returns the list of keys of the property's settings
98  virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE;
99 
100  //! Returns a string containing the type of the property
101  virtual QString type() const Q_DECL_OVERRIDE;
102 
103  //! Clones this property
104  //! \param include_children Indicates whether to also clone the children
105  //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
106  //! to fill all the data into container. This can also be used when subclassing this function.
107  //! \return Returns the newly created property (or container, if it was not NULL)
108  Q_REQUIRED_RESULT virtual VProperty *clone(bool include_children = true,
109  VProperty *container = nullptr) const Q_DECL_OVERRIDE;
110 
111  virtual void updateParent(const QVariant &value) Q_DECL_OVERRIDE;
112 
113  int getTypeForParent() const;
114  void setTypeForParent(int value);
115 
116 protected:
118 
119 private:
120  Q_DISABLE_COPY(VLabelProperty)
121 };
122 
123 }
124 
125 #endif // VLABELPROPERTY_H
Class for holding a string property.
virtual void updateParent(const QVariant &value) Q_DECL_OVERRIDE
int getTypeForParent() const
virtual void setSetting(const QString &key, const QVariant &value) Q_DECL_OVERRIDE
Sets the settings.
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
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 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 QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
virtual QStringList getSettingKeys() const Q_DECL_OVERRIDE
Returns the list of keys of the property's settings.
VLabelProperty(const QString &name, const QMap< QString, QVariant > &settings)
void setTypeForParent(int value)
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.