Seamly2D
Code documentation
vemptyproperty.cpp
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vemptyproperty.cpp
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 #include "vemptyproperty.h"
22 
23 #include <stddef.h>
24 #include <QBrush>
25 #include <QColor>
26 #include <QFlags>
27 #include <QFont>
28 
29 #include "../vproperty.h"
30 
31 namespace VPE {
32 class VPropertyPrivate;
33 } // namespace VPE
34 
36  : VProperty(name, QVariant::Invalid)
37 {
38 }
39 
40 
42  : VProperty(d)
43 {
44 }
45 
46 
48 {
49  //
50 }
51 
52 //! Get the data how it should be displayed
53 QVariant VPE::VEmptyProperty::data (int column, int role) const
54 {
55  if (column == DPC_Data && (Qt::DisplayRole == role || Qt::EditRole == role))
56  {
57  return QVariant();
58  }
59  else if (role == Qt::BackgroundRole)
60  {
61  return QBrush(QColor(217, 217, 217));
62  }
63  else if (role == Qt::FontRole)
64  {
65  QFont tmpFont; tmpFont.setBold(true); return tmpFont;
66  }
67  else
68  return VProperty::data(column, role);
69 }
70 
71 //! Returns an editor widget, or NULL if it doesn't supply one
72 QWidget* VPE::VEmptyProperty::createEditor(QWidget * parent, const QStyleOptionViewItem& options,
73  const QAbstractItemDelegate* delegate)
74 {
75  Q_UNUSED(options)
76  Q_UNUSED(parent)
77  Q_UNUSED(delegate)
78 
79  return NULL;
80 }
81 
82 
83 //! Gets the data from the widget
84 QVariant VPE::VEmptyProperty::getEditorData(const QWidget *editor) const
85 {
86  Q_UNUSED(editor)
87 
88  return QVariant();
89 }
90 
91 //! Returns item flags
92 Qt::ItemFlags VPE::VEmptyProperty::flags(int column) const
93 {
94  Q_UNUSED(column)
95 
96  return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
97 }
98 
100 {
101  return "empty";
102 }
103 
104 VPE::VProperty* VPE::VEmptyProperty::clone(bool include_children, VProperty* container) const
105 {
106  return VProperty::clone(include_children, container ? container : new VEmptyProperty(getName()));
107 }
virtual QVariant getEditorData(const QWidget *editor) const Q_DECL_OVERRIDE
Gets the data from the widget.
VEmptyProperty(const QString &name)
Standard constructor, takes a name and a parent property as argument.
virtual Qt::ItemFlags flags(int column=DPC_Name) const Q_DECL_OVERRIDE
Returns item flags.
virtual Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const Q_DECL_OVERRIDE
Clones this 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 ~VEmptyProperty() Q_DECL_OVERRIDE
Destructor.
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 Q_REQUIRED_RESULT VProperty * clone(bool include_children=true, VProperty *container=nullptr) const
Clones this property.
Definition: vproperty.cpp:372
virtual QVariant data(int column=DPC_Name, int role=Qt::DisplayRole) const
Get the data how it should be displayed.
Definition: vproperty.cpp:68