Seamly2D
Code documentation
vpropertyformview.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vpropertyformview.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 VPROPERTYFORMVIEW_H
22 #define VPROPERTYFORMVIEW_H
23 
24 #include <qcompilerdetection.h>
25 #include <QMetaObject>
26 #include <QObject>
27 #include <QPointer>
28 #include <QString>
29 #include <QtGlobal>
30 
31 #include "vpropertyformwidget.h"
32 
33 namespace VPE
34 {
35 
36 class VPropertyModel;
37 
38 //! This class populates a form layout with the properties in a model
40 {
41  Q_OBJECT
42 public:
43  //! Constructor
44  explicit VPropertyFormView(QWidget *parent = nullptr);
45 
46  //! Constructor
47  explicit VPropertyFormView(VPropertyModel *model, QWidget *parent = nullptr);
48 
49  //! Constructor
50  explicit VPropertyFormView(VPropertySet *property_set, QWidget *parent = nullptr);
51 
52  //! Destructor
53  virtual ~VPropertyFormView() Q_DECL_OVERRIDE;
54 
55 
56 public slots:
57  //! Rebuilds the whole form
58  virtual void build() Q_DECL_OVERRIDE;
59 
60  //! Set the source model. Leads to the rebuild of the form
61  //! \param model The model to use
62  void setModel(VPropertyModel *model);
63 
64  //! Set the property set to use. Note that if using a property set directly, adding and removing properties to the
65  //! property set leads to undifined behaviour for the property set misses notification signals.
66  //! \param property_set The property set to use
67  void setPropertySet(VPropertySet *property_set);
68 
69  //! Called when a row gets removed in the model
70  void rowsRemoved(const QModelIndex &parent, int start, int end);
71 
72  //! Called when a new row is being inserted into the model
73  void rowsInserted(const QModelIndex &parent, int start, int end);
74 
75  //! Called when the model is being reset
76  void modelReset();
77 
78 
79 private slots:
80  //! Called, when the model gets destroyed
81  void modelDestroyed();
82 
83  //! Called when data in the model gets changed
84  void dataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right);
85 
86  //! Updates the model when data was submitted by the view
87  void dataSubmitted(VProperty *property);
88 
89 protected:
90  virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
91 
92  //! Rebuilds the widegt only if it is visible
93  void updatePropertyList();
94 
95  //! Removes the model and property set if they were set
96  void removeModelAndSet();
97 
98  //! Function to handle newly created VPropertyWidgets
99  virtual void connectPropertyFormWidget(VPropertyFormWidget *widget);
100 
101 private:
102  Q_DISABLE_COPY(VPropertyFormView)
103 };
104 
105 } // Namespace VPE
106 
107 #endif // VPROPERTYFORMVIEW_H
This class populates a form layout with the properties in a model.
void rowsInserted(const QModelIndex &parent, int start, int end)
Called when a new row is being inserted into the model.
virtual ~VPropertyFormView() Q_DECL_OVERRIDE
Destructor.
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
void dataSubmitted(VProperty *property)
Updates the model when data was submitted by the view.
virtual void connectPropertyFormWidget(VPropertyFormWidget *widget)
Function to handle newly created VPropertyWidgets.
void setModel(VPropertyModel *model)
Set the source model. Leads to the rebuild of the form.
void modelDestroyed()
Called, when the model gets destroyed.
void rowsRemoved(const QModelIndex &parent, int start, int end)
Called when a row gets removed in the model.
void dataChanged(const QModelIndex &top_left, const QModelIndex &bottom_right)
Called when data in the model gets changed.
void removeModelAndSet()
Removes the model and property set if they were set.
virtual void build() Q_DECL_OVERRIDE
Rebuilds the whole form.
void modelReset()
Called when the model is being reset.
VPropertyFormView(QWidget *parent=nullptr)
Constructor.
void setPropertySet(VPropertySet *property_set)
Set the property set to use. Note that if using a property set directly, adding and removing properti...
void updatePropertyList()
Rebuilds the widegt only if it is visible.
Class that displays the sub properties of a property using a form layout.
This is the base model for managing all the properties and passing them to the view.
VPropertySet is a simple class for managing a set of properties. If you don't need all the Model-func...
Definition: vpropertyset.h:48