All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #pragma GCC system_header
41 
42 #ifndef QTGROUPBOXPROPERTYBROWSER_H
43 #define QTGROUPBOXPROPERTYBROWSER_H
44 
45 #include <QtGui/QGridLayout>
46 #include <QtGui/QLabel>
47 #include <QtGui/QGroupBox>
48 
49 #include "qtpropertybrowser.h"
50 
51 #if QT_VERSION >= 0x040400
52 QT_BEGIN_NAMESPACE
53 #endif
54 
56 
57 
60 {
61  Q_OBJECT
62  public:
63 
64  explicit QtGroupBoxPropertyBrowser(QWidget *parent = 0);
66 
67  protected:
68  virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem);
69  virtual void itemRemoved(QtBrowserItem *item);
70  virtual void itemChanged(QtBrowserItem *item);
71 
72  private:
73 
75  Q_DECLARE_PRIVATE(QtGroupBoxPropertyBrowser)
76  Q_DISABLE_COPY(QtGroupBoxPropertyBrowser)
77  Q_PRIVATE_SLOT(d_func(), void slotUpdate())
78  Q_PRIVATE_SLOT(d_func(), void slotEditorDestroyed())
79 };
80 
82 {
84  Q_DECLARE_PUBLIC(QtGroupBoxPropertyBrowser)
85  public:
86  QtGroupBoxPropertyBrowserPrivate() : q_ptr(NULL), m_mainLayout(NULL) {}
87 
88  void init(QWidget *parent);
89 
90  void propertyInserted(QtBrowserItem *index, QtBrowserItem *afterIndex);
91  void propertyRemoved(QtBrowserItem *index);
92  void propertyChanged(QtBrowserItem *index);
93  QWidget *createEditor(QtProperty *property, QWidget *parent) const
94  { return q_ptr->createEditor(property, parent); }
95 
96  void slotEditorDestroyed();
97  void slotUpdate();
98 
99  struct WidgetItem
100  {
101  WidgetItem() : widget(0), label(0), widgetLabel(0),
102  groupBox(0), layout(0), line(0), parent(0)
103  { }
104  QWidget *widget; // can be null
105  QLabel *label;
106  QLabel *widgetLabel;
107  QGroupBox *groupBox;
108  QGridLayout *layout;
109  QFrame *line;
110  WidgetItem *parent;
111  QList<WidgetItem *> children;
112  };
113  private:
114  void updateLater();
115  void updateItem(WidgetItem *item);
116  void insertRow(QGridLayout *layout, int row) const;
117  void removeRow(QGridLayout *layout, int row) const;
118 
119  bool hasHeader(WidgetItem *item) const;
120 
121  QMap<QtBrowserItem *, WidgetItem *> m_indexToItem;
122  QMap<WidgetItem *, QtBrowserItem *> m_itemToIndex;
123  QMap<QWidget *, WidgetItem *> m_widgetToItem;
124  QGridLayout *m_mainLayout;
125  QList<WidgetItem *> m_children;
126  QList<WidgetItem *> m_recreateQueue;
127 };
128 
129 #if QT_VERSION >= 0x040400
130 QT_END_NAMESPACE
131 #endif
132 
133 #endif
Definition: qtpropertybrowser.h:384
virtual void itemChanged(QtBrowserItem *item)=0
Definition: qtpropertybrowser.h:311
virtual void itemRemoved(QtBrowserItem *item)=0
Definition: qtgroupboxpropertybrowser.h:81
#define NULL
Definition: CommonTypes.hh:30
virtual QWidget * createEditor(QtProperty *property, QWidget *parent)
#define QT_QTPROPERTYBROWSER_EXPORT
Definition: qtpropertybrowser.h:68
virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem)=0
Definition: qtgroupboxpropertybrowser.h:58
Definition: qtpropertybrowser.h:77