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 setSorted(bool value);
104
105 bool sorted() const { return m_sorted; }
106
107
108private:
109
111 void addDynamicProperties( Property* parent, QObject* propertyObject );
112
115
117 QList<QPropertyEditorWidget::UserTypeCB> m_userCallbacks;
118
119 bool m_sorted;
120
121
122};
123#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)
QList< QPropertyEditorWidget::UserTypeCB > m_userCallbacks
Custom callback.
Definition QPropertyModel.h:120
void addItem(QObject *propertyObject)
int columnCount(const QModelIndex &parent=QModelIndex()) const
QAbstractItemModel implementation.
QModelIndex buddy(const QModelIndex &index) const
QAbstractItemModel implementation.
int rowCount(const QModelIndex &parent=QModelIndex()) const
QAbstractItemModel implementation.
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.
virtual ~QPropertyModel()
Destructor.
void addDynamicProperties(Property *parent, QObject *propertyObject)
Adds dynamic properties to the model.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
QAbstractItemModel implementation.
void updateItem(QObject *propertyObject, const QModelIndex &parent=QModelIndex())
QModelIndex parent(const QModelIndex &index) const
QAbstractItemModel implementation.
Definition QPropertyModel.cpp:106
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
QAbstractItemModel implementation.
void unregisterCustomPropertyCB(QPropertyEditorWidget::UserTypeCB callback)
Qt::ItemFlags flags(const QModelIndex &index) const
QAbstractItemModel implementation.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
QAbstractItemModel implementation.
QPropertyModel(QObject *parent=0)