Seamly2D
Code documentation
vformulaproperty.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 vformulaproperty.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 28 8, 2014
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) 2013-2015 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 VFORMULAPROPERTY_H
53 #define VFORMULAPROPERTY_H
54 
55 #include "../vpropertyexplorer/vproperty.h"
56 
57 class VFormula;
58 
60 {
61  Q_OBJECT
62 public:
63  explicit VFormulaProperty(const QString &name);
64 
65  //! Get the data how it should be displayed
66  virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
67 
68  //! Returns item flags
69  virtual Qt::ItemFlags flags(int column = DPC_Name) const Q_DECL_OVERRIDE;
70 
71  //! Returns an editor widget, or NULL if it doesn't supply one
72  //! \param parent The widget to which the editor will be added as a child
73  //! \options Render options
74  //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and
75  //! slots.
76  virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& options,
77  const QAbstractItemDelegate* delegate) Q_DECL_OVERRIDE;
78 
79  //! Sets the property's data to the editor (returns false, if the standard delegate should do that)
80  virtual bool setEditorData(QWidget* editor) Q_DECL_OVERRIDE;
81 
82  //! Gets the data from the widget
83  virtual QVariant getEditorData(const QWidget* editor) const Q_DECL_OVERRIDE;
84 
85  //! Returns a string containing the type of the property
86  virtual QString type() const Q_DECL_OVERRIDE;
87 
88  //! Clones this property
89  //! \param include_children Indicates whether to also clone the children
90  //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
91  //! to fill all the data into container. This can also be used when subclassing this function.
92  //! \return Returns the newly created property (or container, if it was not NULL)
93  Q_REQUIRED_RESULT virtual VProperty* clone(bool include_children = true,
94  VProperty* container = nullptr) const Q_DECL_OVERRIDE;
95 
96  //! Sets the value of the property
97  virtual void setValue(const QVariant& value) Q_DECL_OVERRIDE;
98 
99  //! Returns the value of the property as a QVariant
100  virtual QVariant getValue() const Q_DECL_OVERRIDE;
101 
102  //! Returns the formula
103  VFormula GetFormula() const;
104 
105  //! Sets the formula
106  void SetFormula(const VFormula &formula);
107 
108 public slots:
109  virtual void childValueChanged(const QVariant &value, int typeForParent) Q_DECL_OVERRIDE;
110 
111 };
112 
113 #endif // VFORMULAPROPERTY_H
VFormulaProperty(const QString &name)
virtual void setValue(const QVariant &value) Q_DECL_OVERRIDE
Sets the value of the property.
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
Get the data how it should be displayed.
virtual Qt::ItemFlags flags(int column=DPC_Name) const Q_DECL_OVERRIDE
Returns item flags.
VFormula GetFormula() const
Returns the formula.
void SetFormula(const VFormula &formula)
Sets the formula.
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 void childValueChanged(const QVariant &value, int typeForParent) Q_DECL_OVERRIDE
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 Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
virtual QVariant getValue() const Q_DECL_OVERRIDE
Returns the value of the property as a QVariant.
VProperty(const QString &name, QVariant::Type type=QVariant::String)
Standard constructor, takes a name and a parent property as argument.
Definition: vproperty.cpp:36