itom
Loading...
Searching...
No Matches
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
33class Property;
34
38class QPropertyModel : public QAbstractItemModel
39{
40 Q_OBJECT
41public:
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 setGroupByInheritance(bool enabled);
104
105 bool groupByInheritance() const
106 {
107 return m_groupByInheritance;
108 }
109
110 QSize span(const QModelIndex &index) const;
111
112private:
114 void addDynamicProperties(Property* parent, QObject* propertyObject);
115
118
120 QList<QPropertyEditorWidget::UserTypeCB> m_userCallbacks;
121
122 bool m_groupByInheritance;
123};
124#endif
Definition Property.h:41
Property *(*) UserTypeCB(const QString &name, QObject *propertyObject, Property *parent)
Definition QPropertyEditorWidget.h:77
Definition QPropertyModel.h:39
void registerCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback)
Definition QPropertyModel.cpp:575
QList< QPropertyEditorWidget::UserTypeCB > m_userCallbacks
Custom callback.
Definition QPropertyModel.h:120
void addItem(QObject *propertyObject)
Definition QPropertyModel.cpp:290
int columnCount(const QModelIndex &parent=QModelIndex()) const
QAbstractItemModel implementation.
Definition QPropertyModel.cpp:157
QModelIndex buddy(const QModelIndex &index) const
QAbstractItemModel implementation.
Definition QPropertyModel.cpp:266
int rowCount(const QModelIndex &parent=QModelIndex()) const
QAbstractItemModel implementation.
Definition QPropertyModel.cpp:130
Property * m_rootItem
The Root Property for all objects.
Definition QPropertyModel.h:117
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
QAbstractItemModel implementation.
Definition QPropertyModel.cpp:200
void addDynamicProperties(Property *parent, QObject *propertyObject)
Adds dynamic properties to the model.
Definition QPropertyModel.cpp:484
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QAbstractItemModel implementation.
Definition QPropertyModel.cpp:163
virtual ~QPropertyModel()
Destructor.
Definition QPropertyModel.cpp:64
void updateItem(QObject *propertyObject, const QModelIndex &parent=QModelIndex())
Definition QPropertyModel.cpp:438
QModelIndex parent(const QModelIndex &index) const
QAbstractItemModel implementation.
Definition QPropertyModel.cpp:106
void clear()
Definition QPropertyModel.cpp:555
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QAbstractItemModel implementation.
Definition QPropertyModel.cpp:69
void unregisterCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback)
Definition QPropertyModel.cpp:584
Qt::ItemFlags flags(const QModelIndex &index) const
QAbstractItemModel implementation.
Definition QPropertyModel.cpp:225
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
QAbstractItemModel implementation.
Definition QPropertyModel.cpp:249
QPropertyModel(QObject *parent=0)
Definition QPropertyModel.cpp:57