Add wpseditor, the Google Summer of Code 2008 project of Rostislav Chekan. Closes...
[kugel-rb.git] / utils / wpseditor / gui / src / QPropertyEditor / QPropertyEditorWidget.cpp
blobfc4b90c227e351d9cb73a668b5ce20c7db3fc09a
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.
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 // *************************************************************************************************
25 #include "QPropertyEditorWidget.h"
26 #include "QPropertyModel.h"
27 #include "QVariantDelegate.h"
28 #include "Property.h"
30 QPropertyEditorWidget::QPropertyEditorWidget(QWidget* parent /*= 0*/) : QTreeView(parent) {
31 m_model = new QPropertyModel(this);
32 setModel(m_model);
33 setItemDelegate(new QVariantDelegate(this));
37 QPropertyEditorWidget::~QPropertyEditorWidget() {}
39 void QPropertyEditorWidget::addObject(QObject* propertyObject) {
40 m_model->addItem(propertyObject);
41 expandToDepth(0);
44 void QPropertyEditorWidget::setObject(QObject* propertyObject) {
45 m_model->clear();
46 if (propertyObject)
47 addObject(propertyObject);
50 void QPropertyEditorWidget::updateObject(QObject* propertyObject) {
51 m_model->updateItem(propertyObject);
54 void QPropertyEditorWidget::setCustomPropertyCB(UserTypeCB callback) {
55 m_model->setCustomPropertyCB(callback);