Seamly2D
Code documentation
vwidgetproperty.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vwidgetproperty.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 VWIDGETROPERTY_H
22 #define VWIDGETROPERTY_H
23 
24 #include <qcompilerdetection.h>
25 #include <QPointer>
26 #include <QString>
27 
28 #include "vemptyproperty.h"
29 
30 namespace VPE {
31 class VProperty;
32 } // namespace VPE
33 
34 namespace VPE
35 {
36 
37 // todo: this way, this class doesn't really make sense. What we have to do is pass a widget factory instead of the
38 // actual widget!
39 
40 //! This property holds a QWidget and displays it, if the view supports that. If not, it will behave like an empty
41 //! property
43 {
44 public:
45  //! Constructor
46  explicit VWidgetProperty(const QString &name, QWidget* widget = nullptr);
47 
48  //! The destructor
49  virtual ~VWidgetProperty() Q_DECL_OVERRIDE;
50 
51  //! Returns the widget held by this property
52  QWidget* getWidget() const;
53 
54  //! Sets the widget for this property. If there is already an old one, it will be deleted.
55  void setWidget(QWidget* widget);
56 
57  //! Returns a string containing the type of the property
58  virtual QString type() const Q_DECL_OVERRIDE;
59 
60  //! Clones this property
61  //! \param include_children Indicates whether to also clone the children
62  //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried
63  //! to fill all the data into container. This can also be used when subclassing this function.
64  //! \return Returns the newly created property (or container, if it was not NULL)
65  Q_REQUIRED_RESULT virtual VProperty* clone(bool include_children = true,
66  VProperty* container = nullptr) const Q_DECL_OVERRIDE;
67 };
68 
69 }
70 
71 #endif // VWIDGETROPERTY_H
This property holds a QWidget and displays it, if the view supports that. If not, it will behave like...
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this property.
virtual ~VWidgetProperty() Q_DECL_OVERRIDE
The destructor.
QWidget * getWidget() const
Returns the widget held by this property.
void setWidget(QWidget *widget)
Sets the widget for this property. If there is already an old one, it will be deleted.
VWidgetProperty(const QString &name, QWidget *widget=nullptr)
Constructor.
virtual QString type() const Q_DECL_OVERRIDE
Returns a string containing the type of the property.