Seamly2D
Code documentation
vpropertyformwidget.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vpropertyformwidget.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 VPROPERTYFORMWIDGET_H
22 #define VPROPERTYFORMWIDGET_H
23 
24 #include <QGroupBox>
25 #include <QLabel>
26 #include <QList>
27 #include <QMetaObject>
28 #include <QObject>
29 #include <QString>
30 #include <QtGlobal>
31 
32 #include "vproperty.h"
33 
34 class QFormLayout;
35 
36 namespace VPE
37 {
38 
39 class VPropertyFormWidgetPrivate;
40 class VPropertySet;
41 
42 //! Class that displays the sub properties of a property using a form layout
43 class VPropertyFormWidget : public QGroupBox
44 {
45  Q_OBJECT
46 public:
47  //! Constructor
48  VPropertyFormWidget(const QString &title, const QString &description, const QList<VProperty*> &properties,
49  QWidget* parent);
50 
51  //! Constructor
52  VPropertyFormWidget(VProperty *parent_property, QWidget *parent);
53 
54  //! Destructor
56 
57 
58  //! Returns a list of all child property form widgets (note that indirect children will not be in the list)
60 
61 public slots:
62  //! Rebuilds the whole form
63  virtual void build();
64 
65  void buildEditor(VProperty *property, QFormLayout *formLayout, Property type = Property::Simple);
66 
67  //! Reads the data from the editors and commits it to the properties
68  void commitData();
69 
70  //! Refills the editors with the propertie's data
71  void loadData();
72 
73  //! Reads the data from row'th editor and commits it to the property
74  void commitData(int row);
75 
76  //! Reads the data from row'th property
77  void loadData(int row);
78 
79  //! Sets the update behaviour
80  //! \param auto_commit If set to true, whenever an event like focusOut is triggered on an editor, the data will be
81  //! submitted to the property.
82  void setCommitBehaviour(bool auto_commit = true);
83 
84 signals:
85  //! Emitted whenever a property data changes
87 
88 protected:
89  //! Protected Constructor
90  VPropertyFormWidget(VPropertyFormWidgetPrivate *d_pointer, QWidget *parent, const QString &title = QString(),
91  const QString &description = QString());
92 
93  //! The protected data
95 
96  //! Event filter for the editor widgets
97  bool eventFilter(QObject *object, QEvent *event);
98 
99  //! Commits data of an editor
100  void commitData(const QWidget *editor);
101 
102 private:
103  Q_DISABLE_COPY(VPropertyFormWidget)
104 };
105 
106 } // Namespace VPE
107 
108 #endif // VPROPERTYFORMWIDGET_H
Class that displays the sub properties of a property using a form layout.
void propertyDataSubmitted(VProperty *property)
Emitted whenever a property data changes.
void setCommitBehaviour(bool auto_commit=true)
Sets the update behaviour.
QList< VPropertyFormWidget * > getChildPropertyFormWidgets() const
Returns a list of all child property form widgets (note that indirect children will not be in the lis...
VPropertyFormWidgetPrivate * d_ptr
The protected data.
VPropertyFormWidget(const QString &title, const QString &description, const QList< VProperty * > &properties, QWidget *parent)
Constructor.
virtual void build()
Rebuilds the whole form.
void loadData()
Refills the editors with the propertie's data.
void buildEditor(VProperty *property, QFormLayout *formLayout, Property type=Property::Simple)
void commitData()
Reads the data from the editors and commits it to the properties.
bool eventFilter(QObject *object, QEvent *event)
Event filter for the editor widgets.
Property
Definition: vproperty.h:43