1 // *************************************************************************************************
3 // QPropertyEditor v 0.1
5 // --------------------------------------
6 // Copyright (C) 2007 Volker Wiendl
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>
30 #include "QPropertyEditorWidget.h"
35 * The QPropertyModel handles the user defined properties of QObjects
37 class QPropertyModel
: public QAbstractItemModel
{
42 * @param parent optional parent object
44 QPropertyModel(QObject
* parent
= 0);
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;
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
);
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() ) ;
87 * Removes all objects from the model
92 * Sets custom callback that will be used to create Property instances for custom datatypes
94 void setCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback
);
98 /// The Root Property for all objects
102 QPropertyEditorWidget::UserTypeCB m_userCallback
;