itom  4.1.0
QPropertyModel.h
1 // *************************************************************************************************
2 //
3 // QPropertyEditor v 0.3
4 //
5 // --------------------------------------
6 // Copyright (C) 2007 Volker Wiendl
7 // Acknowledgements to Roman alias banal from qt-apps.org for the Enum enhancement
8 //
9 //
10 // The QPropertyEditor Library is free software; you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by the Free Software
12 // Foundation; either version 2 of the License, or (at your option) any later
13 // version.
14 //
15 // This program is distributed in the hope that it will be useful, but WITHOUT
16 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public License along with
20 // this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 // Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22 // http://www.gnu.org/copyleft/lesser.txt.
23 //
24 // *************************************************************************************************
25 #ifndef QPROPERTYMODEL_H_
26 #define QPROPERTYMODEL_H_
27 
28 #include <qabstractitemmodel.h>
29 #include <qmap.h>
30 
31 #include "QPropertyEditorWidget.h"
32 
33 class Property;
34 
38 class QPropertyModel : public QAbstractItemModel
39 {
40  Q_OBJECT
41 public:
46  QPropertyModel(QObject* parent = 0);
48  virtual ~QPropertyModel();
49 
51  QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const;
52 
54  QModelIndex parent(const QModelIndex & index) const;
56  int rowCount(const QModelIndex & parent = QModelIndex()) const;
58  int columnCount (const QModelIndex & parent = QModelIndex()) const;
60  QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
61 
63  bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
65  Qt::ItemFlags flags(const QModelIndex & index) const;
66 
68  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
69 
71  QModelIndex buddy(const QModelIndex & index) const;
72 
79  void addItem(QObject* propertyObject);
80 
86  void updateItem(QObject* propertyObject, const QModelIndex& parent = QModelIndex()) ;
87 
91  void clear();
92 
97 
102 
103  void setSorted(bool value);
104 
105  bool sorted() const { return m_sorted; }
106 
107 private:
109  void addDynamicProperties(Property* parent, QObject* propertyObject);
110 
113 
115  QList<QPropertyEditorWidget::UserTypeCB> m_userCallbacks;
116 
117  bool m_sorted;
118 
119 };
120 #endif
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QAbstractItemModel implementation.
Definition: QPropertyModel.cpp:151
void unregisterCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback)
Definition: QPropertyModel.cpp:507
QList< QPropertyEditorWidget::UserTypeCB > m_userCallbacks
Custom callback.
Definition: QPropertyModel.h:115
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
QAbstractItemModel implementation.
Definition: QPropertyModel.cpp:183
void registerCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback)
Definition: QPropertyModel.cpp:498
void clear()
Definition: QPropertyModel.cpp:479
QModelIndex parent(const QModelIndex &index) const
QAbstractItemModel implementation.
Definition: QPropertyModel.cpp:96
Definition: QPropertyModel.h:38
void addDynamicProperties(Property *parent, QObject *propertyObject)
Adds dynamic properties to the model.
Definition: QPropertyModel.cpp:415
virtual ~QPropertyModel()
Destructor.
Definition: QPropertyModel.cpp:57
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QAbstractItemModel implementation.
Definition: QPropertyModel.cpp:63
int rowCount(const QModelIndex &parent=QModelIndex()) const
QAbstractItemModel implementation.
Definition: QPropertyModel.cpp:120
void updateItem(QObject *propertyObject, const QModelIndex &parent=QModelIndex())
Definition: QPropertyModel.cpp:380
Property * m_rootItem
The Root Property for all objects.
Definition: QPropertyModel.h:112
QPropertyModel(QObject *parent=0)
Definition: QPropertyModel.cpp:51
QModelIndex buddy(const QModelIndex &index) const
QAbstractItemModel implementation.
Definition: QPropertyModel.cpp:245
Definition: Property.h:40
Property *(* UserTypeCB)(const QString &name, QObject *propertyObject, Property *parent)
Definition: QPropertyEditorWidget.h:68
int columnCount(const QModelIndex &parent=QModelIndex()) const
QAbstractItemModel implementation.
Definition: QPropertyModel.cpp:145
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
QAbstractItemModel implementation.
Definition: QPropertyModel.cpp:229
Qt::ItemFlags flags(const QModelIndex &index) const
QAbstractItemModel implementation.
Definition: QPropertyModel.cpp:206
void addItem(QObject *propertyObject)
Definition: QPropertyModel.cpp:255