author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
child 5 | d3bac044e0f0 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt Designer of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
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 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef DESIGNERPROPERTYMANAGER_H |
|
43 |
#define DESIGNERPROPERTYMANAGER_H |
|
44 |
||
45 |
#include "qtvariantproperty.h" |
|
46 |
#include "brushpropertymanager.h" |
|
47 |
#include "fontpropertymanager.h" |
|
48 |
||
49 |
#include <qdesigner_utils_p.h> |
|
50 |
#include <shared_enums_p.h> |
|
51 |
||
52 |
#include <QtCore/QUrl> |
|
53 |
#include <QtCore/QMap> |
|
54 |
#include <QtGui/QFont> |
|
55 |
#include <QtGui/QIcon> |
|
56 |
||
57 |
QT_BEGIN_NAMESPACE |
|
58 |
||
59 |
typedef QPair<QString, uint> DesignerIntPair; |
|
60 |
typedef QList<DesignerIntPair> DesignerFlagList; |
|
61 |
||
62 |
class QDesignerFormEditorInterface; |
|
63 |
class QLineEdit; |
|
64 |
class QUrl; |
|
65 |
class QtKeySequenceEdit; |
|
66 |
||
67 |
namespace qdesigner_internal |
|
68 |
{ |
|
69 |
||
70 |
class ResetWidget; |
|
71 |
||
72 |
class TextEditor; |
|
73 |
class PaletteEditorButton; |
|
74 |
class PixmapEditor; |
|
75 |
class StringListEditorButton; |
|
76 |
class FormWindowBase; |
|
77 |
||
78 |
class ResetDecorator : public QObject |
|
79 |
{ |
|
80 |
Q_OBJECT |
|
81 |
public: |
|
82 |
ResetDecorator(QObject *parent = 0) : QObject(parent), m_spacing(-1) {} |
|
83 |
~ResetDecorator(); |
|
84 |
||
85 |
void connectPropertyManager(QtAbstractPropertyManager *manager); |
|
86 |
QWidget *editor(QWidget *subEditor, bool resettable, QtAbstractPropertyManager *manager, QtProperty *property, |
|
87 |
QWidget *parent); |
|
88 |
void disconnectPropertyManager(QtAbstractPropertyManager *manager); |
|
89 |
void setSpacing(int spacing); |
|
90 |
signals: |
|
91 |
void resetProperty(QtProperty *property); |
|
92 |
private slots: |
|
93 |
void slotPropertyChanged(QtProperty *property); |
|
94 |
void slotEditorDestroyed(QObject *object); |
|
95 |
private: |
|
96 |
QMap<QtProperty *, QList<ResetWidget *> > m_createdResetWidgets; |
|
97 |
QMap<ResetWidget *, QtProperty *> m_resetWidgetToProperty; |
|
98 |
int m_spacing; |
|
99 |
}; |
|
100 |
||
101 |
class DesignerPropertyManager : public QtVariantPropertyManager |
|
102 |
{ |
|
103 |
Q_OBJECT |
|
104 |
public: |
|
105 |
DesignerPropertyManager(QDesignerFormEditorInterface *core, QObject *parent = 0); |
|
106 |
~DesignerPropertyManager(); |
|
107 |
||
108 |
virtual QStringList attributes(int propertyType) const; |
|
109 |
virtual int attributeType(int propertyType, const QString &attribute) const; |
|
110 |
||
111 |
virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const; |
|
112 |
virtual bool isPropertyTypeSupported(int propertyType) const; |
|
113 |
virtual QVariant value(const QtProperty *property) const; |
|
114 |
virtual int valueType(int propertyType) const; |
|
115 |
virtual QString valueText(const QtProperty *property) const; |
|
116 |
virtual QIcon valueIcon(const QtProperty *property) const; |
|
117 |
||
118 |
bool resetFontSubProperty(QtProperty *property); |
|
119 |
bool resetIconSubProperty(QtProperty *subProperty); |
|
120 |
||
121 |
void reloadResourceProperties(); |
|
122 |
||
123 |
static int designerFlagTypeId(); |
|
124 |
static int designerFlagListTypeId(); |
|
125 |
static int designerAlignmentTypeId(); |
|
126 |
static int designerPixmapTypeId(); |
|
127 |
static int designerIconTypeId(); |
|
128 |
static int designerStringTypeId(); |
|
129 |
static int designerKeySequenceTypeId(); |
|
130 |
||
131 |
void setObject(QObject *object) { m_object = object; } |
|
132 |
||
133 |
public Q_SLOTS: |
|
134 |
virtual void setAttribute(QtProperty *property, |
|
135 |
const QString &attribute, const QVariant &value); |
|
136 |
virtual void setValue(QtProperty *property, const QVariant &value); |
|
137 |
Q_SIGNALS: |
|
138 |
// sourceOfChange - a subproperty (or just property) which caused a change |
|
139 |
//void valueChanged(QtProperty *property, const QVariant &value, QtProperty *sourceOfChange); |
|
140 |
void valueChanged(QtProperty *property, const QVariant &value, bool enableSubPropertyHandling); |
|
141 |
protected: |
|
142 |
virtual void initializeProperty(QtProperty *property); |
|
143 |
virtual void uninitializeProperty(QtProperty *property); |
|
144 |
private Q_SLOTS: |
|
145 |
void slotValueChanged(QtProperty *property, const QVariant &value); |
|
146 |
void slotPropertyDestroyed(QtProperty *property); |
|
147 |
private: |
|
148 |
void createIconSubProperty(QtProperty *iconProperty, QIcon::Mode mode, QIcon::State state, const QString &subName); |
|
149 |
||
150 |
typedef QMap<QtProperty *, bool> PropertyBoolMap; |
|
151 |
PropertyBoolMap m_resetMap; |
|
152 |
||
153 |
int bitCount(int mask) const; |
|
154 |
struct FlagData |
|
155 |
{ |
|
156 |
FlagData() : val(0) {} |
|
157 |
uint val; |
|
158 |
DesignerFlagList flags; |
|
159 |
QList<uint> values; |
|
160 |
}; |
|
161 |
typedef QMap<QtProperty *, FlagData> PropertyFlagDataMap; |
|
162 |
PropertyFlagDataMap m_flagValues; |
|
163 |
typedef QMap<QtProperty *, QList<QtProperty *> > PropertyToPropertyListMap; |
|
164 |
PropertyToPropertyListMap m_propertyToFlags; |
|
165 |
QMap<QtProperty *, QtProperty *> m_flagToProperty; |
|
166 |
||
167 |
int alignToIndexH(uint align) const; |
|
168 |
int alignToIndexV(uint align) const; |
|
169 |
uint indexHToAlign(int idx) const; |
|
170 |
uint indexVToAlign(int idx) const; |
|
171 |
QString indexHToString(int idx) const; |
|
172 |
QString indexVToString(int idx) const; |
|
173 |
QMap<QtProperty *, uint> m_alignValues; |
|
174 |
typedef QMap<QtProperty *, QtProperty *> PropertyToPropertyMap; |
|
175 |
PropertyToPropertyMap m_propertyToAlignH; |
|
176 |
PropertyToPropertyMap m_propertyToAlignV; |
|
177 |
PropertyToPropertyMap m_alignHToProperty; |
|
178 |
PropertyToPropertyMap m_alignVToProperty; |
|
179 |
||
180 |
QMap<QtProperty *, QMap<QPair<QIcon::Mode, QIcon::State>, QtProperty *> > m_propertyToIconSubProperties; |
|
181 |
QMap<QtProperty *, QPair<QIcon::Mode, QIcon::State> > m_iconSubPropertyToState; |
|
182 |
PropertyToPropertyMap m_iconSubPropertyToProperty; |
|
183 |
||
184 |
QMap<QtProperty *, qdesigner_internal::PropertySheetStringValue> m_stringValues; |
|
185 |
QMap<QtProperty *, QtProperty *> m_stringToComment; |
|
186 |
QMap<QtProperty *, QtProperty *> m_stringToTranslatable; |
|
187 |
QMap<QtProperty *, QtProperty *> m_stringToDisambiguation; |
|
188 |
||
189 |
QMap<QtProperty *, QtProperty *> m_commentToString; |
|
190 |
QMap<QtProperty *, QtProperty *> m_translatableToString; |
|
191 |
QMap<QtProperty *, QtProperty *> m_disambiguationToString; |
|
192 |
||
193 |
QMap<QtProperty *, qdesigner_internal::PropertySheetKeySequenceValue> m_keySequenceValues; |
|
194 |
QMap<QtProperty *, QtProperty *> m_keySequenceToComment; |
|
195 |
QMap<QtProperty *, QtProperty *> m_keySequenceToTranslatable; |
|
196 |
QMap<QtProperty *, QtProperty *> m_keySequenceToDisambiguation; |
|
197 |
||
198 |
QMap<QtProperty *, QtProperty *> m_commentToKeySequence; |
|
199 |
QMap<QtProperty *, QtProperty *> m_translatableToKeySequence; |
|
200 |
QMap<QtProperty *, QtProperty *> m_disambiguationToKeySequence; |
|
201 |
||
202 |
struct PaletteData |
|
203 |
{ |
|
204 |
QPalette val; |
|
205 |
QPalette superPalette; |
|
206 |
}; |
|
207 |
typedef QMap<QtProperty *, PaletteData> PropertyPaletteDataMap; |
|
208 |
PropertyPaletteDataMap m_paletteValues; |
|
209 |
||
210 |
QMap<QtProperty *, qdesigner_internal::PropertySheetPixmapValue> m_pixmapValues; |
|
211 |
QMap<QtProperty *, qdesigner_internal::PropertySheetIconValue> m_iconValues; |
|
212 |
||
213 |
QMap<QtProperty *, uint> m_uintValues; |
|
214 |
QMap<QtProperty *, qlonglong> m_longLongValues; |
|
215 |
QMap<QtProperty *, qulonglong> m_uLongLongValues; |
|
216 |
QMap<QtProperty *, QUrl> m_urlValues; |
|
217 |
QMap<QtProperty *, QByteArray> m_byteArrayValues; |
|
218 |
QMap<QtProperty *, QStringList> m_stringListValues; |
|
219 |
||
220 |
typedef QMap<QtProperty *, int> PropertyIntMap; |
|
221 |
PropertyIntMap m_stringAttributes; |
|
222 |
typedef QMap<QtProperty *, QFont> PropertyFontMap; |
|
223 |
PropertyFontMap m_stringFontAttributes; |
|
224 |
||
225 |
BrushPropertyManager m_brushManager; |
|
226 |
FontPropertyManager m_fontManager; |
|
227 |
||
228 |
QMap<QtProperty *, QPixmap> m_defaultPixmaps; |
|
229 |
QMap<QtProperty *, QIcon> m_defaultIcons; |
|
230 |
||
231 |
bool m_changingSubValue; |
|
232 |
QDesignerFormEditorInterface *m_core; |
|
233 |
||
234 |
QObject *m_object; |
|
235 |
||
236 |
QtProperty *m_sourceOfChange; |
|
237 |
}; |
|
238 |
||
239 |
class DesignerEditorFactory : public QtVariantEditorFactory |
|
240 |
{ |
|
241 |
Q_OBJECT |
|
242 |
public: |
|
243 |
explicit DesignerEditorFactory(QDesignerFormEditorInterface *core, QObject *parent = 0); |
|
244 |
~DesignerEditorFactory(); |
|
245 |
void setSpacing(int spacing); |
|
246 |
void setFormWindowBase(FormWindowBase *fwb); |
|
247 |
signals: |
|
248 |
void resetProperty(QtProperty *property); |
|
249 |
protected: |
|
250 |
void connectPropertyManager(QtVariantPropertyManager *manager); |
|
251 |
QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property, |
|
252 |
QWidget *parent); |
|
253 |
void disconnectPropertyManager(QtVariantPropertyManager *manager); |
|
254 |
private slots: |
|
255 |
void slotEditorDestroyed(QObject *object); |
|
256 |
void slotAttributeChanged(QtProperty *property, const QString &attribute, const QVariant &value); |
|
257 |
void slotPropertyChanged(QtProperty *property); |
|
258 |
void slotValueChanged(QtProperty *property, const QVariant &value); |
|
259 |
void slotStringTextChanged(const QString &value); |
|
260 |
void slotKeySequenceChanged(const QKeySequence &value); |
|
261 |
void slotPaletteChanged(const QPalette &value); |
|
262 |
void slotPixmapChanged(const QString &value); |
|
263 |
void slotIconChanged(const QString &value); |
|
264 |
void slotUintChanged(const QString &value); |
|
265 |
void slotLongLongChanged(const QString &value); |
|
266 |
void slotULongLongChanged(const QString &value); |
|
267 |
void slotUrlChanged(const QString &value); |
|
268 |
void slotByteArrayChanged(const QString &value); |
|
269 |
void slotStringListChanged(const QStringList &value); |
|
270 |
private: |
|
271 |
TextEditor *createTextEditor(QWidget *parent, TextPropertyValidationMode vm, const QString &value); |
|
272 |
||
273 |
ResetDecorator *m_resetDecorator; |
|
274 |
bool m_changingPropertyValue; |
|
275 |
QDesignerFormEditorInterface *m_core; |
|
276 |
FormWindowBase *m_fwb; |
|
277 |
||
278 |
int m_spacing; |
|
279 |
||
280 |
QMap<QtProperty *, QList<TextEditor *> > m_stringPropertyToEditors; |
|
281 |
QMap<TextEditor *, QtProperty *> m_editorToStringProperty; |
|
282 |
QMap<QtProperty *, QList<QtKeySequenceEdit *> > m_keySequencePropertyToEditors; |
|
283 |
QMap<QtKeySequenceEdit *, QtProperty *> m_editorToKeySequenceProperty; |
|
284 |
QMap<QtProperty *, QList<PaletteEditorButton *> > m_palettePropertyToEditors; |
|
285 |
QMap<PaletteEditorButton *, QtProperty *> m_editorToPaletteProperty; |
|
286 |
QMap<QtProperty *, QList<PixmapEditor *> > m_pixmapPropertyToEditors; |
|
287 |
QMap<PixmapEditor *, QtProperty *> m_editorToPixmapProperty; |
|
288 |
QMap<QtProperty *, QList<PixmapEditor *> > m_iconPropertyToEditors; |
|
289 |
QMap<PixmapEditor *, QtProperty *> m_editorToIconProperty; |
|
290 |
QMap<QtProperty *, QList<QLineEdit *> > m_uintPropertyToEditors; |
|
291 |
QMap<QLineEdit *, QtProperty *> m_editorToUintProperty; |
|
292 |
QMap<QtProperty *, QList<QLineEdit *> > m_longLongPropertyToEditors; |
|
293 |
QMap<QLineEdit *, QtProperty *> m_editorToLongLongProperty; |
|
294 |
QMap<QtProperty *, QList<QLineEdit *> > m_uLongLongPropertyToEditors; |
|
295 |
QMap<QLineEdit *, QtProperty *> m_editorToULongLongProperty; |
|
296 |
QMap<QtProperty *, QList<TextEditor *> > m_urlPropertyToEditors; |
|
297 |
QMap<TextEditor *, QtProperty *> m_editorToUrlProperty; |
|
298 |
QMap<QtProperty *, QList<TextEditor *> > m_byteArrayPropertyToEditors; |
|
299 |
QMap<TextEditor *, QtProperty *> m_editorToByteArrayProperty; |
|
300 |
QMap<QtProperty *, QList<StringListEditorButton *> > m_stringListPropertyToEditors; |
|
301 |
QMap<StringListEditorButton *, QtProperty *> m_editorToStringListProperty; |
|
302 |
}; |
|
303 |
||
304 |
} |
|
305 |
||
306 |
QT_END_NAMESPACE |
|
307 |
||
308 |
Q_DECLARE_METATYPE(DesignerIntPair) |
|
309 |
Q_DECLARE_METATYPE(DesignerFlagList) |
|
310 |
||
311 |
#endif |
|
312 |