diff options
Diffstat (limited to 'utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h')
-rw-r--r-- | utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h new file mode 100644 index 0000000000..8a52bbe87c --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyModel.h | |||
@@ -0,0 +1,105 @@ | |||
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. | ||
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 | // 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 | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | #ifndef QPROPERTYMODEL_H_ | ||
25 | #define QPROPERTYMODEL_H_ | ||
26 | |||
27 | #include <Qt/qabstractitemmodel.h> | ||
28 | #include <Qt/qmap.h> | ||
29 | |||
30 | #include "QPropertyEditorWidget.h" | ||
31 | |||
32 | class Property; | ||
33 | |||
34 | /** | ||
35 | * The QPropertyModel handles the user defined properties of QObjects | ||
36 | */ | ||
37 | class QPropertyModel : public QAbstractItemModel { | ||
38 | Q_OBJECT | ||
39 | public: | ||
40 | /** | ||
41 | * Constructor | ||
42 | * @param parent optional parent object | ||
43 | */ | ||
44 | QPropertyModel(QObject* parent = 0); | ||
45 | /// Destructor | ||
46 | virtual ~QPropertyModel(); | ||
47 | |||
48 | /// QAbstractItemModel implementation | ||
49 | QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; | ||
50 | |||
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; | ||
59 | |||
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; | ||
64 | |||
65 | /// QAbstractItemModel implementation | ||
66 | QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; | ||
67 | |||
68 | /// QAbstractItemModel implementation | ||
69 | QModelIndex buddy ( const QModelIndex & index ) const; | ||
70 | |||
71 | /** | ||
72 | * Adds the user properties of the given class to the QPropertyModel instance | ||
73 | * | ||
74 | * @param propertyObject the class inherited from QObject that contains user properties that should be | ||
75 | * managed by this instance | ||
76 | */ | ||
77 | void addItem(QObject* propertyObject); | ||
78 | |||
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 | ||
83 | */ | ||
84 | void updateItem ( QObject* propertyObject, const QModelIndex& parent = QModelIndex() ) ; | ||
85 | |||
86 | /** | ||
87 | * Removes all objects from the model | ||
88 | */ | ||
89 | void clear(); | ||
90 | |||
91 | /** | ||
92 | * Sets custom callback that will be used to create Property instances for custom datatypes | ||
93 | */ | ||
94 | void setCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback); | ||
95 | |||
96 | private: | ||
97 | |||
98 | /// The Root Property for all objects | ||
99 | Property* m_rootItem; | ||
100 | |||
101 | /// Custom callback | ||
102 | QPropertyEditorWidget::UserTypeCB m_userCallback; | ||
103 | |||
104 | }; | ||
105 | #endif | ||