Add wpseditor, the Google Summer of Code 2008 project of Rostislav Chekan. Closes...
[kugel-rb.git] / utils / wpseditor / gui / src / QPropertyEditor / QPropertyModel.h
blob8a52bbe87ce6f2ebbe8d87e02a34ba56eabc57f4
1 // *************************************************************************************************
2 //
3 // QPropertyEditor v 0.1
4 //
5 // --------------------------------------
6 // Copyright (C) 2007 Volker Wiendl
7 //
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or any later version.
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.
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 // *************************************************************************************************
24 #ifndef QPROPERTYMODEL_H_
25 #define QPROPERTYMODEL_H_
27 #include <Qt/qabstractitemmodel.h>
28 #include <Qt/qmap.h>
30 #include "QPropertyEditorWidget.h"
32 class Property;
34 /**
35 * The QPropertyModel handles the user defined properties of QObjects
37 class QPropertyModel : public QAbstractItemModel {
38 Q_OBJECT
39 public:
40 /**
41 * Constructor
42 * @param parent optional parent object
44 QPropertyModel(QObject* parent = 0);
45 /// Destructor
46 virtual ~QPropertyModel();
48 /// QAbstractItemModel implementation
49 QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const;
51 /// QAbstractItemModel implementation
52 QModelIndex parent ( const QModelIndex & index ) const;
53 /// QAbstractItemModel implementation
54 int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
55 /// QAbstractItemModel implementation
56 int columnCount ( const QModelIndex & parent = QModelIndex() ) const;
57 /// QAbstractItemModel implementation
58 QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
60 /// QAbstractItemModel implementation
61 bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole );
62 /// QAbstractItemModel implementation
63 Qt::ItemFlags flags ( const QModelIndex & index ) const;
65 /// QAbstractItemModel implementation
66 QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
68 /// QAbstractItemModel implementation
69 QModelIndex buddy ( const QModelIndex & index ) const;
71 /**
72 * Adds the user properties of the given class to the QPropertyModel instance
74 * @param propertyObject the class inherited from QObject that contains user properties that should be
75 * managed by this instance
77 void addItem(QObject* propertyObject);
79 /**
80 * Creates a dataChanged signal for the given object
81 * @param propertyObject the instance of a QObject based class that should be updated
82 * @param parent optional model index the propertyObject is child of
84 void updateItem ( QObject* propertyObject, const QModelIndex& parent = QModelIndex() ) ;
86 /**
87 * Removes all objects from the model
89 void clear();
91 /**
92 * Sets custom callback that will be used to create Property instances for custom datatypes
94 void setCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback);
96 private:
98 /// The Root Property for all objects
99 Property* m_rootItem;
101 /// Custom callback
102 QPropertyEditorWidget::UserTypeCB m_userCallback;
105 #endif