1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QTTREEPROPERTYBROWSER_H
41 #define QTTREEPROPERTYBROWSER_H
42 
43 #include "qtpropertybrowser.h"
44 
45 QT_BEGIN_NAMESPACE
46 
47 class QTreeWidgetItem;
48 class QtTreePropertyBrowserPrivate;
49 
50 class QtTreePropertyBrowser : public QtAbstractPropertyBrowser
51 {
52     Q_OBJECT
53     Q_PROPERTY(int indentation READ indentation WRITE setIndentation)
54     Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated)
55     Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
56     Q_PROPERTY(bool headerVisible READ isHeaderVisible WRITE setHeaderVisible)
57     Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
58     Q_PROPERTY(int splitterPosition READ splitterPosition WRITE setSplitterPosition)
59     Q_PROPERTY(bool propertiesWithoutValueMarked READ propertiesWithoutValueMarked WRITE setPropertiesWithoutValueMarked)
60 public:
61 
62     enum ResizeMode
63     {
64         Interactive,
65         Stretch,
66         Fixed,
67         ResizeToContents
68     };
69     Q_ENUM(ResizeMode)
70 
71     QtTreePropertyBrowser(QWidget *parent = 0);
72     ~QtTreePropertyBrowser();
73 
74     int indentation() const;
75     void setIndentation(int i);
76 
77     bool rootIsDecorated() const;
78     void setRootIsDecorated(bool show);
79 
80     bool alternatingRowColors() const;
81     void setAlternatingRowColors(bool enable);
82 
83     bool isHeaderVisible() const;
84     void setHeaderVisible(bool visible);
85 
86     ResizeMode resizeMode() const;
87     void setResizeMode(ResizeMode mode);
88 
89     int splitterPosition() const;
90     void setSplitterPosition(int position);
91 
92     void setExpanded(QtBrowserItem *item, bool expanded);
93     bool isExpanded(QtBrowserItem *item) const;
94 
95     bool isItemVisible(QtBrowserItem *item) const;
96     void setItemVisible(QtBrowserItem *item, bool visible);
97 
98     void setBackgroundColor(QtBrowserItem *item, const QColor &color);
99     QColor backgroundColor(QtBrowserItem *item) const;
100     QColor calculatedBackgroundColor(QtBrowserItem *item) const;
101 
102     void setPropertiesWithoutValueMarked(bool mark);
103     bool propertiesWithoutValueMarked() const;
104 
105     void editItem(QtBrowserItem *item);
106 
107 Q_SIGNALS:
108 
109     void collapsed(QtBrowserItem *item);
110     void expanded(QtBrowserItem *item);
111 
112 protected:
113     virtual void itemInserted(QtBrowserItem *item, QtBrowserItem *afterItem);
114     virtual void itemRemoved(QtBrowserItem *item);
115     virtual void itemChanged(QtBrowserItem *item);
116 
117 private:
118 
119     QScopedPointer<QtTreePropertyBrowserPrivate> d_ptr;
120     Q_DECLARE_PRIVATE(QtTreePropertyBrowser)
121     Q_DISABLE_COPY_MOVE(QtTreePropertyBrowser)
122 
123     Q_PRIVATE_SLOT(d_func(), void slotCollapsed(const QModelIndex &))
124     Q_PRIVATE_SLOT(d_func(), void slotExpanded(const QModelIndex &))
125     Q_PRIVATE_SLOT(d_func(), void slotCurrentBrowserItemChanged(QtBrowserItem *))
126     Q_PRIVATE_SLOT(d_func(), void slotCurrentTreeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))
127 
128 };
129 
130 QT_END_NAMESPACE
131 
132 #endif
133