1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the Qt Designer of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #ifndef PROPERTYEDITOR_H
|
---|
43 | #define PROPERTYEDITOR_H
|
---|
44 |
|
---|
45 | #include "propertyeditor_global.h"
|
---|
46 | #include <qdesigner_propertyeditor_p.h>
|
---|
47 |
|
---|
48 | #include <QtCore/QPointer>
|
---|
49 | #include <QtCore/QMap>
|
---|
50 | #include <QtCore/QVector>
|
---|
51 | #include <QtCore/QSet>
|
---|
52 |
|
---|
53 | QT_BEGIN_NAMESPACE
|
---|
54 |
|
---|
55 | class DomProperty;
|
---|
56 | class QDesignerMetaDataBaseItemInterface;
|
---|
57 | class QDesignerPropertySheetExtension;
|
---|
58 |
|
---|
59 | class QtAbstractPropertyBrowser;
|
---|
60 | class QtButtonPropertyBrowser;
|
---|
61 | class QtTreePropertyBrowser;
|
---|
62 | class QtProperty;
|
---|
63 | class QtVariantProperty;
|
---|
64 | class QtBrowserItem;
|
---|
65 | class QStackedWidget;
|
---|
66 |
|
---|
67 | namespace qdesigner_internal {
|
---|
68 |
|
---|
69 | class StringProperty;
|
---|
70 | class DesignerPropertyManager;
|
---|
71 | class DesignerEditorFactory;
|
---|
72 | class FilterWidget;
|
---|
73 | class ElidingLabel;
|
---|
74 |
|
---|
75 | class QT_PROPERTYEDITOR_EXPORT PropertyEditor: public QDesignerPropertyEditor
|
---|
76 | {
|
---|
77 | Q_OBJECT
|
---|
78 | public:
|
---|
79 | explicit PropertyEditor(QDesignerFormEditorInterface *core, QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
---|
80 | virtual ~PropertyEditor();
|
---|
81 |
|
---|
82 | virtual QDesignerFormEditorInterface *core() const;
|
---|
83 |
|
---|
84 | virtual bool isReadOnly() const;
|
---|
85 | virtual void setReadOnly(bool readOnly);
|
---|
86 | virtual void setPropertyValue(const QString &name, const QVariant &value, bool changed = true);
|
---|
87 | virtual void updatePropertySheet();
|
---|
88 |
|
---|
89 | virtual void setObject(QObject *object);
|
---|
90 |
|
---|
91 | void reloadResourceProperties();
|
---|
92 |
|
---|
93 | virtual QObject *object() const
|
---|
94 | { return m_object; }
|
---|
95 |
|
---|
96 | virtual QString currentPropertyName() const;
|
---|
97 |
|
---|
98 | protected:
|
---|
99 |
|
---|
100 | bool event(QEvent *event);
|
---|
101 |
|
---|
102 | private slots:
|
---|
103 | void slotResetProperty(QtProperty *property);
|
---|
104 | void slotValueChanged(QtProperty *property, const QVariant &value, bool enableSubPropertyHandling);
|
---|
105 | void slotViewTriggered(QAction *action);
|
---|
106 | void slotAddDynamicProperty(QAction *action);
|
---|
107 | void slotRemoveDynamicProperty();
|
---|
108 | void slotSorting(bool sort);
|
---|
109 | void slotColoring(bool color);
|
---|
110 | void slotCurrentItemChanged(QtBrowserItem*);
|
---|
111 | void setFilter(const QString &pattern);
|
---|
112 |
|
---|
113 | private:
|
---|
114 | void updateBrowserValue(QtVariantProperty *property, const QVariant &value);
|
---|
115 | void updateToolBarLabel();
|
---|
116 | int toBrowserType(const QVariant &value, const QString &propertyName) const;
|
---|
117 | QString removeScope(const QString &value) const;
|
---|
118 | QDesignerMetaDataBaseItemInterface *metaDataBaseItem() const;
|
---|
119 | void setupStringProperty(QtVariantProperty *property, bool isMainContainer);
|
---|
120 | void setupPaletteProperty(QtVariantProperty *property);
|
---|
121 | QString realClassName(QObject *object) const;
|
---|
122 | void storeExpansionState();
|
---|
123 | void applyExpansionState();
|
---|
124 | void storePropertiesExpansionState(const QList<QtBrowserItem *> &items);
|
---|
125 | void applyPropertiesExpansionState(const QList<QtBrowserItem *> &items);
|
---|
126 | void applyFilter();
|
---|
127 | int applyPropertiesFilter(const QList<QtBrowserItem *> &items);
|
---|
128 | void setExpanded(QtBrowserItem *item, bool expanded);
|
---|
129 | bool isExpanded(QtBrowserItem *item) const;
|
---|
130 | void setItemVisible(QtBrowserItem *item, bool visible);
|
---|
131 | bool isItemVisible(QtBrowserItem *item) const;
|
---|
132 | void collapseAll();
|
---|
133 | void clearView();
|
---|
134 | void fillView();
|
---|
135 | bool isLayoutGroup(QtProperty *group) const;
|
---|
136 | void updateColors();
|
---|
137 | void updateForegroundBrightness();
|
---|
138 | QColor propertyColor(QtProperty *property) const;
|
---|
139 | void updateActionsState();
|
---|
140 | QtBrowserItem *nonFakePropertyBrowserItem(QtBrowserItem *item) const;
|
---|
141 | void saveSettings() const;
|
---|
142 | void editProperty(const QString &name);
|
---|
143 | bool isDynamicProperty(const QtBrowserItem* item) const;
|
---|
144 |
|
---|
145 | struct Strings {
|
---|
146 | Strings();
|
---|
147 | QSet<QString> m_alignmentProperties;
|
---|
148 | const QString m_fontProperty;
|
---|
149 | const QString m_qLayoutWidget;
|
---|
150 | const QString m_designerPrefix;
|
---|
151 | const QString m_layout;
|
---|
152 | const QString m_validationModeAttribute;
|
---|
153 | const QString m_fontAttribute;
|
---|
154 | const QString m_superPaletteAttribute;
|
---|
155 | const QString m_enumNamesAttribute;
|
---|
156 | const QString m_resettableAttribute;
|
---|
157 | const QString m_flagsAttribute;
|
---|
158 | };
|
---|
159 |
|
---|
160 | const Strings m_strings;
|
---|
161 | QDesignerFormEditorInterface *m_core;
|
---|
162 | QDesignerPropertySheetExtension *m_propertySheet;
|
---|
163 | QtAbstractPropertyBrowser *m_currentBrowser;
|
---|
164 | QtButtonPropertyBrowser *m_buttonBrowser;
|
---|
165 | QtTreePropertyBrowser *m_treeBrowser;
|
---|
166 | DesignerPropertyManager *m_propertyManager;
|
---|
167 | DesignerEditorFactory *m_treeFactory;
|
---|
168 | DesignerEditorFactory *m_groupFactory;
|
---|
169 | QPointer<QObject> m_object;
|
---|
170 | QMap<QString, QtVariantProperty*> m_nameToProperty;
|
---|
171 | QMap<QtProperty*, QString> m_propertyToGroup;
|
---|
172 | QMap<QString, QtVariantProperty*> m_nameToGroup;
|
---|
173 | QList<QtProperty *> m_groups;
|
---|
174 | QtProperty *m_dynamicGroup;
|
---|
175 | QString m_recentlyAddedDynamicProperty;
|
---|
176 | bool m_updatingBrowser;
|
---|
177 |
|
---|
178 | QStackedWidget *m_stackedWidget;
|
---|
179 | FilterWidget *m_filterWidget;
|
---|
180 | int m_buttonIndex;
|
---|
181 | int m_treeIndex;
|
---|
182 | QAction *m_addDynamicAction;
|
---|
183 | QAction *m_removeDynamicAction;
|
---|
184 | QAction *m_sortingAction;
|
---|
185 | QAction *m_coloringAction;
|
---|
186 | QAction *m_treeAction;
|
---|
187 | QAction *m_buttonAction;
|
---|
188 | ElidingLabel *m_classLabel;
|
---|
189 |
|
---|
190 | bool m_sorting;
|
---|
191 | bool m_coloring;
|
---|
192 |
|
---|
193 | QMap<QString, bool> m_expansionState;
|
---|
194 |
|
---|
195 | QString m_filterPattern;
|
---|
196 | QVector<QPair<QColor, QColor> > m_colors;
|
---|
197 | QPair<QColor, QColor> m_dynamicColor;
|
---|
198 | QPair<QColor, QColor> m_layoutColor;
|
---|
199 |
|
---|
200 | bool m_brightness;
|
---|
201 | };
|
---|
202 |
|
---|
203 | } // namespace qdesigner_internal
|
---|
204 |
|
---|
205 | QT_END_NAMESPACE
|
---|
206 |
|
---|
207 | #endif // PROPERTYEDITOR_H
|
---|