Seamly2D
Code documentation
vpropertydelegate.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vpropertydelegate.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 VPROPERTYDELEGATE_H
22 #define VPROPERTYDELEGATE_H
23 
24 #include <qcompilerdetection.h>
25 #include <QMetaObject>
26 #include <QObject>
27 #include <QSize>
28 #include <QString>
29 #include <QStyleOptionViewItem>
30 #include <QStyledItemDelegate>
31 
32 namespace VPE
33 {
34 
35 class VPropertyDelegate : public QStyledItemDelegate
36 {
37  Q_OBJECT
38 public:
39  explicit VPropertyDelegate(QObject *parent = nullptr);
40  virtual ~VPropertyDelegate() Q_DECL_OVERRIDE;
41 
42  //! Creates the editor widget
43  virtual QWidget* createEditor (QWidget* parent, const QStyleOptionViewItem& option,
44  const QModelIndex& index) const Q_DECL_OVERRIDE;
45 
46  //! Sets the index data to the editor
47  virtual void setEditorData (QWidget * editor, const QModelIndex & index) const Q_DECL_OVERRIDE;
48 
49  //! Updates the index data
50  virtual void setModelData (QWidget * editor, QAbstractItemModel * model,
51  const QModelIndex & index) const Q_DECL_OVERRIDE;
52 
53  //! Returns the size hint
54  virtual QSize sizeHint (const QStyleOptionViewItem& option, const QModelIndex& index) const Q_DECL_OVERRIDE;
55 
56  //! Sets the row height. Set this to 0 and the standard will be taken
57  void setRowHeight(int height = 0, bool add_to_standard = false);
58 
59  //! Renders the delegate using the given painter and style option for the item specified by index.
60  virtual void paint (QPainter* painter, const QStyleOptionViewItem& option,
61  const QModelIndex& index ) const Q_DECL_OVERRIDE;
62 
63 protected:
64  int RowHeight;
66 
67 
68 };
69 
70 }
71 
72 #endif // VPROPERTYDELEGATE_H
virtual ~VPropertyDelegate() Q_DECL_OVERRIDE
void setRowHeight(int height=0, bool add_to_standard=false)
Sets the row height. Set this to 0 and the standard will be taken.
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const Q_DECL_OVERRIDE
Sets the index data to the editor.
VPropertyDelegate(QObject *parent=nullptr)
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE
Updates the index data.
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE
Returns the size hint.
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE
Renders the delegate using the given painter and style option for the item specified by index.
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE
Creates the editor widget.