vizkit3d
qtgroupboxpropertybrowser.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 **
6 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 **
8 ** This file is part of a Qt Solutions component.
9 **
10 ** You may use this file under the terms of the BSD license as follows:
11 **
12 ** "Redistribution and use in source and binary forms, with or without
13 ** modification, are permitted provided that the following conditions are
14 ** met:
15 ** * Redistributions of source code must retain the above copyright
16 ** notice, this list of conditions and the following disclaimer.
17 ** * Redistributions in binary form must reproduce the above copyright
18 ** notice, this list of conditions and the following disclaimer in
19 ** the documentation and/or other materials provided with the
20 ** distribution.
21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22 ** the names of its contributors may be used to endorse or promote
23 ** products derived from this software without specific prior written
24 ** permission.
25 **
26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
37 **
38 ****************************************************************************/
39 
40 
41 #ifndef QTGROUPBOXPROPERTYBROWSER_H
42 #define QTGROUPBOXPROPERTYBROWSER_H
43 
44 #include "qtpropertybrowser.h"
45 #include <QtGui/QGridLayout>
46 #include <QtGui/QLabel>
47 #include <QtGui/QGroupBox>
48 
49 #if QT_VERSION >= 0x040400
50 QT_BEGIN_NAMESPACE
51 #endif
52 
54 
56 {
57  Q_OBJECT
58 public:
59 
60  QtGroupBoxPropertyBrowser(QWidget *parent = 0);
62 
63 protected:
64  virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem);
65  virtual void itemRemoved(QtBrowserItem *item);
66  virtual void itemChanged(QtBrowserItem *item);
67 
68 private:
69 
71  Q_DECLARE_PRIVATE(QtGroupBoxPropertyBrowser)
72  Q_DISABLE_COPY(QtGroupBoxPropertyBrowser)
73  Q_PRIVATE_SLOT(d_func(), void slotUpdate())
74  Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed())
75 
76 };
77 
79 {
81  Q_DECLARE_PUBLIC(QtGroupBoxPropertyBrowser)
82 public:
83 
84  void init(QWidget *parent);
85 
86  void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex);
87  void propertyRemoved(QtBrowserItem *index);
88  void propertyChanged(QtBrowserItem *index);
89  QWidget *createEditor(QtProperty *property, QWidget *parent) const
90  { return q_ptr->createEditor(property, parent); }
91 
92  void slotEditorDestroyed();
93  void slotUpdate();
94 
95  struct WidgetItem
96  {
98  groupBox(0), layout(0), line(0), parent(0) { }
99  QWidget *widget; // can be null
100  QLabel *label;
101  QLabel *widgetLabel;
102  QGroupBox *groupBox;
103  QGridLayout *layout;
104  QFrame *line;
106  QList<WidgetItem *> children;
107  };
108 private:
109  void updateLater();
110  void updateItem(WidgetItem *item);
111  void insertRow(QGridLayout *layout, int row) const;
112  void removeRow(QGridLayout *layout, int row) const;
113 
114  bool hasHeader(WidgetItem *item) const;
115 
116  QMap<QtBrowserItem *, WidgetItem *> m_indexToItem;
117  QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex;
118  QMap<QWidget *, WidgetItem *> m_widgetToItem;
119  QGridLayout *m_mainLayout;
120  QList<WidgetItem *> m_children;
121  QList<WidgetItem *> m_recreateQueue;
122 };
123 
124 #if QT_VERSION >= 0x040400
125 QT_END_NAMESPACE
126 #endif
127 
128 #endif
void slotEditorDestroyed()
Definition: qtgroupboxpropertybrowser.cpp:59
QLabel * label
Definition: qtgroupboxpropertybrowser.h:100
void slotUpdate()
Definition: qtgroupboxpropertybrowser.cpp:70
QtAbstractPropertyBrowser provides a base class for implementing property browsers.
Definition: qtpropertybrowser.h:357
The QtBrowserItem class represents a property in a property browser instance.
Definition: qtpropertybrowser.h:309
virtual void itemRemoved(QtBrowserItem *item)=0
QLabel * widgetLabel
Definition: qtgroupboxpropertybrowser.h:101
QFrame * line
Definition: qtgroupboxpropertybrowser.h:104
QList< WidgetItem * > children
Definition: qtgroupboxpropertybrowser.h:106
Definition: qtgroupboxpropertybrowser.h:78
virtual void itemChanged(QtBrowserItem *item)=0
virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem)=0
Definition: qtgroupboxpropertybrowser.h:95
void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex)
Definition: qtgroupboxpropertybrowser.cpp:122
WidgetItem()
Definition: qtgroupboxpropertybrowser.h:97
void propertyRemoved(QtBrowserItem *index)
Definition: qtgroupboxpropertybrowser.cpp:230
#define QT_QTPROPERTYBROWSER_EXPORT
Definition: qtpropertybrowser.h:66
void propertyChanged(QtBrowserItem *index)
Definition: qtgroupboxpropertybrowser.cpp:350
The QtGroupBoxPropertyBrowser class provides a QGroupBox based property browser.
Definition: qtgroupboxpropertybrowser.h:55
QGridLayout * layout
Definition: qtgroupboxpropertybrowser.h:103
The QtProperty class encapsulates an instance of a property.
Definition: qtpropertybrowser.h:74
WidgetItem * parent
Definition: qtgroupboxpropertybrowser.h:105
virtual QWidget * createEditor(QtProperty *property, QWidget *parent)
Definition: qtpropertybrowser.cpp:1840
QWidget * widget
Definition: qtgroupboxpropertybrowser.h:99
QWidget * createEditor(QtProperty *property, QWidget *parent) const
Definition: qtgroupboxpropertybrowser.h:89
void init(QWidget *parent)
Definition: qtgroupboxpropertybrowser.cpp:50
QGroupBox * groupBox
Definition: qtgroupboxpropertybrowser.h:102