1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation (qt-info@nokia.com)
|
---|
6 | **
|
---|
7 | ** This file is part of the tools applications 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 qt-info@nokia.com.
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "qtpropertymanager.h"
|
---|
43 | #include "qtpropertybrowserutils_p.h"
|
---|
44 | #include <QtCore/QDateTime>
|
---|
45 | #include <QtCore/QLocale>
|
---|
46 | #include <QtCore/QMap>
|
---|
47 | #include <QtCore/QTimer>
|
---|
48 | #include <QtGui/QIcon>
|
---|
49 | #include <QtCore/QMetaEnum>
|
---|
50 | #include <QtGui/QFontDatabase>
|
---|
51 | #include <QtGui/QStyleOption>
|
---|
52 | #include <QtGui/QStyle>
|
---|
53 | #include <QtGui/QApplication>
|
---|
54 | #include <QtGui/QPainter>
|
---|
55 | #include <QtGui/QLabel>
|
---|
56 |
|
---|
57 | #include <limits.h>
|
---|
58 | #include <float.h>
|
---|
59 |
|
---|
60 | #if defined(Q_CC_MSVC)
|
---|
61 | # pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */
|
---|
62 | #endif
|
---|
63 |
|
---|
64 | QT_BEGIN_NAMESPACE
|
---|
65 |
|
---|
66 | template <class PrivateData, class Value>
|
---|
67 | static void setSimpleMinimumData(PrivateData *data, const Value &minVal)
|
---|
68 | {
|
---|
69 | data->minVal = minVal;
|
---|
70 | if (data->maxVal < data->minVal)
|
---|
71 | data->maxVal = data->minVal;
|
---|
72 |
|
---|
73 | if (data->val < data->minVal)
|
---|
74 | data->val = data->minVal;
|
---|
75 | }
|
---|
76 |
|
---|
77 | template <class PrivateData, class Value>
|
---|
78 | static void setSimpleMaximumData(PrivateData *data, const Value &maxVal)
|
---|
79 | {
|
---|
80 | data->maxVal = maxVal;
|
---|
81 | if (data->minVal > data->maxVal)
|
---|
82 | data->minVal = data->maxVal;
|
---|
83 |
|
---|
84 | if (data->val > data->maxVal)
|
---|
85 | data->val = data->maxVal;
|
---|
86 | }
|
---|
87 |
|
---|
88 | template <class PrivateData, class Value>
|
---|
89 | static void setSizeMinimumData(PrivateData *data, const Value &newMinVal)
|
---|
90 | {
|
---|
91 | data->minVal = newMinVal;
|
---|
92 | if (data->maxVal.width() < data->minVal.width())
|
---|
93 | data->maxVal.setWidth(data->minVal.width());
|
---|
94 | if (data->maxVal.height() < data->minVal.height())
|
---|
95 | data->maxVal.setHeight(data->minVal.height());
|
---|
96 |
|
---|
97 | if (data->val.width() < data->minVal.width())
|
---|
98 | data->val.setWidth(data->minVal.width());
|
---|
99 | if (data->val.height() < data->minVal.height())
|
---|
100 | data->val.setHeight(data->minVal.height());
|
---|
101 | }
|
---|
102 |
|
---|
103 | template <class PrivateData, class Value>
|
---|
104 | static void setSizeMaximumData(PrivateData *data, const Value &newMaxVal)
|
---|
105 | {
|
---|
106 | data->maxVal = newMaxVal;
|
---|
107 | if (data->minVal.width() > data->maxVal.width())
|
---|
108 | data->minVal.setWidth(data->maxVal.width());
|
---|
109 | if (data->minVal.height() > data->maxVal.height())
|
---|
110 | data->minVal.setHeight(data->maxVal.height());
|
---|
111 |
|
---|
112 | if (data->val.width() > data->maxVal.width())
|
---|
113 | data->val.setWidth(data->maxVal.width());
|
---|
114 | if (data->val.height() > data->maxVal.height())
|
---|
115 | data->val.setHeight(data->maxVal.height());
|
---|
116 | }
|
---|
117 |
|
---|
118 | template <class SizeValue>
|
---|
119 | static SizeValue qBoundSize(const SizeValue &minVal, const SizeValue &val, const SizeValue &maxVal)
|
---|
120 | {
|
---|
121 | SizeValue croppedVal = val;
|
---|
122 | if (minVal.width() > val.width())
|
---|
123 | croppedVal.setWidth(minVal.width());
|
---|
124 | else if (maxVal.width() < val.width())
|
---|
125 | croppedVal.setWidth(maxVal.width());
|
---|
126 |
|
---|
127 | if (minVal.height() > val.height())
|
---|
128 | croppedVal.setHeight(minVal.height());
|
---|
129 | else if (maxVal.height() < val.height())
|
---|
130 | croppedVal.setHeight(maxVal.height());
|
---|
131 |
|
---|
132 | return croppedVal;
|
---|
133 | }
|
---|
134 |
|
---|
135 | // Match the exact signature of qBound for VS 6.
|
---|
136 | QSize qBound(QSize minVal, QSize val, QSize maxVal)
|
---|
137 | {
|
---|
138 | return qBoundSize(minVal, val, maxVal);
|
---|
139 | }
|
---|
140 |
|
---|
141 | QSizeF qBound(QSizeF minVal, QSizeF val, QSizeF maxVal)
|
---|
142 | {
|
---|
143 | return qBoundSize(minVal, val, maxVal);
|
---|
144 | }
|
---|
145 |
|
---|
146 | namespace {
|
---|
147 |
|
---|
148 | namespace {
|
---|
149 | template <class Value>
|
---|
150 | void orderBorders(Value &minVal, Value &maxVal)
|
---|
151 | {
|
---|
152 | if (minVal > maxVal)
|
---|
153 | qSwap(minVal, maxVal);
|
---|
154 | }
|
---|
155 |
|
---|
156 | template <class Value>
|
---|
157 | static void orderSizeBorders(Value &minVal, Value &maxVal)
|
---|
158 | {
|
---|
159 | Value fromSize = minVal;
|
---|
160 | Value toSize = maxVal;
|
---|
161 | if (fromSize.width() > toSize.width()) {
|
---|
162 | fromSize.setWidth(maxVal.width());
|
---|
163 | toSize.setWidth(minVal.width());
|
---|
164 | }
|
---|
165 | if (fromSize.height() > toSize.height()) {
|
---|
166 | fromSize.setHeight(maxVal.height());
|
---|
167 | toSize.setHeight(minVal.height());
|
---|
168 | }
|
---|
169 | minVal = fromSize;
|
---|
170 | maxVal = toSize;
|
---|
171 | }
|
---|
172 |
|
---|
173 | void orderBorders(QSize &minVal, QSize &maxVal)
|
---|
174 | {
|
---|
175 | orderSizeBorders(minVal, maxVal);
|
---|
176 | }
|
---|
177 |
|
---|
178 | void orderBorders(QSizeF &minVal, QSizeF &maxVal)
|
---|
179 | {
|
---|
180 | orderSizeBorders(minVal, maxVal);
|
---|
181 | }
|
---|
182 |
|
---|
183 | }
|
---|
184 | }
|
---|
185 | ////////
|
---|
186 |
|
---|
187 | template <class Value, class PrivateData>
|
---|
188 | static Value getData(const QMap<const QtProperty *, PrivateData> &propertyMap,
|
---|
189 | Value PrivateData::*data,
|
---|
190 | const QtProperty *property, const Value &defaultValue = Value())
|
---|
191 | {
|
---|
192 | typedef QMap<const QtProperty *, PrivateData> PropertyToData;
|
---|
193 | typedef Q_TYPENAME PropertyToData::const_iterator PropertyToDataConstIterator;
|
---|
194 | const PropertyToDataConstIterator it = propertyMap.constFind(property);
|
---|
195 | if (it == propertyMap.constEnd())
|
---|
196 | return defaultValue;
|
---|
197 | return it.value().*data;
|
---|
198 | }
|
---|
199 |
|
---|
200 | template <class Value, class PrivateData>
|
---|
201 | static Value getValue(const QMap<const QtProperty *, PrivateData> &propertyMap,
|
---|
202 | const QtProperty *property, const Value &defaultValue = Value())
|
---|
203 | {
|
---|
204 | return getData<Value>(propertyMap, &PrivateData::val, property, defaultValue);
|
---|
205 | }
|
---|
206 |
|
---|
207 | template <class Value, class PrivateData>
|
---|
208 | static Value getMinimum(const QMap<const QtProperty *, PrivateData> &propertyMap,
|
---|
209 | const QtProperty *property, const Value &defaultValue = Value())
|
---|
210 | {
|
---|
211 | return getData<Value>(propertyMap, &PrivateData::minVal, property, defaultValue);
|
---|
212 | }
|
---|
213 |
|
---|
214 | template <class Value, class PrivateData>
|
---|
215 | static Value getMaximum(const QMap<const QtProperty *, PrivateData> &propertyMap,
|
---|
216 | const QtProperty *property, const Value &defaultValue = Value())
|
---|
217 | {
|
---|
218 | return getData<Value>(propertyMap, &PrivateData::maxVal, property, defaultValue);
|
---|
219 | }
|
---|
220 |
|
---|
221 | template <class ValueChangeParameter, class Value, class PropertyManager>
|
---|
222 | static void setSimpleValue(QMap<const QtProperty *, Value> &propertyMap,
|
---|
223 | PropertyManager *manager,
|
---|
224 | void (PropertyManager::*propertyChangedSignal)(QtProperty *),
|
---|
225 | void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter),
|
---|
226 | QtProperty *property, const Value &val)
|
---|
227 | {
|
---|
228 | typedef QMap<const QtProperty *, Value> PropertyToData;
|
---|
229 | typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator;
|
---|
230 | const PropertyToDataIterator it = propertyMap.find(property);
|
---|
231 | if (it == propertyMap.end())
|
---|
232 | return;
|
---|
233 |
|
---|
234 | if (it.value() == val)
|
---|
235 | return;
|
---|
236 |
|
---|
237 | it.value() = val;
|
---|
238 |
|
---|
239 | emit (manager->*propertyChangedSignal)(property);
|
---|
240 | emit (manager->*valueChangedSignal)(property, val);
|
---|
241 | }
|
---|
242 |
|
---|
243 | template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value>
|
---|
244 | static void setValueInRange(PropertyManager *manager, PropertyManagerPrivate *managerPrivate,
|
---|
245 | void (PropertyManager::*propertyChangedSignal)(QtProperty *),
|
---|
246 | void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter),
|
---|
247 | QtProperty *property, const Value &val,
|
---|
248 | void (PropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, ValueChangeParameter))
|
---|
249 | {
|
---|
250 | typedef Q_TYPENAME PropertyManagerPrivate::Data PrivateData;
|
---|
251 | typedef QMap<const QtProperty *, PrivateData> PropertyToData;
|
---|
252 | typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator;
|
---|
253 | const PropertyToDataIterator it = managerPrivate->m_values.find(property);
|
---|
254 | if (it == managerPrivate->m_values.end())
|
---|
255 | return;
|
---|
256 |
|
---|
257 | PrivateData &data = it.value();
|
---|
258 |
|
---|
259 | if (data.val == val)
|
---|
260 | return;
|
---|
261 |
|
---|
262 | const Value oldVal = data.val;
|
---|
263 |
|
---|
264 | data.val = qBound(data.minVal, val, data.maxVal);
|
---|
265 |
|
---|
266 | if (data.val == oldVal)
|
---|
267 | return;
|
---|
268 |
|
---|
269 | if (setSubPropertyValue)
|
---|
270 | (managerPrivate->*setSubPropertyValue)(property, data.val);
|
---|
271 |
|
---|
272 | emit (manager->*propertyChangedSignal)(property);
|
---|
273 | emit (manager->*valueChangedSignal)(property, data.val);
|
---|
274 | }
|
---|
275 |
|
---|
276 | template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value>
|
---|
277 | static void setBorderValues(PropertyManager *manager, PropertyManagerPrivate *managerPrivate,
|
---|
278 | void (PropertyManager::*propertyChangedSignal)(QtProperty *),
|
---|
279 | void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter),
|
---|
280 | void (PropertyManager::*rangeChangedSignal)(QtProperty *, ValueChangeParameter, ValueChangeParameter),
|
---|
281 | QtProperty *property, const Value &minVal, const Value &maxVal,
|
---|
282 | void (PropertyManagerPrivate::*setSubPropertyRange)(QtProperty *,
|
---|
283 | ValueChangeParameter, ValueChangeParameter, ValueChangeParameter))
|
---|
284 | {
|
---|
285 | typedef Q_TYPENAME PropertyManagerPrivate::Data PrivateData;
|
---|
286 | typedef QMap<const QtProperty *, PrivateData> PropertyToData;
|
---|
287 | typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator;
|
---|
288 | const PropertyToDataIterator it = managerPrivate->m_values.find(property);
|
---|
289 | if (it == managerPrivate->m_values.end())
|
---|
290 | return;
|
---|
291 |
|
---|
292 | Value fromVal = minVal;
|
---|
293 | Value toVal = maxVal;
|
---|
294 | orderBorders(fromVal, toVal);
|
---|
295 |
|
---|
296 | PrivateData &data = it.value();
|
---|
297 |
|
---|
298 | if (data.minVal == fromVal && data.maxVal == toVal)
|
---|
299 | return;
|
---|
300 |
|
---|
301 | const Value oldVal = data.val;
|
---|
302 |
|
---|
303 | data.setMinimumValue(fromVal);
|
---|
304 | data.setMaximumValue(toVal);
|
---|
305 |
|
---|
306 | emit (manager->*rangeChangedSignal)(property, data.minVal, data.maxVal);
|
---|
307 |
|
---|
308 | if (setSubPropertyRange)
|
---|
309 | (managerPrivate->*setSubPropertyRange)(property, data.minVal, data.maxVal, data.val);
|
---|
310 |
|
---|
311 | if (data.val == oldVal)
|
---|
312 | return;
|
---|
313 |
|
---|
314 | emit (manager->*propertyChangedSignal)(property);
|
---|
315 | emit (manager->*valueChangedSignal)(property, data.val);
|
---|
316 | }
|
---|
317 |
|
---|
318 | template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value, class PrivateData>
|
---|
319 | static void setBorderValue(PropertyManager *manager, PropertyManagerPrivate *managerPrivate,
|
---|
320 | void (PropertyManager::*propertyChangedSignal)(QtProperty *),
|
---|
321 | void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter),
|
---|
322 | void (PropertyManager::*rangeChangedSignal)(QtProperty *, ValueChangeParameter, ValueChangeParameter),
|
---|
323 | QtProperty *property,
|
---|
324 | Value (PrivateData::*getRangeVal)() const,
|
---|
325 | void (PrivateData::*setRangeVal)(ValueChangeParameter), const Value &borderVal,
|
---|
326 | void (PropertyManagerPrivate::*setSubPropertyRange)(QtProperty *,
|
---|
327 | ValueChangeParameter, ValueChangeParameter, ValueChangeParameter))
|
---|
328 | {
|
---|
329 | typedef QMap<const QtProperty *, PrivateData> PropertyToData;
|
---|
330 | typedef Q_TYPENAME PropertyToData::iterator PropertyToDataIterator;
|
---|
331 | const PropertyToDataIterator it = managerPrivate->m_values.find(property);
|
---|
332 | if (it == managerPrivate->m_values.end())
|
---|
333 | return;
|
---|
334 |
|
---|
335 | PrivateData &data = it.value();
|
---|
336 |
|
---|
337 | if ((data.*getRangeVal)() == borderVal)
|
---|
338 | return;
|
---|
339 |
|
---|
340 | const Value oldVal = data.val;
|
---|
341 |
|
---|
342 | (data.*setRangeVal)(borderVal);
|
---|
343 |
|
---|
344 | emit (manager->*rangeChangedSignal)(property, data.minVal, data.maxVal);
|
---|
345 |
|
---|
346 | if (setSubPropertyRange)
|
---|
347 | (managerPrivate->*setSubPropertyRange)(property, data.minVal, data.maxVal, data.val);
|
---|
348 |
|
---|
349 | if (data.val == oldVal)
|
---|
350 | return;
|
---|
351 |
|
---|
352 | emit (manager->*propertyChangedSignal)(property);
|
---|
353 | emit (manager->*valueChangedSignal)(property, data.val);
|
---|
354 | }
|
---|
355 |
|
---|
356 | template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value, class PrivateData>
|
---|
357 | static void setMinimumValue(PropertyManager *manager, PropertyManagerPrivate *managerPrivate,
|
---|
358 | void (PropertyManager::*propertyChangedSignal)(QtProperty *),
|
---|
359 | void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter),
|
---|
360 | void (PropertyManager::*rangeChangedSignal)(QtProperty *, ValueChangeParameter, ValueChangeParameter),
|
---|
361 | QtProperty *property, const Value &minVal)
|
---|
362 | {
|
---|
363 | void (PropertyManagerPrivate::*setSubPropertyRange)(QtProperty *,
|
---|
364 | ValueChangeParameter, ValueChangeParameter, ValueChangeParameter) = 0;
|
---|
365 | setBorderValue<ValueChangeParameter, PropertyManagerPrivate, PropertyManager, Value, PrivateData>(manager, managerPrivate,
|
---|
366 | propertyChangedSignal, valueChangedSignal, rangeChangedSignal,
|
---|
367 | property, &PropertyManagerPrivate::Data::minimumValue, &PropertyManagerPrivate::Data::setMinimumValue, minVal, setSubPropertyRange);
|
---|
368 | }
|
---|
369 |
|
---|
370 | template <class ValueChangeParameter, class PropertyManagerPrivate, class PropertyManager, class Value, class PrivateData>
|
---|
371 | static void setMaximumValue(PropertyManager *manager, PropertyManagerPrivate *managerPrivate,
|
---|
372 | void (PropertyManager::*propertyChangedSignal)(QtProperty *),
|
---|
373 | void (PropertyManager::*valueChangedSignal)(QtProperty *, ValueChangeParameter),
|
---|
374 | void (PropertyManager::*rangeChangedSignal)(QtProperty *, ValueChangeParameter, ValueChangeParameter),
|
---|
375 | QtProperty *property, const Value &maxVal)
|
---|
376 | {
|
---|
377 | void (PropertyManagerPrivate::*setSubPropertyRange)(QtProperty *,
|
---|
378 | ValueChangeParameter, ValueChangeParameter, ValueChangeParameter) = 0;
|
---|
379 | setBorderValue<ValueChangeParameter, PropertyManagerPrivate, PropertyManager, Value, PrivateData>(manager, managerPrivate,
|
---|
380 | propertyChangedSignal, valueChangedSignal, rangeChangedSignal,
|
---|
381 | property, &PropertyManagerPrivate::Data::maximumValue, &PropertyManagerPrivate::Data::setMaximumValue, maxVal, setSubPropertyRange);
|
---|
382 | }
|
---|
383 |
|
---|
384 | class QtMetaEnumWrapper : public QObject
|
---|
385 | {
|
---|
386 | Q_OBJECT
|
---|
387 | Q_PROPERTY(QSizePolicy::Policy policy READ policy)
|
---|
388 | public:
|
---|
389 | QSizePolicy::Policy policy() const { return QSizePolicy::Ignored; }
|
---|
390 | private:
|
---|
391 | QtMetaEnumWrapper(QObject *parent) : QObject(parent) {}
|
---|
392 | };
|
---|
393 |
|
---|
394 | class QtMetaEnumProvider
|
---|
395 | {
|
---|
396 | public:
|
---|
397 | QtMetaEnumProvider();
|
---|
398 |
|
---|
399 | QStringList policyEnumNames() const { return m_policyEnumNames; }
|
---|
400 | QStringList languageEnumNames() const { return m_languageEnumNames; }
|
---|
401 | QStringList countryEnumNames(QLocale::Language language) const { return m_countryEnumNames.value(language); }
|
---|
402 |
|
---|
403 | QSizePolicy::Policy indexToSizePolicy(int index) const;
|
---|
404 | int sizePolicyToIndex(QSizePolicy::Policy policy) const;
|
---|
405 |
|
---|
406 | void indexToLocale(int languageIndex, int countryIndex, QLocale::Language *language, QLocale::Country *country) const;
|
---|
407 | void localeToIndex(QLocale::Language language, QLocale::Country country, int *languageIndex, int *countryIndex) const;
|
---|
408 |
|
---|
409 | private:
|
---|
410 | void initLocale();
|
---|
411 |
|
---|
412 | QStringList m_policyEnumNames;
|
---|
413 | QStringList m_languageEnumNames;
|
---|
414 | QMap<QLocale::Language, QStringList> m_countryEnumNames;
|
---|
415 | QMap<int, QLocale::Language> m_indexToLanguage;
|
---|
416 | QMap<QLocale::Language, int> m_languageToIndex;
|
---|
417 | QMap<int, QMap<int, QLocale::Country> > m_indexToCountry;
|
---|
418 | QMap<QLocale::Language, QMap<QLocale::Country, int> > m_countryToIndex;
|
---|
419 | QMetaEnum m_policyEnum;
|
---|
420 | };
|
---|
421 |
|
---|
422 | static QList<QLocale::Country> sortCountries(const QList<QLocale::Country> &countries)
|
---|
423 | {
|
---|
424 | QMultiMap<QString, QLocale::Country> nameToCountry;
|
---|
425 | QListIterator<QLocale::Country> itCountry(countries);
|
---|
426 | while (itCountry.hasNext()) {
|
---|
427 | QLocale::Country country = itCountry.next();
|
---|
428 | nameToCountry.insert(QLocale::countryToString(country), country);
|
---|
429 | }
|
---|
430 | return nameToCountry.values();
|
---|
431 | }
|
---|
432 |
|
---|
433 | void QtMetaEnumProvider::initLocale()
|
---|
434 | {
|
---|
435 | QMultiMap<QString, QLocale::Language> nameToLanguage;
|
---|
436 | QLocale::Language language = QLocale::C;
|
---|
437 | while (language <= QLocale::LastLanguage) {
|
---|
438 | QLocale locale(language);
|
---|
439 | if (locale.language() == language)
|
---|
440 | nameToLanguage.insert(QLocale::languageToString(language), language);
|
---|
441 | language = (QLocale::Language)((uint)language + 1); // ++language
|
---|
442 | }
|
---|
443 |
|
---|
444 | const QLocale system = QLocale::system();
|
---|
445 | if (!nameToLanguage.contains(QLocale::languageToString(system.language())))
|
---|
446 | nameToLanguage.insert(QLocale::languageToString(system.language()), system.language());
|
---|
447 |
|
---|
448 | QList<QLocale::Language> languages = nameToLanguage.values();
|
---|
449 | QListIterator<QLocale::Language> itLang(languages);
|
---|
450 | while (itLang.hasNext()) {
|
---|
451 | QLocale::Language language = itLang.next();
|
---|
452 | QList<QLocale::Country> countries;
|
---|
453 | countries = QLocale::countriesForLanguage(language);
|
---|
454 | if (countries.isEmpty() && language == system.language())
|
---|
455 | countries << system.country();
|
---|
456 |
|
---|
457 | if (!countries.isEmpty() && !m_languageToIndex.contains(language)) {
|
---|
458 | countries = sortCountries(countries);
|
---|
459 | int langIdx = m_languageEnumNames.count();
|
---|
460 | m_indexToLanguage[langIdx] = language;
|
---|
461 | m_languageToIndex[language] = langIdx;
|
---|
462 | QStringList countryNames;
|
---|
463 | QListIterator<QLocale::Country> it(countries);
|
---|
464 | int countryIdx = 0;
|
---|
465 | while (it.hasNext()) {
|
---|
466 | QLocale::Country country = it.next();
|
---|
467 | countryNames << QLocale::countryToString(country);
|
---|
468 | m_indexToCountry[langIdx][countryIdx] = country;
|
---|
469 | m_countryToIndex[language][country] = countryIdx;
|
---|
470 | ++countryIdx;
|
---|
471 | }
|
---|
472 | m_languageEnumNames << QLocale::languageToString(language);
|
---|
473 | m_countryEnumNames[language] = countryNames;
|
---|
474 | }
|
---|
475 | }
|
---|
476 | }
|
---|
477 |
|
---|
478 | QtMetaEnumProvider::QtMetaEnumProvider()
|
---|
479 | {
|
---|
480 | QMetaProperty p;
|
---|
481 |
|
---|
482 | p = QtMetaEnumWrapper::staticMetaObject.property(
|
---|
483 | QtMetaEnumWrapper::staticMetaObject.propertyOffset() + 0);
|
---|
484 | m_policyEnum = p.enumerator();
|
---|
485 | const int keyCount = m_policyEnum.keyCount();
|
---|
486 | for (int i = 0; i < keyCount; i++)
|
---|
487 | m_policyEnumNames << QLatin1String(m_policyEnum.key(i));
|
---|
488 |
|
---|
489 | initLocale();
|
---|
490 | }
|
---|
491 |
|
---|
492 | QSizePolicy::Policy QtMetaEnumProvider::indexToSizePolicy(int index) const
|
---|
493 | {
|
---|
494 | return static_cast<QSizePolicy::Policy>(m_policyEnum.value(index));
|
---|
495 | }
|
---|
496 |
|
---|
497 | int QtMetaEnumProvider::sizePolicyToIndex(QSizePolicy::Policy policy) const
|
---|
498 | {
|
---|
499 | const int keyCount = m_policyEnum.keyCount();
|
---|
500 | for (int i = 0; i < keyCount; i++)
|
---|
501 | if (indexToSizePolicy(i) == policy)
|
---|
502 | return i;
|
---|
503 | return -1;
|
---|
504 | }
|
---|
505 |
|
---|
506 | void QtMetaEnumProvider::indexToLocale(int languageIndex, int countryIndex, QLocale::Language *language, QLocale::Country *country) const
|
---|
507 | {
|
---|
508 | QLocale::Language l = QLocale::C;
|
---|
509 | QLocale::Country c = QLocale::AnyCountry;
|
---|
510 | if (m_indexToLanguage.contains(languageIndex)) {
|
---|
511 | l = m_indexToLanguage[languageIndex];
|
---|
512 | if (m_indexToCountry.contains(languageIndex) && m_indexToCountry[languageIndex].contains(countryIndex))
|
---|
513 | c = m_indexToCountry[languageIndex][countryIndex];
|
---|
514 | }
|
---|
515 | if (language)
|
---|
516 | *language = l;
|
---|
517 | if (country)
|
---|
518 | *country = c;
|
---|
519 | }
|
---|
520 |
|
---|
521 | void QtMetaEnumProvider::localeToIndex(QLocale::Language language, QLocale::Country country, int *languageIndex, int *countryIndex) const
|
---|
522 | {
|
---|
523 | int l = -1;
|
---|
524 | int c = -1;
|
---|
525 | if (m_languageToIndex.contains(language)) {
|
---|
526 | l = m_languageToIndex[language];
|
---|
527 | if (m_countryToIndex.contains(language) && m_countryToIndex[language].contains(country))
|
---|
528 | c = m_countryToIndex[language][country];
|
---|
529 | }
|
---|
530 |
|
---|
531 | if (languageIndex)
|
---|
532 | *languageIndex = l;
|
---|
533 | if (countryIndex)
|
---|
534 | *countryIndex = c;
|
---|
535 | }
|
---|
536 |
|
---|
537 | Q_GLOBAL_STATIC(QtMetaEnumProvider, metaEnumProvider)
|
---|
538 |
|
---|
539 | // QtGroupPropertyManager
|
---|
540 |
|
---|
541 | /*!
|
---|
542 | \class QtGroupPropertyManager
|
---|
543 | \internal
|
---|
544 | \inmodule QtDesigner
|
---|
545 | \since 4.4
|
---|
546 |
|
---|
547 | \brief The QtGroupPropertyManager provides and manages group properties.
|
---|
548 |
|
---|
549 | This class is intended to provide a grouping element without any value.
|
---|
550 |
|
---|
551 | \sa QtAbstractPropertyManager
|
---|
552 | */
|
---|
553 |
|
---|
554 | /*!
|
---|
555 | Creates a manager with the given \a parent.
|
---|
556 | */
|
---|
557 | QtGroupPropertyManager::QtGroupPropertyManager(QObject *parent)
|
---|
558 | : QtAbstractPropertyManager(parent)
|
---|
559 | {
|
---|
560 |
|
---|
561 | }
|
---|
562 |
|
---|
563 | /*!
|
---|
564 | Destroys this manager, and all the properties it has created.
|
---|
565 | */
|
---|
566 | QtGroupPropertyManager::~QtGroupPropertyManager()
|
---|
567 | {
|
---|
568 |
|
---|
569 | }
|
---|
570 |
|
---|
571 | /*!
|
---|
572 | \reimp
|
---|
573 | */
|
---|
574 | bool QtGroupPropertyManager::hasValue(const QtProperty *property) const
|
---|
575 | {
|
---|
576 | Q_UNUSED(property)
|
---|
577 | return false;
|
---|
578 | }
|
---|
579 |
|
---|
580 | /*!
|
---|
581 | \reimp
|
---|
582 | */
|
---|
583 | void QtGroupPropertyManager::initializeProperty(QtProperty *property)
|
---|
584 | {
|
---|
585 | Q_UNUSED(property)
|
---|
586 | }
|
---|
587 |
|
---|
588 | /*!
|
---|
589 | \reimp
|
---|
590 | */
|
---|
591 | void QtGroupPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
592 | {
|
---|
593 | Q_UNUSED(property)
|
---|
594 | }
|
---|
595 |
|
---|
596 | // QtIntPropertyManager
|
---|
597 |
|
---|
598 | class QtIntPropertyManagerPrivate
|
---|
599 | {
|
---|
600 | QtIntPropertyManager *q_ptr;
|
---|
601 | Q_DECLARE_PUBLIC(QtIntPropertyManager)
|
---|
602 | public:
|
---|
603 |
|
---|
604 | struct Data
|
---|
605 | {
|
---|
606 | Data() : val(0), minVal(-INT_MAX), maxVal(INT_MAX), singleStep(1) {}
|
---|
607 | int val;
|
---|
608 | int minVal;
|
---|
609 | int maxVal;
|
---|
610 | int singleStep;
|
---|
611 | int minimumValue() const { return minVal; }
|
---|
612 | int maximumValue() const { return maxVal; }
|
---|
613 | void setMinimumValue(int newMinVal) { setSimpleMinimumData(this, newMinVal); }
|
---|
614 | void setMaximumValue(int newMaxVal) { setSimpleMaximumData(this, newMaxVal); }
|
---|
615 | };
|
---|
616 |
|
---|
617 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
618 | PropertyValueMap m_values;
|
---|
619 | };
|
---|
620 |
|
---|
621 | /*!
|
---|
622 | \class QtIntPropertyManager
|
---|
623 | \internal
|
---|
624 | \inmodule QtDesigner
|
---|
625 | \since 4.4
|
---|
626 |
|
---|
627 | \brief The QtIntPropertyManager provides and manages int properties.
|
---|
628 |
|
---|
629 | An int property has a current value, and a range specifying the
|
---|
630 | valid values. The range is defined by a minimum and a maximum
|
---|
631 | value.
|
---|
632 |
|
---|
633 | The property's value and range can be retrieved using the value(),
|
---|
634 | minimum() and maximum() functions, and can be set using the
|
---|
635 | setValue(), setMinimum() and setMaximum() slots. Alternatively,
|
---|
636 | the range can be defined in one go using the setRange() slot.
|
---|
637 |
|
---|
638 | In addition, QtIntPropertyManager provides the valueChanged() signal which
|
---|
639 | is emitted whenever a property created by this manager changes,
|
---|
640 | and the rangeChanged() signal which is emitted whenever such a
|
---|
641 | property changes its range of valid values.
|
---|
642 |
|
---|
643 | \sa QtAbstractPropertyManager, QtSpinBoxFactory, QtSliderFactory, QtScrollBarFactory
|
---|
644 | */
|
---|
645 |
|
---|
646 | /*!
|
---|
647 | \fn void QtIntPropertyManager::valueChanged(QtProperty *property, int value)
|
---|
648 |
|
---|
649 | This signal is emitted whenever a property created by this manager
|
---|
650 | changes its value, passing a pointer to the \a property and the new
|
---|
651 | \a value as parameters.
|
---|
652 |
|
---|
653 | \sa setValue()
|
---|
654 | */
|
---|
655 |
|
---|
656 | /*!
|
---|
657 | \fn void QtIntPropertyManager::rangeChanged(QtProperty *property, int minimum, int maximum)
|
---|
658 |
|
---|
659 | This signal is emitted whenever a property created by this manager
|
---|
660 | changes its range of valid values, passing a pointer to the
|
---|
661 | \a property and the new \a minimum and \a maximum values.
|
---|
662 |
|
---|
663 | \sa setRange()
|
---|
664 | */
|
---|
665 |
|
---|
666 | /*!
|
---|
667 | \fn void QtIntPropertyManager::singleStepChanged(QtProperty *property, int step)
|
---|
668 |
|
---|
669 | This signal is emitted whenever a property created by this manager
|
---|
670 | changes its single step property, passing a pointer to the
|
---|
671 | \a property and the new \a step value
|
---|
672 |
|
---|
673 | \sa setSingleStep()
|
---|
674 | */
|
---|
675 |
|
---|
676 | /*!
|
---|
677 | Creates a manager with the given \a parent.
|
---|
678 | */
|
---|
679 | QtIntPropertyManager::QtIntPropertyManager(QObject *parent)
|
---|
680 | : QtAbstractPropertyManager(parent), d_ptr(new QtIntPropertyManagerPrivate)
|
---|
681 | {
|
---|
682 | d_ptr->q_ptr = this;
|
---|
683 | }
|
---|
684 |
|
---|
685 | /*!
|
---|
686 | Destroys this manager, and all the properties it has created.
|
---|
687 | */
|
---|
688 | QtIntPropertyManager::~QtIntPropertyManager()
|
---|
689 | {
|
---|
690 | clear();
|
---|
691 | }
|
---|
692 |
|
---|
693 | /*!
|
---|
694 | Returns the given \a property's value.
|
---|
695 |
|
---|
696 | If the given property is not managed by this manager, this
|
---|
697 | function returns 0.
|
---|
698 |
|
---|
699 | \sa setValue()
|
---|
700 | */
|
---|
701 | int QtIntPropertyManager::value(const QtProperty *property) const
|
---|
702 | {
|
---|
703 | return getValue<int>(d_ptr->m_values, property, 0);
|
---|
704 | }
|
---|
705 |
|
---|
706 | /*!
|
---|
707 | Returns the given \a property's minimum value.
|
---|
708 |
|
---|
709 | \sa setMinimum(), maximum(), setRange()
|
---|
710 | */
|
---|
711 | int QtIntPropertyManager::minimum(const QtProperty *property) const
|
---|
712 | {
|
---|
713 | return getMinimum<int>(d_ptr->m_values, property, 0);
|
---|
714 | }
|
---|
715 |
|
---|
716 | /*!
|
---|
717 | Returns the given \a property's maximum value.
|
---|
718 |
|
---|
719 | \sa setMaximum(), minimum(), setRange()
|
---|
720 | */
|
---|
721 | int QtIntPropertyManager::maximum(const QtProperty *property) const
|
---|
722 | {
|
---|
723 | return getMaximum<int>(d_ptr->m_values, property, 0);
|
---|
724 | }
|
---|
725 |
|
---|
726 | /*!
|
---|
727 | Returns the given \a property's step value.
|
---|
728 |
|
---|
729 | The step is typically used to increment or decrement a property value while pressing an arrow key.
|
---|
730 |
|
---|
731 | \sa setSingleStep()
|
---|
732 | */
|
---|
733 | int QtIntPropertyManager::singleStep(const QtProperty *property) const
|
---|
734 | {
|
---|
735 | return getData<int>(d_ptr->m_values, &QtIntPropertyManagerPrivate::Data::singleStep, property, 0);
|
---|
736 | }
|
---|
737 |
|
---|
738 | /*!
|
---|
739 | \reimp
|
---|
740 | */
|
---|
741 | QString QtIntPropertyManager::valueText(const QtProperty *property) const
|
---|
742 | {
|
---|
743 | const QtIntPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
744 | if (it == d_ptr->m_values.constEnd())
|
---|
745 | return QString();
|
---|
746 | return QString::number(it.value().val);
|
---|
747 | }
|
---|
748 |
|
---|
749 | /*!
|
---|
750 | \fn void QtIntPropertyManager::setValue(QtProperty *property, int value)
|
---|
751 |
|
---|
752 | Sets the value of the given \a property to \a value.
|
---|
753 |
|
---|
754 | If the specified \a value is not valid according to the given \a
|
---|
755 | property's range, the \a value is adjusted to the nearest valid
|
---|
756 | value within the range.
|
---|
757 |
|
---|
758 | \sa value(), setRange(), valueChanged()
|
---|
759 | */
|
---|
760 | void QtIntPropertyManager::setValue(QtProperty *property, int val)
|
---|
761 | {
|
---|
762 | void (QtIntPropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, int) = 0;
|
---|
763 | setValueInRange<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(this, d_ptr.data(),
|
---|
764 | &QtIntPropertyManager::propertyChanged,
|
---|
765 | &QtIntPropertyManager::valueChanged,
|
---|
766 | property, val, setSubPropertyValue);
|
---|
767 | }
|
---|
768 |
|
---|
769 | /*!
|
---|
770 | Sets the minimum value for the given \a property to \a minVal.
|
---|
771 |
|
---|
772 | When setting the minimum value, the maximum and current values are
|
---|
773 | adjusted if necessary (ensuring that the range remains valid and
|
---|
774 | that the current value is within the range).
|
---|
775 |
|
---|
776 | \sa minimum(), setRange(), rangeChanged()
|
---|
777 | */
|
---|
778 | void QtIntPropertyManager::setMinimum(QtProperty *property, int minVal)
|
---|
779 | {
|
---|
780 | setMinimumValue<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int, QtIntPropertyManagerPrivate::Data>(this, d_ptr.data(),
|
---|
781 | &QtIntPropertyManager::propertyChanged,
|
---|
782 | &QtIntPropertyManager::valueChanged,
|
---|
783 | &QtIntPropertyManager::rangeChanged,
|
---|
784 | property, minVal);
|
---|
785 | }
|
---|
786 |
|
---|
787 | /*!
|
---|
788 | Sets the maximum value for the given \a property to \a maxVal.
|
---|
789 |
|
---|
790 | When setting maximum value, the minimum and current values are
|
---|
791 | adjusted if necessary (ensuring that the range remains valid and
|
---|
792 | that the current value is within the range).
|
---|
793 |
|
---|
794 | \sa maximum(), setRange(), rangeChanged()
|
---|
795 | */
|
---|
796 | void QtIntPropertyManager::setMaximum(QtProperty *property, int maxVal)
|
---|
797 | {
|
---|
798 | setMaximumValue<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int, QtIntPropertyManagerPrivate::Data>(this, d_ptr.data(),
|
---|
799 | &QtIntPropertyManager::propertyChanged,
|
---|
800 | &QtIntPropertyManager::valueChanged,
|
---|
801 | &QtIntPropertyManager::rangeChanged,
|
---|
802 | property, maxVal);
|
---|
803 | }
|
---|
804 |
|
---|
805 | /*!
|
---|
806 | \fn void QtIntPropertyManager::setRange(QtProperty *property, int minimum, int maximum)
|
---|
807 |
|
---|
808 | Sets the range of valid values.
|
---|
809 |
|
---|
810 | This is a convenience function defining the range of valid values
|
---|
811 | in one go; setting the \a minimum and \a maximum values for the
|
---|
812 | given \a property with a single function call.
|
---|
813 |
|
---|
814 | When setting a new range, the current value is adjusted if
|
---|
815 | necessary (ensuring that the value remains within range).
|
---|
816 |
|
---|
817 | \sa setMinimum(), setMaximum(), rangeChanged()
|
---|
818 | */
|
---|
819 | void QtIntPropertyManager::setRange(QtProperty *property, int minVal, int maxVal)
|
---|
820 | {
|
---|
821 | void (QtIntPropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, int, int, int) = 0;
|
---|
822 | setBorderValues<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(this, d_ptr.data(),
|
---|
823 | &QtIntPropertyManager::propertyChanged,
|
---|
824 | &QtIntPropertyManager::valueChanged,
|
---|
825 | &QtIntPropertyManager::rangeChanged,
|
---|
826 | property, minVal, maxVal, setSubPropertyRange);
|
---|
827 | }
|
---|
828 |
|
---|
829 | /*!
|
---|
830 | Sets the step value for the given \a property to \a step.
|
---|
831 |
|
---|
832 | The step is typically used to increment or decrement a property value while pressing an arrow key.
|
---|
833 |
|
---|
834 | \sa singleStep()
|
---|
835 | */
|
---|
836 | void QtIntPropertyManager::setSingleStep(QtProperty *property, int step)
|
---|
837 | {
|
---|
838 | const QtIntPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
839 | if (it == d_ptr->m_values.end())
|
---|
840 | return;
|
---|
841 |
|
---|
842 | QtIntPropertyManagerPrivate::Data data = it.value();
|
---|
843 |
|
---|
844 | if (step < 0)
|
---|
845 | step = 0;
|
---|
846 |
|
---|
847 | if (data.singleStep == step)
|
---|
848 | return;
|
---|
849 |
|
---|
850 | data.singleStep = step;
|
---|
851 |
|
---|
852 | it.value() = data;
|
---|
853 |
|
---|
854 | emit singleStepChanged(property, data.singleStep);
|
---|
855 | }
|
---|
856 |
|
---|
857 | /*!
|
---|
858 | \reimp
|
---|
859 | */
|
---|
860 | void QtIntPropertyManager::initializeProperty(QtProperty *property)
|
---|
861 | {
|
---|
862 | d_ptr->m_values[property] = QtIntPropertyManagerPrivate::Data();
|
---|
863 | }
|
---|
864 |
|
---|
865 | /*!
|
---|
866 | \reimp
|
---|
867 | */
|
---|
868 | void QtIntPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
869 | {
|
---|
870 | d_ptr->m_values.remove(property);
|
---|
871 | }
|
---|
872 |
|
---|
873 | // QtDoublePropertyManager
|
---|
874 |
|
---|
875 | class QtDoublePropertyManagerPrivate
|
---|
876 | {
|
---|
877 | QtDoublePropertyManager *q_ptr;
|
---|
878 | Q_DECLARE_PUBLIC(QtDoublePropertyManager)
|
---|
879 | public:
|
---|
880 |
|
---|
881 | struct Data
|
---|
882 | {
|
---|
883 | Data() : val(0), minVal(-INT_MAX), maxVal(INT_MAX), singleStep(1), decimals(2) {}
|
---|
884 | double val;
|
---|
885 | double minVal;
|
---|
886 | double maxVal;
|
---|
887 | double singleStep;
|
---|
888 | int decimals;
|
---|
889 | double minimumValue() const { return minVal; }
|
---|
890 | double maximumValue() const { return maxVal; }
|
---|
891 | void setMinimumValue(double newMinVal) { setSimpleMinimumData(this, newMinVal); }
|
---|
892 | void setMaximumValue(double newMaxVal) { setSimpleMaximumData(this, newMaxVal); }
|
---|
893 | };
|
---|
894 |
|
---|
895 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
896 | PropertyValueMap m_values;
|
---|
897 | };
|
---|
898 |
|
---|
899 | /*!
|
---|
900 | \class QtDoublePropertyManager
|
---|
901 | \internal
|
---|
902 | \inmodule QtDesigner
|
---|
903 | \since 4.4
|
---|
904 |
|
---|
905 | \brief The QtDoublePropertyManager provides and manages double properties.
|
---|
906 |
|
---|
907 | A double property has a current value, and a range specifying the
|
---|
908 | valid values. The range is defined by a minimum and a maximum
|
---|
909 | value.
|
---|
910 |
|
---|
911 | The property's value and range can be retrieved using the value(),
|
---|
912 | minimum() and maximum() functions, and can be set using the
|
---|
913 | setValue(), setMinimum() and setMaximum() slots.
|
---|
914 | Alternatively, the range can be defined in one go using the
|
---|
915 | setRange() slot.
|
---|
916 |
|
---|
917 | In addition, QtDoublePropertyManager provides the valueChanged() signal
|
---|
918 | which is emitted whenever a property created by this manager
|
---|
919 | changes, and the rangeChanged() signal which is emitted whenever
|
---|
920 | such a property changes its range of valid values.
|
---|
921 |
|
---|
922 | \sa QtAbstractPropertyManager, QtDoubleSpinBoxFactory
|
---|
923 | */
|
---|
924 |
|
---|
925 | /*!
|
---|
926 | \fn void QtDoublePropertyManager::valueChanged(QtProperty *property, double value)
|
---|
927 |
|
---|
928 | This signal is emitted whenever a property created by this manager
|
---|
929 | changes its value, passing a pointer to the \a property and the new
|
---|
930 | \a value as parameters.
|
---|
931 |
|
---|
932 | \sa setValue()
|
---|
933 | */
|
---|
934 |
|
---|
935 | /*!
|
---|
936 | \fn void QtDoublePropertyManager::rangeChanged(QtProperty *property, double minimum, double maximum)
|
---|
937 |
|
---|
938 | This signal is emitted whenever a property created by this manager
|
---|
939 | changes its range of valid values, passing a pointer to the
|
---|
940 | \a property and the new \a minimum and \a maximum values
|
---|
941 |
|
---|
942 | \sa setRange()
|
---|
943 | */
|
---|
944 |
|
---|
945 | /*!
|
---|
946 | \fn void QtDoublePropertyManager::decimalsChanged(QtProperty *property, int prec)
|
---|
947 |
|
---|
948 | This signal is emitted whenever a property created by this manager
|
---|
949 | changes its precision of value, passing a pointer to the
|
---|
950 | \a property and the new \a prec value
|
---|
951 |
|
---|
952 | \sa setDecimals()
|
---|
953 | */
|
---|
954 |
|
---|
955 | /*!
|
---|
956 | \fn void QtDoublePropertyManager::singleStepChanged(QtProperty *property, double step)
|
---|
957 |
|
---|
958 | This signal is emitted whenever a property created by this manager
|
---|
959 | changes its single step property, passing a pointer to the
|
---|
960 | \a property and the new \a step value
|
---|
961 |
|
---|
962 | \sa setSingleStep()
|
---|
963 | */
|
---|
964 |
|
---|
965 | /*!
|
---|
966 | Creates a manager with the given \a parent.
|
---|
967 | */
|
---|
968 | QtDoublePropertyManager::QtDoublePropertyManager(QObject *parent)
|
---|
969 | : QtAbstractPropertyManager(parent), d_ptr(new QtDoublePropertyManagerPrivate)
|
---|
970 | {
|
---|
971 | d_ptr->q_ptr = this;
|
---|
972 | }
|
---|
973 |
|
---|
974 | /*!
|
---|
975 | Destroys this manager, and all the properties it has created.
|
---|
976 | */
|
---|
977 | QtDoublePropertyManager::~QtDoublePropertyManager()
|
---|
978 | {
|
---|
979 | clear();
|
---|
980 | }
|
---|
981 |
|
---|
982 | /*!
|
---|
983 | Returns the given \a property's value.
|
---|
984 |
|
---|
985 | If the given property is not managed by this manager, this
|
---|
986 | function returns 0.
|
---|
987 |
|
---|
988 | \sa setValue()
|
---|
989 | */
|
---|
990 | double QtDoublePropertyManager::value(const QtProperty *property) const
|
---|
991 | {
|
---|
992 | return getValue<double>(d_ptr->m_values, property, 0.0);
|
---|
993 | }
|
---|
994 |
|
---|
995 | /*!
|
---|
996 | Returns the given \a property's minimum value.
|
---|
997 |
|
---|
998 | \sa maximum(), setRange()
|
---|
999 | */
|
---|
1000 | double QtDoublePropertyManager::minimum(const QtProperty *property) const
|
---|
1001 | {
|
---|
1002 | return getMinimum<double>(d_ptr->m_values, property, 0.0);
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 | /*!
|
---|
1006 | Returns the given \a property's maximum value.
|
---|
1007 |
|
---|
1008 | \sa minimum(), setRange()
|
---|
1009 | */
|
---|
1010 | double QtDoublePropertyManager::maximum(const QtProperty *property) const
|
---|
1011 | {
|
---|
1012 | return getMaximum<double>(d_ptr->m_values, property, 0.0);
|
---|
1013 | }
|
---|
1014 |
|
---|
1015 | /*!
|
---|
1016 | Returns the given \a property's step value.
|
---|
1017 |
|
---|
1018 | The step is typically used to increment or decrement a property value while pressing an arrow key.
|
---|
1019 |
|
---|
1020 | \sa setSingleStep()
|
---|
1021 | */
|
---|
1022 | double QtDoublePropertyManager::singleStep(const QtProperty *property) const
|
---|
1023 | {
|
---|
1024 | return getData<double>(d_ptr->m_values, &QtDoublePropertyManagerPrivate::Data::singleStep, property, 0);
|
---|
1025 | }
|
---|
1026 |
|
---|
1027 | /*!
|
---|
1028 | Returns the given \a property's precision, in decimals.
|
---|
1029 |
|
---|
1030 | \sa setDecimals()
|
---|
1031 | */
|
---|
1032 | int QtDoublePropertyManager::decimals(const QtProperty *property) const
|
---|
1033 | {
|
---|
1034 | return getData<int>(d_ptr->m_values, &QtDoublePropertyManagerPrivate::Data::decimals, property, 0);
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 | /*!
|
---|
1038 | \reimp
|
---|
1039 | */
|
---|
1040 | QString QtDoublePropertyManager::valueText(const QtProperty *property) const
|
---|
1041 | {
|
---|
1042 | const QtDoublePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
1043 | if (it == d_ptr->m_values.constEnd())
|
---|
1044 | return QString();
|
---|
1045 | return QString::number(it.value().val, 'f', it.value().decimals);
|
---|
1046 | }
|
---|
1047 |
|
---|
1048 | /*!
|
---|
1049 | \fn void QtDoublePropertyManager::setValue(QtProperty *property, double value)
|
---|
1050 |
|
---|
1051 | Sets the value of the given \a property to \a value.
|
---|
1052 |
|
---|
1053 | If the specified \a value is not valid according to the given
|
---|
1054 | \a property's range, the \a value is adjusted to the nearest valid value
|
---|
1055 | within the range.
|
---|
1056 |
|
---|
1057 | \sa value(), setRange(), valueChanged()
|
---|
1058 | */
|
---|
1059 | void QtDoublePropertyManager::setValue(QtProperty *property, double val)
|
---|
1060 | {
|
---|
1061 | void (QtDoublePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, double) = 0;
|
---|
1062 | setValueInRange<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(this, d_ptr.data(),
|
---|
1063 | &QtDoublePropertyManager::propertyChanged,
|
---|
1064 | &QtDoublePropertyManager::valueChanged,
|
---|
1065 | property, val, setSubPropertyValue);
|
---|
1066 | }
|
---|
1067 |
|
---|
1068 | /*!
|
---|
1069 | Sets the step value for the given \a property to \a step.
|
---|
1070 |
|
---|
1071 | The step is typically used to increment or decrement a property value while pressing an arrow key.
|
---|
1072 |
|
---|
1073 | \sa singleStep()
|
---|
1074 | */
|
---|
1075 | void QtDoublePropertyManager::setSingleStep(QtProperty *property, double step)
|
---|
1076 | {
|
---|
1077 | const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
1078 | if (it == d_ptr->m_values.end())
|
---|
1079 | return;
|
---|
1080 |
|
---|
1081 | QtDoublePropertyManagerPrivate::Data data = it.value();
|
---|
1082 |
|
---|
1083 | if (step < 0)
|
---|
1084 | step = 0;
|
---|
1085 |
|
---|
1086 | if (data.singleStep == step)
|
---|
1087 | return;
|
---|
1088 |
|
---|
1089 | data.singleStep = step;
|
---|
1090 |
|
---|
1091 | it.value() = data;
|
---|
1092 |
|
---|
1093 | emit singleStepChanged(property, data.singleStep);
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 | /*!
|
---|
1097 | \fn void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec)
|
---|
1098 |
|
---|
1099 | Sets the precision of the given \a property to \a prec.
|
---|
1100 |
|
---|
1101 | The valid decimal range is 0-13. The default is 2.
|
---|
1102 |
|
---|
1103 | \sa decimals()
|
---|
1104 | */
|
---|
1105 | void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec)
|
---|
1106 | {
|
---|
1107 | const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
1108 | if (it == d_ptr->m_values.end())
|
---|
1109 | return;
|
---|
1110 |
|
---|
1111 | QtDoublePropertyManagerPrivate::Data data = it.value();
|
---|
1112 |
|
---|
1113 | if (prec > 13)
|
---|
1114 | prec = 13;
|
---|
1115 | else if (prec < 0)
|
---|
1116 | prec = 0;
|
---|
1117 |
|
---|
1118 | if (data.decimals == prec)
|
---|
1119 | return;
|
---|
1120 |
|
---|
1121 | data.decimals = prec;
|
---|
1122 |
|
---|
1123 | it.value() = data;
|
---|
1124 |
|
---|
1125 | emit decimalsChanged(property, data.decimals);
|
---|
1126 | }
|
---|
1127 |
|
---|
1128 | /*!
|
---|
1129 | Sets the minimum value for the given \a property to \a minVal.
|
---|
1130 |
|
---|
1131 | When setting the minimum value, the maximum and current values are
|
---|
1132 | adjusted if necessary (ensuring that the range remains valid and
|
---|
1133 | that the current value is within in the range).
|
---|
1134 |
|
---|
1135 | \sa minimum(), setRange(), rangeChanged()
|
---|
1136 | */
|
---|
1137 | void QtDoublePropertyManager::setMinimum(QtProperty *property, double minVal)
|
---|
1138 | {
|
---|
1139 | setMinimumValue<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double, QtDoublePropertyManagerPrivate::Data>(this, d_ptr.data(),
|
---|
1140 | &QtDoublePropertyManager::propertyChanged,
|
---|
1141 | &QtDoublePropertyManager::valueChanged,
|
---|
1142 | &QtDoublePropertyManager::rangeChanged,
|
---|
1143 | property, minVal);
|
---|
1144 | }
|
---|
1145 |
|
---|
1146 | /*!
|
---|
1147 | Sets the maximum value for the given \a property to \a maxVal.
|
---|
1148 |
|
---|
1149 | When setting the maximum value, the minimum and current values are
|
---|
1150 | adjusted if necessary (ensuring that the range remains valid and
|
---|
1151 | that the current value is within in the range).
|
---|
1152 |
|
---|
1153 | \sa maximum(), setRange(), rangeChanged()
|
---|
1154 | */
|
---|
1155 | void QtDoublePropertyManager::setMaximum(QtProperty *property, double maxVal)
|
---|
1156 | {
|
---|
1157 | setMaximumValue<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double, QtDoublePropertyManagerPrivate::Data>(this, d_ptr.data(),
|
---|
1158 | &QtDoublePropertyManager::propertyChanged,
|
---|
1159 | &QtDoublePropertyManager::valueChanged,
|
---|
1160 | &QtDoublePropertyManager::rangeChanged,
|
---|
1161 | property, maxVal);
|
---|
1162 | }
|
---|
1163 |
|
---|
1164 | /*!
|
---|
1165 | \fn void QtDoublePropertyManager::setRange(QtProperty *property, double minimum, double maximum)
|
---|
1166 |
|
---|
1167 | Sets the range of valid values.
|
---|
1168 |
|
---|
1169 | This is a convenience function defining the range of valid values
|
---|
1170 | in one go; setting the \a minimum and \a maximum values for the
|
---|
1171 | given \a property with a single function call.
|
---|
1172 |
|
---|
1173 | When setting a new range, the current value is adjusted if
|
---|
1174 | necessary (ensuring that the value remains within range).
|
---|
1175 |
|
---|
1176 | \sa setMinimum(), setMaximum(), rangeChanged()
|
---|
1177 | */
|
---|
1178 | void QtDoublePropertyManager::setRange(QtProperty *property, double minVal, double maxVal)
|
---|
1179 | {
|
---|
1180 | void (QtDoublePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, double, double, double) = 0;
|
---|
1181 | setBorderValues<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(this, d_ptr.data(),
|
---|
1182 | &QtDoublePropertyManager::propertyChanged,
|
---|
1183 | &QtDoublePropertyManager::valueChanged,
|
---|
1184 | &QtDoublePropertyManager::rangeChanged,
|
---|
1185 | property, minVal, maxVal, setSubPropertyRange);
|
---|
1186 | }
|
---|
1187 |
|
---|
1188 | /*!
|
---|
1189 | \reimp
|
---|
1190 | */
|
---|
1191 | void QtDoublePropertyManager::initializeProperty(QtProperty *property)
|
---|
1192 | {
|
---|
1193 | d_ptr->m_values[property] = QtDoublePropertyManagerPrivate::Data();
|
---|
1194 | }
|
---|
1195 |
|
---|
1196 | /*!
|
---|
1197 | \reimp
|
---|
1198 | */
|
---|
1199 | void QtDoublePropertyManager::uninitializeProperty(QtProperty *property)
|
---|
1200 | {
|
---|
1201 | d_ptr->m_values.remove(property);
|
---|
1202 | }
|
---|
1203 |
|
---|
1204 | // QtStringPropertyManager
|
---|
1205 |
|
---|
1206 | class QtStringPropertyManagerPrivate
|
---|
1207 | {
|
---|
1208 | QtStringPropertyManager *q_ptr;
|
---|
1209 | Q_DECLARE_PUBLIC(QtStringPropertyManager)
|
---|
1210 | public:
|
---|
1211 |
|
---|
1212 | struct Data
|
---|
1213 | {
|
---|
1214 | Data() : regExp(QString(QLatin1Char('*')), Qt::CaseSensitive, QRegExp::Wildcard)
|
---|
1215 | {
|
---|
1216 | }
|
---|
1217 | QString val;
|
---|
1218 | QRegExp regExp;
|
---|
1219 | };
|
---|
1220 |
|
---|
1221 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
1222 | QMap<const QtProperty *, Data> m_values;
|
---|
1223 | };
|
---|
1224 |
|
---|
1225 | /*!
|
---|
1226 | \class QtStringPropertyManager
|
---|
1227 | \internal
|
---|
1228 | \inmodule QtDesigner
|
---|
1229 | \since 4.4
|
---|
1230 |
|
---|
1231 | \brief The QtStringPropertyManager provides and manages QString properties.
|
---|
1232 |
|
---|
1233 | A string property's value can be retrieved using the value()
|
---|
1234 | function, and set using the setValue() slot.
|
---|
1235 |
|
---|
1236 | The current value can be checked against a regular expression. To
|
---|
1237 | set the regular expression use the setRegExp() slot, use the
|
---|
1238 | regExp() function to retrieve the currently set expression.
|
---|
1239 |
|
---|
1240 | In addition, QtStringPropertyManager provides the valueChanged() signal
|
---|
1241 | which is emitted whenever a property created by this manager
|
---|
1242 | changes, and the regExpChanged() signal which is emitted whenever
|
---|
1243 | such a property changes its currently set regular expression.
|
---|
1244 |
|
---|
1245 | \sa QtAbstractPropertyManager, QtLineEditFactory
|
---|
1246 | */
|
---|
1247 |
|
---|
1248 | /*!
|
---|
1249 | \fn void QtStringPropertyManager::valueChanged(QtProperty *property, const QString &value)
|
---|
1250 |
|
---|
1251 | This signal is emitted whenever a property created by this manager
|
---|
1252 | changes its value, passing a pointer to the \a property and the
|
---|
1253 | new \a value as parameters.
|
---|
1254 |
|
---|
1255 | \sa setValue()
|
---|
1256 | */
|
---|
1257 |
|
---|
1258 | /*!
|
---|
1259 | \fn void QtStringPropertyManager::regExpChanged(QtProperty *property, const QRegExp ®Exp)
|
---|
1260 |
|
---|
1261 | This signal is emitted whenever a property created by this manager
|
---|
1262 | changes its currenlty set regular expression, passing a pointer to
|
---|
1263 | the \a property and the new \a regExp as parameters.
|
---|
1264 |
|
---|
1265 | \sa setRegExp()
|
---|
1266 | */
|
---|
1267 |
|
---|
1268 | /*!
|
---|
1269 | Creates a manager with the given \a parent.
|
---|
1270 | */
|
---|
1271 | QtStringPropertyManager::QtStringPropertyManager(QObject *parent)
|
---|
1272 | : QtAbstractPropertyManager(parent), d_ptr(new QtStringPropertyManagerPrivate)
|
---|
1273 | {
|
---|
1274 | d_ptr->q_ptr = this;
|
---|
1275 | }
|
---|
1276 |
|
---|
1277 | /*!
|
---|
1278 | Destroys this manager, and all the properties it has created.
|
---|
1279 | */
|
---|
1280 | QtStringPropertyManager::~QtStringPropertyManager()
|
---|
1281 | {
|
---|
1282 | clear();
|
---|
1283 | }
|
---|
1284 |
|
---|
1285 | /*!
|
---|
1286 | Returns the given \a property's value.
|
---|
1287 |
|
---|
1288 | If the given property is not managed by this manager, this
|
---|
1289 | function returns an empty string.
|
---|
1290 |
|
---|
1291 | \sa setValue()
|
---|
1292 | */
|
---|
1293 | QString QtStringPropertyManager::value(const QtProperty *property) const
|
---|
1294 | {
|
---|
1295 | return getValue<QString>(d_ptr->m_values, property);
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 | /*!
|
---|
1299 | Returns the given \a property's currently set regular expression.
|
---|
1300 |
|
---|
1301 | If the given \a property is not managed by this manager, this
|
---|
1302 | function returns an empty expression.
|
---|
1303 |
|
---|
1304 | \sa setRegExp()
|
---|
1305 | */
|
---|
1306 | QRegExp QtStringPropertyManager::regExp(const QtProperty *property) const
|
---|
1307 | {
|
---|
1308 | return getData<QRegExp>(d_ptr->m_values, &QtStringPropertyManagerPrivate::Data::regExp, property, QRegExp());
|
---|
1309 | }
|
---|
1310 |
|
---|
1311 | /*!
|
---|
1312 | \reimp
|
---|
1313 | */
|
---|
1314 | QString QtStringPropertyManager::valueText(const QtProperty *property) const
|
---|
1315 | {
|
---|
1316 | const QtStringPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
1317 | if (it == d_ptr->m_values.constEnd())
|
---|
1318 | return QString();
|
---|
1319 | return it.value().val;
|
---|
1320 | }
|
---|
1321 |
|
---|
1322 | /*!
|
---|
1323 | \fn void QtStringPropertyManager::setValue(QtProperty *property, const QString &value)
|
---|
1324 |
|
---|
1325 | Sets the value of the given \a property to \a value.
|
---|
1326 |
|
---|
1327 | If the specified \a value doesn't match the given \a property's
|
---|
1328 | regular expression, this function does nothing.
|
---|
1329 |
|
---|
1330 | \sa value(), setRegExp(), valueChanged()
|
---|
1331 | */
|
---|
1332 | void QtStringPropertyManager::setValue(QtProperty *property, const QString &val)
|
---|
1333 | {
|
---|
1334 | const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
1335 | if (it == d_ptr->m_values.end())
|
---|
1336 | return;
|
---|
1337 |
|
---|
1338 | QtStringPropertyManagerPrivate::Data data = it.value();
|
---|
1339 |
|
---|
1340 | if (data.val == val)
|
---|
1341 | return;
|
---|
1342 |
|
---|
1343 | if (data.regExp.isValid() && !data.regExp.exactMatch(val))
|
---|
1344 | return;
|
---|
1345 |
|
---|
1346 | data.val = val;
|
---|
1347 |
|
---|
1348 | it.value() = data;
|
---|
1349 |
|
---|
1350 | emit propertyChanged(property);
|
---|
1351 | emit valueChanged(property, data.val);
|
---|
1352 | }
|
---|
1353 |
|
---|
1354 | /*!
|
---|
1355 | Sets the regular expression of the given \a property to \a regExp.
|
---|
1356 |
|
---|
1357 | \sa regExp(), setValue(), regExpChanged()
|
---|
1358 | */
|
---|
1359 | void QtStringPropertyManager::setRegExp(QtProperty *property, const QRegExp ®Exp)
|
---|
1360 | {
|
---|
1361 | const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
1362 | if (it == d_ptr->m_values.end())
|
---|
1363 | return;
|
---|
1364 |
|
---|
1365 | QtStringPropertyManagerPrivate::Data data = it.value() ;
|
---|
1366 |
|
---|
1367 | if (data.regExp == regExp)
|
---|
1368 | return;
|
---|
1369 |
|
---|
1370 | data.regExp = regExp;
|
---|
1371 |
|
---|
1372 | it.value() = data;
|
---|
1373 |
|
---|
1374 | emit regExpChanged(property, data.regExp);
|
---|
1375 | }
|
---|
1376 |
|
---|
1377 | /*!
|
---|
1378 | \reimp
|
---|
1379 | */
|
---|
1380 | void QtStringPropertyManager::initializeProperty(QtProperty *property)
|
---|
1381 | {
|
---|
1382 | d_ptr->m_values[property] = QtStringPropertyManagerPrivate::Data();
|
---|
1383 | }
|
---|
1384 |
|
---|
1385 | /*!
|
---|
1386 | \reimp
|
---|
1387 | */
|
---|
1388 | void QtStringPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
1389 | {
|
---|
1390 | d_ptr->m_values.remove(property);
|
---|
1391 | }
|
---|
1392 |
|
---|
1393 | // QtBoolPropertyManager
|
---|
1394 |
|
---|
1395 | class QtBoolPropertyManagerPrivate
|
---|
1396 | {
|
---|
1397 | QtBoolPropertyManager *q_ptr;
|
---|
1398 | Q_DECLARE_PUBLIC(QtBoolPropertyManager)
|
---|
1399 | public:
|
---|
1400 |
|
---|
1401 | QMap<const QtProperty *, bool> m_values;
|
---|
1402 | };
|
---|
1403 |
|
---|
1404 | /*!
|
---|
1405 | \class QtBoolPropertyManager
|
---|
1406 | \internal
|
---|
1407 | \inmodule QtDesigner
|
---|
1408 | \since 4.4
|
---|
1409 |
|
---|
1410 | \brief The QtBoolPropertyManager class provides and manages boolean properties.
|
---|
1411 |
|
---|
1412 | The property's value can be retrieved using the value() function,
|
---|
1413 | and set using the setValue() slot.
|
---|
1414 |
|
---|
1415 | In addition, QtBoolPropertyManager provides the valueChanged() signal
|
---|
1416 | which is emitted whenever a property created by this manager
|
---|
1417 | changes.
|
---|
1418 |
|
---|
1419 | \sa QtAbstractPropertyManager, QtCheckBoxFactory
|
---|
1420 | */
|
---|
1421 |
|
---|
1422 | /*!
|
---|
1423 | \fn void QtBoolPropertyManager::valueChanged(QtProperty *property, bool value)
|
---|
1424 |
|
---|
1425 | This signal is emitted whenever a property created by this manager
|
---|
1426 | changes its value, passing a pointer to the \a property and the
|
---|
1427 | new \a value as parameters.
|
---|
1428 | */
|
---|
1429 |
|
---|
1430 | /*!
|
---|
1431 | Creates a manager with the given \a parent.
|
---|
1432 | */
|
---|
1433 | QtBoolPropertyManager::QtBoolPropertyManager(QObject *parent)
|
---|
1434 | : QtAbstractPropertyManager(parent), d_ptr(new QtBoolPropertyManagerPrivate)
|
---|
1435 | {
|
---|
1436 | d_ptr->q_ptr = this;
|
---|
1437 | }
|
---|
1438 |
|
---|
1439 | /*!
|
---|
1440 | Destroys this manager, and all the properties it has created.
|
---|
1441 | */
|
---|
1442 | QtBoolPropertyManager::~QtBoolPropertyManager()
|
---|
1443 | {
|
---|
1444 | clear();
|
---|
1445 | }
|
---|
1446 |
|
---|
1447 | /*!
|
---|
1448 | Returns the given \a property's value.
|
---|
1449 |
|
---|
1450 | If the given \a property is not managed by \e this manager, this
|
---|
1451 | function returns false.
|
---|
1452 |
|
---|
1453 | \sa setValue()
|
---|
1454 | */
|
---|
1455 | bool QtBoolPropertyManager::value(const QtProperty *property) const
|
---|
1456 | {
|
---|
1457 | return d_ptr->m_values.value(property, false);
|
---|
1458 | }
|
---|
1459 |
|
---|
1460 | /*!
|
---|
1461 | \reimp
|
---|
1462 | */
|
---|
1463 | QString QtBoolPropertyManager::valueText(const QtProperty *property) const
|
---|
1464 | {
|
---|
1465 | const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
1466 | if (it == d_ptr->m_values.constEnd())
|
---|
1467 | return QString();
|
---|
1468 |
|
---|
1469 | static const QString trueText = tr("True");
|
---|
1470 | static const QString falseText = tr("False");
|
---|
1471 | return it.value() ? trueText : falseText;
|
---|
1472 | }
|
---|
1473 |
|
---|
1474 | // Return an icon containing a check box indicator
|
---|
1475 | static QIcon drawCheckBox(bool value)
|
---|
1476 | {
|
---|
1477 | QStyleOptionButton opt;
|
---|
1478 | opt.state |= value ? QStyle::State_On : QStyle::State_Off;
|
---|
1479 | opt.state |= QStyle::State_Enabled;
|
---|
1480 | const QStyle *style = QApplication::style();
|
---|
1481 | // Figure out size of an indicator and make sure it is not scaled down in a list view item
|
---|
1482 | // by making the pixmap as big as a list view icon and centering the indicator in it.
|
---|
1483 | // (if it is smaller, it can't be helped)
|
---|
1484 | const int indicatorWidth = style->pixelMetric(QStyle::PM_IndicatorWidth, &opt);
|
---|
1485 | const int indicatorHeight = style->pixelMetric(QStyle::PM_IndicatorHeight, &opt);
|
---|
1486 | const int listViewIconSize = indicatorWidth;
|
---|
1487 | const int pixmapWidth = indicatorWidth;
|
---|
1488 | const int pixmapHeight = qMax(indicatorHeight, listViewIconSize);
|
---|
1489 |
|
---|
1490 | opt.rect = QRect(0, 0, indicatorWidth, indicatorHeight);
|
---|
1491 | QPixmap pixmap = QPixmap(pixmapWidth, pixmapHeight);
|
---|
1492 | pixmap.fill(Qt::transparent);
|
---|
1493 | {
|
---|
1494 | // Center?
|
---|
1495 | const int xoff = (pixmapWidth > indicatorWidth) ? (pixmapWidth - indicatorWidth) / 2 : 0;
|
---|
1496 | const int yoff = (pixmapHeight > indicatorHeight) ? (pixmapHeight - indicatorHeight) / 2 : 0;
|
---|
1497 | QPainter painter(&pixmap);
|
---|
1498 | painter.translate(xoff, yoff);
|
---|
1499 | style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter);
|
---|
1500 | }
|
---|
1501 | return QIcon(pixmap);
|
---|
1502 | }
|
---|
1503 |
|
---|
1504 | /*!
|
---|
1505 | \reimp
|
---|
1506 | */
|
---|
1507 | QIcon QtBoolPropertyManager::valueIcon(const QtProperty *property) const
|
---|
1508 | {
|
---|
1509 | const QMap<const QtProperty *, bool>::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
1510 | if (it == d_ptr->m_values.constEnd())
|
---|
1511 | return QIcon();
|
---|
1512 |
|
---|
1513 | static const QIcon checkedIcon = drawCheckBox(true);
|
---|
1514 | static const QIcon uncheckedIcon = drawCheckBox(false);
|
---|
1515 | return it.value() ? checkedIcon : uncheckedIcon;
|
---|
1516 | }
|
---|
1517 |
|
---|
1518 | /*!
|
---|
1519 | \fn void QtBoolPropertyManager::setValue(QtProperty *property, bool value)
|
---|
1520 |
|
---|
1521 | Sets the value of the given \a property to \a value.
|
---|
1522 |
|
---|
1523 | \sa value()
|
---|
1524 | */
|
---|
1525 | void QtBoolPropertyManager::setValue(QtProperty *property, bool val)
|
---|
1526 | {
|
---|
1527 | setSimpleValue<bool, bool, QtBoolPropertyManager>(d_ptr->m_values, this,
|
---|
1528 | &QtBoolPropertyManager::propertyChanged,
|
---|
1529 | &QtBoolPropertyManager::valueChanged,
|
---|
1530 | property, val);
|
---|
1531 | }
|
---|
1532 |
|
---|
1533 | /*!
|
---|
1534 | \reimp
|
---|
1535 | */
|
---|
1536 | void QtBoolPropertyManager::initializeProperty(QtProperty *property)
|
---|
1537 | {
|
---|
1538 | d_ptr->m_values[property] = false;
|
---|
1539 | }
|
---|
1540 |
|
---|
1541 | /*!
|
---|
1542 | \reimp
|
---|
1543 | */
|
---|
1544 | void QtBoolPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
1545 | {
|
---|
1546 | d_ptr->m_values.remove(property);
|
---|
1547 | }
|
---|
1548 |
|
---|
1549 | // QtDatePropertyManager
|
---|
1550 |
|
---|
1551 | class QtDatePropertyManagerPrivate
|
---|
1552 | {
|
---|
1553 | QtDatePropertyManager *q_ptr;
|
---|
1554 | Q_DECLARE_PUBLIC(QtDatePropertyManager)
|
---|
1555 | public:
|
---|
1556 |
|
---|
1557 | struct Data
|
---|
1558 | {
|
---|
1559 | Data() : val(QDate::currentDate()), minVal(QDate(1752, 9, 14)),
|
---|
1560 | maxVal(QDate(7999, 12, 31)) {}
|
---|
1561 | QDate val;
|
---|
1562 | QDate minVal;
|
---|
1563 | QDate maxVal;
|
---|
1564 | QDate minimumValue() const { return minVal; }
|
---|
1565 | QDate maximumValue() const { return maxVal; }
|
---|
1566 | void setMinimumValue(const QDate &newMinVal) { setSimpleMinimumData(this, newMinVal); }
|
---|
1567 | void setMaximumValue(const QDate &newMaxVal) { setSimpleMaximumData(this, newMaxVal); }
|
---|
1568 | };
|
---|
1569 |
|
---|
1570 | QString m_format;
|
---|
1571 |
|
---|
1572 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
1573 | QMap<const QtProperty *, Data> m_values;
|
---|
1574 | };
|
---|
1575 |
|
---|
1576 | /*!
|
---|
1577 | \class QtDatePropertyManager
|
---|
1578 | \internal
|
---|
1579 | \inmodule QtDesigner
|
---|
1580 | \since 4.4
|
---|
1581 |
|
---|
1582 | \brief The QtDatePropertyManager provides and manages QDate properties.
|
---|
1583 |
|
---|
1584 | A date property has a current value, and a range specifying the
|
---|
1585 | valid dates. The range is defined by a minimum and a maximum
|
---|
1586 | value.
|
---|
1587 |
|
---|
1588 | The property's values can be retrieved using the minimum(),
|
---|
1589 | maximum() and value() functions, and can be set using the
|
---|
1590 | setMinimum(), setMaximum() and setValue() slots. Alternatively,
|
---|
1591 | the range can be defined in one go using the setRange() slot.
|
---|
1592 |
|
---|
1593 | In addition, QtDatePropertyManager provides the valueChanged() signal
|
---|
1594 | which is emitted whenever a property created by this manager
|
---|
1595 | changes, and the rangeChanged() signal which is emitted whenever
|
---|
1596 | such a property changes its range of valid dates.
|
---|
1597 |
|
---|
1598 | \sa QtAbstractPropertyManager, QtDateEditFactory, QtDateTimePropertyManager
|
---|
1599 | */
|
---|
1600 |
|
---|
1601 | /*!
|
---|
1602 | \fn void QtDatePropertyManager::valueChanged(QtProperty *property, const QDate &value)
|
---|
1603 |
|
---|
1604 | This signal is emitted whenever a property created by this manager
|
---|
1605 | changes its value, passing a pointer to the \a property and the new
|
---|
1606 | \a value as parameters.
|
---|
1607 |
|
---|
1608 | \sa setValue()
|
---|
1609 | */
|
---|
1610 |
|
---|
1611 | /*!
|
---|
1612 | \fn void QtDatePropertyManager::rangeChanged(QtProperty *property, const QDate &minimum, const QDate &maximum)
|
---|
1613 |
|
---|
1614 | This signal is emitted whenever a property created by this manager
|
---|
1615 | changes its range of valid dates, passing a pointer to the \a
|
---|
1616 | property and the new \a minimum and \a maximum dates.
|
---|
1617 |
|
---|
1618 | \sa setRange()
|
---|
1619 | */
|
---|
1620 |
|
---|
1621 | /*!
|
---|
1622 | Creates a manager with the given \a parent.
|
---|
1623 | */
|
---|
1624 | QtDatePropertyManager::QtDatePropertyManager(QObject *parent)
|
---|
1625 | : QtAbstractPropertyManager(parent), d_ptr(new QtDatePropertyManagerPrivate)
|
---|
1626 | {
|
---|
1627 | d_ptr->q_ptr = this;
|
---|
1628 |
|
---|
1629 | QLocale loc;
|
---|
1630 | d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat);
|
---|
1631 | }
|
---|
1632 |
|
---|
1633 | /*!
|
---|
1634 | Destroys this manager, and all the properties it has created.
|
---|
1635 | */
|
---|
1636 | QtDatePropertyManager::~QtDatePropertyManager()
|
---|
1637 | {
|
---|
1638 | clear();
|
---|
1639 | }
|
---|
1640 |
|
---|
1641 | /*!
|
---|
1642 | Returns the given \a property's value.
|
---|
1643 |
|
---|
1644 | If the given \a property is not managed by \e this manager, this
|
---|
1645 | function returns an invalid date.
|
---|
1646 |
|
---|
1647 | \sa setValue()
|
---|
1648 | */
|
---|
1649 | QDate QtDatePropertyManager::value(const QtProperty *property) const
|
---|
1650 | {
|
---|
1651 | return getValue<QDate>(d_ptr->m_values, property);
|
---|
1652 | }
|
---|
1653 |
|
---|
1654 | /*!
|
---|
1655 | Returns the given \a property's minimum date.
|
---|
1656 |
|
---|
1657 | \sa maximum(), setRange()
|
---|
1658 | */
|
---|
1659 | QDate QtDatePropertyManager::minimum(const QtProperty *property) const
|
---|
1660 | {
|
---|
1661 | return getMinimum<QDate>(d_ptr->m_values, property);
|
---|
1662 | }
|
---|
1663 |
|
---|
1664 | /*!
|
---|
1665 | Returns the given \a property's maximum date.
|
---|
1666 |
|
---|
1667 | \sa minimum(), setRange()
|
---|
1668 | */
|
---|
1669 | QDate QtDatePropertyManager::maximum(const QtProperty *property) const
|
---|
1670 | {
|
---|
1671 | return getMaximum<QDate>(d_ptr->m_values, property);
|
---|
1672 | }
|
---|
1673 |
|
---|
1674 | /*!
|
---|
1675 | \reimp
|
---|
1676 | */
|
---|
1677 | QString QtDatePropertyManager::valueText(const QtProperty *property) const
|
---|
1678 | {
|
---|
1679 | const QtDatePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
1680 | if (it == d_ptr->m_values.constEnd())
|
---|
1681 | return QString();
|
---|
1682 | return it.value().val.toString(d_ptr->m_format);
|
---|
1683 | }
|
---|
1684 |
|
---|
1685 | /*!
|
---|
1686 | \fn void QtDatePropertyManager::setValue(QtProperty *property, const QDate &value)
|
---|
1687 |
|
---|
1688 | Sets the value of the given \a property to \a value.
|
---|
1689 |
|
---|
1690 | If the specified \a value is not a valid date according to the
|
---|
1691 | given \a property's range, the value is adjusted to the nearest
|
---|
1692 | valid value within the range.
|
---|
1693 |
|
---|
1694 | \sa value(), setRange(), valueChanged()
|
---|
1695 | */
|
---|
1696 | void QtDatePropertyManager::setValue(QtProperty *property, const QDate &val)
|
---|
1697 | {
|
---|
1698 | void (QtDatePropertyManagerPrivate::*setSubPropertyValue)(QtProperty *, const QDate &) = 0;
|
---|
1699 | setValueInRange<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, const QDate>(this, d_ptr.data(),
|
---|
1700 | &QtDatePropertyManager::propertyChanged,
|
---|
1701 | &QtDatePropertyManager::valueChanged,
|
---|
1702 | property, val, setSubPropertyValue);
|
---|
1703 | }
|
---|
1704 |
|
---|
1705 | /*!
|
---|
1706 | Sets the minimum value for the given \a property to \a minVal.
|
---|
1707 |
|
---|
1708 | When setting the minimum value, the maximum and current values are
|
---|
1709 | adjusted if necessary (ensuring that the range remains valid and
|
---|
1710 | that the current value is within in the range).
|
---|
1711 |
|
---|
1712 | \sa minimum(), setRange()
|
---|
1713 | */
|
---|
1714 | void QtDatePropertyManager::setMinimum(QtProperty *property, const QDate &minVal)
|
---|
1715 | {
|
---|
1716 | setMinimumValue<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate, QtDatePropertyManagerPrivate::Data>(this, d_ptr.data(),
|
---|
1717 | &QtDatePropertyManager::propertyChanged,
|
---|
1718 | &QtDatePropertyManager::valueChanged,
|
---|
1719 | &QtDatePropertyManager::rangeChanged,
|
---|
1720 | property, minVal);
|
---|
1721 | }
|
---|
1722 |
|
---|
1723 | /*!
|
---|
1724 | Sets the maximum value for the given \a property to \a maxVal.
|
---|
1725 |
|
---|
1726 | When setting the maximum value, the minimum and current
|
---|
1727 | values are adjusted if necessary (ensuring that the range remains
|
---|
1728 | valid and that the current value is within in the range).
|
---|
1729 |
|
---|
1730 | \sa maximum(), setRange()
|
---|
1731 | */
|
---|
1732 | void QtDatePropertyManager::setMaximum(QtProperty *property, const QDate &maxVal)
|
---|
1733 | {
|
---|
1734 | setMaximumValue<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate, QtDatePropertyManagerPrivate::Data>(this, d_ptr.data(),
|
---|
1735 | &QtDatePropertyManager::propertyChanged,
|
---|
1736 | &QtDatePropertyManager::valueChanged,
|
---|
1737 | &QtDatePropertyManager::rangeChanged,
|
---|
1738 | property, maxVal);
|
---|
1739 | }
|
---|
1740 |
|
---|
1741 | /*!
|
---|
1742 | \fn void QtDatePropertyManager::setRange(QtProperty *property, const QDate &minimum, const QDate &maximum)
|
---|
1743 |
|
---|
1744 | Sets the range of valid dates.
|
---|
1745 |
|
---|
1746 | This is a convenience function defining the range of valid dates
|
---|
1747 | in one go; setting the \a minimum and \a maximum values for the
|
---|
1748 | given \a property with a single function call.
|
---|
1749 |
|
---|
1750 | When setting a new date range, the current value is adjusted if
|
---|
1751 | necessary (ensuring that the value remains in date range).
|
---|
1752 |
|
---|
1753 | \sa setMinimum(), setMaximum(), rangeChanged()
|
---|
1754 | */
|
---|
1755 | void QtDatePropertyManager::setRange(QtProperty *property, const QDate &minVal, const QDate &maxVal)
|
---|
1756 | {
|
---|
1757 | void (QtDatePropertyManagerPrivate::*setSubPropertyRange)(QtProperty *, const QDate &,
|
---|
1758 | const QDate &, const QDate &) = 0;
|
---|
1759 | setBorderValues<const QDate &, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate>(this, d_ptr.data(),
|
---|
1760 | &QtDatePropertyManager::propertyChanged,
|
---|
1761 | &QtDatePropertyManager::valueChanged,
|
---|
1762 | &QtDatePropertyManager::rangeChanged,
|
---|
1763 | property, minVal, maxVal, setSubPropertyRange);
|
---|
1764 | }
|
---|
1765 |
|
---|
1766 | /*!
|
---|
1767 | \reimp
|
---|
1768 | */
|
---|
1769 | void QtDatePropertyManager::initializeProperty(QtProperty *property)
|
---|
1770 | {
|
---|
1771 | d_ptr->m_values[property] = QtDatePropertyManagerPrivate::Data();
|
---|
1772 | }
|
---|
1773 |
|
---|
1774 | /*!
|
---|
1775 | \reimp
|
---|
1776 | */
|
---|
1777 | void QtDatePropertyManager::uninitializeProperty(QtProperty *property)
|
---|
1778 | {
|
---|
1779 | d_ptr->m_values.remove(property);
|
---|
1780 | }
|
---|
1781 |
|
---|
1782 | // QtTimePropertyManager
|
---|
1783 |
|
---|
1784 | class QtTimePropertyManagerPrivate
|
---|
1785 | {
|
---|
1786 | QtTimePropertyManager *q_ptr;
|
---|
1787 | Q_DECLARE_PUBLIC(QtTimePropertyManager)
|
---|
1788 | public:
|
---|
1789 |
|
---|
1790 | QString m_format;
|
---|
1791 |
|
---|
1792 | typedef QMap<const QtProperty *, QTime> PropertyValueMap;
|
---|
1793 | PropertyValueMap m_values;
|
---|
1794 | };
|
---|
1795 |
|
---|
1796 | /*!
|
---|
1797 | \class QtTimePropertyManager
|
---|
1798 | \internal
|
---|
1799 | \inmodule QtDesigner
|
---|
1800 | \since 4.4
|
---|
1801 |
|
---|
1802 | \brief The QtTimePropertyManager provides and manages QTime properties.
|
---|
1803 |
|
---|
1804 | A time property's value can be retrieved using the value()
|
---|
1805 | function, and set using the setValue() slot.
|
---|
1806 |
|
---|
1807 | In addition, QtTimePropertyManager provides the valueChanged() signal
|
---|
1808 | which is emitted whenever a property created by this manager
|
---|
1809 | changes.
|
---|
1810 |
|
---|
1811 | \sa QtAbstractPropertyManager, QtTimeEditFactory
|
---|
1812 | */
|
---|
1813 |
|
---|
1814 | /*!
|
---|
1815 | \fn void QtTimePropertyManager::valueChanged(QtProperty *property, const QTime &value)
|
---|
1816 |
|
---|
1817 | This signal is emitted whenever a property created by this manager
|
---|
1818 | changes its value, passing a pointer to the \a property and the
|
---|
1819 | new \a value as parameters.
|
---|
1820 |
|
---|
1821 | \sa setValue()
|
---|
1822 | */
|
---|
1823 |
|
---|
1824 | /*!
|
---|
1825 | Creates a manager with the given \a parent.
|
---|
1826 | */
|
---|
1827 | QtTimePropertyManager::QtTimePropertyManager(QObject *parent)
|
---|
1828 | : QtAbstractPropertyManager(parent), d_ptr(new QtTimePropertyManagerPrivate)
|
---|
1829 | {
|
---|
1830 | d_ptr->q_ptr = this;
|
---|
1831 |
|
---|
1832 | QLocale loc;
|
---|
1833 | d_ptr->m_format = loc.timeFormat(QLocale::ShortFormat);
|
---|
1834 | }
|
---|
1835 |
|
---|
1836 | /*!
|
---|
1837 | Destroys this manager, and all the properties it has created.
|
---|
1838 | */
|
---|
1839 | QtTimePropertyManager::~QtTimePropertyManager()
|
---|
1840 | {
|
---|
1841 | clear();
|
---|
1842 | }
|
---|
1843 |
|
---|
1844 | /*!
|
---|
1845 | Returns the given \a property's value.
|
---|
1846 |
|
---|
1847 | If the given property is not managed by this manager, this
|
---|
1848 | function returns an invalid time object.
|
---|
1849 |
|
---|
1850 | \sa setValue()
|
---|
1851 | */
|
---|
1852 | QTime QtTimePropertyManager::value(const QtProperty *property) const
|
---|
1853 | {
|
---|
1854 | return d_ptr->m_values.value(property, QTime());
|
---|
1855 | }
|
---|
1856 |
|
---|
1857 | /*!
|
---|
1858 | \reimp
|
---|
1859 | */
|
---|
1860 | QString QtTimePropertyManager::valueText(const QtProperty *property) const
|
---|
1861 | {
|
---|
1862 | const QtTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
1863 | if (it == d_ptr->m_values.constEnd())
|
---|
1864 | return QString();
|
---|
1865 | return it.value().toString(d_ptr->m_format);
|
---|
1866 | }
|
---|
1867 |
|
---|
1868 | /*!
|
---|
1869 | \fn void QtTimePropertyManager::setValue(QtProperty *property, const QTime &value)
|
---|
1870 |
|
---|
1871 | Sets the value of the given \a property to \a value.
|
---|
1872 |
|
---|
1873 | \sa value(), valueChanged()
|
---|
1874 | */
|
---|
1875 | void QtTimePropertyManager::setValue(QtProperty *property, const QTime &val)
|
---|
1876 | {
|
---|
1877 | setSimpleValue<const QTime &, QTime, QtTimePropertyManager>(d_ptr->m_values, this,
|
---|
1878 | &QtTimePropertyManager::propertyChanged,
|
---|
1879 | &QtTimePropertyManager::valueChanged,
|
---|
1880 | property, val);
|
---|
1881 | }
|
---|
1882 |
|
---|
1883 | /*!
|
---|
1884 | \reimp
|
---|
1885 | */
|
---|
1886 | void QtTimePropertyManager::initializeProperty(QtProperty *property)
|
---|
1887 | {
|
---|
1888 | d_ptr->m_values[property] = QTime::currentTime();
|
---|
1889 | }
|
---|
1890 |
|
---|
1891 | /*!
|
---|
1892 | \reimp
|
---|
1893 | */
|
---|
1894 | void QtTimePropertyManager::uninitializeProperty(QtProperty *property)
|
---|
1895 | {
|
---|
1896 | d_ptr->m_values.remove(property);
|
---|
1897 | }
|
---|
1898 |
|
---|
1899 | // QtDateTimePropertyManager
|
---|
1900 |
|
---|
1901 | class QtDateTimePropertyManagerPrivate
|
---|
1902 | {
|
---|
1903 | QtDateTimePropertyManager *q_ptr;
|
---|
1904 | Q_DECLARE_PUBLIC(QtDateTimePropertyManager)
|
---|
1905 | public:
|
---|
1906 |
|
---|
1907 | QString m_format;
|
---|
1908 |
|
---|
1909 | typedef QMap<const QtProperty *, QDateTime> PropertyValueMap;
|
---|
1910 | PropertyValueMap m_values;
|
---|
1911 | };
|
---|
1912 |
|
---|
1913 | /*! \class QtDateTimePropertyManager
|
---|
1914 | \internal
|
---|
1915 | \inmodule QtDesigner
|
---|
1916 | \since 4.4
|
---|
1917 |
|
---|
1918 | \brief The QtDateTimePropertyManager provides and manages QDateTime properties.
|
---|
1919 |
|
---|
1920 | A date and time property has a current value which can be
|
---|
1921 | retrieved using the value() function, and set using the setValue()
|
---|
1922 | slot. In addition, QtDateTimePropertyManager provides the
|
---|
1923 | valueChanged() signal which is emitted whenever a property created
|
---|
1924 | by this manager changes.
|
---|
1925 |
|
---|
1926 | \sa QtAbstractPropertyManager, QtDateTimeEditFactory, QtDatePropertyManager
|
---|
1927 | */
|
---|
1928 |
|
---|
1929 | /*!
|
---|
1930 | \fn void QtDateTimePropertyManager::valueChanged(QtProperty *property, const QDateTime &value)
|
---|
1931 |
|
---|
1932 | This signal is emitted whenever a property created by this manager
|
---|
1933 | changes its value, passing a pointer to the \a property and the new
|
---|
1934 | \a value as parameters.
|
---|
1935 | */
|
---|
1936 |
|
---|
1937 | /*!
|
---|
1938 | Creates a manager with the given \a parent.
|
---|
1939 | */
|
---|
1940 | QtDateTimePropertyManager::QtDateTimePropertyManager(QObject *parent)
|
---|
1941 | : QtAbstractPropertyManager(parent), d_ptr(new QtDateTimePropertyManagerPrivate)
|
---|
1942 | {
|
---|
1943 | d_ptr->q_ptr = this;
|
---|
1944 |
|
---|
1945 | QLocale loc;
|
---|
1946 | d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat);
|
---|
1947 | d_ptr->m_format += QLatin1Char(' ');
|
---|
1948 | d_ptr->m_format += loc.timeFormat(QLocale::ShortFormat);
|
---|
1949 | }
|
---|
1950 |
|
---|
1951 | /*!
|
---|
1952 | Destroys this manager, and all the properties it has created.
|
---|
1953 | */
|
---|
1954 | QtDateTimePropertyManager::~QtDateTimePropertyManager()
|
---|
1955 | {
|
---|
1956 | clear();
|
---|
1957 | }
|
---|
1958 |
|
---|
1959 | /*!
|
---|
1960 | Returns the given \a property's value.
|
---|
1961 |
|
---|
1962 | If the given \a property is not managed by this manager, this
|
---|
1963 | function returns an invalid QDateTime object.
|
---|
1964 |
|
---|
1965 | \sa setValue()
|
---|
1966 | */
|
---|
1967 | QDateTime QtDateTimePropertyManager::value(const QtProperty *property) const
|
---|
1968 | {
|
---|
1969 | return d_ptr->m_values.value(property, QDateTime());
|
---|
1970 | }
|
---|
1971 |
|
---|
1972 | /*!
|
---|
1973 | \reimp
|
---|
1974 | */
|
---|
1975 | QString QtDateTimePropertyManager::valueText(const QtProperty *property) const
|
---|
1976 | {
|
---|
1977 | const QtDateTimePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
1978 | if (it == d_ptr->m_values.constEnd())
|
---|
1979 | return QString();
|
---|
1980 | return it.value().toString(d_ptr->m_format);
|
---|
1981 | }
|
---|
1982 |
|
---|
1983 | /*!
|
---|
1984 | \fn void QtDateTimePropertyManager::setValue(QtProperty *property, const QDateTime &value)
|
---|
1985 |
|
---|
1986 | Sets the value of the given \a property to \a value.
|
---|
1987 |
|
---|
1988 | \sa value(), valueChanged()
|
---|
1989 | */
|
---|
1990 | void QtDateTimePropertyManager::setValue(QtProperty *property, const QDateTime &val)
|
---|
1991 | {
|
---|
1992 | setSimpleValue<const QDateTime &, QDateTime, QtDateTimePropertyManager>(d_ptr->m_values, this,
|
---|
1993 | &QtDateTimePropertyManager::propertyChanged,
|
---|
1994 | &QtDateTimePropertyManager::valueChanged,
|
---|
1995 | property, val);
|
---|
1996 | }
|
---|
1997 |
|
---|
1998 | /*!
|
---|
1999 | \reimp
|
---|
2000 | */
|
---|
2001 | void QtDateTimePropertyManager::initializeProperty(QtProperty *property)
|
---|
2002 | {
|
---|
2003 | d_ptr->m_values[property] = QDateTime::currentDateTime();
|
---|
2004 | }
|
---|
2005 |
|
---|
2006 | /*!
|
---|
2007 | \reimp
|
---|
2008 | */
|
---|
2009 | void QtDateTimePropertyManager::uninitializeProperty(QtProperty *property)
|
---|
2010 | {
|
---|
2011 | d_ptr->m_values.remove(property);
|
---|
2012 | }
|
---|
2013 |
|
---|
2014 | // QtKeySequencePropertyManager
|
---|
2015 |
|
---|
2016 | class QtKeySequencePropertyManagerPrivate
|
---|
2017 | {
|
---|
2018 | QtKeySequencePropertyManager *q_ptr;
|
---|
2019 | Q_DECLARE_PUBLIC(QtKeySequencePropertyManager)
|
---|
2020 | public:
|
---|
2021 |
|
---|
2022 | QString m_format;
|
---|
2023 |
|
---|
2024 | typedef QMap<const QtProperty *, QKeySequence> PropertyValueMap;
|
---|
2025 | PropertyValueMap m_values;
|
---|
2026 | };
|
---|
2027 |
|
---|
2028 | /*! \class QtKeySequencePropertyManager
|
---|
2029 | \internal
|
---|
2030 | \inmodule QtDesigner
|
---|
2031 | \since 4.4
|
---|
2032 |
|
---|
2033 | \brief The QtKeySequencePropertyManager provides and manages QKeySequence properties.
|
---|
2034 |
|
---|
2035 | A key sequence's value can be retrieved using the value()
|
---|
2036 | function, and set using the setValue() slot.
|
---|
2037 |
|
---|
2038 | In addition, QtKeySequencePropertyManager provides the valueChanged() signal
|
---|
2039 | which is emitted whenever a property created by this manager
|
---|
2040 | changes.
|
---|
2041 |
|
---|
2042 | \sa QtAbstractPropertyManager
|
---|
2043 | */
|
---|
2044 |
|
---|
2045 | /*!
|
---|
2046 | \fn void QtKeySequencePropertyManager::valueChanged(QtProperty *property, const QKeySequence &value)
|
---|
2047 |
|
---|
2048 | This signal is emitted whenever a property created by this manager
|
---|
2049 | changes its value, passing a pointer to the \a property and the new
|
---|
2050 | \a value as parameters.
|
---|
2051 | */
|
---|
2052 |
|
---|
2053 | /*!
|
---|
2054 | Creates a manager with the given \a parent.
|
---|
2055 | */
|
---|
2056 | QtKeySequencePropertyManager::QtKeySequencePropertyManager(QObject *parent)
|
---|
2057 | : QtAbstractPropertyManager(parent), d_ptr(new QtKeySequencePropertyManagerPrivate)
|
---|
2058 | {
|
---|
2059 | d_ptr->q_ptr = this;
|
---|
2060 | }
|
---|
2061 |
|
---|
2062 | /*!
|
---|
2063 | Destroys this manager, and all the properties it has created.
|
---|
2064 | */
|
---|
2065 | QtKeySequencePropertyManager::~QtKeySequencePropertyManager()
|
---|
2066 | {
|
---|
2067 | clear();
|
---|
2068 | }
|
---|
2069 |
|
---|
2070 | /*!
|
---|
2071 | Returns the given \a property's value.
|
---|
2072 |
|
---|
2073 | If the given \a property is not managed by this manager, this
|
---|
2074 | function returns an empty QKeySequence object.
|
---|
2075 |
|
---|
2076 | \sa setValue()
|
---|
2077 | */
|
---|
2078 | QKeySequence QtKeySequencePropertyManager::value(const QtProperty *property) const
|
---|
2079 | {
|
---|
2080 | return d_ptr->m_values.value(property, QKeySequence());
|
---|
2081 | }
|
---|
2082 |
|
---|
2083 | /*!
|
---|
2084 | \reimp
|
---|
2085 | */
|
---|
2086 | QString QtKeySequencePropertyManager::valueText(const QtProperty *property) const
|
---|
2087 | {
|
---|
2088 | const QtKeySequencePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
2089 | if (it == d_ptr->m_values.constEnd())
|
---|
2090 | return QString();
|
---|
2091 | return it.value().toString(QKeySequence::NativeText);
|
---|
2092 | }
|
---|
2093 |
|
---|
2094 | /*!
|
---|
2095 | \fn void QtKeySequencePropertyManager::setValue(QtProperty *property, const QKeySequence &value)
|
---|
2096 |
|
---|
2097 | Sets the value of the given \a property to \a value.
|
---|
2098 |
|
---|
2099 | \sa value(), valueChanged()
|
---|
2100 | */
|
---|
2101 | void QtKeySequencePropertyManager::setValue(QtProperty *property, const QKeySequence &val)
|
---|
2102 | {
|
---|
2103 | setSimpleValue<const QKeySequence &, QKeySequence, QtKeySequencePropertyManager>(d_ptr->m_values, this,
|
---|
2104 | &QtKeySequencePropertyManager::propertyChanged,
|
---|
2105 | &QtKeySequencePropertyManager::valueChanged,
|
---|
2106 | property, val);
|
---|
2107 | }
|
---|
2108 |
|
---|
2109 | /*!
|
---|
2110 | \reimp
|
---|
2111 | */
|
---|
2112 | void QtKeySequencePropertyManager::initializeProperty(QtProperty *property)
|
---|
2113 | {
|
---|
2114 | d_ptr->m_values[property] = QKeySequence();
|
---|
2115 | }
|
---|
2116 |
|
---|
2117 | /*!
|
---|
2118 | \reimp
|
---|
2119 | */
|
---|
2120 | void QtKeySequencePropertyManager::uninitializeProperty(QtProperty *property)
|
---|
2121 | {
|
---|
2122 | d_ptr->m_values.remove(property);
|
---|
2123 | }
|
---|
2124 |
|
---|
2125 | // QtCharPropertyManager
|
---|
2126 |
|
---|
2127 | class QtCharPropertyManagerPrivate
|
---|
2128 | {
|
---|
2129 | QtCharPropertyManager *q_ptr;
|
---|
2130 | Q_DECLARE_PUBLIC(QtCharPropertyManager)
|
---|
2131 | public:
|
---|
2132 |
|
---|
2133 | typedef QMap<const QtProperty *, QChar> PropertyValueMap;
|
---|
2134 | PropertyValueMap m_values;
|
---|
2135 | };
|
---|
2136 |
|
---|
2137 | /*! \class QtCharPropertyManager
|
---|
2138 | \internal
|
---|
2139 | \inmodule QtDesigner
|
---|
2140 | \since 4.4
|
---|
2141 |
|
---|
2142 | \brief The QtCharPropertyManager provides and manages QChar properties.
|
---|
2143 |
|
---|
2144 | A char's value can be retrieved using the value()
|
---|
2145 | function, and set using the setValue() slot.
|
---|
2146 |
|
---|
2147 | In addition, QtCharPropertyManager provides the valueChanged() signal
|
---|
2148 | which is emitted whenever a property created by this manager
|
---|
2149 | changes.
|
---|
2150 |
|
---|
2151 | \sa QtAbstractPropertyManager
|
---|
2152 | */
|
---|
2153 |
|
---|
2154 | /*!
|
---|
2155 | \fn void QtCharPropertyManager::valueChanged(QtProperty *property, const QChar &value)
|
---|
2156 |
|
---|
2157 | This signal is emitted whenever a property created by this manager
|
---|
2158 | changes its value, passing a pointer to the \a property and the new
|
---|
2159 | \a value as parameters.
|
---|
2160 | */
|
---|
2161 |
|
---|
2162 | /*!
|
---|
2163 | Creates a manager with the given \a parent.
|
---|
2164 | */
|
---|
2165 | QtCharPropertyManager::QtCharPropertyManager(QObject *parent)
|
---|
2166 | : QtAbstractPropertyManager(parent), d_ptr(new QtCharPropertyManagerPrivate)
|
---|
2167 | {
|
---|
2168 | d_ptr->q_ptr = this;
|
---|
2169 | }
|
---|
2170 |
|
---|
2171 | /*!
|
---|
2172 | Destroys this manager, and all the properties it has created.
|
---|
2173 | */
|
---|
2174 | QtCharPropertyManager::~QtCharPropertyManager()
|
---|
2175 | {
|
---|
2176 | clear();
|
---|
2177 | }
|
---|
2178 |
|
---|
2179 | /*!
|
---|
2180 | Returns the given \a property's value.
|
---|
2181 |
|
---|
2182 | If the given \a property is not managed by this manager, this
|
---|
2183 | function returns an null QChar object.
|
---|
2184 |
|
---|
2185 | \sa setValue()
|
---|
2186 | */
|
---|
2187 | QChar QtCharPropertyManager::value(const QtProperty *property) const
|
---|
2188 | {
|
---|
2189 | return d_ptr->m_values.value(property, QChar());
|
---|
2190 | }
|
---|
2191 |
|
---|
2192 | /*!
|
---|
2193 | \reimp
|
---|
2194 | */
|
---|
2195 | QString QtCharPropertyManager::valueText(const QtProperty *property) const
|
---|
2196 | {
|
---|
2197 | const QtCharPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
2198 | if (it == d_ptr->m_values.constEnd())
|
---|
2199 | return QString();
|
---|
2200 | const QChar c = it.value();
|
---|
2201 | return c.isNull() ? QString() : QString(c);
|
---|
2202 | }
|
---|
2203 |
|
---|
2204 | /*!
|
---|
2205 | \fn void QtCharPropertyManager::setValue(QtProperty *property, const QChar &value)
|
---|
2206 |
|
---|
2207 | Sets the value of the given \a property to \a value.
|
---|
2208 |
|
---|
2209 | \sa value(), valueChanged()
|
---|
2210 | */
|
---|
2211 | void QtCharPropertyManager::setValue(QtProperty *property, const QChar &val)
|
---|
2212 | {
|
---|
2213 | setSimpleValue<const QChar &, QChar, QtCharPropertyManager>(d_ptr->m_values, this,
|
---|
2214 | &QtCharPropertyManager::propertyChanged,
|
---|
2215 | &QtCharPropertyManager::valueChanged,
|
---|
2216 | property, val);
|
---|
2217 | }
|
---|
2218 |
|
---|
2219 | /*!
|
---|
2220 | \reimp
|
---|
2221 | */
|
---|
2222 | void QtCharPropertyManager::initializeProperty(QtProperty *property)
|
---|
2223 | {
|
---|
2224 | d_ptr->m_values[property] = QChar();
|
---|
2225 | }
|
---|
2226 |
|
---|
2227 | /*!
|
---|
2228 | \reimp
|
---|
2229 | */
|
---|
2230 | void QtCharPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
2231 | {
|
---|
2232 | d_ptr->m_values.remove(property);
|
---|
2233 | }
|
---|
2234 |
|
---|
2235 | // QtLocalePropertyManager
|
---|
2236 |
|
---|
2237 | class QtLocalePropertyManagerPrivate
|
---|
2238 | {
|
---|
2239 | QtLocalePropertyManager *q_ptr;
|
---|
2240 | Q_DECLARE_PUBLIC(QtLocalePropertyManager)
|
---|
2241 | public:
|
---|
2242 |
|
---|
2243 | QtLocalePropertyManagerPrivate();
|
---|
2244 |
|
---|
2245 | void slotEnumChanged(QtProperty *property, int value);
|
---|
2246 | void slotPropertyDestroyed(QtProperty *property);
|
---|
2247 |
|
---|
2248 | typedef QMap<const QtProperty *, QLocale> PropertyValueMap;
|
---|
2249 | PropertyValueMap m_values;
|
---|
2250 |
|
---|
2251 | QtEnumPropertyManager *m_enumPropertyManager;
|
---|
2252 |
|
---|
2253 | QMap<const QtProperty *, QtProperty *> m_propertyToLanguage;
|
---|
2254 | QMap<const QtProperty *, QtProperty *> m_propertyToCountry;
|
---|
2255 |
|
---|
2256 | QMap<const QtProperty *, QtProperty *> m_languageToProperty;
|
---|
2257 | QMap<const QtProperty *, QtProperty *> m_countryToProperty;
|
---|
2258 | };
|
---|
2259 |
|
---|
2260 | QtLocalePropertyManagerPrivate::QtLocalePropertyManagerPrivate()
|
---|
2261 | {
|
---|
2262 | }
|
---|
2263 |
|
---|
2264 | void QtLocalePropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value)
|
---|
2265 | {
|
---|
2266 | if (QtProperty *prop = m_languageToProperty.value(property, 0)) {
|
---|
2267 | const QLocale loc = m_values[prop];
|
---|
2268 | QLocale::Language newLanguage = loc.language();
|
---|
2269 | QLocale::Country newCountry = loc.country();
|
---|
2270 | metaEnumProvider()->indexToLocale(value, 0, &newLanguage, 0);
|
---|
2271 | QLocale newLoc(newLanguage, newCountry);
|
---|
2272 | q_ptr->setValue(prop, newLoc);
|
---|
2273 | } else if (QtProperty *prop = m_countryToProperty.value(property, 0)) {
|
---|
2274 | const QLocale loc = m_values[prop];
|
---|
2275 | QLocale::Language newLanguage = loc.language();
|
---|
2276 | QLocale::Country newCountry = loc.country();
|
---|
2277 | metaEnumProvider()->indexToLocale(m_enumPropertyManager->value(m_propertyToLanguage.value(prop)), value, &newLanguage, &newCountry);
|
---|
2278 | QLocale newLoc(newLanguage, newCountry);
|
---|
2279 | q_ptr->setValue(prop, newLoc);
|
---|
2280 | }
|
---|
2281 | }
|
---|
2282 |
|
---|
2283 | void QtLocalePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
2284 | {
|
---|
2285 | if (QtProperty *subProp = m_languageToProperty.value(property, 0)) {
|
---|
2286 | m_propertyToLanguage[subProp] = 0;
|
---|
2287 | m_languageToProperty.remove(property);
|
---|
2288 | } else if (QtProperty *subProp = m_countryToProperty.value(property, 0)) {
|
---|
2289 | m_propertyToCountry[subProp] = 0;
|
---|
2290 | m_countryToProperty.remove(property);
|
---|
2291 | }
|
---|
2292 | }
|
---|
2293 |
|
---|
2294 | /*!
|
---|
2295 | \class QtLocalePropertyManager
|
---|
2296 | \internal
|
---|
2297 | \inmodule QtDesigner
|
---|
2298 | \since 4.4
|
---|
2299 |
|
---|
2300 | \brief The QtLocalePropertyManager provides and manages QLocale properties.
|
---|
2301 |
|
---|
2302 | A locale property has nested \e language and \e country
|
---|
2303 | subproperties. The top-level property's value can be retrieved
|
---|
2304 | using the value() function, and set using the setValue() slot.
|
---|
2305 |
|
---|
2306 | The subproperties are created by QtEnumPropertyManager object.
|
---|
2307 | These submanager can be retrieved using the subEnumPropertyManager()
|
---|
2308 | function. In order to provide editing widgets for the subproperties
|
---|
2309 | in a property browser widget, this manager must be associated with editor factory.
|
---|
2310 |
|
---|
2311 | In addition, QtLocalePropertyManager provides the valueChanged()
|
---|
2312 | signal which is emitted whenever a property created by this
|
---|
2313 | manager changes.
|
---|
2314 |
|
---|
2315 | \sa QtAbstractPropertyManager, QtEnumPropertyManager
|
---|
2316 | */
|
---|
2317 |
|
---|
2318 | /*!
|
---|
2319 | \fn void QtLocalePropertyManager::valueChanged(QtProperty *property, const QLocale &value)
|
---|
2320 |
|
---|
2321 | This signal is emitted whenever a property created by this manager
|
---|
2322 | changes its value, passing a pointer to the \a property and the
|
---|
2323 | new \a value as parameters.
|
---|
2324 |
|
---|
2325 | \sa setValue()
|
---|
2326 | */
|
---|
2327 |
|
---|
2328 | /*!
|
---|
2329 | Creates a manager with the given \a parent.
|
---|
2330 | */
|
---|
2331 | QtLocalePropertyManager::QtLocalePropertyManager(QObject *parent)
|
---|
2332 | : QtAbstractPropertyManager(parent), d_ptr(new QtLocalePropertyManagerPrivate)
|
---|
2333 | {
|
---|
2334 | d_ptr->q_ptr = this;
|
---|
2335 |
|
---|
2336 | d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
|
---|
2337 | connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
|
---|
2338 | this, SLOT(slotEnumChanged(QtProperty*,int)));
|
---|
2339 |
|
---|
2340 | connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
2341 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
2342 | }
|
---|
2343 |
|
---|
2344 | /*!
|
---|
2345 | Destroys this manager, and all the properties it has created.
|
---|
2346 | */
|
---|
2347 | QtLocalePropertyManager::~QtLocalePropertyManager()
|
---|
2348 | {
|
---|
2349 | clear();
|
---|
2350 | }
|
---|
2351 |
|
---|
2352 | /*!
|
---|
2353 | Returns the manager that creates the nested \e language
|
---|
2354 | and \e country subproperties.
|
---|
2355 |
|
---|
2356 | In order to provide editing widgets for the mentioned subproperties
|
---|
2357 | in a property browser widget, this manager must be associated with
|
---|
2358 | an editor factory.
|
---|
2359 |
|
---|
2360 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
2361 | */
|
---|
2362 | QtEnumPropertyManager *QtLocalePropertyManager::subEnumPropertyManager() const
|
---|
2363 | {
|
---|
2364 | return d_ptr->m_enumPropertyManager;
|
---|
2365 | }
|
---|
2366 |
|
---|
2367 | /*!
|
---|
2368 | Returns the given \a property's value.
|
---|
2369 |
|
---|
2370 | If the given property is not managed by this manager, this
|
---|
2371 | function returns the default locale.
|
---|
2372 |
|
---|
2373 | \sa setValue()
|
---|
2374 | */
|
---|
2375 | QLocale QtLocalePropertyManager::value(const QtProperty *property) const
|
---|
2376 | {
|
---|
2377 | return d_ptr->m_values.value(property, QLocale());
|
---|
2378 | }
|
---|
2379 |
|
---|
2380 | /*!
|
---|
2381 | \reimp
|
---|
2382 | */
|
---|
2383 | QString QtLocalePropertyManager::valueText(const QtProperty *property) const
|
---|
2384 | {
|
---|
2385 | const QtLocalePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
2386 | if (it == d_ptr->m_values.constEnd())
|
---|
2387 | return QString();
|
---|
2388 |
|
---|
2389 | QLocale loc = it.value();
|
---|
2390 |
|
---|
2391 | int langIdx = 0;
|
---|
2392 | int countryIdx = 0;
|
---|
2393 | metaEnumProvider()->localeToIndex(loc.language(), loc.country(), &langIdx, &countryIdx);
|
---|
2394 | QString str = tr("%1, %2")
|
---|
2395 | .arg(metaEnumProvider()->languageEnumNames().at(langIdx))
|
---|
2396 | .arg(metaEnumProvider()->countryEnumNames(loc.language()).at(countryIdx));
|
---|
2397 | return str;
|
---|
2398 | }
|
---|
2399 |
|
---|
2400 | /*!
|
---|
2401 | \fn void QtLocalePropertyManager::setValue(QtProperty *property, const QLocale &value)
|
---|
2402 |
|
---|
2403 | Sets the value of the given \a property to \a value. Nested
|
---|
2404 | properties are updated automatically.
|
---|
2405 |
|
---|
2406 | \sa value(), valueChanged()
|
---|
2407 | */
|
---|
2408 | void QtLocalePropertyManager::setValue(QtProperty *property, const QLocale &val)
|
---|
2409 | {
|
---|
2410 | const QtLocalePropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
2411 | if (it == d_ptr->m_values.end())
|
---|
2412 | return;
|
---|
2413 |
|
---|
2414 | const QLocale loc = it.value();
|
---|
2415 | if (loc == val)
|
---|
2416 | return;
|
---|
2417 |
|
---|
2418 | it.value() = val;
|
---|
2419 |
|
---|
2420 | int langIdx = 0;
|
---|
2421 | int countryIdx = 0;
|
---|
2422 | metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx);
|
---|
2423 | if (loc.language() != val.language()) {
|
---|
2424 | d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToLanguage.value(property), langIdx);
|
---|
2425 | d_ptr->m_enumPropertyManager->setEnumNames(d_ptr->m_propertyToCountry.value(property),
|
---|
2426 | metaEnumProvider()->countryEnumNames(val.language()));
|
---|
2427 | }
|
---|
2428 | d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToCountry.value(property), countryIdx);
|
---|
2429 |
|
---|
2430 | emit propertyChanged(property);
|
---|
2431 | emit valueChanged(property, val);
|
---|
2432 | }
|
---|
2433 |
|
---|
2434 | /*!
|
---|
2435 | \reimp
|
---|
2436 | */
|
---|
2437 | void QtLocalePropertyManager::initializeProperty(QtProperty *property)
|
---|
2438 | {
|
---|
2439 | QLocale val;
|
---|
2440 | d_ptr->m_values[property] = val;
|
---|
2441 |
|
---|
2442 | int langIdx = 0;
|
---|
2443 | int countryIdx = 0;
|
---|
2444 | metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx);
|
---|
2445 |
|
---|
2446 | QtProperty *languageProp = d_ptr->m_enumPropertyManager->addProperty();
|
---|
2447 | languageProp->setPropertyName(tr("Language"));
|
---|
2448 | d_ptr->m_enumPropertyManager->setEnumNames(languageProp, metaEnumProvider()->languageEnumNames());
|
---|
2449 | d_ptr->m_enumPropertyManager->setValue(languageProp, langIdx);
|
---|
2450 | d_ptr->m_propertyToLanguage[property] = languageProp;
|
---|
2451 | d_ptr->m_languageToProperty[languageProp] = property;
|
---|
2452 | property->addSubProperty(languageProp);
|
---|
2453 |
|
---|
2454 | QtProperty *countryProp = d_ptr->m_enumPropertyManager->addProperty();
|
---|
2455 | countryProp->setPropertyName(tr("Country"));
|
---|
2456 | d_ptr->m_enumPropertyManager->setEnumNames(countryProp, metaEnumProvider()->countryEnumNames(val.language()));
|
---|
2457 | d_ptr->m_enumPropertyManager->setValue(countryProp, countryIdx);
|
---|
2458 | d_ptr->m_propertyToCountry[property] = countryProp;
|
---|
2459 | d_ptr->m_countryToProperty[countryProp] = property;
|
---|
2460 | property->addSubProperty(countryProp);
|
---|
2461 | }
|
---|
2462 |
|
---|
2463 | /*!
|
---|
2464 | \reimp
|
---|
2465 | */
|
---|
2466 | void QtLocalePropertyManager::uninitializeProperty(QtProperty *property)
|
---|
2467 | {
|
---|
2468 | QtProperty *languageProp = d_ptr->m_propertyToLanguage[property];
|
---|
2469 | if (languageProp) {
|
---|
2470 | d_ptr->m_languageToProperty.remove(languageProp);
|
---|
2471 | delete languageProp;
|
---|
2472 | }
|
---|
2473 | d_ptr->m_propertyToLanguage.remove(property);
|
---|
2474 |
|
---|
2475 | QtProperty *countryProp = d_ptr->m_propertyToCountry[property];
|
---|
2476 | if (countryProp) {
|
---|
2477 | d_ptr->m_countryToProperty.remove(countryProp);
|
---|
2478 | delete countryProp;
|
---|
2479 | }
|
---|
2480 | d_ptr->m_propertyToCountry.remove(property);
|
---|
2481 |
|
---|
2482 | d_ptr->m_values.remove(property);
|
---|
2483 | }
|
---|
2484 |
|
---|
2485 | // QtPointPropertyManager
|
---|
2486 |
|
---|
2487 | class QtPointPropertyManagerPrivate
|
---|
2488 | {
|
---|
2489 | QtPointPropertyManager *q_ptr;
|
---|
2490 | Q_DECLARE_PUBLIC(QtPointPropertyManager)
|
---|
2491 | public:
|
---|
2492 |
|
---|
2493 | void slotIntChanged(QtProperty *property, int value);
|
---|
2494 | void slotPropertyDestroyed(QtProperty *property);
|
---|
2495 |
|
---|
2496 | typedef QMap<const QtProperty *, QPoint> PropertyValueMap;
|
---|
2497 | PropertyValueMap m_values;
|
---|
2498 |
|
---|
2499 | QtIntPropertyManager *m_intPropertyManager;
|
---|
2500 |
|
---|
2501 | QMap<const QtProperty *, QtProperty *> m_propertyToX;
|
---|
2502 | QMap<const QtProperty *, QtProperty *> m_propertyToY;
|
---|
2503 |
|
---|
2504 | QMap<const QtProperty *, QtProperty *> m_xToProperty;
|
---|
2505 | QMap<const QtProperty *, QtProperty *> m_yToProperty;
|
---|
2506 | };
|
---|
2507 |
|
---|
2508 | void QtPointPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
|
---|
2509 | {
|
---|
2510 | if (QtProperty *xprop = m_xToProperty.value(property, 0)) {
|
---|
2511 | QPoint p = m_values[xprop];
|
---|
2512 | p.setX(value);
|
---|
2513 | q_ptr->setValue(xprop, p);
|
---|
2514 | } else if (QtProperty *yprop = m_yToProperty.value(property, 0)) {
|
---|
2515 | QPoint p = m_values[yprop];
|
---|
2516 | p.setY(value);
|
---|
2517 | q_ptr->setValue(yprop, p);
|
---|
2518 | }
|
---|
2519 | }
|
---|
2520 |
|
---|
2521 | void QtPointPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
2522 | {
|
---|
2523 | if (QtProperty *pointProp = m_xToProperty.value(property, 0)) {
|
---|
2524 | m_propertyToX[pointProp] = 0;
|
---|
2525 | m_xToProperty.remove(property);
|
---|
2526 | } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) {
|
---|
2527 | m_propertyToY[pointProp] = 0;
|
---|
2528 | m_yToProperty.remove(property);
|
---|
2529 | }
|
---|
2530 | }
|
---|
2531 |
|
---|
2532 | /*! \class QtPointPropertyManager
|
---|
2533 | \internal
|
---|
2534 | \inmodule QtDesigner
|
---|
2535 | \since 4.4
|
---|
2536 |
|
---|
2537 | \brief The QtPointPropertyManager provides and manages QPoint properties.
|
---|
2538 |
|
---|
2539 | A point property has nested \e x and \e y subproperties. The
|
---|
2540 | top-level property's value can be retrieved using the value()
|
---|
2541 | function, and set using the setValue() slot.
|
---|
2542 |
|
---|
2543 | The subproperties are created by a QtIntPropertyManager object. This
|
---|
2544 | manager can be retrieved using the subIntPropertyManager() function. In
|
---|
2545 | order to provide editing widgets for the subproperties in a
|
---|
2546 | property browser widget, this manager must be associated with an
|
---|
2547 | editor factory.
|
---|
2548 |
|
---|
2549 | In addition, QtPointPropertyManager provides the valueChanged() signal which
|
---|
2550 | is emitted whenever a property created by this manager changes.
|
---|
2551 |
|
---|
2552 | \sa QtAbstractPropertyManager, QtIntPropertyManager, QtPointFPropertyManager
|
---|
2553 | */
|
---|
2554 |
|
---|
2555 | /*!
|
---|
2556 | \fn void QtPointPropertyManager::valueChanged(QtProperty *property, const QPoint &value)
|
---|
2557 |
|
---|
2558 | This signal is emitted whenever a property created by this manager
|
---|
2559 | changes its value, passing a pointer to the \a property and the
|
---|
2560 | new \a value as parameters.
|
---|
2561 |
|
---|
2562 | \sa setValue()
|
---|
2563 | */
|
---|
2564 |
|
---|
2565 | /*!
|
---|
2566 | Creates a manager with the given \a parent.
|
---|
2567 | */
|
---|
2568 | QtPointPropertyManager::QtPointPropertyManager(QObject *parent)
|
---|
2569 | : QtAbstractPropertyManager(parent), d_ptr(new QtPointPropertyManagerPrivate)
|
---|
2570 | {
|
---|
2571 | d_ptr->q_ptr = this;
|
---|
2572 |
|
---|
2573 | d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
|
---|
2574 | connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
|
---|
2575 | this, SLOT(slotIntChanged(QtProperty*,int)));
|
---|
2576 | connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
2577 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
2578 | }
|
---|
2579 |
|
---|
2580 | /*!
|
---|
2581 | Destroys this manager, and all the properties it has created.
|
---|
2582 | */
|
---|
2583 | QtPointPropertyManager::~QtPointPropertyManager()
|
---|
2584 | {
|
---|
2585 | clear();
|
---|
2586 | }
|
---|
2587 |
|
---|
2588 | /*!
|
---|
2589 | Returns the manager that creates the nested \e x and \e y
|
---|
2590 | subproperties.
|
---|
2591 |
|
---|
2592 | In order to provide editing widgets for the subproperties in a
|
---|
2593 | property browser widget, this manager must be associated with an
|
---|
2594 | editor factory.
|
---|
2595 |
|
---|
2596 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
2597 | */
|
---|
2598 | QtIntPropertyManager *QtPointPropertyManager::subIntPropertyManager() const
|
---|
2599 | {
|
---|
2600 | return d_ptr->m_intPropertyManager;
|
---|
2601 | }
|
---|
2602 |
|
---|
2603 | /*!
|
---|
2604 | Returns the given \a property's value.
|
---|
2605 |
|
---|
2606 | If the given \a property is not managed by this manager, this
|
---|
2607 | function returns a point with coordinates (0, 0).
|
---|
2608 |
|
---|
2609 | \sa setValue()
|
---|
2610 | */
|
---|
2611 | QPoint QtPointPropertyManager::value(const QtProperty *property) const
|
---|
2612 | {
|
---|
2613 | return d_ptr->m_values.value(property, QPoint());
|
---|
2614 | }
|
---|
2615 |
|
---|
2616 | /*!
|
---|
2617 | \reimp
|
---|
2618 | */
|
---|
2619 | QString QtPointPropertyManager::valueText(const QtProperty *property) const
|
---|
2620 | {
|
---|
2621 | const QtPointPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
2622 | if (it == d_ptr->m_values.constEnd())
|
---|
2623 | return QString();
|
---|
2624 | const QPoint v = it.value();
|
---|
2625 | return QString(tr("(%1, %2)").arg(QString::number(v.x()))
|
---|
2626 | .arg(QString::number(v.y())));
|
---|
2627 | }
|
---|
2628 |
|
---|
2629 | /*!
|
---|
2630 | \fn void QtPointPropertyManager::setValue(QtProperty *property, const QPoint &value)
|
---|
2631 |
|
---|
2632 | Sets the value of the given \a property to \a value. Nested
|
---|
2633 | properties are updated automatically.
|
---|
2634 |
|
---|
2635 | \sa value(), valueChanged()
|
---|
2636 | */
|
---|
2637 | void QtPointPropertyManager::setValue(QtProperty *property, const QPoint &val)
|
---|
2638 | {
|
---|
2639 | const QtPointPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
2640 | if (it == d_ptr->m_values.end())
|
---|
2641 | return;
|
---|
2642 |
|
---|
2643 | if (it.value() == val)
|
---|
2644 | return;
|
---|
2645 |
|
---|
2646 | it.value() = val;
|
---|
2647 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToX[property], val.x());
|
---|
2648 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToY[property], val.y());
|
---|
2649 |
|
---|
2650 | emit propertyChanged(property);
|
---|
2651 | emit valueChanged(property, val);
|
---|
2652 | }
|
---|
2653 |
|
---|
2654 | /*!
|
---|
2655 | \reimp
|
---|
2656 | */
|
---|
2657 | void QtPointPropertyManager::initializeProperty(QtProperty *property)
|
---|
2658 | {
|
---|
2659 | d_ptr->m_values[property] = QPoint(0, 0);
|
---|
2660 |
|
---|
2661 | QtProperty *xProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
2662 | xProp->setPropertyName(tr("X"));
|
---|
2663 | d_ptr->m_intPropertyManager->setValue(xProp, 0);
|
---|
2664 | d_ptr->m_propertyToX[property] = xProp;
|
---|
2665 | d_ptr->m_xToProperty[xProp] = property;
|
---|
2666 | property->addSubProperty(xProp);
|
---|
2667 |
|
---|
2668 | QtProperty *yProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
2669 | yProp->setPropertyName(tr("Y"));
|
---|
2670 | d_ptr->m_intPropertyManager->setValue(yProp, 0);
|
---|
2671 | d_ptr->m_propertyToY[property] = yProp;
|
---|
2672 | d_ptr->m_yToProperty[yProp] = property;
|
---|
2673 | property->addSubProperty(yProp);
|
---|
2674 | }
|
---|
2675 |
|
---|
2676 | /*!
|
---|
2677 | \reimp
|
---|
2678 | */
|
---|
2679 | void QtPointPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
2680 | {
|
---|
2681 | QtProperty *xProp = d_ptr->m_propertyToX[property];
|
---|
2682 | if (xProp) {
|
---|
2683 | d_ptr->m_xToProperty.remove(xProp);
|
---|
2684 | delete xProp;
|
---|
2685 | }
|
---|
2686 | d_ptr->m_propertyToX.remove(property);
|
---|
2687 |
|
---|
2688 | QtProperty *yProp = d_ptr->m_propertyToY[property];
|
---|
2689 | if (yProp) {
|
---|
2690 | d_ptr->m_yToProperty.remove(yProp);
|
---|
2691 | delete yProp;
|
---|
2692 | }
|
---|
2693 | d_ptr->m_propertyToY.remove(property);
|
---|
2694 |
|
---|
2695 | d_ptr->m_values.remove(property);
|
---|
2696 | }
|
---|
2697 |
|
---|
2698 | // QtPointFPropertyManager
|
---|
2699 |
|
---|
2700 | class QtPointFPropertyManagerPrivate
|
---|
2701 | {
|
---|
2702 | QtPointFPropertyManager *q_ptr;
|
---|
2703 | Q_DECLARE_PUBLIC(QtPointFPropertyManager)
|
---|
2704 | public:
|
---|
2705 |
|
---|
2706 | struct Data
|
---|
2707 | {
|
---|
2708 | Data() : decimals(2) {}
|
---|
2709 | QPointF val;
|
---|
2710 | int decimals;
|
---|
2711 | };
|
---|
2712 |
|
---|
2713 | void slotDoubleChanged(QtProperty *property, double value);
|
---|
2714 | void slotPropertyDestroyed(QtProperty *property);
|
---|
2715 |
|
---|
2716 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
2717 | PropertyValueMap m_values;
|
---|
2718 |
|
---|
2719 | QtDoublePropertyManager *m_doublePropertyManager;
|
---|
2720 |
|
---|
2721 | QMap<const QtProperty *, QtProperty *> m_propertyToX;
|
---|
2722 | QMap<const QtProperty *, QtProperty *> m_propertyToY;
|
---|
2723 |
|
---|
2724 | QMap<const QtProperty *, QtProperty *> m_xToProperty;
|
---|
2725 | QMap<const QtProperty *, QtProperty *> m_yToProperty;
|
---|
2726 | };
|
---|
2727 |
|
---|
2728 | void QtPointFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value)
|
---|
2729 | {
|
---|
2730 | if (QtProperty *prop = m_xToProperty.value(property, 0)) {
|
---|
2731 | QPointF p = m_values[prop].val;
|
---|
2732 | p.setX(value);
|
---|
2733 | q_ptr->setValue(prop, p);
|
---|
2734 | } else if (QtProperty *prop = m_yToProperty.value(property, 0)) {
|
---|
2735 | QPointF p = m_values[prop].val;
|
---|
2736 | p.setY(value);
|
---|
2737 | q_ptr->setValue(prop, p);
|
---|
2738 | }
|
---|
2739 | }
|
---|
2740 |
|
---|
2741 | void QtPointFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
2742 | {
|
---|
2743 | if (QtProperty *pointProp = m_xToProperty.value(property, 0)) {
|
---|
2744 | m_propertyToX[pointProp] = 0;
|
---|
2745 | m_xToProperty.remove(property);
|
---|
2746 | } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) {
|
---|
2747 | m_propertyToY[pointProp] = 0;
|
---|
2748 | m_yToProperty.remove(property);
|
---|
2749 | }
|
---|
2750 | }
|
---|
2751 |
|
---|
2752 | /*! \class QtPointFPropertyManager
|
---|
2753 | \internal
|
---|
2754 | \inmodule QtDesigner
|
---|
2755 | \since 4.4
|
---|
2756 |
|
---|
2757 | \brief The QtPointFPropertyManager provides and manages QPointF properties.
|
---|
2758 |
|
---|
2759 | A point property has nested \e x and \e y subproperties. The
|
---|
2760 | top-level property's value can be retrieved using the value()
|
---|
2761 | function, and set using the setValue() slot.
|
---|
2762 |
|
---|
2763 | The subproperties are created by a QtDoublePropertyManager object. This
|
---|
2764 | manager can be retrieved using the subDoublePropertyManager() function. In
|
---|
2765 | order to provide editing widgets for the subproperties in a
|
---|
2766 | property browser widget, this manager must be associated with an
|
---|
2767 | editor factory.
|
---|
2768 |
|
---|
2769 | In addition, QtPointFPropertyManager provides the valueChanged() signal which
|
---|
2770 | is emitted whenever a property created by this manager changes.
|
---|
2771 |
|
---|
2772 | \sa QtAbstractPropertyManager, QtDoublePropertyManager, QtPointPropertyManager
|
---|
2773 | */
|
---|
2774 |
|
---|
2775 | /*!
|
---|
2776 | \fn void QtPointFPropertyManager::valueChanged(QtProperty *property, const QPointF &value)
|
---|
2777 |
|
---|
2778 | This signal is emitted whenever a property created by this manager
|
---|
2779 | changes its value, passing a pointer to the \a property and the
|
---|
2780 | new \a value as parameters.
|
---|
2781 |
|
---|
2782 | \sa setValue()
|
---|
2783 | */
|
---|
2784 |
|
---|
2785 | /*!
|
---|
2786 | \fn void QtPointFPropertyManager::decimalsChanged(QtProperty *property, int prec)
|
---|
2787 |
|
---|
2788 | This signal is emitted whenever a property created by this manager
|
---|
2789 | changes its precision of value, passing a pointer to the
|
---|
2790 | \a property and the new \a prec value
|
---|
2791 |
|
---|
2792 | \sa setDecimals()
|
---|
2793 | */
|
---|
2794 |
|
---|
2795 | /*!
|
---|
2796 | Creates a manager with the given \a parent.
|
---|
2797 | */
|
---|
2798 | QtPointFPropertyManager::QtPointFPropertyManager(QObject *parent)
|
---|
2799 | : QtAbstractPropertyManager(parent), d_ptr(new QtPointFPropertyManagerPrivate)
|
---|
2800 | {
|
---|
2801 | d_ptr->q_ptr = this;
|
---|
2802 |
|
---|
2803 | d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this);
|
---|
2804 | connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)),
|
---|
2805 | this, SLOT(slotDoubleChanged(QtProperty*,double)));
|
---|
2806 | connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
2807 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
2808 | }
|
---|
2809 |
|
---|
2810 | /*!
|
---|
2811 | Destroys this manager, and all the properties it has created.
|
---|
2812 | */
|
---|
2813 | QtPointFPropertyManager::~QtPointFPropertyManager()
|
---|
2814 | {
|
---|
2815 | clear();
|
---|
2816 | }
|
---|
2817 |
|
---|
2818 | /*!
|
---|
2819 | Returns the manager that creates the nested \e x and \e y
|
---|
2820 | subproperties.
|
---|
2821 |
|
---|
2822 | In order to provide editing widgets for the subproperties in a
|
---|
2823 | property browser widget, this manager must be associated with an
|
---|
2824 | editor factory.
|
---|
2825 |
|
---|
2826 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
2827 | */
|
---|
2828 | QtDoublePropertyManager *QtPointFPropertyManager::subDoublePropertyManager() const
|
---|
2829 | {
|
---|
2830 | return d_ptr->m_doublePropertyManager;
|
---|
2831 | }
|
---|
2832 |
|
---|
2833 | /*!
|
---|
2834 | Returns the given \a property's value.
|
---|
2835 |
|
---|
2836 | If the given \a property is not managed by this manager, this
|
---|
2837 | function returns a point with coordinates (0, 0).
|
---|
2838 |
|
---|
2839 | \sa setValue()
|
---|
2840 | */
|
---|
2841 | QPointF QtPointFPropertyManager::value(const QtProperty *property) const
|
---|
2842 | {
|
---|
2843 | return getValue<QPointF>(d_ptr->m_values, property);
|
---|
2844 | }
|
---|
2845 |
|
---|
2846 | /*!
|
---|
2847 | Returns the given \a property's precision, in decimals.
|
---|
2848 |
|
---|
2849 | \sa setDecimals()
|
---|
2850 | */
|
---|
2851 | int QtPointFPropertyManager::decimals(const QtProperty *property) const
|
---|
2852 | {
|
---|
2853 | return getData<int>(d_ptr->m_values, &QtPointFPropertyManagerPrivate::Data::decimals, property, 0);
|
---|
2854 | }
|
---|
2855 |
|
---|
2856 | /*!
|
---|
2857 | \reimp
|
---|
2858 | */
|
---|
2859 | QString QtPointFPropertyManager::valueText(const QtProperty *property) const
|
---|
2860 | {
|
---|
2861 | const QtPointFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
2862 | if (it == d_ptr->m_values.constEnd())
|
---|
2863 | return QString();
|
---|
2864 | const QPointF v = it.value().val;
|
---|
2865 | const int dec = it.value().decimals;
|
---|
2866 | return QString(tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec))
|
---|
2867 | .arg(QString::number(v.y(), 'f', dec)));
|
---|
2868 | }
|
---|
2869 |
|
---|
2870 | /*!
|
---|
2871 | \fn void QtPointFPropertyManager::setValue(QtProperty *property, const QPointF &value)
|
---|
2872 |
|
---|
2873 | Sets the value of the given \a property to \a value. Nested
|
---|
2874 | properties are updated automatically.
|
---|
2875 |
|
---|
2876 | \sa value(), valueChanged()
|
---|
2877 | */
|
---|
2878 | void QtPointFPropertyManager::setValue(QtProperty *property, const QPointF &val)
|
---|
2879 | {
|
---|
2880 | const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
2881 | if (it == d_ptr->m_values.end())
|
---|
2882 | return;
|
---|
2883 |
|
---|
2884 | if (it.value().val == val)
|
---|
2885 | return;
|
---|
2886 |
|
---|
2887 | it.value().val = val;
|
---|
2888 | d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], val.x());
|
---|
2889 | d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], val.y());
|
---|
2890 |
|
---|
2891 | emit propertyChanged(property);
|
---|
2892 | emit valueChanged(property, val);
|
---|
2893 | }
|
---|
2894 |
|
---|
2895 | /*!
|
---|
2896 | \fn void QtPointFPropertyManager::setDecimals(QtProperty *property, int prec)
|
---|
2897 |
|
---|
2898 | Sets the precision of the given \a property to \a prec.
|
---|
2899 |
|
---|
2900 | The valid decimal range is 0-13. The default is 2.
|
---|
2901 |
|
---|
2902 | \sa decimals()
|
---|
2903 | */
|
---|
2904 | void QtPointFPropertyManager::setDecimals(QtProperty *property, int prec)
|
---|
2905 | {
|
---|
2906 | const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
2907 | if (it == d_ptr->m_values.end())
|
---|
2908 | return;
|
---|
2909 |
|
---|
2910 | QtPointFPropertyManagerPrivate::Data data = it.value();
|
---|
2911 |
|
---|
2912 | if (prec > 13)
|
---|
2913 | prec = 13;
|
---|
2914 | else if (prec < 0)
|
---|
2915 | prec = 0;
|
---|
2916 |
|
---|
2917 | if (data.decimals == prec)
|
---|
2918 | return;
|
---|
2919 |
|
---|
2920 | data.decimals = prec;
|
---|
2921 | d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], prec);
|
---|
2922 | d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], prec);
|
---|
2923 |
|
---|
2924 | it.value() = data;
|
---|
2925 |
|
---|
2926 | emit decimalsChanged(property, data.decimals);
|
---|
2927 | }
|
---|
2928 |
|
---|
2929 | /*!
|
---|
2930 | \reimp
|
---|
2931 | */
|
---|
2932 | void QtPointFPropertyManager::initializeProperty(QtProperty *property)
|
---|
2933 | {
|
---|
2934 | d_ptr->m_values[property] = QtPointFPropertyManagerPrivate::Data();
|
---|
2935 |
|
---|
2936 | QtProperty *xProp = d_ptr->m_doublePropertyManager->addProperty();
|
---|
2937 | xProp->setPropertyName(tr("X"));
|
---|
2938 | d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property));
|
---|
2939 | d_ptr->m_doublePropertyManager->setValue(xProp, 0);
|
---|
2940 | d_ptr->m_propertyToX[property] = xProp;
|
---|
2941 | d_ptr->m_xToProperty[xProp] = property;
|
---|
2942 | property->addSubProperty(xProp);
|
---|
2943 |
|
---|
2944 | QtProperty *yProp = d_ptr->m_doublePropertyManager->addProperty();
|
---|
2945 | yProp->setPropertyName(tr("Y"));
|
---|
2946 | d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property));
|
---|
2947 | d_ptr->m_doublePropertyManager->setValue(yProp, 0);
|
---|
2948 | d_ptr->m_propertyToY[property] = yProp;
|
---|
2949 | d_ptr->m_yToProperty[yProp] = property;
|
---|
2950 | property->addSubProperty(yProp);
|
---|
2951 | }
|
---|
2952 |
|
---|
2953 | /*!
|
---|
2954 | \reimp
|
---|
2955 | */
|
---|
2956 | void QtPointFPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
2957 | {
|
---|
2958 | QtProperty *xProp = d_ptr->m_propertyToX[property];
|
---|
2959 | if (xProp) {
|
---|
2960 | d_ptr->m_xToProperty.remove(xProp);
|
---|
2961 | delete xProp;
|
---|
2962 | }
|
---|
2963 | d_ptr->m_propertyToX.remove(property);
|
---|
2964 |
|
---|
2965 | QtProperty *yProp = d_ptr->m_propertyToY[property];
|
---|
2966 | if (yProp) {
|
---|
2967 | d_ptr->m_yToProperty.remove(yProp);
|
---|
2968 | delete yProp;
|
---|
2969 | }
|
---|
2970 | d_ptr->m_propertyToY.remove(property);
|
---|
2971 |
|
---|
2972 | d_ptr->m_values.remove(property);
|
---|
2973 | }
|
---|
2974 |
|
---|
2975 | // QtSizePropertyManager
|
---|
2976 |
|
---|
2977 | class QtSizePropertyManagerPrivate
|
---|
2978 | {
|
---|
2979 | QtSizePropertyManager *q_ptr;
|
---|
2980 | Q_DECLARE_PUBLIC(QtSizePropertyManager)
|
---|
2981 | public:
|
---|
2982 |
|
---|
2983 | void slotIntChanged(QtProperty *property, int value);
|
---|
2984 | void slotPropertyDestroyed(QtProperty *property);
|
---|
2985 | void setValue(QtProperty *property, const QSize &val);
|
---|
2986 | void setRange(QtProperty *property,
|
---|
2987 | const QSize &minVal, const QSize &maxVal, const QSize &val);
|
---|
2988 |
|
---|
2989 | struct Data
|
---|
2990 | {
|
---|
2991 | Data() : val(QSize(0, 0)), minVal(QSize(0, 0)), maxVal(QSize(INT_MAX, INT_MAX)) {}
|
---|
2992 | QSize val;
|
---|
2993 | QSize minVal;
|
---|
2994 | QSize maxVal;
|
---|
2995 | QSize minimumValue() const { return minVal; }
|
---|
2996 | QSize maximumValue() const { return maxVal; }
|
---|
2997 | void setMinimumValue(const QSize &newMinVal) { setSizeMinimumData(this, newMinVal); }
|
---|
2998 | void setMaximumValue(const QSize &newMaxVal) { setSizeMaximumData(this, newMaxVal); }
|
---|
2999 | };
|
---|
3000 |
|
---|
3001 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
3002 | PropertyValueMap m_values;
|
---|
3003 |
|
---|
3004 | QtIntPropertyManager *m_intPropertyManager;
|
---|
3005 |
|
---|
3006 | QMap<const QtProperty *, QtProperty *> m_propertyToW;
|
---|
3007 | QMap<const QtProperty *, QtProperty *> m_propertyToH;
|
---|
3008 |
|
---|
3009 | QMap<const QtProperty *, QtProperty *> m_wToProperty;
|
---|
3010 | QMap<const QtProperty *, QtProperty *> m_hToProperty;
|
---|
3011 | };
|
---|
3012 |
|
---|
3013 | void QtSizePropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
|
---|
3014 | {
|
---|
3015 | if (QtProperty *prop = m_wToProperty.value(property, 0)) {
|
---|
3016 | QSize s = m_values[prop].val;
|
---|
3017 | s.setWidth(value);
|
---|
3018 | q_ptr->setValue(prop, s);
|
---|
3019 | } else if (QtProperty *prop = m_hToProperty.value(property, 0)) {
|
---|
3020 | QSize s = m_values[prop].val;
|
---|
3021 | s.setHeight(value);
|
---|
3022 | q_ptr->setValue(prop, s);
|
---|
3023 | }
|
---|
3024 | }
|
---|
3025 |
|
---|
3026 | void QtSizePropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
3027 | {
|
---|
3028 | if (QtProperty *pointProp = m_wToProperty.value(property, 0)) {
|
---|
3029 | m_propertyToW[pointProp] = 0;
|
---|
3030 | m_wToProperty.remove(property);
|
---|
3031 | } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) {
|
---|
3032 | m_propertyToH[pointProp] = 0;
|
---|
3033 | m_hToProperty.remove(property);
|
---|
3034 | }
|
---|
3035 | }
|
---|
3036 |
|
---|
3037 | void QtSizePropertyManagerPrivate::setValue(QtProperty *property, const QSize &val)
|
---|
3038 | {
|
---|
3039 | m_intPropertyManager->setValue(m_propertyToW.value(property), val.width());
|
---|
3040 | m_intPropertyManager->setValue(m_propertyToH.value(property), val.height());
|
---|
3041 | }
|
---|
3042 |
|
---|
3043 | void QtSizePropertyManagerPrivate::setRange(QtProperty *property,
|
---|
3044 | const QSize &minVal, const QSize &maxVal, const QSize &val)
|
---|
3045 | {
|
---|
3046 | QtProperty *wProperty = m_propertyToW.value(property);
|
---|
3047 | QtProperty *hProperty = m_propertyToH.value(property);
|
---|
3048 | m_intPropertyManager->setRange(wProperty, minVal.width(), maxVal.width());
|
---|
3049 | m_intPropertyManager->setValue(wProperty, val.width());
|
---|
3050 | m_intPropertyManager->setRange(hProperty, minVal.height(), maxVal.height());
|
---|
3051 | m_intPropertyManager->setValue(hProperty, val.height());
|
---|
3052 | }
|
---|
3053 |
|
---|
3054 | /*!
|
---|
3055 | \class QtSizePropertyManager
|
---|
3056 | \internal
|
---|
3057 | \inmodule QtDesigner
|
---|
3058 | \since 4.4
|
---|
3059 |
|
---|
3060 | \brief The QtSizePropertyManager provides and manages QSize properties.
|
---|
3061 |
|
---|
3062 | A size property has nested \e width and \e height
|
---|
3063 | subproperties. The top-level property's value can be retrieved
|
---|
3064 | using the value() function, and set using the setValue() slot.
|
---|
3065 |
|
---|
3066 | The subproperties are created by a QtIntPropertyManager object. This
|
---|
3067 | manager can be retrieved using the subIntPropertyManager() function. In
|
---|
3068 | order to provide editing widgets for the subproperties in a
|
---|
3069 | property browser widget, this manager must be associated with an
|
---|
3070 | editor factory.
|
---|
3071 |
|
---|
3072 | A size property also has a range of valid values defined by a
|
---|
3073 | minimum size and a maximum size. These sizes can be retrieved
|
---|
3074 | using the minimum() and the maximum() functions, and set using the
|
---|
3075 | setMinimum() and setMaximum() slots. Alternatively, the range can
|
---|
3076 | be defined in one go using the setRange() slot.
|
---|
3077 |
|
---|
3078 | In addition, QtSizePropertyManager provides the valueChanged() signal
|
---|
3079 | which is emitted whenever a property created by this manager
|
---|
3080 | changes, and the rangeChanged() signal which is emitted whenever
|
---|
3081 | such a property changes its range of valid sizes.
|
---|
3082 |
|
---|
3083 | \sa QtAbstractPropertyManager, QtIntPropertyManager, QtSizeFPropertyManager
|
---|
3084 | */
|
---|
3085 |
|
---|
3086 | /*!
|
---|
3087 | \fn void QtSizePropertyManager::valueChanged(QtProperty *property, const QSize &value)
|
---|
3088 |
|
---|
3089 | This signal is emitted whenever a property created by this manager
|
---|
3090 | changes its value, passing a pointer to the \a property and the new
|
---|
3091 | \a value as parameters.
|
---|
3092 |
|
---|
3093 | \sa setValue()
|
---|
3094 | */
|
---|
3095 |
|
---|
3096 | /*!
|
---|
3097 | \fn void QtSizePropertyManager::rangeChanged(QtProperty *property, const QSize &minimum, const QSize &maximum)
|
---|
3098 |
|
---|
3099 | This signal is emitted whenever a property created by this manager
|
---|
3100 | changes its range of valid sizes, passing a pointer to the \a
|
---|
3101 | property and the new \a minimum and \a maximum sizes.
|
---|
3102 |
|
---|
3103 | \sa setRange()
|
---|
3104 | */
|
---|
3105 |
|
---|
3106 | /*!
|
---|
3107 | Creates a manager with the given \a parent.
|
---|
3108 | */
|
---|
3109 | QtSizePropertyManager::QtSizePropertyManager(QObject *parent)
|
---|
3110 | : QtAbstractPropertyManager(parent), d_ptr(new QtSizePropertyManagerPrivate)
|
---|
3111 | {
|
---|
3112 | d_ptr->q_ptr = this;
|
---|
3113 |
|
---|
3114 | d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
|
---|
3115 | connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
|
---|
3116 | this, SLOT(slotIntChanged(QtProperty*,int)));
|
---|
3117 | connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
3118 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
3119 | }
|
---|
3120 |
|
---|
3121 | /*!
|
---|
3122 | Destroys this manager, and all the properties it has created.
|
---|
3123 | */
|
---|
3124 | QtSizePropertyManager::~QtSizePropertyManager()
|
---|
3125 | {
|
---|
3126 | clear();
|
---|
3127 | }
|
---|
3128 |
|
---|
3129 | /*!
|
---|
3130 | Returns the manager that creates the nested \e width and \e height
|
---|
3131 | subproperties.
|
---|
3132 |
|
---|
3133 | In order to provide editing widgets for the \e width and \e height
|
---|
3134 | properties in a property browser widget, this manager must be
|
---|
3135 | associated with an editor factory.
|
---|
3136 |
|
---|
3137 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
3138 | */
|
---|
3139 | QtIntPropertyManager *QtSizePropertyManager::subIntPropertyManager() const
|
---|
3140 | {
|
---|
3141 | return d_ptr->m_intPropertyManager;
|
---|
3142 | }
|
---|
3143 |
|
---|
3144 | /*!
|
---|
3145 | Returns the given \a property's value.
|
---|
3146 |
|
---|
3147 | If the given \a property is not managed by this manager, this
|
---|
3148 | function returns an invalid size
|
---|
3149 |
|
---|
3150 | \sa setValue()
|
---|
3151 | */
|
---|
3152 | QSize QtSizePropertyManager::value(const QtProperty *property) const
|
---|
3153 | {
|
---|
3154 | return getValue<QSize>(d_ptr->m_values, property);
|
---|
3155 | }
|
---|
3156 |
|
---|
3157 | /*!
|
---|
3158 | Returns the given \a property's minimum size value.
|
---|
3159 |
|
---|
3160 | \sa setMinimum(), maximum(), setRange()
|
---|
3161 | */
|
---|
3162 | QSize QtSizePropertyManager::minimum(const QtProperty *property) const
|
---|
3163 | {
|
---|
3164 | return getMinimum<QSize>(d_ptr->m_values, property);
|
---|
3165 | }
|
---|
3166 |
|
---|
3167 | /*!
|
---|
3168 | Returns the given \a property's maximum size value.
|
---|
3169 |
|
---|
3170 | \sa setMaximum(), minimum(), setRange()
|
---|
3171 | */
|
---|
3172 | QSize QtSizePropertyManager::maximum(const QtProperty *property) const
|
---|
3173 | {
|
---|
3174 | return getMaximum<QSize>(d_ptr->m_values, property);
|
---|
3175 | }
|
---|
3176 |
|
---|
3177 | /*!
|
---|
3178 | \reimp
|
---|
3179 | */
|
---|
3180 | QString QtSizePropertyManager::valueText(const QtProperty *property) const
|
---|
3181 | {
|
---|
3182 | const QtSizePropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
3183 | if (it == d_ptr->m_values.constEnd())
|
---|
3184 | return QString();
|
---|
3185 | const QSize v = it.value().val;
|
---|
3186 | return QString(tr("%1 x %2").arg(QString::number(v.width()))
|
---|
3187 | .arg(QString::number(v.height())));
|
---|
3188 | }
|
---|
3189 |
|
---|
3190 | /*!
|
---|
3191 | \fn void QtSizePropertyManager::setValue(QtProperty *property, const QSize &value)
|
---|
3192 |
|
---|
3193 | Sets the value of the given \a property to \a value.
|
---|
3194 |
|
---|
3195 | If the specified \a value is not valid according to the given \a
|
---|
3196 | property's size range, the \a value is adjusted to the nearest
|
---|
3197 | valid value within the size range.
|
---|
3198 |
|
---|
3199 | \sa value(), setRange(), valueChanged()
|
---|
3200 | */
|
---|
3201 | void QtSizePropertyManager::setValue(QtProperty *property, const QSize &val)
|
---|
3202 | {
|
---|
3203 | setValueInRange<const QSize &, QtSizePropertyManagerPrivate, QtSizePropertyManager, const QSize>(this, d_ptr.data(),
|
---|
3204 | &QtSizePropertyManager::propertyChanged,
|
---|
3205 | &QtSizePropertyManager::valueChanged,
|
---|
3206 | property, val, &QtSizePropertyManagerPrivate::setValue);
|
---|
3207 | }
|
---|
3208 |
|
---|
3209 | /*!
|
---|
3210 | Sets the minimum size value for the given \a property to \a minVal.
|
---|
3211 |
|
---|
3212 | When setting the minimum size value, the maximum and current
|
---|
3213 | values are adjusted if necessary (ensuring that the size range
|
---|
3214 | remains valid and that the current value is within the range).
|
---|
3215 |
|
---|
3216 | \sa minimum(), setRange(), rangeChanged()
|
---|
3217 | */
|
---|
3218 | void QtSizePropertyManager::setMinimum(QtProperty *property, const QSize &minVal)
|
---|
3219 | {
|
---|
3220 | setBorderValue<const QSize &, QtSizePropertyManagerPrivate, QtSizePropertyManager, QSize, QtSizePropertyManagerPrivate::Data>(this, d_ptr.data(),
|
---|
3221 | &QtSizePropertyManager::propertyChanged,
|
---|
3222 | &QtSizePropertyManager::valueChanged,
|
---|
3223 | &QtSizePropertyManager::rangeChanged,
|
---|
3224 | property,
|
---|
3225 | &QtSizePropertyManagerPrivate::Data::minimumValue,
|
---|
3226 | &QtSizePropertyManagerPrivate::Data::setMinimumValue,
|
---|
3227 | minVal, &QtSizePropertyManagerPrivate::setRange);
|
---|
3228 | }
|
---|
3229 |
|
---|
3230 | /*!
|
---|
3231 | Sets the maximum size value for the given \a property to \a maxVal.
|
---|
3232 |
|
---|
3233 | When setting the maximum size value, the minimum and current
|
---|
3234 | values are adjusted if necessary (ensuring that the size range
|
---|
3235 | remains valid and that the current value is within the range).
|
---|
3236 |
|
---|
3237 | \sa maximum(), setRange(), rangeChanged()
|
---|
3238 | */
|
---|
3239 | void QtSizePropertyManager::setMaximum(QtProperty *property, const QSize &maxVal)
|
---|
3240 | {
|
---|
3241 | setBorderValue<const QSize &, QtSizePropertyManagerPrivate, QtSizePropertyManager, QSize, QtSizePropertyManagerPrivate::Data>(this, d_ptr.data(),
|
---|
3242 | &QtSizePropertyManager::propertyChanged,
|
---|
3243 | &QtSizePropertyManager::valueChanged,
|
---|
3244 | &QtSizePropertyManager::rangeChanged,
|
---|
3245 | property,
|
---|
3246 | &QtSizePropertyManagerPrivate::Data::maximumValue,
|
---|
3247 | &QtSizePropertyManagerPrivate::Data::setMaximumValue,
|
---|
3248 | maxVal, &QtSizePropertyManagerPrivate::setRange);
|
---|
3249 | }
|
---|
3250 |
|
---|
3251 | /*!
|
---|
3252 | \fn void QtSizePropertyManager::setRange(QtProperty *property, const QSize &minimum, const QSize &maximum)
|
---|
3253 |
|
---|
3254 | Sets the range of valid values.
|
---|
3255 |
|
---|
3256 | This is a convenience function defining the range of valid values
|
---|
3257 | in one go; setting the \a minimum and \a maximum values for the
|
---|
3258 | given \a property with a single function call.
|
---|
3259 |
|
---|
3260 | When setting a new range, the current value is adjusted if
|
---|
3261 | necessary (ensuring that the value remains within the range).
|
---|
3262 |
|
---|
3263 | \sa setMinimum(), setMaximum(), rangeChanged()
|
---|
3264 | */
|
---|
3265 | void QtSizePropertyManager::setRange(QtProperty *property, const QSize &minVal, const QSize &maxVal)
|
---|
3266 | {
|
---|
3267 | setBorderValues<const QSize &, QtSizePropertyManagerPrivate, QtSizePropertyManager, QSize>(this, d_ptr.data(),
|
---|
3268 | &QtSizePropertyManager::propertyChanged,
|
---|
3269 | &QtSizePropertyManager::valueChanged,
|
---|
3270 | &QtSizePropertyManager::rangeChanged,
|
---|
3271 | property, minVal, maxVal, &QtSizePropertyManagerPrivate::setRange);
|
---|
3272 | }
|
---|
3273 |
|
---|
3274 | /*!
|
---|
3275 | \reimp
|
---|
3276 | */
|
---|
3277 | void QtSizePropertyManager::initializeProperty(QtProperty *property)
|
---|
3278 | {
|
---|
3279 | d_ptr->m_values[property] = QtSizePropertyManagerPrivate::Data();
|
---|
3280 |
|
---|
3281 | QtProperty *wProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
3282 | wProp->setPropertyName(tr("Width"));
|
---|
3283 | d_ptr->m_intPropertyManager->setValue(wProp, 0);
|
---|
3284 | d_ptr->m_intPropertyManager->setMinimum(wProp, 0);
|
---|
3285 | d_ptr->m_propertyToW[property] = wProp;
|
---|
3286 | d_ptr->m_wToProperty[wProp] = property;
|
---|
3287 | property->addSubProperty(wProp);
|
---|
3288 |
|
---|
3289 | QtProperty *hProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
3290 | hProp->setPropertyName(tr("Height"));
|
---|
3291 | d_ptr->m_intPropertyManager->setValue(hProp, 0);
|
---|
3292 | d_ptr->m_intPropertyManager->setMinimum(hProp, 0);
|
---|
3293 | d_ptr->m_propertyToH[property] = hProp;
|
---|
3294 | d_ptr->m_hToProperty[hProp] = property;
|
---|
3295 | property->addSubProperty(hProp);
|
---|
3296 | }
|
---|
3297 |
|
---|
3298 | /*!
|
---|
3299 | \reimp
|
---|
3300 | */
|
---|
3301 | void QtSizePropertyManager::uninitializeProperty(QtProperty *property)
|
---|
3302 | {
|
---|
3303 | QtProperty *wProp = d_ptr->m_propertyToW[property];
|
---|
3304 | if (wProp) {
|
---|
3305 | d_ptr->m_wToProperty.remove(wProp);
|
---|
3306 | delete wProp;
|
---|
3307 | }
|
---|
3308 | d_ptr->m_propertyToW.remove(property);
|
---|
3309 |
|
---|
3310 | QtProperty *hProp = d_ptr->m_propertyToH[property];
|
---|
3311 | if (hProp) {
|
---|
3312 | d_ptr->m_hToProperty.remove(hProp);
|
---|
3313 | delete hProp;
|
---|
3314 | }
|
---|
3315 | d_ptr->m_propertyToH.remove(property);
|
---|
3316 |
|
---|
3317 | d_ptr->m_values.remove(property);
|
---|
3318 | }
|
---|
3319 |
|
---|
3320 | // QtSizeFPropertyManager
|
---|
3321 |
|
---|
3322 | class QtSizeFPropertyManagerPrivate
|
---|
3323 | {
|
---|
3324 | QtSizeFPropertyManager *q_ptr;
|
---|
3325 | Q_DECLARE_PUBLIC(QtSizeFPropertyManager)
|
---|
3326 | public:
|
---|
3327 |
|
---|
3328 | void slotDoubleChanged(QtProperty *property, double value);
|
---|
3329 | void slotPropertyDestroyed(QtProperty *property);
|
---|
3330 | void setValue(QtProperty *property, const QSizeF &val);
|
---|
3331 | void setRange(QtProperty *property,
|
---|
3332 | const QSizeF &minVal, const QSizeF &maxVal, const QSizeF &val);
|
---|
3333 |
|
---|
3334 | struct Data
|
---|
3335 | {
|
---|
3336 | Data() : val(QSizeF(0, 0)), minVal(QSizeF(0, 0)), maxVal(QSizeF(INT_MAX, INT_MAX)), decimals(2) {}
|
---|
3337 | QSizeF val;
|
---|
3338 | QSizeF minVal;
|
---|
3339 | QSizeF maxVal;
|
---|
3340 | int decimals;
|
---|
3341 | QSizeF minimumValue() const { return minVal; }
|
---|
3342 | QSizeF maximumValue() const { return maxVal; }
|
---|
3343 | void setMinimumValue(const QSizeF &newMinVal) { setSizeMinimumData(this, newMinVal); }
|
---|
3344 | void setMaximumValue(const QSizeF &newMaxVal) { setSizeMaximumData(this, newMaxVal); }
|
---|
3345 | };
|
---|
3346 |
|
---|
3347 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
3348 | PropertyValueMap m_values;
|
---|
3349 |
|
---|
3350 | QtDoublePropertyManager *m_doublePropertyManager;
|
---|
3351 |
|
---|
3352 | QMap<const QtProperty *, QtProperty *> m_propertyToW;
|
---|
3353 | QMap<const QtProperty *, QtProperty *> m_propertyToH;
|
---|
3354 |
|
---|
3355 | QMap<const QtProperty *, QtProperty *> m_wToProperty;
|
---|
3356 | QMap<const QtProperty *, QtProperty *> m_hToProperty;
|
---|
3357 | };
|
---|
3358 |
|
---|
3359 | void QtSizeFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value)
|
---|
3360 | {
|
---|
3361 | if (QtProperty *prop = m_wToProperty.value(property, 0)) {
|
---|
3362 | QSizeF s = m_values[prop].val;
|
---|
3363 | s.setWidth(value);
|
---|
3364 | q_ptr->setValue(prop, s);
|
---|
3365 | } else if (QtProperty *prop = m_hToProperty.value(property, 0)) {
|
---|
3366 | QSizeF s = m_values[prop].val;
|
---|
3367 | s.setHeight(value);
|
---|
3368 | q_ptr->setValue(prop, s);
|
---|
3369 | }
|
---|
3370 | }
|
---|
3371 |
|
---|
3372 | void QtSizeFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
3373 | {
|
---|
3374 | if (QtProperty *pointProp = m_wToProperty.value(property, 0)) {
|
---|
3375 | m_propertyToW[pointProp] = 0;
|
---|
3376 | m_wToProperty.remove(property);
|
---|
3377 | } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) {
|
---|
3378 | m_propertyToH[pointProp] = 0;
|
---|
3379 | m_hToProperty.remove(property);
|
---|
3380 | }
|
---|
3381 | }
|
---|
3382 |
|
---|
3383 | void QtSizeFPropertyManagerPrivate::setValue(QtProperty *property, const QSizeF &val)
|
---|
3384 | {
|
---|
3385 | m_doublePropertyManager->setValue(m_propertyToW.value(property), val.width());
|
---|
3386 | m_doublePropertyManager->setValue(m_propertyToH.value(property), val.height());
|
---|
3387 | }
|
---|
3388 |
|
---|
3389 | void QtSizeFPropertyManagerPrivate::setRange(QtProperty *property,
|
---|
3390 | const QSizeF &minVal, const QSizeF &maxVal, const QSizeF &val)
|
---|
3391 | {
|
---|
3392 | m_doublePropertyManager->setRange(m_propertyToW[property], minVal.width(), maxVal.width());
|
---|
3393 | m_doublePropertyManager->setValue(m_propertyToW[property], val.width());
|
---|
3394 | m_doublePropertyManager->setRange(m_propertyToH[property], minVal.height(), maxVal.height());
|
---|
3395 | m_doublePropertyManager->setValue(m_propertyToH[property], val.height());
|
---|
3396 | }
|
---|
3397 |
|
---|
3398 | /*!
|
---|
3399 | \class QtSizeFPropertyManager
|
---|
3400 | \internal
|
---|
3401 | \inmodule QtDesigner
|
---|
3402 | \since 4.4
|
---|
3403 |
|
---|
3404 | \brief The QtSizeFPropertyManager provides and manages QSizeF properties.
|
---|
3405 |
|
---|
3406 | A size property has nested \e width and \e height
|
---|
3407 | subproperties. The top-level property's value can be retrieved
|
---|
3408 | using the value() function, and set using the setValue() slot.
|
---|
3409 |
|
---|
3410 | The subproperties are created by a QtDoublePropertyManager object. This
|
---|
3411 | manager can be retrieved using the subDoublePropertyManager() function. In
|
---|
3412 | order to provide editing widgets for the subproperties in a
|
---|
3413 | property browser widget, this manager must be associated with an
|
---|
3414 | editor factory.
|
---|
3415 |
|
---|
3416 | A size property also has a range of valid values defined by a
|
---|
3417 | minimum size and a maximum size. These sizes can be retrieved
|
---|
3418 | using the minimum() and the maximum() functions, and set using the
|
---|
3419 | setMinimum() and setMaximum() slots. Alternatively, the range can
|
---|
3420 | be defined in one go using the setRange() slot.
|
---|
3421 |
|
---|
3422 | In addition, QtSizeFPropertyManager provides the valueChanged() signal
|
---|
3423 | which is emitted whenever a property created by this manager
|
---|
3424 | changes, and the rangeChanged() signal which is emitted whenever
|
---|
3425 | such a property changes its range of valid sizes.
|
---|
3426 |
|
---|
3427 | \sa QtAbstractPropertyManager, QtDoublePropertyManager, QtSizePropertyManager
|
---|
3428 | */
|
---|
3429 |
|
---|
3430 | /*!
|
---|
3431 | \fn void QtSizeFPropertyManager::valueChanged(QtProperty *property, const QSizeF &value)
|
---|
3432 |
|
---|
3433 | This signal is emitted whenever a property created by this manager
|
---|
3434 | changes its value, passing a pointer to the \a property and the new
|
---|
3435 | \a value as parameters.
|
---|
3436 |
|
---|
3437 | \sa setValue()
|
---|
3438 | */
|
---|
3439 |
|
---|
3440 | /*!
|
---|
3441 | \fn void QtSizeFPropertyManager::rangeChanged(QtProperty *property, const QSizeF &minimum, const QSizeF &maximum)
|
---|
3442 |
|
---|
3443 | This signal is emitted whenever a property created by this manager
|
---|
3444 | changes its range of valid sizes, passing a pointer to the \a
|
---|
3445 | property and the new \a minimum and \a maximum sizes.
|
---|
3446 |
|
---|
3447 | \sa setRange()
|
---|
3448 | */
|
---|
3449 |
|
---|
3450 | /*!
|
---|
3451 | \fn void QtSizeFPropertyManager::decimalsChanged(QtProperty *property, int prec)
|
---|
3452 |
|
---|
3453 | This signal is emitted whenever a property created by this manager
|
---|
3454 | changes its precision of value, passing a pointer to the
|
---|
3455 | \a property and the new \a prec value
|
---|
3456 |
|
---|
3457 | \sa setDecimals()
|
---|
3458 | */
|
---|
3459 |
|
---|
3460 | /*!
|
---|
3461 | Creates a manager with the given \a parent.
|
---|
3462 | */
|
---|
3463 | QtSizeFPropertyManager::QtSizeFPropertyManager(QObject *parent)
|
---|
3464 | : QtAbstractPropertyManager(parent), d_ptr(new QtSizeFPropertyManagerPrivate)
|
---|
3465 | {
|
---|
3466 | d_ptr->q_ptr = this;
|
---|
3467 |
|
---|
3468 | d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this);
|
---|
3469 | connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)),
|
---|
3470 | this, SLOT(slotDoubleChanged(QtProperty*,double)));
|
---|
3471 | connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
3472 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
3473 | }
|
---|
3474 |
|
---|
3475 | /*!
|
---|
3476 | Destroys this manager, and all the properties it has created.
|
---|
3477 | */
|
---|
3478 | QtSizeFPropertyManager::~QtSizeFPropertyManager()
|
---|
3479 | {
|
---|
3480 | clear();
|
---|
3481 | }
|
---|
3482 |
|
---|
3483 | /*!
|
---|
3484 | Returns the manager that creates the nested \e width and \e height
|
---|
3485 | subproperties.
|
---|
3486 |
|
---|
3487 | In order to provide editing widgets for the \e width and \e height
|
---|
3488 | properties in a property browser widget, this manager must be
|
---|
3489 | associated with an editor factory.
|
---|
3490 |
|
---|
3491 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
3492 | */
|
---|
3493 | QtDoublePropertyManager *QtSizeFPropertyManager::subDoublePropertyManager() const
|
---|
3494 | {
|
---|
3495 | return d_ptr->m_doublePropertyManager;
|
---|
3496 | }
|
---|
3497 |
|
---|
3498 | /*!
|
---|
3499 | Returns the given \a property's value.
|
---|
3500 |
|
---|
3501 | If the given \a property is not managed by this manager, this
|
---|
3502 | function returns an invalid size
|
---|
3503 |
|
---|
3504 | \sa setValue()
|
---|
3505 | */
|
---|
3506 | QSizeF QtSizeFPropertyManager::value(const QtProperty *property) const
|
---|
3507 | {
|
---|
3508 | return getValue<QSizeF>(d_ptr->m_values, property);
|
---|
3509 | }
|
---|
3510 |
|
---|
3511 | /*!
|
---|
3512 | Returns the given \a property's precision, in decimals.
|
---|
3513 |
|
---|
3514 | \sa setDecimals()
|
---|
3515 | */
|
---|
3516 | int QtSizeFPropertyManager::decimals(const QtProperty *property) const
|
---|
3517 | {
|
---|
3518 | return getData<int>(d_ptr->m_values, &QtSizeFPropertyManagerPrivate::Data::decimals, property, 0);
|
---|
3519 | }
|
---|
3520 |
|
---|
3521 | /*!
|
---|
3522 | Returns the given \a property's minimum size value.
|
---|
3523 |
|
---|
3524 | \sa setMinimum(), maximum(), setRange()
|
---|
3525 | */
|
---|
3526 | QSizeF QtSizeFPropertyManager::minimum(const QtProperty *property) const
|
---|
3527 | {
|
---|
3528 | return getMinimum<QSizeF>(d_ptr->m_values, property);
|
---|
3529 | }
|
---|
3530 |
|
---|
3531 | /*!
|
---|
3532 | Returns the given \a property's maximum size value.
|
---|
3533 |
|
---|
3534 | \sa setMaximum(), minimum(), setRange()
|
---|
3535 | */
|
---|
3536 | QSizeF QtSizeFPropertyManager::maximum(const QtProperty *property) const
|
---|
3537 | {
|
---|
3538 | return getMaximum<QSizeF>(d_ptr->m_values, property);
|
---|
3539 | }
|
---|
3540 |
|
---|
3541 | /*!
|
---|
3542 | \reimp
|
---|
3543 | */
|
---|
3544 | QString QtSizeFPropertyManager::valueText(const QtProperty *property) const
|
---|
3545 | {
|
---|
3546 | const QtSizeFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
3547 | if (it == d_ptr->m_values.constEnd())
|
---|
3548 | return QString();
|
---|
3549 | const QSizeF v = it.value().val;
|
---|
3550 | const int dec = it.value().decimals;
|
---|
3551 | return QString(tr("%1 x %2").arg(QString::number(v.width(), 'f', dec))
|
---|
3552 | .arg(QString::number(v.height(), 'f', dec)));
|
---|
3553 | }
|
---|
3554 |
|
---|
3555 | /*!
|
---|
3556 | \fn void QtSizeFPropertyManager::setValue(QtProperty *property, const QSizeF &value)
|
---|
3557 |
|
---|
3558 | Sets the value of the given \a property to \a value.
|
---|
3559 |
|
---|
3560 | If the specified \a value is not valid according to the given \a
|
---|
3561 | property's size range, the \a value is adjusted to the nearest
|
---|
3562 | valid value within the size range.
|
---|
3563 |
|
---|
3564 | \sa value(), setRange(), valueChanged()
|
---|
3565 | */
|
---|
3566 | void QtSizeFPropertyManager::setValue(QtProperty *property, const QSizeF &val)
|
---|
3567 | {
|
---|
3568 | setValueInRange<const QSizeF &, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF>(this, d_ptr.data(),
|
---|
3569 | &QtSizeFPropertyManager::propertyChanged,
|
---|
3570 | &QtSizeFPropertyManager::valueChanged,
|
---|
3571 | property, val, &QtSizeFPropertyManagerPrivate::setValue);
|
---|
3572 | }
|
---|
3573 |
|
---|
3574 | /*!
|
---|
3575 | \fn void QtSizeFPropertyManager::setDecimals(QtProperty *property, int prec)
|
---|
3576 |
|
---|
3577 | Sets the precision of the given \a property to \a prec.
|
---|
3578 |
|
---|
3579 | The valid decimal range is 0-13. The default is 2.
|
---|
3580 |
|
---|
3581 | \sa decimals()
|
---|
3582 | */
|
---|
3583 | void QtSizeFPropertyManager::setDecimals(QtProperty *property, int prec)
|
---|
3584 | {
|
---|
3585 | const QtSizeFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
3586 | if (it == d_ptr->m_values.end())
|
---|
3587 | return;
|
---|
3588 |
|
---|
3589 | QtSizeFPropertyManagerPrivate::Data data = it.value();
|
---|
3590 |
|
---|
3591 | if (prec > 13)
|
---|
3592 | prec = 13;
|
---|
3593 | else if (prec < 0)
|
---|
3594 | prec = 0;
|
---|
3595 |
|
---|
3596 | if (data.decimals == prec)
|
---|
3597 | return;
|
---|
3598 |
|
---|
3599 | data.decimals = prec;
|
---|
3600 | d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], prec);
|
---|
3601 | d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], prec);
|
---|
3602 |
|
---|
3603 | it.value() = data;
|
---|
3604 |
|
---|
3605 | emit decimalsChanged(property, data.decimals);
|
---|
3606 | }
|
---|
3607 |
|
---|
3608 | /*!
|
---|
3609 | Sets the minimum size value for the given \a property to \a minVal.
|
---|
3610 |
|
---|
3611 | When setting the minimum size value, the maximum and current
|
---|
3612 | values are adjusted if necessary (ensuring that the size range
|
---|
3613 | remains valid and that the current value is within the range).
|
---|
3614 |
|
---|
3615 | \sa minimum(), setRange(), rangeChanged()
|
---|
3616 | */
|
---|
3617 | void QtSizeFPropertyManager::setMinimum(QtProperty *property, const QSizeF &minVal)
|
---|
3618 | {
|
---|
3619 | setBorderValue<const QSizeF &, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF, QtSizeFPropertyManagerPrivate::Data>(this, d_ptr.data(),
|
---|
3620 | &QtSizeFPropertyManager::propertyChanged,
|
---|
3621 | &QtSizeFPropertyManager::valueChanged,
|
---|
3622 | &QtSizeFPropertyManager::rangeChanged,
|
---|
3623 | property,
|
---|
3624 | &QtSizeFPropertyManagerPrivate::Data::minimumValue,
|
---|
3625 | &QtSizeFPropertyManagerPrivate::Data::setMinimumValue,
|
---|
3626 | minVal, &QtSizeFPropertyManagerPrivate::setRange);
|
---|
3627 | }
|
---|
3628 |
|
---|
3629 | /*!
|
---|
3630 | Sets the maximum size value for the given \a property to \a maxVal.
|
---|
3631 |
|
---|
3632 | When setting the maximum size value, the minimum and current
|
---|
3633 | values are adjusted if necessary (ensuring that the size range
|
---|
3634 | remains valid and that the current value is within the range).
|
---|
3635 |
|
---|
3636 | \sa maximum(), setRange(), rangeChanged()
|
---|
3637 | */
|
---|
3638 | void QtSizeFPropertyManager::setMaximum(QtProperty *property, const QSizeF &maxVal)
|
---|
3639 | {
|
---|
3640 | setBorderValue<const QSizeF &, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF, QtSizeFPropertyManagerPrivate::Data>(this, d_ptr.data(),
|
---|
3641 | &QtSizeFPropertyManager::propertyChanged,
|
---|
3642 | &QtSizeFPropertyManager::valueChanged,
|
---|
3643 | &QtSizeFPropertyManager::rangeChanged,
|
---|
3644 | property,
|
---|
3645 | &QtSizeFPropertyManagerPrivate::Data::maximumValue,
|
---|
3646 | &QtSizeFPropertyManagerPrivate::Data::setMaximumValue,
|
---|
3647 | maxVal, &QtSizeFPropertyManagerPrivate::setRange);
|
---|
3648 | }
|
---|
3649 |
|
---|
3650 | /*!
|
---|
3651 | \fn void QtSizeFPropertyManager::setRange(QtProperty *property, const QSizeF &minimum, const QSizeF &maximum)
|
---|
3652 |
|
---|
3653 | Sets the range of valid values.
|
---|
3654 |
|
---|
3655 | This is a convenience function defining the range of valid values
|
---|
3656 | in one go; setting the \a minimum and \a maximum values for the
|
---|
3657 | given \a property with a single function call.
|
---|
3658 |
|
---|
3659 | When setting a new range, the current value is adjusted if
|
---|
3660 | necessary (ensuring that the value remains within the range).
|
---|
3661 |
|
---|
3662 | \sa setMinimum(), setMaximum(), rangeChanged()
|
---|
3663 | */
|
---|
3664 | void QtSizeFPropertyManager::setRange(QtProperty *property, const QSizeF &minVal, const QSizeF &maxVal)
|
---|
3665 | {
|
---|
3666 | setBorderValues<const QSizeF &, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF>(this, d_ptr.data(),
|
---|
3667 | &QtSizeFPropertyManager::propertyChanged,
|
---|
3668 | &QtSizeFPropertyManager::valueChanged,
|
---|
3669 | &QtSizeFPropertyManager::rangeChanged,
|
---|
3670 | property, minVal, maxVal, &QtSizeFPropertyManagerPrivate::setRange);
|
---|
3671 | }
|
---|
3672 |
|
---|
3673 | /*!
|
---|
3674 | \reimp
|
---|
3675 | */
|
---|
3676 | void QtSizeFPropertyManager::initializeProperty(QtProperty *property)
|
---|
3677 | {
|
---|
3678 | d_ptr->m_values[property] = QtSizeFPropertyManagerPrivate::Data();
|
---|
3679 |
|
---|
3680 | QtProperty *wProp = d_ptr->m_doublePropertyManager->addProperty();
|
---|
3681 | wProp->setPropertyName(tr("Width"));
|
---|
3682 | d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property));
|
---|
3683 | d_ptr->m_doublePropertyManager->setValue(wProp, 0);
|
---|
3684 | d_ptr->m_doublePropertyManager->setMinimum(wProp, 0);
|
---|
3685 | d_ptr->m_propertyToW[property] = wProp;
|
---|
3686 | d_ptr->m_wToProperty[wProp] = property;
|
---|
3687 | property->addSubProperty(wProp);
|
---|
3688 |
|
---|
3689 | QtProperty *hProp = d_ptr->m_doublePropertyManager->addProperty();
|
---|
3690 | hProp->setPropertyName(tr("Height"));
|
---|
3691 | d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property));
|
---|
3692 | d_ptr->m_doublePropertyManager->setValue(hProp, 0);
|
---|
3693 | d_ptr->m_doublePropertyManager->setMinimum(hProp, 0);
|
---|
3694 | d_ptr->m_propertyToH[property] = hProp;
|
---|
3695 | d_ptr->m_hToProperty[hProp] = property;
|
---|
3696 | property->addSubProperty(hProp);
|
---|
3697 | }
|
---|
3698 |
|
---|
3699 | /*!
|
---|
3700 | \reimp
|
---|
3701 | */
|
---|
3702 | void QtSizeFPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
3703 | {
|
---|
3704 | QtProperty *wProp = d_ptr->m_propertyToW[property];
|
---|
3705 | if (wProp) {
|
---|
3706 | d_ptr->m_wToProperty.remove(wProp);
|
---|
3707 | delete wProp;
|
---|
3708 | }
|
---|
3709 | d_ptr->m_propertyToW.remove(property);
|
---|
3710 |
|
---|
3711 | QtProperty *hProp = d_ptr->m_propertyToH[property];
|
---|
3712 | if (hProp) {
|
---|
3713 | d_ptr->m_hToProperty.remove(hProp);
|
---|
3714 | delete hProp;
|
---|
3715 | }
|
---|
3716 | d_ptr->m_propertyToH.remove(property);
|
---|
3717 |
|
---|
3718 | d_ptr->m_values.remove(property);
|
---|
3719 | }
|
---|
3720 |
|
---|
3721 | // QtRectPropertyManager
|
---|
3722 |
|
---|
3723 | class QtRectPropertyManagerPrivate
|
---|
3724 | {
|
---|
3725 | QtRectPropertyManager *q_ptr;
|
---|
3726 | Q_DECLARE_PUBLIC(QtRectPropertyManager)
|
---|
3727 | public:
|
---|
3728 |
|
---|
3729 | void slotIntChanged(QtProperty *property, int value);
|
---|
3730 | void slotPropertyDestroyed(QtProperty *property);
|
---|
3731 | void setConstraint(QtProperty *property, const QRect &constraint, const QRect &val);
|
---|
3732 |
|
---|
3733 | struct Data
|
---|
3734 | {
|
---|
3735 | Data() : val(0, 0, 0, 0) {}
|
---|
3736 | QRect val;
|
---|
3737 | QRect constraint;
|
---|
3738 | };
|
---|
3739 |
|
---|
3740 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
3741 | PropertyValueMap m_values;
|
---|
3742 |
|
---|
3743 | QtIntPropertyManager *m_intPropertyManager;
|
---|
3744 |
|
---|
3745 | QMap<const QtProperty *, QtProperty *> m_propertyToX;
|
---|
3746 | QMap<const QtProperty *, QtProperty *> m_propertyToY;
|
---|
3747 | QMap<const QtProperty *, QtProperty *> m_propertyToW;
|
---|
3748 | QMap<const QtProperty *, QtProperty *> m_propertyToH;
|
---|
3749 |
|
---|
3750 | QMap<const QtProperty *, QtProperty *> m_xToProperty;
|
---|
3751 | QMap<const QtProperty *, QtProperty *> m_yToProperty;
|
---|
3752 | QMap<const QtProperty *, QtProperty *> m_wToProperty;
|
---|
3753 | QMap<const QtProperty *, QtProperty *> m_hToProperty;
|
---|
3754 | };
|
---|
3755 |
|
---|
3756 | void QtRectPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
|
---|
3757 | {
|
---|
3758 | if (QtProperty *prop = m_xToProperty.value(property, 0)) {
|
---|
3759 | QRect r = m_values[prop].val;
|
---|
3760 | r.moveLeft(value);
|
---|
3761 | q_ptr->setValue(prop, r);
|
---|
3762 | } else if (QtProperty *prop = m_yToProperty.value(property)) {
|
---|
3763 | QRect r = m_values[prop].val;
|
---|
3764 | r.moveTop(value);
|
---|
3765 | q_ptr->setValue(prop, r);
|
---|
3766 | } else if (QtProperty *prop = m_wToProperty.value(property, 0)) {
|
---|
3767 | Data data = m_values[prop];
|
---|
3768 | QRect r = data.val;
|
---|
3769 | r.setWidth(value);
|
---|
3770 | if (!data.constraint.isNull() && data.constraint.x() + data.constraint.width() < r.x() + r.width()) {
|
---|
3771 | r.moveLeft(data.constraint.left() + data.constraint.width() - r.width());
|
---|
3772 | }
|
---|
3773 | q_ptr->setValue(prop, r);
|
---|
3774 | } else if (QtProperty *prop = m_hToProperty.value(property, 0)) {
|
---|
3775 | Data data = m_values[prop];
|
---|
3776 | QRect r = data.val;
|
---|
3777 | r.setHeight(value);
|
---|
3778 | if (!data.constraint.isNull() && data.constraint.y() + data.constraint.height() < r.y() + r.height()) {
|
---|
3779 | r.moveTop(data.constraint.top() + data.constraint.height() - r.height());
|
---|
3780 | }
|
---|
3781 | q_ptr->setValue(prop, r);
|
---|
3782 | }
|
---|
3783 | }
|
---|
3784 |
|
---|
3785 | void QtRectPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
3786 | {
|
---|
3787 | if (QtProperty *pointProp = m_xToProperty.value(property, 0)) {
|
---|
3788 | m_propertyToX[pointProp] = 0;
|
---|
3789 | m_xToProperty.remove(property);
|
---|
3790 | } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) {
|
---|
3791 | m_propertyToY[pointProp] = 0;
|
---|
3792 | m_yToProperty.remove(property);
|
---|
3793 | } else if (QtProperty *pointProp = m_wToProperty.value(property, 0)) {
|
---|
3794 | m_propertyToW[pointProp] = 0;
|
---|
3795 | m_wToProperty.remove(property);
|
---|
3796 | } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) {
|
---|
3797 | m_propertyToH[pointProp] = 0;
|
---|
3798 | m_hToProperty.remove(property);
|
---|
3799 | }
|
---|
3800 | }
|
---|
3801 |
|
---|
3802 | void QtRectPropertyManagerPrivate::setConstraint(QtProperty *property,
|
---|
3803 | const QRect &constraint, const QRect &val)
|
---|
3804 | {
|
---|
3805 | const bool isNull = constraint.isNull();
|
---|
3806 | const int left = isNull ? INT_MIN : constraint.left();
|
---|
3807 | const int right = isNull ? INT_MAX : constraint.left() + constraint.width();
|
---|
3808 | const int top = isNull ? INT_MIN : constraint.top();
|
---|
3809 | const int bottom = isNull ? INT_MAX : constraint.top() + constraint.height();
|
---|
3810 | const int width = isNull ? INT_MAX : constraint.width();
|
---|
3811 | const int height = isNull ? INT_MAX : constraint.height();
|
---|
3812 |
|
---|
3813 | m_intPropertyManager->setRange(m_propertyToX[property], left, right);
|
---|
3814 | m_intPropertyManager->setRange(m_propertyToY[property], top, bottom);
|
---|
3815 | m_intPropertyManager->setRange(m_propertyToW[property], 0, width);
|
---|
3816 | m_intPropertyManager->setRange(m_propertyToH[property], 0, height);
|
---|
3817 |
|
---|
3818 | m_intPropertyManager->setValue(m_propertyToX[property], val.x());
|
---|
3819 | m_intPropertyManager->setValue(m_propertyToY[property], val.y());
|
---|
3820 | m_intPropertyManager->setValue(m_propertyToW[property], val.width());
|
---|
3821 | m_intPropertyManager->setValue(m_propertyToH[property], val.height());
|
---|
3822 | }
|
---|
3823 |
|
---|
3824 | /*!
|
---|
3825 | \class QtRectPropertyManager
|
---|
3826 | \internal
|
---|
3827 | \inmodule QtDesigner
|
---|
3828 | \since 4.4
|
---|
3829 |
|
---|
3830 | \brief The QtRectPropertyManager provides and manages QRect properties.
|
---|
3831 |
|
---|
3832 | A rectangle property has nested \e x, \e y, \e width and \e height
|
---|
3833 | subproperties. The top-level property's value can be retrieved
|
---|
3834 | using the value() function, and set using the setValue() slot.
|
---|
3835 |
|
---|
3836 | The subproperties are created by a QtIntPropertyManager object. This
|
---|
3837 | manager can be retrieved using the subIntPropertyManager() function. In
|
---|
3838 | order to provide editing widgets for the subproperties in a
|
---|
3839 | property browser widget, this manager must be associated with an
|
---|
3840 | editor factory.
|
---|
3841 |
|
---|
3842 | A rectangle property also has a constraint rectangle which can be
|
---|
3843 | retrieved using the constraint() function, and set using the
|
---|
3844 | setConstraint() slot.
|
---|
3845 |
|
---|
3846 | In addition, QtRectPropertyManager provides the valueChanged() signal
|
---|
3847 | which is emitted whenever a property created by this manager
|
---|
3848 | changes, and the constraintChanged() signal which is emitted
|
---|
3849 | whenever such a property changes its constraint rectangle.
|
---|
3850 |
|
---|
3851 | \sa QtAbstractPropertyManager, QtIntPropertyManager, QtRectFPropertyManager
|
---|
3852 | */
|
---|
3853 |
|
---|
3854 | /*!
|
---|
3855 | \fn void QtRectPropertyManager::valueChanged(QtProperty *property, const QRect &value)
|
---|
3856 |
|
---|
3857 | This signal is emitted whenever a property created by this manager
|
---|
3858 | changes its value, passing a pointer to the \a property and the new
|
---|
3859 | \a value as parameters.
|
---|
3860 |
|
---|
3861 | \sa setValue()
|
---|
3862 | */
|
---|
3863 |
|
---|
3864 | /*!
|
---|
3865 | \fn void QtRectPropertyManager::constraintChanged(QtProperty *property, const QRect &constraint)
|
---|
3866 |
|
---|
3867 | This signal is emitted whenever property changes its constraint
|
---|
3868 | rectangle, passing a pointer to the \a property and the new \a
|
---|
3869 | constraint rectangle as parameters.
|
---|
3870 |
|
---|
3871 | \sa setConstraint()
|
---|
3872 | */
|
---|
3873 |
|
---|
3874 | /*!
|
---|
3875 | Creates a manager with the given \a parent.
|
---|
3876 | */
|
---|
3877 | QtRectPropertyManager::QtRectPropertyManager(QObject *parent)
|
---|
3878 | : QtAbstractPropertyManager(parent), d_ptr(new QtRectPropertyManagerPrivate)
|
---|
3879 | {
|
---|
3880 | d_ptr->q_ptr = this;
|
---|
3881 |
|
---|
3882 | d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
|
---|
3883 | connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
|
---|
3884 | this, SLOT(slotIntChanged(QtProperty*,int)));
|
---|
3885 | connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
3886 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
3887 | }
|
---|
3888 |
|
---|
3889 | /*!
|
---|
3890 | Destroys this manager, and all the properties it has created.
|
---|
3891 | */
|
---|
3892 | QtRectPropertyManager::~QtRectPropertyManager()
|
---|
3893 | {
|
---|
3894 | clear();
|
---|
3895 | }
|
---|
3896 |
|
---|
3897 | /*!
|
---|
3898 | Returns the manager that creates the nested \e x, \e y, \e width
|
---|
3899 | and \e height subproperties.
|
---|
3900 |
|
---|
3901 | In order to provide editing widgets for the mentioned
|
---|
3902 | subproperties in a property browser widget, this manager must be
|
---|
3903 | associated with an editor factory.
|
---|
3904 |
|
---|
3905 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
3906 | */
|
---|
3907 | QtIntPropertyManager *QtRectPropertyManager::subIntPropertyManager() const
|
---|
3908 | {
|
---|
3909 | return d_ptr->m_intPropertyManager;
|
---|
3910 | }
|
---|
3911 |
|
---|
3912 | /*!
|
---|
3913 | Returns the given \a property's value.
|
---|
3914 |
|
---|
3915 | If the given \a property is not managed by this manager, this
|
---|
3916 | function returns an invalid rectangle.
|
---|
3917 |
|
---|
3918 | \sa setValue(), constraint()
|
---|
3919 | */
|
---|
3920 | QRect QtRectPropertyManager::value(const QtProperty *property) const
|
---|
3921 | {
|
---|
3922 | return getValue<QRect>(d_ptr->m_values, property);
|
---|
3923 | }
|
---|
3924 |
|
---|
3925 | /*!
|
---|
3926 | Returns the given \a property's constraining rectangle. If returned value is null QRect it means there is no constraint applied.
|
---|
3927 |
|
---|
3928 | \sa value(), setConstraint()
|
---|
3929 | */
|
---|
3930 | QRect QtRectPropertyManager::constraint(const QtProperty *property) const
|
---|
3931 | {
|
---|
3932 | return getData<QRect>(d_ptr->m_values, &QtRectPropertyManagerPrivate::Data::constraint, property, QRect());
|
---|
3933 | }
|
---|
3934 |
|
---|
3935 | /*!
|
---|
3936 | \reimp
|
---|
3937 | */
|
---|
3938 | QString QtRectPropertyManager::valueText(const QtProperty *property) const
|
---|
3939 | {
|
---|
3940 | const QtRectPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
3941 | if (it == d_ptr->m_values.constEnd())
|
---|
3942 | return QString();
|
---|
3943 | const QRect v = it.value().val;
|
---|
3944 | return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x()))
|
---|
3945 | .arg(QString::number(v.y()))
|
---|
3946 | .arg(QString::number(v.width()))
|
---|
3947 | .arg(QString::number(v.height())));
|
---|
3948 | }
|
---|
3949 |
|
---|
3950 | /*!
|
---|
3951 | \fn void QtRectPropertyManager::setValue(QtProperty *property, const QRect &value)
|
---|
3952 |
|
---|
3953 | Sets the value of the given \a property to \a value. Nested
|
---|
3954 | properties are updated automatically.
|
---|
3955 |
|
---|
3956 | If the specified \a value is not inside the given \a property's
|
---|
3957 | constraining rectangle, the value is adjusted accordingly to fit
|
---|
3958 | within the constraint.
|
---|
3959 |
|
---|
3960 | \sa value(), setConstraint(), valueChanged()
|
---|
3961 | */
|
---|
3962 | void QtRectPropertyManager::setValue(QtProperty *property, const QRect &val)
|
---|
3963 | {
|
---|
3964 | const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
3965 | if (it == d_ptr->m_values.end())
|
---|
3966 | return;
|
---|
3967 |
|
---|
3968 | QtRectPropertyManagerPrivate::Data data = it.value();
|
---|
3969 |
|
---|
3970 | QRect newRect = val.normalized();
|
---|
3971 | if (!data.constraint.isNull() && !data.constraint.contains(newRect)) {
|
---|
3972 | const QRect r1 = data.constraint;
|
---|
3973 | const QRect r2 = newRect;
|
---|
3974 | newRect.setLeft(qMax(r1.left(), r2.left()));
|
---|
3975 | newRect.setRight(qMin(r1.right(), r2.right()));
|
---|
3976 | newRect.setTop(qMax(r1.top(), r2.top()));
|
---|
3977 | newRect.setBottom(qMin(r1.bottom(), r2.bottom()));
|
---|
3978 | if (newRect.width() < 0 || newRect.height() < 0)
|
---|
3979 | return;
|
---|
3980 | }
|
---|
3981 |
|
---|
3982 | if (data.val == newRect)
|
---|
3983 | return;
|
---|
3984 |
|
---|
3985 | data.val = newRect;
|
---|
3986 |
|
---|
3987 | it.value() = data;
|
---|
3988 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToX[property], newRect.x());
|
---|
3989 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToY[property], newRect.y());
|
---|
3990 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToW[property], newRect.width());
|
---|
3991 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToH[property], newRect.height());
|
---|
3992 |
|
---|
3993 | emit propertyChanged(property);
|
---|
3994 | emit valueChanged(property, data.val);
|
---|
3995 | }
|
---|
3996 |
|
---|
3997 | /*!
|
---|
3998 | Sets the given \a property's constraining rectangle to \a
|
---|
3999 | constraint.
|
---|
4000 |
|
---|
4001 | When setting the constraint, the current value is adjusted if
|
---|
4002 | necessary (ensuring that the current rectangle value is inside the
|
---|
4003 | constraint). In order to reset the constraint pass a null QRect value.
|
---|
4004 |
|
---|
4005 | \sa setValue(), constraint(), constraintChanged()
|
---|
4006 | */
|
---|
4007 | void QtRectPropertyManager::setConstraint(QtProperty *property, const QRect &constraint)
|
---|
4008 | {
|
---|
4009 | const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
4010 | if (it == d_ptr->m_values.end())
|
---|
4011 | return;
|
---|
4012 |
|
---|
4013 | QtRectPropertyManagerPrivate::Data data = it.value();
|
---|
4014 |
|
---|
4015 | QRect newConstraint = constraint.normalized();
|
---|
4016 | if (data.constraint == newConstraint)
|
---|
4017 | return;
|
---|
4018 |
|
---|
4019 | const QRect oldVal = data.val;
|
---|
4020 |
|
---|
4021 | data.constraint = newConstraint;
|
---|
4022 |
|
---|
4023 | if (!data.constraint.isNull() && !data.constraint.contains(oldVal)) {
|
---|
4024 | QRect r1 = data.constraint;
|
---|
4025 | QRect r2 = data.val;
|
---|
4026 |
|
---|
4027 | if (r2.width() > r1.width())
|
---|
4028 | r2.setWidth(r1.width());
|
---|
4029 | if (r2.height() > r1.height())
|
---|
4030 | r2.setHeight(r1.height());
|
---|
4031 | if (r2.left() < r1.left())
|
---|
4032 | r2.moveLeft(r1.left());
|
---|
4033 | else if (r2.right() > r1.right())
|
---|
4034 | r2.moveRight(r1.right());
|
---|
4035 | if (r2.top() < r1.top())
|
---|
4036 | r2.moveTop(r1.top());
|
---|
4037 | else if (r2.bottom() > r1.bottom())
|
---|
4038 | r2.moveBottom(r1.bottom());
|
---|
4039 |
|
---|
4040 | data.val = r2;
|
---|
4041 | }
|
---|
4042 |
|
---|
4043 | it.value() = data;
|
---|
4044 |
|
---|
4045 | emit constraintChanged(property, data.constraint);
|
---|
4046 |
|
---|
4047 | d_ptr->setConstraint(property, data.constraint, data.val);
|
---|
4048 |
|
---|
4049 | if (data.val == oldVal)
|
---|
4050 | return;
|
---|
4051 |
|
---|
4052 | emit propertyChanged(property);
|
---|
4053 | emit valueChanged(property, data.val);
|
---|
4054 | }
|
---|
4055 |
|
---|
4056 | /*!
|
---|
4057 | \reimp
|
---|
4058 | */
|
---|
4059 | void QtRectPropertyManager::initializeProperty(QtProperty *property)
|
---|
4060 | {
|
---|
4061 | d_ptr->m_values[property] = QtRectPropertyManagerPrivate::Data();
|
---|
4062 |
|
---|
4063 | QtProperty *xProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
4064 | xProp->setPropertyName(tr("X"));
|
---|
4065 | d_ptr->m_intPropertyManager->setValue(xProp, 0);
|
---|
4066 | d_ptr->m_propertyToX[property] = xProp;
|
---|
4067 | d_ptr->m_xToProperty[xProp] = property;
|
---|
4068 | property->addSubProperty(xProp);
|
---|
4069 |
|
---|
4070 | QtProperty *yProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
4071 | yProp->setPropertyName(tr("Y"));
|
---|
4072 | d_ptr->m_intPropertyManager->setValue(yProp, 0);
|
---|
4073 | d_ptr->m_propertyToY[property] = yProp;
|
---|
4074 | d_ptr->m_yToProperty[yProp] = property;
|
---|
4075 | property->addSubProperty(yProp);
|
---|
4076 |
|
---|
4077 | QtProperty *wProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
4078 | wProp->setPropertyName(tr("Width"));
|
---|
4079 | d_ptr->m_intPropertyManager->setValue(wProp, 0);
|
---|
4080 | d_ptr->m_intPropertyManager->setMinimum(wProp, 0);
|
---|
4081 | d_ptr->m_propertyToW[property] = wProp;
|
---|
4082 | d_ptr->m_wToProperty[wProp] = property;
|
---|
4083 | property->addSubProperty(wProp);
|
---|
4084 |
|
---|
4085 | QtProperty *hProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
4086 | hProp->setPropertyName(tr("Height"));
|
---|
4087 | d_ptr->m_intPropertyManager->setValue(hProp, 0);
|
---|
4088 | d_ptr->m_intPropertyManager->setMinimum(hProp, 0);
|
---|
4089 | d_ptr->m_propertyToH[property] = hProp;
|
---|
4090 | d_ptr->m_hToProperty[hProp] = property;
|
---|
4091 | property->addSubProperty(hProp);
|
---|
4092 | }
|
---|
4093 |
|
---|
4094 | /*!
|
---|
4095 | \reimp
|
---|
4096 | */
|
---|
4097 | void QtRectPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
4098 | {
|
---|
4099 | QtProperty *xProp = d_ptr->m_propertyToX[property];
|
---|
4100 | if (xProp) {
|
---|
4101 | d_ptr->m_xToProperty.remove(xProp);
|
---|
4102 | delete xProp;
|
---|
4103 | }
|
---|
4104 | d_ptr->m_propertyToX.remove(property);
|
---|
4105 |
|
---|
4106 | QtProperty *yProp = d_ptr->m_propertyToY[property];
|
---|
4107 | if (yProp) {
|
---|
4108 | d_ptr->m_yToProperty.remove(yProp);
|
---|
4109 | delete yProp;
|
---|
4110 | }
|
---|
4111 | d_ptr->m_propertyToY.remove(property);
|
---|
4112 |
|
---|
4113 | QtProperty *wProp = d_ptr->m_propertyToW[property];
|
---|
4114 | if (wProp) {
|
---|
4115 | d_ptr->m_wToProperty.remove(wProp);
|
---|
4116 | delete wProp;
|
---|
4117 | }
|
---|
4118 | d_ptr->m_propertyToW.remove(property);
|
---|
4119 |
|
---|
4120 | QtProperty *hProp = d_ptr->m_propertyToH[property];
|
---|
4121 | if (hProp) {
|
---|
4122 | d_ptr->m_hToProperty.remove(hProp);
|
---|
4123 | delete hProp;
|
---|
4124 | }
|
---|
4125 | d_ptr->m_propertyToH.remove(property);
|
---|
4126 |
|
---|
4127 | d_ptr->m_values.remove(property);
|
---|
4128 | }
|
---|
4129 |
|
---|
4130 | // QtRectFPropertyManager
|
---|
4131 |
|
---|
4132 | class QtRectFPropertyManagerPrivate
|
---|
4133 | {
|
---|
4134 | QtRectFPropertyManager *q_ptr;
|
---|
4135 | Q_DECLARE_PUBLIC(QtRectFPropertyManager)
|
---|
4136 | public:
|
---|
4137 |
|
---|
4138 | void slotDoubleChanged(QtProperty *property, double value);
|
---|
4139 | void slotPropertyDestroyed(QtProperty *property);
|
---|
4140 | void setConstraint(QtProperty *property, const QRectF &constraint, const QRectF &val);
|
---|
4141 |
|
---|
4142 | struct Data
|
---|
4143 | {
|
---|
4144 | Data() : val(0, 0, 0, 0), decimals(2) {}
|
---|
4145 | QRectF val;
|
---|
4146 | QRectF constraint;
|
---|
4147 | int decimals;
|
---|
4148 | };
|
---|
4149 |
|
---|
4150 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
4151 | PropertyValueMap m_values;
|
---|
4152 |
|
---|
4153 | QtDoublePropertyManager *m_doublePropertyManager;
|
---|
4154 |
|
---|
4155 | QMap<const QtProperty *, QtProperty *> m_propertyToX;
|
---|
4156 | QMap<const QtProperty *, QtProperty *> m_propertyToY;
|
---|
4157 | QMap<const QtProperty *, QtProperty *> m_propertyToW;
|
---|
4158 | QMap<const QtProperty *, QtProperty *> m_propertyToH;
|
---|
4159 |
|
---|
4160 | QMap<const QtProperty *, QtProperty *> m_xToProperty;
|
---|
4161 | QMap<const QtProperty *, QtProperty *> m_yToProperty;
|
---|
4162 | QMap<const QtProperty *, QtProperty *> m_wToProperty;
|
---|
4163 | QMap<const QtProperty *, QtProperty *> m_hToProperty;
|
---|
4164 | };
|
---|
4165 |
|
---|
4166 | void QtRectFPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value)
|
---|
4167 | {
|
---|
4168 | if (QtProperty *prop = m_xToProperty.value(property, 0)) {
|
---|
4169 | QRectF r = m_values[prop].val;
|
---|
4170 | r.moveLeft(value);
|
---|
4171 | q_ptr->setValue(prop, r);
|
---|
4172 | } else if (QtProperty *prop = m_yToProperty.value(property, 0)) {
|
---|
4173 | QRectF r = m_values[prop].val;
|
---|
4174 | r.moveTop(value);
|
---|
4175 | q_ptr->setValue(prop, r);
|
---|
4176 | } else if (QtProperty *prop = m_wToProperty.value(property, 0)) {
|
---|
4177 | Data data = m_values[prop];
|
---|
4178 | QRectF r = data.val;
|
---|
4179 | r.setWidth(value);
|
---|
4180 | if (!data.constraint.isNull() && data.constraint.x() + data.constraint.width() < r.x() + r.width()) {
|
---|
4181 | r.moveLeft(data.constraint.left() + data.constraint.width() - r.width());
|
---|
4182 | }
|
---|
4183 | q_ptr->setValue(prop, r);
|
---|
4184 | } else if (QtProperty *prop = m_hToProperty.value(property, 0)) {
|
---|
4185 | Data data = m_values[prop];
|
---|
4186 | QRectF r = data.val;
|
---|
4187 | r.setHeight(value);
|
---|
4188 | if (!data.constraint.isNull() && data.constraint.y() + data.constraint.height() < r.y() + r.height()) {
|
---|
4189 | r.moveTop(data.constraint.top() + data.constraint.height() - r.height());
|
---|
4190 | }
|
---|
4191 | q_ptr->setValue(prop, r);
|
---|
4192 | }
|
---|
4193 | }
|
---|
4194 |
|
---|
4195 | void QtRectFPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
4196 | {
|
---|
4197 | if (QtProperty *pointProp = m_xToProperty.value(property, 0)) {
|
---|
4198 | m_propertyToX[pointProp] = 0;
|
---|
4199 | m_xToProperty.remove(property);
|
---|
4200 | } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) {
|
---|
4201 | m_propertyToY[pointProp] = 0;
|
---|
4202 | m_yToProperty.remove(property);
|
---|
4203 | } else if (QtProperty *pointProp = m_wToProperty.value(property, 0)) {
|
---|
4204 | m_propertyToW[pointProp] = 0;
|
---|
4205 | m_wToProperty.remove(property);
|
---|
4206 | } else if (QtProperty *pointProp = m_hToProperty.value(property, 0)) {
|
---|
4207 | m_propertyToH[pointProp] = 0;
|
---|
4208 | m_hToProperty.remove(property);
|
---|
4209 | }
|
---|
4210 | }
|
---|
4211 |
|
---|
4212 | void QtRectFPropertyManagerPrivate::setConstraint(QtProperty *property,
|
---|
4213 | const QRectF &constraint, const QRectF &val)
|
---|
4214 | {
|
---|
4215 | const bool isNull = constraint.isNull();
|
---|
4216 | const float left = isNull ? FLT_MIN : constraint.left();
|
---|
4217 | const float right = isNull ? FLT_MAX : constraint.left() + constraint.width();
|
---|
4218 | const float top = isNull ? FLT_MIN : constraint.top();
|
---|
4219 | const float bottom = isNull ? FLT_MAX : constraint.top() + constraint.height();
|
---|
4220 | const float width = isNull ? FLT_MAX : constraint.width();
|
---|
4221 | const float height = isNull ? FLT_MAX : constraint.height();
|
---|
4222 |
|
---|
4223 | m_doublePropertyManager->setRange(m_propertyToX[property], left, right);
|
---|
4224 | m_doublePropertyManager->setRange(m_propertyToY[property], top, bottom);
|
---|
4225 | m_doublePropertyManager->setRange(m_propertyToW[property], 0, width);
|
---|
4226 | m_doublePropertyManager->setRange(m_propertyToH[property], 0, height);
|
---|
4227 |
|
---|
4228 | m_doublePropertyManager->setValue(m_propertyToX[property], val.x());
|
---|
4229 | m_doublePropertyManager->setValue(m_propertyToY[property], val.y());
|
---|
4230 | m_doublePropertyManager->setValue(m_propertyToW[property], val.width());
|
---|
4231 | m_doublePropertyManager->setValue(m_propertyToH[property], val.height());
|
---|
4232 | }
|
---|
4233 |
|
---|
4234 | /*!
|
---|
4235 | \class QtRectFPropertyManager
|
---|
4236 | \internal
|
---|
4237 | \inmodule QtDesigner
|
---|
4238 | \since 4.4
|
---|
4239 |
|
---|
4240 | \brief The QtRectFPropertyManager provides and manages QRectF properties.
|
---|
4241 |
|
---|
4242 | A rectangle property has nested \e x, \e y, \e width and \e height
|
---|
4243 | subproperties. The top-level property's value can be retrieved
|
---|
4244 | using the value() function, and set using the setValue() slot.
|
---|
4245 |
|
---|
4246 | The subproperties are created by a QtDoublePropertyManager object. This
|
---|
4247 | manager can be retrieved using the subDoublePropertyManager() function. In
|
---|
4248 | order to provide editing widgets for the subproperties in a
|
---|
4249 | property browser widget, this manager must be associated with an
|
---|
4250 | editor factory.
|
---|
4251 |
|
---|
4252 | A rectangle property also has a constraint rectangle which can be
|
---|
4253 | retrieved using the constraint() function, and set using the
|
---|
4254 | setConstraint() slot.
|
---|
4255 |
|
---|
4256 | In addition, QtRectFPropertyManager provides the valueChanged() signal
|
---|
4257 | which is emitted whenever a property created by this manager
|
---|
4258 | changes, and the constraintChanged() signal which is emitted
|
---|
4259 | whenever such a property changes its constraint rectangle.
|
---|
4260 |
|
---|
4261 | \sa QtAbstractPropertyManager, QtDoublePropertyManager, QtRectPropertyManager
|
---|
4262 | */
|
---|
4263 |
|
---|
4264 | /*!
|
---|
4265 | \fn void QtRectFPropertyManager::valueChanged(QtProperty *property, const QRectF &value)
|
---|
4266 |
|
---|
4267 | This signal is emitted whenever a property created by this manager
|
---|
4268 | changes its value, passing a pointer to the \a property and the new
|
---|
4269 | \a value as parameters.
|
---|
4270 |
|
---|
4271 | \sa setValue()
|
---|
4272 | */
|
---|
4273 |
|
---|
4274 | /*!
|
---|
4275 | \fn void QtRectFPropertyManager::constraintChanged(QtProperty *property, const QRectF &constraint)
|
---|
4276 |
|
---|
4277 | This signal is emitted whenever property changes its constraint
|
---|
4278 | rectangle, passing a pointer to the \a property and the new \a
|
---|
4279 | constraint rectangle as parameters.
|
---|
4280 |
|
---|
4281 | \sa setConstraint()
|
---|
4282 | */
|
---|
4283 |
|
---|
4284 | /*!
|
---|
4285 | \fn void QtRectFPropertyManager::decimalsChanged(QtProperty *property, int prec)
|
---|
4286 |
|
---|
4287 | This signal is emitted whenever a property created by this manager
|
---|
4288 | changes its precision of value, passing a pointer to the
|
---|
4289 | \a property and the new \a prec value
|
---|
4290 |
|
---|
4291 | \sa setDecimals()
|
---|
4292 | */
|
---|
4293 |
|
---|
4294 | /*!
|
---|
4295 | Creates a manager with the given \a parent.
|
---|
4296 | */
|
---|
4297 | QtRectFPropertyManager::QtRectFPropertyManager(QObject *parent)
|
---|
4298 | : QtAbstractPropertyManager(parent), d_ptr(new QtRectFPropertyManagerPrivate)
|
---|
4299 | {
|
---|
4300 | d_ptr->q_ptr = this;
|
---|
4301 |
|
---|
4302 | d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this);
|
---|
4303 | connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty*,double)),
|
---|
4304 | this, SLOT(slotDoubleChanged(QtProperty*,double)));
|
---|
4305 | connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
4306 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
4307 | }
|
---|
4308 |
|
---|
4309 | /*!
|
---|
4310 | Destroys this manager, and all the properties it has created.
|
---|
4311 | */
|
---|
4312 | QtRectFPropertyManager::~QtRectFPropertyManager()
|
---|
4313 | {
|
---|
4314 | clear();
|
---|
4315 | }
|
---|
4316 |
|
---|
4317 | /*!
|
---|
4318 | Returns the manager that creates the nested \e x, \e y, \e width
|
---|
4319 | and \e height subproperties.
|
---|
4320 |
|
---|
4321 | In order to provide editing widgets for the mentioned
|
---|
4322 | subproperties in a property browser widget, this manager must be
|
---|
4323 | associated with an editor factory.
|
---|
4324 |
|
---|
4325 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
4326 | */
|
---|
4327 | QtDoublePropertyManager *QtRectFPropertyManager::subDoublePropertyManager() const
|
---|
4328 | {
|
---|
4329 | return d_ptr->m_doublePropertyManager;
|
---|
4330 | }
|
---|
4331 |
|
---|
4332 | /*!
|
---|
4333 | Returns the given \a property's value.
|
---|
4334 |
|
---|
4335 | If the given \a property is not managed by this manager, this
|
---|
4336 | function returns an invalid rectangle.
|
---|
4337 |
|
---|
4338 | \sa setValue(), constraint()
|
---|
4339 | */
|
---|
4340 | QRectF QtRectFPropertyManager::value(const QtProperty *property) const
|
---|
4341 | {
|
---|
4342 | return getValue<QRectF>(d_ptr->m_values, property);
|
---|
4343 | }
|
---|
4344 |
|
---|
4345 | /*!
|
---|
4346 | Returns the given \a property's precision, in decimals.
|
---|
4347 |
|
---|
4348 | \sa setDecimals()
|
---|
4349 | */
|
---|
4350 | int QtRectFPropertyManager::decimals(const QtProperty *property) const
|
---|
4351 | {
|
---|
4352 | return getData<int>(d_ptr->m_values, &QtRectFPropertyManagerPrivate::Data::decimals, property, 0);
|
---|
4353 | }
|
---|
4354 |
|
---|
4355 | /*!
|
---|
4356 | Returns the given \a property's constraining rectangle. If returned value is null QRectF it means there is no constraint applied.
|
---|
4357 |
|
---|
4358 | \sa value(), setConstraint()
|
---|
4359 | */
|
---|
4360 | QRectF QtRectFPropertyManager::constraint(const QtProperty *property) const
|
---|
4361 | {
|
---|
4362 | return getData<QRectF>(d_ptr->m_values, &QtRectFPropertyManagerPrivate::Data::constraint, property, QRect());
|
---|
4363 | }
|
---|
4364 |
|
---|
4365 | /*!
|
---|
4366 | \reimp
|
---|
4367 | */
|
---|
4368 | QString QtRectFPropertyManager::valueText(const QtProperty *property) const
|
---|
4369 | {
|
---|
4370 | const QtRectFPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
4371 | if (it == d_ptr->m_values.constEnd())
|
---|
4372 | return QString();
|
---|
4373 | const QRectF v = it.value().val;
|
---|
4374 | const int dec = it.value().decimals;
|
---|
4375 | return QString(tr("[(%1, %2), %3 x %4]").arg(QString::number(v.x(), 'f', dec))
|
---|
4376 | .arg(QString::number(v.y(), 'f', dec))
|
---|
4377 | .arg(QString::number(v.width(), 'f', dec))
|
---|
4378 | .arg(QString::number(v.height(), 'f', dec)));
|
---|
4379 | }
|
---|
4380 |
|
---|
4381 | /*!
|
---|
4382 | \fn void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &value)
|
---|
4383 |
|
---|
4384 | Sets the value of the given \a property to \a value. Nested
|
---|
4385 | properties are updated automatically.
|
---|
4386 |
|
---|
4387 | If the specified \a value is not inside the given \a property's
|
---|
4388 | constraining rectangle, the value is adjusted accordingly to fit
|
---|
4389 | within the constraint.
|
---|
4390 |
|
---|
4391 | \sa value(), setConstraint(), valueChanged()
|
---|
4392 | */
|
---|
4393 | void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &val)
|
---|
4394 | {
|
---|
4395 | const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
4396 | if (it == d_ptr->m_values.end())
|
---|
4397 | return;
|
---|
4398 |
|
---|
4399 | QtRectFPropertyManagerPrivate::Data data = it.value();
|
---|
4400 |
|
---|
4401 | QRectF newRect = val.normalized();
|
---|
4402 | if (!data.constraint.isNull() && !data.constraint.contains(newRect)) {
|
---|
4403 | const QRectF r1 = data.constraint;
|
---|
4404 | const QRectF r2 = newRect;
|
---|
4405 | newRect.setLeft(qMax(r1.left(), r2.left()));
|
---|
4406 | newRect.setRight(qMin(r1.right(), r2.right()));
|
---|
4407 | newRect.setTop(qMax(r1.top(), r2.top()));
|
---|
4408 | newRect.setBottom(qMin(r1.bottom(), r2.bottom()));
|
---|
4409 | if (newRect.width() < 0 || newRect.height() < 0)
|
---|
4410 | return;
|
---|
4411 | }
|
---|
4412 |
|
---|
4413 | if (data.val == newRect)
|
---|
4414 | return;
|
---|
4415 |
|
---|
4416 | data.val = newRect;
|
---|
4417 |
|
---|
4418 | it.value() = data;
|
---|
4419 | d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], newRect.x());
|
---|
4420 | d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], newRect.y());
|
---|
4421 | d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToW[property], newRect.width());
|
---|
4422 | d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToH[property], newRect.height());
|
---|
4423 |
|
---|
4424 | emit propertyChanged(property);
|
---|
4425 | emit valueChanged(property, data.val);
|
---|
4426 | }
|
---|
4427 |
|
---|
4428 | /*!
|
---|
4429 | Sets the given \a property's constraining rectangle to \a
|
---|
4430 | constraint.
|
---|
4431 |
|
---|
4432 | When setting the constraint, the current value is adjusted if
|
---|
4433 | necessary (ensuring that the current rectangle value is inside the
|
---|
4434 | constraint). In order to reset the constraint pass a null QRectF value.
|
---|
4435 |
|
---|
4436 | \sa setValue(), constraint(), constraintChanged()
|
---|
4437 | */
|
---|
4438 | void QtRectFPropertyManager::setConstraint(QtProperty *property, const QRectF &constraint)
|
---|
4439 | {
|
---|
4440 | const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
4441 | if (it == d_ptr->m_values.end())
|
---|
4442 | return;
|
---|
4443 |
|
---|
4444 | QtRectFPropertyManagerPrivate::Data data = it.value();
|
---|
4445 |
|
---|
4446 | QRectF newConstraint = constraint.normalized();
|
---|
4447 | if (data.constraint == newConstraint)
|
---|
4448 | return;
|
---|
4449 |
|
---|
4450 | const QRectF oldVal = data.val;
|
---|
4451 |
|
---|
4452 | data.constraint = newConstraint;
|
---|
4453 |
|
---|
4454 | if (!data.constraint.isNull() && !data.constraint.contains(oldVal)) {
|
---|
4455 | QRectF r1 = data.constraint;
|
---|
4456 | QRectF r2 = data.val;
|
---|
4457 |
|
---|
4458 | if (r2.width() > r1.width())
|
---|
4459 | r2.setWidth(r1.width());
|
---|
4460 | if (r2.height() > r1.height())
|
---|
4461 | r2.setHeight(r1.height());
|
---|
4462 | if (r2.left() < r1.left())
|
---|
4463 | r2.moveLeft(r1.left());
|
---|
4464 | else if (r2.right() > r1.right())
|
---|
4465 | r2.moveRight(r1.right());
|
---|
4466 | if (r2.top() < r1.top())
|
---|
4467 | r2.moveTop(r1.top());
|
---|
4468 | else if (r2.bottom() > r1.bottom())
|
---|
4469 | r2.moveBottom(r1.bottom());
|
---|
4470 |
|
---|
4471 | data.val = r2;
|
---|
4472 | }
|
---|
4473 |
|
---|
4474 | it.value() = data;
|
---|
4475 |
|
---|
4476 | emit constraintChanged(property, data.constraint);
|
---|
4477 |
|
---|
4478 | d_ptr->setConstraint(property, data.constraint, data.val);
|
---|
4479 |
|
---|
4480 | if (data.val == oldVal)
|
---|
4481 | return;
|
---|
4482 |
|
---|
4483 | emit propertyChanged(property);
|
---|
4484 | emit valueChanged(property, data.val);
|
---|
4485 | }
|
---|
4486 |
|
---|
4487 | /*!
|
---|
4488 | \fn void QtRectFPropertyManager::setDecimals(QtProperty *property, int prec)
|
---|
4489 |
|
---|
4490 | Sets the precision of the given \a property to \a prec.
|
---|
4491 |
|
---|
4492 | The valid decimal range is 0-13. The default is 2.
|
---|
4493 |
|
---|
4494 | \sa decimals()
|
---|
4495 | */
|
---|
4496 | void QtRectFPropertyManager::setDecimals(QtProperty *property, int prec)
|
---|
4497 | {
|
---|
4498 | const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
4499 | if (it == d_ptr->m_values.end())
|
---|
4500 | return;
|
---|
4501 |
|
---|
4502 | QtRectFPropertyManagerPrivate::Data data = it.value();
|
---|
4503 |
|
---|
4504 | if (prec > 13)
|
---|
4505 | prec = 13;
|
---|
4506 | else if (prec < 0)
|
---|
4507 | prec = 0;
|
---|
4508 |
|
---|
4509 | if (data.decimals == prec)
|
---|
4510 | return;
|
---|
4511 |
|
---|
4512 | data.decimals = prec;
|
---|
4513 | d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], prec);
|
---|
4514 | d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], prec);
|
---|
4515 | d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], prec);
|
---|
4516 | d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], prec);
|
---|
4517 |
|
---|
4518 | it.value() = data;
|
---|
4519 |
|
---|
4520 | emit decimalsChanged(property, data.decimals);
|
---|
4521 | }
|
---|
4522 |
|
---|
4523 | /*!
|
---|
4524 | \reimp
|
---|
4525 | */
|
---|
4526 | void QtRectFPropertyManager::initializeProperty(QtProperty *property)
|
---|
4527 | {
|
---|
4528 | d_ptr->m_values[property] = QtRectFPropertyManagerPrivate::Data();
|
---|
4529 |
|
---|
4530 | QtProperty *xProp = d_ptr->m_doublePropertyManager->addProperty();
|
---|
4531 | xProp->setPropertyName(tr("X"));
|
---|
4532 | d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property));
|
---|
4533 | d_ptr->m_doublePropertyManager->setValue(xProp, 0);
|
---|
4534 | d_ptr->m_propertyToX[property] = xProp;
|
---|
4535 | d_ptr->m_xToProperty[xProp] = property;
|
---|
4536 | property->addSubProperty(xProp);
|
---|
4537 |
|
---|
4538 | QtProperty *yProp = d_ptr->m_doublePropertyManager->addProperty();
|
---|
4539 | yProp->setPropertyName(tr("Y"));
|
---|
4540 | d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property));
|
---|
4541 | d_ptr->m_doublePropertyManager->setValue(yProp, 0);
|
---|
4542 | d_ptr->m_propertyToY[property] = yProp;
|
---|
4543 | d_ptr->m_yToProperty[yProp] = property;
|
---|
4544 | property->addSubProperty(yProp);
|
---|
4545 |
|
---|
4546 | QtProperty *wProp = d_ptr->m_doublePropertyManager->addProperty();
|
---|
4547 | wProp->setPropertyName(tr("Width"));
|
---|
4548 | d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property));
|
---|
4549 | d_ptr->m_doublePropertyManager->setValue(wProp, 0);
|
---|
4550 | d_ptr->m_doublePropertyManager->setMinimum(wProp, 0);
|
---|
4551 | d_ptr->m_propertyToW[property] = wProp;
|
---|
4552 | d_ptr->m_wToProperty[wProp] = property;
|
---|
4553 | property->addSubProperty(wProp);
|
---|
4554 |
|
---|
4555 | QtProperty *hProp = d_ptr->m_doublePropertyManager->addProperty();
|
---|
4556 | hProp->setPropertyName(tr("Height"));
|
---|
4557 | d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property));
|
---|
4558 | d_ptr->m_doublePropertyManager->setValue(hProp, 0);
|
---|
4559 | d_ptr->m_doublePropertyManager->setMinimum(hProp, 0);
|
---|
4560 | d_ptr->m_propertyToH[property] = hProp;
|
---|
4561 | d_ptr->m_hToProperty[hProp] = property;
|
---|
4562 | property->addSubProperty(hProp);
|
---|
4563 | }
|
---|
4564 |
|
---|
4565 | /*!
|
---|
4566 | \reimp
|
---|
4567 | */
|
---|
4568 | void QtRectFPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
4569 | {
|
---|
4570 | QtProperty *xProp = d_ptr->m_propertyToX[property];
|
---|
4571 | if (xProp) {
|
---|
4572 | d_ptr->m_xToProperty.remove(xProp);
|
---|
4573 | delete xProp;
|
---|
4574 | }
|
---|
4575 | d_ptr->m_propertyToX.remove(property);
|
---|
4576 |
|
---|
4577 | QtProperty *yProp = d_ptr->m_propertyToY[property];
|
---|
4578 | if (yProp) {
|
---|
4579 | d_ptr->m_yToProperty.remove(yProp);
|
---|
4580 | delete yProp;
|
---|
4581 | }
|
---|
4582 | d_ptr->m_propertyToY.remove(property);
|
---|
4583 |
|
---|
4584 | QtProperty *wProp = d_ptr->m_propertyToW[property];
|
---|
4585 | if (wProp) {
|
---|
4586 | d_ptr->m_wToProperty.remove(wProp);
|
---|
4587 | delete wProp;
|
---|
4588 | }
|
---|
4589 | d_ptr->m_propertyToW.remove(property);
|
---|
4590 |
|
---|
4591 | QtProperty *hProp = d_ptr->m_propertyToH[property];
|
---|
4592 | if (hProp) {
|
---|
4593 | d_ptr->m_hToProperty.remove(hProp);
|
---|
4594 | delete hProp;
|
---|
4595 | }
|
---|
4596 | d_ptr->m_propertyToH.remove(property);
|
---|
4597 |
|
---|
4598 | d_ptr->m_values.remove(property);
|
---|
4599 | }
|
---|
4600 |
|
---|
4601 | // QtEnumPropertyManager
|
---|
4602 |
|
---|
4603 | class QtEnumPropertyManagerPrivate
|
---|
4604 | {
|
---|
4605 | QtEnumPropertyManager *q_ptr;
|
---|
4606 | Q_DECLARE_PUBLIC(QtEnumPropertyManager)
|
---|
4607 | public:
|
---|
4608 |
|
---|
4609 | struct Data
|
---|
4610 | {
|
---|
4611 | Data() : val(-1) {}
|
---|
4612 | int val;
|
---|
4613 | QStringList enumNames;
|
---|
4614 | QMap<int, QIcon> enumIcons;
|
---|
4615 | };
|
---|
4616 |
|
---|
4617 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
4618 | PropertyValueMap m_values;
|
---|
4619 | };
|
---|
4620 |
|
---|
4621 | /*!
|
---|
4622 | \class QtEnumPropertyManager
|
---|
4623 | \internal
|
---|
4624 | \inmodule QtDesigner
|
---|
4625 | \since 4.4
|
---|
4626 |
|
---|
4627 | \brief The QtEnumPropertyManager provides and manages enum properties.
|
---|
4628 |
|
---|
4629 | Each enum property has an associated list of enum names which can
|
---|
4630 | be retrieved using the enumNames() function, and set using the
|
---|
4631 | corresponding setEnumNames() function. An enum property's value is
|
---|
4632 | represented by an index in this list, and can be retrieved and set
|
---|
4633 | using the value() and setValue() slots respectively.
|
---|
4634 |
|
---|
4635 | Each enum value can also have an associated icon. The mapping from
|
---|
4636 | values to icons can be set using the setEnumIcons() function and
|
---|
4637 | queried with the enumIcons() function.
|
---|
4638 |
|
---|
4639 | In addition, QtEnumPropertyManager provides the valueChanged() signal
|
---|
4640 | which is emitted whenever a property created by this manager
|
---|
4641 | changes. The enumNamesChanged() or enumIconsChanged() signal is emitted
|
---|
4642 | whenever the list of enum names or icons is altered.
|
---|
4643 |
|
---|
4644 | \sa QtAbstractPropertyManager, QtEnumEditorFactory
|
---|
4645 | */
|
---|
4646 |
|
---|
4647 | /*!
|
---|
4648 | \fn void QtEnumPropertyManager::valueChanged(QtProperty *property, int value)
|
---|
4649 |
|
---|
4650 | This signal is emitted whenever a property created by this manager
|
---|
4651 | changes its value, passing a pointer to the \a property and the new
|
---|
4652 | \a value as parameters.
|
---|
4653 |
|
---|
4654 | \sa setValue()
|
---|
4655 | */
|
---|
4656 |
|
---|
4657 | /*!
|
---|
4658 | \fn void QtEnumPropertyManager::enumNamesChanged(QtProperty *property, const QStringList &names)
|
---|
4659 |
|
---|
4660 | This signal is emitted whenever a property created by this manager
|
---|
4661 | changes its enum names, passing a pointer to the \a property and
|
---|
4662 | the new \a names as parameters.
|
---|
4663 |
|
---|
4664 | \sa setEnumNames()
|
---|
4665 | */
|
---|
4666 |
|
---|
4667 | /*!
|
---|
4668 | \fn void QtEnumPropertyManager::enumIconsChanged(QtProperty *property, const QMap<int, QIcon> &icons)
|
---|
4669 |
|
---|
4670 | This signal is emitted whenever a property created by this manager
|
---|
4671 | changes its enum icons, passing a pointer to the \a property and
|
---|
4672 | the new mapping of values to \a icons as parameters.
|
---|
4673 |
|
---|
4674 | \sa setEnumIcons()
|
---|
4675 | */
|
---|
4676 |
|
---|
4677 | /*!
|
---|
4678 | Creates a manager with the given \a parent.
|
---|
4679 | */
|
---|
4680 | QtEnumPropertyManager::QtEnumPropertyManager(QObject *parent)
|
---|
4681 | : QtAbstractPropertyManager(parent), d_ptr(new QtEnumPropertyManagerPrivate)
|
---|
4682 | {
|
---|
4683 | d_ptr->q_ptr = this;
|
---|
4684 | }
|
---|
4685 |
|
---|
4686 | /*!
|
---|
4687 | Destroys this manager, and all the properties it has created.
|
---|
4688 | */
|
---|
4689 | QtEnumPropertyManager::~QtEnumPropertyManager()
|
---|
4690 | {
|
---|
4691 | clear();
|
---|
4692 | }
|
---|
4693 |
|
---|
4694 | /*!
|
---|
4695 | Returns the given \a property's value which is an index in the
|
---|
4696 | list returned by enumNames()
|
---|
4697 |
|
---|
4698 | If the given property is not managed by this manager, this
|
---|
4699 | function returns -1.
|
---|
4700 |
|
---|
4701 | \sa enumNames(), setValue()
|
---|
4702 | */
|
---|
4703 | int QtEnumPropertyManager::value(const QtProperty *property) const
|
---|
4704 | {
|
---|
4705 | return getValue<int>(d_ptr->m_values, property, -1);
|
---|
4706 | }
|
---|
4707 |
|
---|
4708 | /*!
|
---|
4709 | Returns the given \a property's list of enum names.
|
---|
4710 |
|
---|
4711 | \sa value(), setEnumNames()
|
---|
4712 | */
|
---|
4713 | QStringList QtEnumPropertyManager::enumNames(const QtProperty *property) const
|
---|
4714 | {
|
---|
4715 | return getData<QStringList>(d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::enumNames, property, QStringList());
|
---|
4716 | }
|
---|
4717 |
|
---|
4718 | /*!
|
---|
4719 | Returns the given \a property's map of enum values to their icons.
|
---|
4720 |
|
---|
4721 | \sa value(), setEnumIcons()
|
---|
4722 | */
|
---|
4723 | QMap<int, QIcon> QtEnumPropertyManager::enumIcons(const QtProperty *property) const
|
---|
4724 | {
|
---|
4725 | return getData<QMap<int, QIcon> >(d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::enumIcons, property, QMap<int, QIcon>());
|
---|
4726 | }
|
---|
4727 |
|
---|
4728 | /*!
|
---|
4729 | \reimp
|
---|
4730 | */
|
---|
4731 | QString QtEnumPropertyManager::valueText(const QtProperty *property) const
|
---|
4732 | {
|
---|
4733 | const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
4734 | if (it == d_ptr->m_values.constEnd())
|
---|
4735 | return QString();
|
---|
4736 |
|
---|
4737 | const QtEnumPropertyManagerPrivate::Data &data = it.value();
|
---|
4738 |
|
---|
4739 | const int v = data.val;
|
---|
4740 | if (v >= 0 && v < data.enumNames.count())
|
---|
4741 | return data.enumNames.at(v);
|
---|
4742 | return QString();
|
---|
4743 | }
|
---|
4744 |
|
---|
4745 | /*!
|
---|
4746 | \reimp
|
---|
4747 | */
|
---|
4748 | QIcon QtEnumPropertyManager::valueIcon(const QtProperty *property) const
|
---|
4749 | {
|
---|
4750 | const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
4751 | if (it == d_ptr->m_values.constEnd())
|
---|
4752 | return QIcon();
|
---|
4753 |
|
---|
4754 | const QtEnumPropertyManagerPrivate::Data &data = it.value();
|
---|
4755 |
|
---|
4756 | const int v = data.val;
|
---|
4757 | return data.enumIcons.value(v);
|
---|
4758 | }
|
---|
4759 |
|
---|
4760 | /*!
|
---|
4761 | \fn void QtEnumPropertyManager::setValue(QtProperty *property, int value)
|
---|
4762 |
|
---|
4763 | Sets the value of the given \a property to \a value.
|
---|
4764 |
|
---|
4765 | The specified \a value must be less than the size of the given \a
|
---|
4766 | property's enumNames() list, and larger than (or equal to) 0.
|
---|
4767 |
|
---|
4768 | \sa value(), valueChanged()
|
---|
4769 | */
|
---|
4770 | void QtEnumPropertyManager::setValue(QtProperty *property, int val)
|
---|
4771 | {
|
---|
4772 | const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
4773 | if (it == d_ptr->m_values.end())
|
---|
4774 | return;
|
---|
4775 |
|
---|
4776 | QtEnumPropertyManagerPrivate::Data data = it.value();
|
---|
4777 |
|
---|
4778 | if (val >= data.enumNames.count())
|
---|
4779 | return;
|
---|
4780 |
|
---|
4781 | if (val < 0 && data.enumNames.count() > 0)
|
---|
4782 | return;
|
---|
4783 |
|
---|
4784 | if (val < 0)
|
---|
4785 | val = -1;
|
---|
4786 |
|
---|
4787 | if (data.val == val)
|
---|
4788 | return;
|
---|
4789 |
|
---|
4790 | data.val = val;
|
---|
4791 |
|
---|
4792 | it.value() = data;
|
---|
4793 |
|
---|
4794 | emit propertyChanged(property);
|
---|
4795 | emit valueChanged(property, data.val);
|
---|
4796 | }
|
---|
4797 |
|
---|
4798 | /*!
|
---|
4799 | Sets the given \a property's list of enum names to \a
|
---|
4800 | enumNames. The \a property's current value is reset to 0
|
---|
4801 | indicating the first item of the list.
|
---|
4802 |
|
---|
4803 | If the specified \a enumNames list is empty, the \a property's
|
---|
4804 | current value is set to -1.
|
---|
4805 |
|
---|
4806 | \sa enumNames(), enumNamesChanged()
|
---|
4807 | */
|
---|
4808 | void QtEnumPropertyManager::setEnumNames(QtProperty *property, const QStringList &enumNames)
|
---|
4809 | {
|
---|
4810 | const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
4811 | if (it == d_ptr->m_values.end())
|
---|
4812 | return;
|
---|
4813 |
|
---|
4814 | QtEnumPropertyManagerPrivate::Data data = it.value();
|
---|
4815 |
|
---|
4816 | if (data.enumNames == enumNames)
|
---|
4817 | return;
|
---|
4818 |
|
---|
4819 | data.enumNames = enumNames;
|
---|
4820 |
|
---|
4821 | data.val = -1;
|
---|
4822 |
|
---|
4823 | if (enumNames.count() > 0)
|
---|
4824 | data.val = 0;
|
---|
4825 |
|
---|
4826 | it.value() = data;
|
---|
4827 |
|
---|
4828 | emit enumNamesChanged(property, data.enumNames);
|
---|
4829 |
|
---|
4830 | emit propertyChanged(property);
|
---|
4831 | emit valueChanged(property, data.val);
|
---|
4832 | }
|
---|
4833 |
|
---|
4834 | /*!
|
---|
4835 | Sets the given \a property's map of enum values to their icons to \a
|
---|
4836 | enumIcons.
|
---|
4837 |
|
---|
4838 | Each enum value can have associated icon. This association is represented with passed \a enumIcons map.
|
---|
4839 |
|
---|
4840 | \sa enumNames(), enumNamesChanged()
|
---|
4841 | */
|
---|
4842 | void QtEnumPropertyManager::setEnumIcons(QtProperty *property, const QMap<int, QIcon> &enumIcons)
|
---|
4843 | {
|
---|
4844 | const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
4845 | if (it == d_ptr->m_values.end())
|
---|
4846 | return;
|
---|
4847 |
|
---|
4848 | it.value().enumIcons = enumIcons;
|
---|
4849 |
|
---|
4850 | emit enumIconsChanged(property, it.value().enumIcons);
|
---|
4851 |
|
---|
4852 | emit propertyChanged(property);
|
---|
4853 | }
|
---|
4854 |
|
---|
4855 | /*!
|
---|
4856 | \reimp
|
---|
4857 | */
|
---|
4858 | void QtEnumPropertyManager::initializeProperty(QtProperty *property)
|
---|
4859 | {
|
---|
4860 | d_ptr->m_values[property] = QtEnumPropertyManagerPrivate::Data();
|
---|
4861 | }
|
---|
4862 |
|
---|
4863 | /*!
|
---|
4864 | \reimp
|
---|
4865 | */
|
---|
4866 | void QtEnumPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
4867 | {
|
---|
4868 | d_ptr->m_values.remove(property);
|
---|
4869 | }
|
---|
4870 |
|
---|
4871 | // QtFlagPropertyManager
|
---|
4872 |
|
---|
4873 | class QtFlagPropertyManagerPrivate
|
---|
4874 | {
|
---|
4875 | QtFlagPropertyManager *q_ptr;
|
---|
4876 | Q_DECLARE_PUBLIC(QtFlagPropertyManager)
|
---|
4877 | public:
|
---|
4878 |
|
---|
4879 | void slotBoolChanged(QtProperty *property, bool value);
|
---|
4880 | void slotPropertyDestroyed(QtProperty *property);
|
---|
4881 |
|
---|
4882 | struct Data
|
---|
4883 | {
|
---|
4884 | Data() : val(-1) {}
|
---|
4885 | int val;
|
---|
4886 | QStringList flagNames;
|
---|
4887 | };
|
---|
4888 |
|
---|
4889 | typedef QMap<const QtProperty *, Data> PropertyValueMap;
|
---|
4890 | PropertyValueMap m_values;
|
---|
4891 |
|
---|
4892 | QtBoolPropertyManager *m_boolPropertyManager;
|
---|
4893 |
|
---|
4894 | QMap<const QtProperty *, QList<QtProperty *> > m_propertyToFlags;
|
---|
4895 |
|
---|
4896 | QMap<const QtProperty *, QtProperty *> m_flagToProperty;
|
---|
4897 | };
|
---|
4898 |
|
---|
4899 | void QtFlagPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool value)
|
---|
4900 | {
|
---|
4901 | QtProperty *prop = m_flagToProperty.value(property, 0);
|
---|
4902 | if (prop == 0)
|
---|
4903 | return;
|
---|
4904 |
|
---|
4905 | QListIterator<QtProperty *> itProp(m_propertyToFlags[prop]);
|
---|
4906 | int level = 0;
|
---|
4907 | while (itProp.hasNext()) {
|
---|
4908 | QtProperty *p = itProp.next();
|
---|
4909 | if (p == property) {
|
---|
4910 | int v = m_values[prop].val;
|
---|
4911 | if (value) {
|
---|
4912 | v |= (1 << level);
|
---|
4913 | } else {
|
---|
4914 | v &= ~(1 << level);
|
---|
4915 | }
|
---|
4916 | q_ptr->setValue(prop, v);
|
---|
4917 | return;
|
---|
4918 | }
|
---|
4919 | level++;
|
---|
4920 | }
|
---|
4921 | }
|
---|
4922 |
|
---|
4923 | void QtFlagPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
4924 | {
|
---|
4925 | QtProperty *flagProperty = m_flagToProperty.value(property, 0);
|
---|
4926 | if (flagProperty == 0)
|
---|
4927 | return;
|
---|
4928 |
|
---|
4929 | m_propertyToFlags[flagProperty].replace(m_propertyToFlags[flagProperty].indexOf(property), 0);
|
---|
4930 | m_flagToProperty.remove(property);
|
---|
4931 | }
|
---|
4932 |
|
---|
4933 | /*!
|
---|
4934 | \class QtFlagPropertyManager
|
---|
4935 | \internal
|
---|
4936 | \inmodule QtDesigner
|
---|
4937 | \since 4.4
|
---|
4938 |
|
---|
4939 | \brief The QtFlagPropertyManager provides and manages flag properties.
|
---|
4940 |
|
---|
4941 | Each flag property has an associated list of flag names which can
|
---|
4942 | be retrieved using the flagNames() function, and set using the
|
---|
4943 | corresponding setFlagNames() function.
|
---|
4944 |
|
---|
4945 | The flag manager provides properties with nested boolean
|
---|
4946 | subproperties representing each flag, i.e. a flag property's value
|
---|
4947 | is the binary combination of the subproperties' values. A
|
---|
4948 | property's value can be retrieved and set using the value() and
|
---|
4949 | setValue() slots respectively. The combination of flags is represented
|
---|
4950 | by single int value - that's why it's possible to store up to
|
---|
4951 | 32 independent flags in one flag property.
|
---|
4952 |
|
---|
4953 | The subproperties are created by a QtBoolPropertyManager object. This
|
---|
4954 | manager can be retrieved using the subBoolPropertyManager() function. In
|
---|
4955 | order to provide editing widgets for the subproperties in a
|
---|
4956 | property browser widget, this manager must be associated with an
|
---|
4957 | editor factory.
|
---|
4958 |
|
---|
4959 | In addition, QtFlagPropertyManager provides the valueChanged() signal
|
---|
4960 | which is emitted whenever a property created by this manager
|
---|
4961 | changes, and the flagNamesChanged() signal which is emitted
|
---|
4962 | whenever the list of flag names is altered.
|
---|
4963 |
|
---|
4964 | \sa QtAbstractPropertyManager, QtBoolPropertyManager
|
---|
4965 | */
|
---|
4966 |
|
---|
4967 | /*!
|
---|
4968 | \fn void QtFlagPropertyManager::valueChanged(QtProperty *property, int value)
|
---|
4969 |
|
---|
4970 | This signal is emitted whenever a property created by this manager
|
---|
4971 | changes its value, passing a pointer to the \a property and the new
|
---|
4972 | \a value as parameters.
|
---|
4973 |
|
---|
4974 | \sa setValue()
|
---|
4975 | */
|
---|
4976 |
|
---|
4977 | /*!
|
---|
4978 | \fn void QtFlagPropertyManager::flagNamesChanged(QtProperty *property, const QStringList &names)
|
---|
4979 |
|
---|
4980 | This signal is emitted whenever a property created by this manager
|
---|
4981 | changes its flag names, passing a pointer to the \a property and the
|
---|
4982 | new \a names as parameters.
|
---|
4983 |
|
---|
4984 | \sa setFlagNames()
|
---|
4985 | */
|
---|
4986 |
|
---|
4987 | /*!
|
---|
4988 | Creates a manager with the given \a parent.
|
---|
4989 | */
|
---|
4990 | QtFlagPropertyManager::QtFlagPropertyManager(QObject *parent)
|
---|
4991 | : QtAbstractPropertyManager(parent), d_ptr(new QtFlagPropertyManagerPrivate)
|
---|
4992 | {
|
---|
4993 | d_ptr->q_ptr = this;
|
---|
4994 |
|
---|
4995 | d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this);
|
---|
4996 | connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(QtProperty*,bool)),
|
---|
4997 | this, SLOT(slotBoolChanged(QtProperty*,bool)));
|
---|
4998 | connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
4999 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
5000 | }
|
---|
5001 |
|
---|
5002 | /*!
|
---|
5003 | Destroys this manager, and all the properties it has created.
|
---|
5004 | */
|
---|
5005 | QtFlagPropertyManager::~QtFlagPropertyManager()
|
---|
5006 | {
|
---|
5007 | clear();
|
---|
5008 | }
|
---|
5009 |
|
---|
5010 | /*!
|
---|
5011 | Returns the manager that produces the nested boolean subproperties
|
---|
5012 | representing each flag.
|
---|
5013 |
|
---|
5014 | In order to provide editing widgets for the subproperties in a
|
---|
5015 | property browser widget, this manager must be associated with an
|
---|
5016 | editor factory.
|
---|
5017 |
|
---|
5018 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
5019 | */
|
---|
5020 | QtBoolPropertyManager *QtFlagPropertyManager::subBoolPropertyManager() const
|
---|
5021 | {
|
---|
5022 | return d_ptr->m_boolPropertyManager;
|
---|
5023 | }
|
---|
5024 |
|
---|
5025 | /*!
|
---|
5026 | Returns the given \a property's value.
|
---|
5027 |
|
---|
5028 | If the given property is not managed by this manager, this
|
---|
5029 | function returns 0.
|
---|
5030 |
|
---|
5031 | \sa flagNames(), setValue()
|
---|
5032 | */
|
---|
5033 | int QtFlagPropertyManager::value(const QtProperty *property) const
|
---|
5034 | {
|
---|
5035 | return getValue<int>(d_ptr->m_values, property, 0);
|
---|
5036 | }
|
---|
5037 |
|
---|
5038 | /*!
|
---|
5039 | Returns the given \a property's list of flag names.
|
---|
5040 |
|
---|
5041 | \sa value(), setFlagNames()
|
---|
5042 | */
|
---|
5043 | QStringList QtFlagPropertyManager::flagNames(const QtProperty *property) const
|
---|
5044 | {
|
---|
5045 | return getData<QStringList>(d_ptr->m_values, &QtFlagPropertyManagerPrivate::Data::flagNames, property, QStringList());
|
---|
5046 | }
|
---|
5047 |
|
---|
5048 | /*!
|
---|
5049 | \reimp
|
---|
5050 | */
|
---|
5051 | QString QtFlagPropertyManager::valueText(const QtProperty *property) const
|
---|
5052 | {
|
---|
5053 | const QtFlagPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
5054 | if (it == d_ptr->m_values.constEnd())
|
---|
5055 | return QString();
|
---|
5056 |
|
---|
5057 | const QtFlagPropertyManagerPrivate::Data &data = it.value();
|
---|
5058 |
|
---|
5059 | QString str;
|
---|
5060 | int level = 0;
|
---|
5061 | const QChar bar = QLatin1Char('|');
|
---|
5062 | const QStringList::const_iterator fncend = data.flagNames.constEnd();
|
---|
5063 | for (QStringList::const_iterator it = data.flagNames.constBegin(); it != fncend; ++it) {
|
---|
5064 | if (data.val & (1 << level)) {
|
---|
5065 | if (!str.isEmpty())
|
---|
5066 | str += bar;
|
---|
5067 | str += *it;
|
---|
5068 | }
|
---|
5069 |
|
---|
5070 | level++;
|
---|
5071 | }
|
---|
5072 | return str;
|
---|
5073 | }
|
---|
5074 |
|
---|
5075 | /*!
|
---|
5076 | \fn void QtFlagPropertyManager::setValue(QtProperty *property, int value)
|
---|
5077 |
|
---|
5078 | Sets the value of the given \a property to \a value. Nested
|
---|
5079 | properties are updated automatically.
|
---|
5080 |
|
---|
5081 | The specified \a value must be less than the binary combination of
|
---|
5082 | the property's flagNames() list size (i.e. less than 2\sup n,
|
---|
5083 | where \c n is the size of the list) and larger than (or equal to)
|
---|
5084 | 0.
|
---|
5085 |
|
---|
5086 | \sa value(), valueChanged()
|
---|
5087 | */
|
---|
5088 | void QtFlagPropertyManager::setValue(QtProperty *property, int val)
|
---|
5089 | {
|
---|
5090 | const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
5091 | if (it == d_ptr->m_values.end())
|
---|
5092 | return;
|
---|
5093 |
|
---|
5094 | QtFlagPropertyManagerPrivate::Data data = it.value();
|
---|
5095 |
|
---|
5096 | if (data.val == val)
|
---|
5097 | return;
|
---|
5098 |
|
---|
5099 | if (val > (1 << data.flagNames.count()) - 1)
|
---|
5100 | return;
|
---|
5101 |
|
---|
5102 | if (val < 0)
|
---|
5103 | return;
|
---|
5104 |
|
---|
5105 | data.val = val;
|
---|
5106 |
|
---|
5107 | it.value() = data;
|
---|
5108 |
|
---|
5109 | QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]);
|
---|
5110 | int level = 0;
|
---|
5111 | while (itProp.hasNext()) {
|
---|
5112 | QtProperty *prop = itProp.next();
|
---|
5113 | if (prop)
|
---|
5114 | d_ptr->m_boolPropertyManager->setValue(prop, val & (1 << level));
|
---|
5115 | level++;
|
---|
5116 | }
|
---|
5117 |
|
---|
5118 | emit propertyChanged(property);
|
---|
5119 | emit valueChanged(property, data.val);
|
---|
5120 | }
|
---|
5121 |
|
---|
5122 | /*!
|
---|
5123 | Sets the given \a property's list of flag names to \a flagNames. The
|
---|
5124 | property's current value is reset to 0 indicating the first item
|
---|
5125 | of the list.
|
---|
5126 |
|
---|
5127 | \sa flagNames(), flagNamesChanged()
|
---|
5128 | */
|
---|
5129 | void QtFlagPropertyManager::setFlagNames(QtProperty *property, const QStringList &flagNames)
|
---|
5130 | {
|
---|
5131 | const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
5132 | if (it == d_ptr->m_values.end())
|
---|
5133 | return;
|
---|
5134 |
|
---|
5135 | QtFlagPropertyManagerPrivate::Data data = it.value();
|
---|
5136 |
|
---|
5137 | if (data.flagNames == flagNames)
|
---|
5138 | return;
|
---|
5139 |
|
---|
5140 | data.flagNames = flagNames;
|
---|
5141 | data.val = 0;
|
---|
5142 |
|
---|
5143 | it.value() = data;
|
---|
5144 |
|
---|
5145 | QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]);
|
---|
5146 | while (itProp.hasNext()) {
|
---|
5147 | QtProperty *prop = itProp.next();
|
---|
5148 | if (prop) {
|
---|
5149 | delete prop;
|
---|
5150 | d_ptr->m_flagToProperty.remove(prop);
|
---|
5151 | }
|
---|
5152 | }
|
---|
5153 | d_ptr->m_propertyToFlags[property].clear();
|
---|
5154 |
|
---|
5155 | QStringListIterator itFlag(flagNames);
|
---|
5156 | while (itFlag.hasNext()) {
|
---|
5157 | const QString flagName = itFlag.next();
|
---|
5158 | QtProperty *prop = d_ptr->m_boolPropertyManager->addProperty();
|
---|
5159 | prop->setPropertyName(flagName);
|
---|
5160 | property->addSubProperty(prop);
|
---|
5161 | d_ptr->m_propertyToFlags[property].append(prop);
|
---|
5162 | d_ptr->m_flagToProperty[prop] = property;
|
---|
5163 | }
|
---|
5164 |
|
---|
5165 | emit flagNamesChanged(property, data.flagNames);
|
---|
5166 |
|
---|
5167 | emit propertyChanged(property);
|
---|
5168 | emit valueChanged(property, data.val);
|
---|
5169 | }
|
---|
5170 |
|
---|
5171 | /*!
|
---|
5172 | \reimp
|
---|
5173 | */
|
---|
5174 | void QtFlagPropertyManager::initializeProperty(QtProperty *property)
|
---|
5175 | {
|
---|
5176 | d_ptr->m_values[property] = QtFlagPropertyManagerPrivate::Data();
|
---|
5177 |
|
---|
5178 | d_ptr->m_propertyToFlags[property] = QList<QtProperty *>();
|
---|
5179 | }
|
---|
5180 |
|
---|
5181 | /*!
|
---|
5182 | \reimp
|
---|
5183 | */
|
---|
5184 | void QtFlagPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
5185 | {
|
---|
5186 | QListIterator<QtProperty *> itProp(d_ptr->m_propertyToFlags[property]);
|
---|
5187 | while (itProp.hasNext()) {
|
---|
5188 | QtProperty *prop = itProp.next();
|
---|
5189 | if (prop) {
|
---|
5190 | delete prop;
|
---|
5191 | d_ptr->m_flagToProperty.remove(prop);
|
---|
5192 | }
|
---|
5193 | }
|
---|
5194 | d_ptr->m_propertyToFlags.remove(property);
|
---|
5195 |
|
---|
5196 | d_ptr->m_values.remove(property);
|
---|
5197 | }
|
---|
5198 |
|
---|
5199 | // QtSizePolicyPropertyManager
|
---|
5200 |
|
---|
5201 | class QtSizePolicyPropertyManagerPrivate
|
---|
5202 | {
|
---|
5203 | QtSizePolicyPropertyManager *q_ptr;
|
---|
5204 | Q_DECLARE_PUBLIC(QtSizePolicyPropertyManager)
|
---|
5205 | public:
|
---|
5206 |
|
---|
5207 | QtSizePolicyPropertyManagerPrivate();
|
---|
5208 |
|
---|
5209 | void slotIntChanged(QtProperty *property, int value);
|
---|
5210 | void slotEnumChanged(QtProperty *property, int value);
|
---|
5211 | void slotPropertyDestroyed(QtProperty *property);
|
---|
5212 |
|
---|
5213 | typedef QMap<const QtProperty *, QSizePolicy> PropertyValueMap;
|
---|
5214 | PropertyValueMap m_values;
|
---|
5215 |
|
---|
5216 | QtIntPropertyManager *m_intPropertyManager;
|
---|
5217 | QtEnumPropertyManager *m_enumPropertyManager;
|
---|
5218 |
|
---|
5219 | QMap<const QtProperty *, QtProperty *> m_propertyToHPolicy;
|
---|
5220 | QMap<const QtProperty *, QtProperty *> m_propertyToVPolicy;
|
---|
5221 | QMap<const QtProperty *, QtProperty *> m_propertyToHStretch;
|
---|
5222 | QMap<const QtProperty *, QtProperty *> m_propertyToVStretch;
|
---|
5223 |
|
---|
5224 | QMap<const QtProperty *, QtProperty *> m_hPolicyToProperty;
|
---|
5225 | QMap<const QtProperty *, QtProperty *> m_vPolicyToProperty;
|
---|
5226 | QMap<const QtProperty *, QtProperty *> m_hStretchToProperty;
|
---|
5227 | QMap<const QtProperty *, QtProperty *> m_vStretchToProperty;
|
---|
5228 | };
|
---|
5229 |
|
---|
5230 | QtSizePolicyPropertyManagerPrivate::QtSizePolicyPropertyManagerPrivate()
|
---|
5231 | {
|
---|
5232 | }
|
---|
5233 |
|
---|
5234 | void QtSizePolicyPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
|
---|
5235 | {
|
---|
5236 | if (QtProperty *prop = m_hStretchToProperty.value(property, 0)) {
|
---|
5237 | QSizePolicy sp = m_values[prop];
|
---|
5238 | sp.setHorizontalStretch(value);
|
---|
5239 | q_ptr->setValue(prop, sp);
|
---|
5240 | } else if (QtProperty *prop = m_vStretchToProperty.value(property, 0)) {
|
---|
5241 | QSizePolicy sp = m_values[prop];
|
---|
5242 | sp.setVerticalStretch(value);
|
---|
5243 | q_ptr->setValue(prop, sp);
|
---|
5244 | }
|
---|
5245 | }
|
---|
5246 |
|
---|
5247 | void QtSizePolicyPropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value)
|
---|
5248 | {
|
---|
5249 | if (QtProperty *prop = m_hPolicyToProperty.value(property, 0)) {
|
---|
5250 | QSizePolicy sp = m_values[prop];
|
---|
5251 | sp.setHorizontalPolicy(metaEnumProvider()->indexToSizePolicy(value));
|
---|
5252 | q_ptr->setValue(prop, sp);
|
---|
5253 | } else if (QtProperty *prop = m_vPolicyToProperty.value(property, 0)) {
|
---|
5254 | QSizePolicy sp = m_values[prop];
|
---|
5255 | sp.setVerticalPolicy(metaEnumProvider()->indexToSizePolicy(value));
|
---|
5256 | q_ptr->setValue(prop, sp);
|
---|
5257 | }
|
---|
5258 | }
|
---|
5259 |
|
---|
5260 | void QtSizePolicyPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
5261 | {
|
---|
5262 | if (QtProperty *pointProp = m_hStretchToProperty.value(property, 0)) {
|
---|
5263 | m_propertyToHStretch[pointProp] = 0;
|
---|
5264 | m_hStretchToProperty.remove(property);
|
---|
5265 | } else if (QtProperty *pointProp = m_vStretchToProperty.value(property, 0)) {
|
---|
5266 | m_propertyToVStretch[pointProp] = 0;
|
---|
5267 | m_vStretchToProperty.remove(property);
|
---|
5268 | } else if (QtProperty *pointProp = m_hPolicyToProperty.value(property, 0)) {
|
---|
5269 | m_propertyToHPolicy[pointProp] = 0;
|
---|
5270 | m_hPolicyToProperty.remove(property);
|
---|
5271 | } else if (QtProperty *pointProp = m_vPolicyToProperty.value(property, 0)) {
|
---|
5272 | m_propertyToVPolicy[pointProp] = 0;
|
---|
5273 | m_vPolicyToProperty.remove(property);
|
---|
5274 | }
|
---|
5275 | }
|
---|
5276 |
|
---|
5277 | /*!
|
---|
5278 | \class QtSizePolicyPropertyManager
|
---|
5279 | \internal
|
---|
5280 | \inmodule QtDesigner
|
---|
5281 | \since 4.4
|
---|
5282 |
|
---|
5283 | \brief The QtSizePolicyPropertyManager provides and manages QSizePolicy properties.
|
---|
5284 |
|
---|
5285 | A size policy property has nested \e horizontalPolicy, \e
|
---|
5286 | verticalPolicy, \e horizontalStretch and \e verticalStretch
|
---|
5287 | subproperties. The top-level property's value can be retrieved
|
---|
5288 | using the value() function, and set using the setValue() slot.
|
---|
5289 |
|
---|
5290 | The subproperties are created by QtIntPropertyManager and QtEnumPropertyManager
|
---|
5291 | objects. These managers can be retrieved using the subIntPropertyManager()
|
---|
5292 | and subEnumPropertyManager() functions respectively. In order to provide
|
---|
5293 | editing widgets for the subproperties in a property browser widget,
|
---|
5294 | these managers must be associated with editor factories.
|
---|
5295 |
|
---|
5296 | In addition, QtSizePolicyPropertyManager provides the valueChanged()
|
---|
5297 | signal which is emitted whenever a property created by this
|
---|
5298 | manager changes.
|
---|
5299 |
|
---|
5300 | \sa QtAbstractPropertyManager, QtIntPropertyManager, QtEnumPropertyManager
|
---|
5301 | */
|
---|
5302 |
|
---|
5303 | /*!
|
---|
5304 | \fn void QtSizePolicyPropertyManager::valueChanged(QtProperty *property, const QSizePolicy &value)
|
---|
5305 |
|
---|
5306 | This signal is emitted whenever a property created by this manager
|
---|
5307 | changes its value, passing a pointer to the \a property and the
|
---|
5308 | new \a value as parameters.
|
---|
5309 |
|
---|
5310 | \sa setValue()
|
---|
5311 | */
|
---|
5312 |
|
---|
5313 | /*!
|
---|
5314 | Creates a manager with the given \a parent.
|
---|
5315 | */
|
---|
5316 | QtSizePolicyPropertyManager::QtSizePolicyPropertyManager(QObject *parent)
|
---|
5317 | : QtAbstractPropertyManager(parent), d_ptr(new QtSizePolicyPropertyManagerPrivate)
|
---|
5318 | {
|
---|
5319 | d_ptr->q_ptr = this;
|
---|
5320 |
|
---|
5321 | d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
|
---|
5322 | connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
|
---|
5323 | this, SLOT(slotIntChanged(QtProperty*,int)));
|
---|
5324 | d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
|
---|
5325 | connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
|
---|
5326 | this, SLOT(slotEnumChanged(QtProperty*,int)));
|
---|
5327 |
|
---|
5328 | connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
5329 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
5330 | connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
5331 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
5332 | }
|
---|
5333 |
|
---|
5334 | /*!
|
---|
5335 | Destroys this manager, and all the properties it has created.
|
---|
5336 | */
|
---|
5337 | QtSizePolicyPropertyManager::~QtSizePolicyPropertyManager()
|
---|
5338 | {
|
---|
5339 | clear();
|
---|
5340 | }
|
---|
5341 |
|
---|
5342 | /*!
|
---|
5343 | Returns the manager that creates the nested \e horizontalStretch
|
---|
5344 | and \e verticalStretch subproperties.
|
---|
5345 |
|
---|
5346 | In order to provide editing widgets for the mentioned subproperties
|
---|
5347 | in a property browser widget, this manager must be associated with
|
---|
5348 | an editor factory.
|
---|
5349 |
|
---|
5350 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
5351 | */
|
---|
5352 | QtIntPropertyManager *QtSizePolicyPropertyManager::subIntPropertyManager() const
|
---|
5353 | {
|
---|
5354 | return d_ptr->m_intPropertyManager;
|
---|
5355 | }
|
---|
5356 |
|
---|
5357 | /*!
|
---|
5358 | Returns the manager that creates the nested \e horizontalPolicy
|
---|
5359 | and \e verticalPolicy subproperties.
|
---|
5360 |
|
---|
5361 | In order to provide editing widgets for the mentioned subproperties
|
---|
5362 | in a property browser widget, this manager must be associated with
|
---|
5363 | an editor factory.
|
---|
5364 |
|
---|
5365 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
5366 | */
|
---|
5367 | QtEnumPropertyManager *QtSizePolicyPropertyManager::subEnumPropertyManager() const
|
---|
5368 | {
|
---|
5369 | return d_ptr->m_enumPropertyManager;
|
---|
5370 | }
|
---|
5371 |
|
---|
5372 | /*!
|
---|
5373 | Returns the given \a property's value.
|
---|
5374 |
|
---|
5375 | If the given property is not managed by this manager, this
|
---|
5376 | function returns the default size policy.
|
---|
5377 |
|
---|
5378 | \sa setValue()
|
---|
5379 | */
|
---|
5380 | QSizePolicy QtSizePolicyPropertyManager::value(const QtProperty *property) const
|
---|
5381 | {
|
---|
5382 | return d_ptr->m_values.value(property, QSizePolicy());
|
---|
5383 | }
|
---|
5384 |
|
---|
5385 | /*!
|
---|
5386 | \reimp
|
---|
5387 | */
|
---|
5388 | QString QtSizePolicyPropertyManager::valueText(const QtProperty *property) const
|
---|
5389 | {
|
---|
5390 | const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
5391 | if (it == d_ptr->m_values.constEnd())
|
---|
5392 | return QString();
|
---|
5393 |
|
---|
5394 | const QSizePolicy sp = it.value();
|
---|
5395 | const QtMetaEnumProvider *mep = metaEnumProvider();
|
---|
5396 | const int hIndex = mep->sizePolicyToIndex(sp.horizontalPolicy());
|
---|
5397 | const int vIndex = mep->sizePolicyToIndex(sp.verticalPolicy());
|
---|
5398 | //! Unknown size policy on reading invalid uic3 files
|
---|
5399 | const QString hPolicy = hIndex != -1 ? mep->policyEnumNames().at(hIndex) : tr("<Invalid>");
|
---|
5400 | const QString vPolicy = vIndex != -1 ? mep->policyEnumNames().at(vIndex) : tr("<Invalid>");
|
---|
5401 | const QString str = tr("[%1, %2, %3, %4]").arg(hPolicy, vPolicy).arg(sp.horizontalStretch()).arg(sp.verticalStretch());
|
---|
5402 | return str;
|
---|
5403 | }
|
---|
5404 |
|
---|
5405 | /*!
|
---|
5406 | \fn void QtSizePolicyPropertyManager::setValue(QtProperty *property, const QSizePolicy &value)
|
---|
5407 |
|
---|
5408 | Sets the value of the given \a property to \a value. Nested
|
---|
5409 | properties are updated automatically.
|
---|
5410 |
|
---|
5411 | \sa value(), valueChanged()
|
---|
5412 | */
|
---|
5413 | void QtSizePolicyPropertyManager::setValue(QtProperty *property, const QSizePolicy &val)
|
---|
5414 | {
|
---|
5415 | const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
5416 | if (it == d_ptr->m_values.end())
|
---|
5417 | return;
|
---|
5418 |
|
---|
5419 | if (it.value() == val)
|
---|
5420 | return;
|
---|
5421 |
|
---|
5422 | it.value() = val;
|
---|
5423 |
|
---|
5424 | d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToHPolicy[property],
|
---|
5425 | metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy()));
|
---|
5426 | d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToVPolicy[property],
|
---|
5427 | metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy()));
|
---|
5428 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToHStretch[property],
|
---|
5429 | val.horizontalStretch());
|
---|
5430 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToVStretch[property],
|
---|
5431 | val.verticalStretch());
|
---|
5432 |
|
---|
5433 | emit propertyChanged(property);
|
---|
5434 | emit valueChanged(property, val);
|
---|
5435 | }
|
---|
5436 |
|
---|
5437 | /*!
|
---|
5438 | \reimp
|
---|
5439 | */
|
---|
5440 | void QtSizePolicyPropertyManager::initializeProperty(QtProperty *property)
|
---|
5441 | {
|
---|
5442 | QSizePolicy val;
|
---|
5443 | d_ptr->m_values[property] = val;
|
---|
5444 |
|
---|
5445 | QtProperty *hPolicyProp = d_ptr->m_enumPropertyManager->addProperty();
|
---|
5446 | hPolicyProp->setPropertyName(tr("Horizontal Policy"));
|
---|
5447 | d_ptr->m_enumPropertyManager->setEnumNames(hPolicyProp, metaEnumProvider()->policyEnumNames());
|
---|
5448 | d_ptr->m_enumPropertyManager->setValue(hPolicyProp,
|
---|
5449 | metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy()));
|
---|
5450 | d_ptr->m_propertyToHPolicy[property] = hPolicyProp;
|
---|
5451 | d_ptr->m_hPolicyToProperty[hPolicyProp] = property;
|
---|
5452 | property->addSubProperty(hPolicyProp);
|
---|
5453 |
|
---|
5454 | QtProperty *vPolicyProp = d_ptr->m_enumPropertyManager->addProperty();
|
---|
5455 | vPolicyProp->setPropertyName(tr("Vertical Policy"));
|
---|
5456 | d_ptr->m_enumPropertyManager->setEnumNames(vPolicyProp, metaEnumProvider()->policyEnumNames());
|
---|
5457 | d_ptr->m_enumPropertyManager->setValue(vPolicyProp,
|
---|
5458 | metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy()));
|
---|
5459 | d_ptr->m_propertyToVPolicy[property] = vPolicyProp;
|
---|
5460 | d_ptr->m_vPolicyToProperty[vPolicyProp] = property;
|
---|
5461 | property->addSubProperty(vPolicyProp);
|
---|
5462 |
|
---|
5463 | QtProperty *hStretchProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
5464 | hStretchProp->setPropertyName(tr("Horizontal Stretch"));
|
---|
5465 | d_ptr->m_intPropertyManager->setValue(hStretchProp, val.horizontalStretch());
|
---|
5466 | d_ptr->m_intPropertyManager->setRange(hStretchProp, 0, 0xff);
|
---|
5467 | d_ptr->m_propertyToHStretch[property] = hStretchProp;
|
---|
5468 | d_ptr->m_hStretchToProperty[hStretchProp] = property;
|
---|
5469 | property->addSubProperty(hStretchProp);
|
---|
5470 |
|
---|
5471 | QtProperty *vStretchProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
5472 | vStretchProp->setPropertyName(tr("Vertical Stretch"));
|
---|
5473 | d_ptr->m_intPropertyManager->setValue(vStretchProp, val.verticalStretch());
|
---|
5474 | d_ptr->m_intPropertyManager->setRange(vStretchProp, 0, 0xff);
|
---|
5475 | d_ptr->m_propertyToVStretch[property] = vStretchProp;
|
---|
5476 | d_ptr->m_vStretchToProperty[vStretchProp] = property;
|
---|
5477 | property->addSubProperty(vStretchProp);
|
---|
5478 |
|
---|
5479 | }
|
---|
5480 |
|
---|
5481 | /*!
|
---|
5482 | \reimp
|
---|
5483 | */
|
---|
5484 | void QtSizePolicyPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
5485 | {
|
---|
5486 | QtProperty *hPolicyProp = d_ptr->m_propertyToHPolicy[property];
|
---|
5487 | if (hPolicyProp) {
|
---|
5488 | d_ptr->m_hPolicyToProperty.remove(hPolicyProp);
|
---|
5489 | delete hPolicyProp;
|
---|
5490 | }
|
---|
5491 | d_ptr->m_propertyToHPolicy.remove(property);
|
---|
5492 |
|
---|
5493 | QtProperty *vPolicyProp = d_ptr->m_propertyToVPolicy[property];
|
---|
5494 | if (vPolicyProp) {
|
---|
5495 | d_ptr->m_vPolicyToProperty.remove(vPolicyProp);
|
---|
5496 | delete vPolicyProp;
|
---|
5497 | }
|
---|
5498 | d_ptr->m_propertyToVPolicy.remove(property);
|
---|
5499 |
|
---|
5500 | QtProperty *hStretchProp = d_ptr->m_propertyToHStretch[property];
|
---|
5501 | if (hStretchProp) {
|
---|
5502 | d_ptr->m_hStretchToProperty.remove(hStretchProp);
|
---|
5503 | delete hStretchProp;
|
---|
5504 | }
|
---|
5505 | d_ptr->m_propertyToHStretch.remove(property);
|
---|
5506 |
|
---|
5507 | QtProperty *vStretchProp = d_ptr->m_propertyToVStretch[property];
|
---|
5508 | if (vStretchProp) {
|
---|
5509 | d_ptr->m_vStretchToProperty.remove(vStretchProp);
|
---|
5510 | delete vStretchProp;
|
---|
5511 | }
|
---|
5512 | d_ptr->m_propertyToVStretch.remove(property);
|
---|
5513 |
|
---|
5514 | d_ptr->m_values.remove(property);
|
---|
5515 | }
|
---|
5516 |
|
---|
5517 | // QtFontPropertyManager:
|
---|
5518 | // QtFontPropertyManagerPrivate has a mechanism for reacting
|
---|
5519 | // to QApplication::fontDatabaseChanged() [4.5], which is emitted
|
---|
5520 | // when someone loads an application font. The signals are compressed
|
---|
5521 | // using a timer with interval 0, which then causes the family
|
---|
5522 | // enumeration manager to re-set its strings and index values
|
---|
5523 | // for each property.
|
---|
5524 |
|
---|
5525 | Q_GLOBAL_STATIC(QFontDatabase, fontDatabase)
|
---|
5526 |
|
---|
5527 | class QtFontPropertyManagerPrivate
|
---|
5528 | {
|
---|
5529 | QtFontPropertyManager *q_ptr;
|
---|
5530 | Q_DECLARE_PUBLIC(QtFontPropertyManager)
|
---|
5531 | public:
|
---|
5532 |
|
---|
5533 | QtFontPropertyManagerPrivate();
|
---|
5534 |
|
---|
5535 | void slotIntChanged(QtProperty *property, int value);
|
---|
5536 | void slotEnumChanged(QtProperty *property, int value);
|
---|
5537 | void slotBoolChanged(QtProperty *property, bool value);
|
---|
5538 | void slotPropertyDestroyed(QtProperty *property);
|
---|
5539 | void slotFontDatabaseChanged();
|
---|
5540 | void slotFontDatabaseDelayedChange();
|
---|
5541 |
|
---|
5542 | QStringList m_familyNames;
|
---|
5543 |
|
---|
5544 | typedef QMap<const QtProperty *, QFont> PropertyValueMap;
|
---|
5545 | PropertyValueMap m_values;
|
---|
5546 |
|
---|
5547 | QtIntPropertyManager *m_intPropertyManager;
|
---|
5548 | QtEnumPropertyManager *m_enumPropertyManager;
|
---|
5549 | QtBoolPropertyManager *m_boolPropertyManager;
|
---|
5550 |
|
---|
5551 | QMap<const QtProperty *, QtProperty *> m_propertyToFamily;
|
---|
5552 | QMap<const QtProperty *, QtProperty *> m_propertyToPointSize;
|
---|
5553 | QMap<const QtProperty *, QtProperty *> m_propertyToBold;
|
---|
5554 | QMap<const QtProperty *, QtProperty *> m_propertyToItalic;
|
---|
5555 | QMap<const QtProperty *, QtProperty *> m_propertyToUnderline;
|
---|
5556 | QMap<const QtProperty *, QtProperty *> m_propertyToStrikeOut;
|
---|
5557 | QMap<const QtProperty *, QtProperty *> m_propertyToKerning;
|
---|
5558 |
|
---|
5559 | QMap<const QtProperty *, QtProperty *> m_familyToProperty;
|
---|
5560 | QMap<const QtProperty *, QtProperty *> m_pointSizeToProperty;
|
---|
5561 | QMap<const QtProperty *, QtProperty *> m_boldToProperty;
|
---|
5562 | QMap<const QtProperty *, QtProperty *> m_italicToProperty;
|
---|
5563 | QMap<const QtProperty *, QtProperty *> m_underlineToProperty;
|
---|
5564 | QMap<const QtProperty *, QtProperty *> m_strikeOutToProperty;
|
---|
5565 | QMap<const QtProperty *, QtProperty *> m_kerningToProperty;
|
---|
5566 |
|
---|
5567 | bool m_settingValue;
|
---|
5568 | QTimer *m_fontDatabaseChangeTimer;
|
---|
5569 | };
|
---|
5570 |
|
---|
5571 | QtFontPropertyManagerPrivate::QtFontPropertyManagerPrivate() :
|
---|
5572 | m_settingValue(false),
|
---|
5573 | m_fontDatabaseChangeTimer(0)
|
---|
5574 | {
|
---|
5575 | }
|
---|
5576 |
|
---|
5577 | void QtFontPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
|
---|
5578 | {
|
---|
5579 | if (m_settingValue)
|
---|
5580 | return;
|
---|
5581 | if (QtProperty *prop = m_pointSizeToProperty.value(property, 0)) {
|
---|
5582 | QFont f = m_values[prop];
|
---|
5583 | f.setPointSize(value);
|
---|
5584 | q_ptr->setValue(prop, f);
|
---|
5585 | }
|
---|
5586 | }
|
---|
5587 |
|
---|
5588 | void QtFontPropertyManagerPrivate::slotEnumChanged(QtProperty *property, int value)
|
---|
5589 | {
|
---|
5590 | if (m_settingValue)
|
---|
5591 | return;
|
---|
5592 | if (QtProperty *prop = m_familyToProperty.value(property, 0)) {
|
---|
5593 | QFont f = m_values[prop];
|
---|
5594 | f.setFamily(m_familyNames.at(value));
|
---|
5595 | q_ptr->setValue(prop, f);
|
---|
5596 | }
|
---|
5597 | }
|
---|
5598 |
|
---|
5599 | void QtFontPropertyManagerPrivate::slotBoolChanged(QtProperty *property, bool value)
|
---|
5600 | {
|
---|
5601 | if (m_settingValue)
|
---|
5602 | return;
|
---|
5603 | if (QtProperty *prop = m_boldToProperty.value(property, 0)) {
|
---|
5604 | QFont f = m_values[prop];
|
---|
5605 | f.setBold(value);
|
---|
5606 | q_ptr->setValue(prop, f);
|
---|
5607 | } else if (QtProperty *prop = m_italicToProperty.value(property, 0)) {
|
---|
5608 | QFont f = m_values[prop];
|
---|
5609 | f.setItalic(value);
|
---|
5610 | q_ptr->setValue(prop, f);
|
---|
5611 | } else if (QtProperty *prop = m_underlineToProperty.value(property, 0)) {
|
---|
5612 | QFont f = m_values[prop];
|
---|
5613 | f.setUnderline(value);
|
---|
5614 | q_ptr->setValue(prop, f);
|
---|
5615 | } else if (QtProperty *prop = m_strikeOutToProperty.value(property, 0)) {
|
---|
5616 | QFont f = m_values[prop];
|
---|
5617 | f.setStrikeOut(value);
|
---|
5618 | q_ptr->setValue(prop, f);
|
---|
5619 | } else if (QtProperty *prop = m_kerningToProperty.value(property, 0)) {
|
---|
5620 | QFont f = m_values[prop];
|
---|
5621 | f.setKerning(value);
|
---|
5622 | q_ptr->setValue(prop, f);
|
---|
5623 | }
|
---|
5624 | }
|
---|
5625 |
|
---|
5626 | void QtFontPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
5627 | {
|
---|
5628 | if (QtProperty *pointProp = m_pointSizeToProperty.value(property, 0)) {
|
---|
5629 | m_propertyToPointSize[pointProp] = 0;
|
---|
5630 | m_pointSizeToProperty.remove(property);
|
---|
5631 | } else if (QtProperty *pointProp = m_familyToProperty.value(property, 0)) {
|
---|
5632 | m_propertyToFamily[pointProp] = 0;
|
---|
5633 | m_familyToProperty.remove(property);
|
---|
5634 | } else if (QtProperty *pointProp = m_boldToProperty.value(property, 0)) {
|
---|
5635 | m_propertyToBold[pointProp] = 0;
|
---|
5636 | m_boldToProperty.remove(property);
|
---|
5637 | } else if (QtProperty *pointProp = m_italicToProperty.value(property, 0)) {
|
---|
5638 | m_propertyToItalic[pointProp] = 0;
|
---|
5639 | m_italicToProperty.remove(property);
|
---|
5640 | } else if (QtProperty *pointProp = m_underlineToProperty.value(property, 0)) {
|
---|
5641 | m_propertyToUnderline[pointProp] = 0;
|
---|
5642 | m_underlineToProperty.remove(property);
|
---|
5643 | } else if (QtProperty *pointProp = m_strikeOutToProperty.value(property, 0)) {
|
---|
5644 | m_propertyToStrikeOut[pointProp] = 0;
|
---|
5645 | m_strikeOutToProperty.remove(property);
|
---|
5646 | } else if (QtProperty *pointProp = m_kerningToProperty.value(property, 0)) {
|
---|
5647 | m_propertyToKerning[pointProp] = 0;
|
---|
5648 | m_kerningToProperty.remove(property);
|
---|
5649 | }
|
---|
5650 | }
|
---|
5651 |
|
---|
5652 | void QtFontPropertyManagerPrivate::slotFontDatabaseChanged()
|
---|
5653 | {
|
---|
5654 | if (!m_fontDatabaseChangeTimer) {
|
---|
5655 | m_fontDatabaseChangeTimer = new QTimer(q_ptr);
|
---|
5656 | m_fontDatabaseChangeTimer->setInterval(0);
|
---|
5657 | m_fontDatabaseChangeTimer->setSingleShot(true);
|
---|
5658 | QObject::connect(m_fontDatabaseChangeTimer, SIGNAL(timeout()), q_ptr, SLOT(slotFontDatabaseDelayedChange()));
|
---|
5659 | }
|
---|
5660 | if (!m_fontDatabaseChangeTimer->isActive())
|
---|
5661 | m_fontDatabaseChangeTimer->start();
|
---|
5662 | }
|
---|
5663 |
|
---|
5664 | void QtFontPropertyManagerPrivate::slotFontDatabaseDelayedChange()
|
---|
5665 | {
|
---|
5666 | typedef QMap<const QtProperty *, QtProperty *> PropertyPropertyMap;
|
---|
5667 | // rescan available font names
|
---|
5668 | const QStringList oldFamilies = m_familyNames;
|
---|
5669 | m_familyNames = fontDatabase()->families();
|
---|
5670 |
|
---|
5671 | // Adapt all existing properties
|
---|
5672 | if (!m_propertyToFamily.empty()) {
|
---|
5673 | PropertyPropertyMap::const_iterator cend = m_propertyToFamily.constEnd();
|
---|
5674 | for (PropertyPropertyMap::const_iterator it = m_propertyToFamily.constBegin(); it != cend; ++it) {
|
---|
5675 | QtProperty *familyProp = it.value();
|
---|
5676 | const int oldIdx = m_enumPropertyManager->value(familyProp);
|
---|
5677 | int newIdx = m_familyNames.indexOf(oldFamilies.at(oldIdx));
|
---|
5678 | if (newIdx < 0)
|
---|
5679 | newIdx = 0;
|
---|
5680 | m_enumPropertyManager->setEnumNames(familyProp, m_familyNames);
|
---|
5681 | m_enumPropertyManager->setValue(familyProp, newIdx);
|
---|
5682 | }
|
---|
5683 | }
|
---|
5684 | }
|
---|
5685 |
|
---|
5686 | /*!
|
---|
5687 | \class QtFontPropertyManager
|
---|
5688 | \internal
|
---|
5689 | \inmodule QtDesigner
|
---|
5690 | \since 4.4
|
---|
5691 |
|
---|
5692 | \brief The QtFontPropertyManager provides and manages QFont properties.
|
---|
5693 |
|
---|
5694 | A font property has nested \e family, \e pointSize, \e bold, \e
|
---|
5695 | italic, \e underline, \e strikeOut and \e kerning subproperties. The top-level
|
---|
5696 | property's value can be retrieved using the value() function, and
|
---|
5697 | set using the setValue() slot.
|
---|
5698 |
|
---|
5699 | The subproperties are created by QtIntPropertyManager, QtEnumPropertyManager and
|
---|
5700 | QtBoolPropertyManager objects. These managers can be retrieved using the
|
---|
5701 | corresponding subIntPropertyManager(), subEnumPropertyManager() and
|
---|
5702 | subBoolPropertyManager() functions. In order to provide editing widgets
|
---|
5703 | for the subproperties in a property browser widget, these managers
|
---|
5704 | must be associated with editor factories.
|
---|
5705 |
|
---|
5706 | In addition, QtFontPropertyManager provides the valueChanged() signal
|
---|
5707 | which is emitted whenever a property created by this manager
|
---|
5708 | changes.
|
---|
5709 |
|
---|
5710 | \sa QtAbstractPropertyManager, QtEnumPropertyManager, QtIntPropertyManager, QtBoolPropertyManager
|
---|
5711 | */
|
---|
5712 |
|
---|
5713 | /*!
|
---|
5714 | \fn void QtFontPropertyManager::valueChanged(QtProperty *property, const QFont &value)
|
---|
5715 |
|
---|
5716 | This signal is emitted whenever a property created by this manager
|
---|
5717 | changes its value, passing a pointer to the \a property and the
|
---|
5718 | new \a value as parameters.
|
---|
5719 |
|
---|
5720 | \sa setValue()
|
---|
5721 | */
|
---|
5722 |
|
---|
5723 | /*!
|
---|
5724 | Creates a manager with the given \a parent.
|
---|
5725 | */
|
---|
5726 | QtFontPropertyManager::QtFontPropertyManager(QObject *parent)
|
---|
5727 | : QtAbstractPropertyManager(parent), d_ptr(new QtFontPropertyManagerPrivate)
|
---|
5728 | {
|
---|
5729 | d_ptr->q_ptr = this;
|
---|
5730 | QObject::connect(qApp, SIGNAL(fontDatabaseChanged()), this, SLOT(slotFontDatabaseChanged()));
|
---|
5731 |
|
---|
5732 | d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
|
---|
5733 | connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
|
---|
5734 | this, SLOT(slotIntChanged(QtProperty*,int)));
|
---|
5735 | d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
|
---|
5736 | connect(d_ptr->m_enumPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
|
---|
5737 | this, SLOT(slotEnumChanged(QtProperty*,int)));
|
---|
5738 | d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this);
|
---|
5739 | connect(d_ptr->m_boolPropertyManager, SIGNAL(valueChanged(QtProperty*,bool)),
|
---|
5740 | this, SLOT(slotBoolChanged(QtProperty*,bool)));
|
---|
5741 |
|
---|
5742 | connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
5743 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
5744 | connect(d_ptr->m_enumPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
5745 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
5746 | connect(d_ptr->m_boolPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
5747 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
5748 | }
|
---|
5749 |
|
---|
5750 | /*!
|
---|
5751 | Destroys this manager, and all the properties it has created.
|
---|
5752 | */
|
---|
5753 | QtFontPropertyManager::~QtFontPropertyManager()
|
---|
5754 | {
|
---|
5755 | clear();
|
---|
5756 | }
|
---|
5757 |
|
---|
5758 | /*!
|
---|
5759 | Returns the manager that creates the \e pointSize subproperty.
|
---|
5760 |
|
---|
5761 | In order to provide editing widgets for the \e pointSize property
|
---|
5762 | in a property browser widget, this manager must be associated
|
---|
5763 | with an editor factory.
|
---|
5764 |
|
---|
5765 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
5766 | */
|
---|
5767 | QtIntPropertyManager *QtFontPropertyManager::subIntPropertyManager() const
|
---|
5768 | {
|
---|
5769 | return d_ptr->m_intPropertyManager;
|
---|
5770 | }
|
---|
5771 |
|
---|
5772 | /*!
|
---|
5773 | Returns the manager that create the \e family subproperty.
|
---|
5774 |
|
---|
5775 | In order to provide editing widgets for the \e family property
|
---|
5776 | in a property browser widget, this manager must be associated
|
---|
5777 | with an editor factory.
|
---|
5778 |
|
---|
5779 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
5780 | */
|
---|
5781 | QtEnumPropertyManager *QtFontPropertyManager::subEnumPropertyManager() const
|
---|
5782 | {
|
---|
5783 | return d_ptr->m_enumPropertyManager;
|
---|
5784 | }
|
---|
5785 |
|
---|
5786 | /*!
|
---|
5787 | Returns the manager that creates the \e bold, \e italic, \e underline,
|
---|
5788 | \e strikeOut and \e kerning subproperties.
|
---|
5789 |
|
---|
5790 | In order to provide editing widgets for the mentioned properties
|
---|
5791 | in a property browser widget, this manager must be associated with
|
---|
5792 | an editor factory.
|
---|
5793 |
|
---|
5794 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
5795 | */
|
---|
5796 | QtBoolPropertyManager *QtFontPropertyManager::subBoolPropertyManager() const
|
---|
5797 | {
|
---|
5798 | return d_ptr->m_boolPropertyManager;
|
---|
5799 | }
|
---|
5800 |
|
---|
5801 | /*!
|
---|
5802 | Returns the given \a property's value.
|
---|
5803 |
|
---|
5804 | If the given property is not managed by this manager, this
|
---|
5805 | function returns a font object that uses the application's default
|
---|
5806 | font.
|
---|
5807 |
|
---|
5808 | \sa setValue()
|
---|
5809 | */
|
---|
5810 | QFont QtFontPropertyManager::value(const QtProperty *property) const
|
---|
5811 | {
|
---|
5812 | return d_ptr->m_values.value(property, QFont());
|
---|
5813 | }
|
---|
5814 |
|
---|
5815 | /*!
|
---|
5816 | \reimp
|
---|
5817 | */
|
---|
5818 | QString QtFontPropertyManager::valueText(const QtProperty *property) const
|
---|
5819 | {
|
---|
5820 | const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
5821 | if (it == d_ptr->m_values.constEnd())
|
---|
5822 | return QString();
|
---|
5823 |
|
---|
5824 | return QtPropertyBrowserUtils::fontValueText(it.value());
|
---|
5825 | }
|
---|
5826 |
|
---|
5827 | /*!
|
---|
5828 | \reimp
|
---|
5829 | */
|
---|
5830 | QIcon QtFontPropertyManager::valueIcon(const QtProperty *property) const
|
---|
5831 | {
|
---|
5832 | const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
5833 | if (it == d_ptr->m_values.constEnd())
|
---|
5834 | return QIcon();
|
---|
5835 |
|
---|
5836 | return QtPropertyBrowserUtils::fontValueIcon(it.value());
|
---|
5837 | }
|
---|
5838 |
|
---|
5839 | /*!
|
---|
5840 | \fn void QtFontPropertyManager::setValue(QtProperty *property, const QFont &value)
|
---|
5841 |
|
---|
5842 | Sets the value of the given \a property to \a value. Nested
|
---|
5843 | properties are updated automatically.
|
---|
5844 |
|
---|
5845 | \sa value(), valueChanged()
|
---|
5846 | */
|
---|
5847 | void QtFontPropertyManager::setValue(QtProperty *property, const QFont &val)
|
---|
5848 | {
|
---|
5849 | const QtFontPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
5850 | if (it == d_ptr->m_values.end())
|
---|
5851 | return;
|
---|
5852 |
|
---|
5853 | const QFont oldVal = it.value();
|
---|
5854 | if (oldVal == val && oldVal.resolve() == val.resolve())
|
---|
5855 | return;
|
---|
5856 |
|
---|
5857 | it.value() = val;
|
---|
5858 |
|
---|
5859 | int idx = d_ptr->m_familyNames.indexOf(val.family());
|
---|
5860 | if (idx == -1)
|
---|
5861 | idx = 0;
|
---|
5862 | bool settingValue = d_ptr->m_settingValue;
|
---|
5863 | d_ptr->m_settingValue = true;
|
---|
5864 | d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToFamily[property], idx);
|
---|
5865 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToPointSize[property], val.pointSize());
|
---|
5866 | d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToBold[property], val.bold());
|
---|
5867 | d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToItalic[property], val.italic());
|
---|
5868 | d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToUnderline[property], val.underline());
|
---|
5869 | d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToStrikeOut[property], val.strikeOut());
|
---|
5870 | d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToKerning[property], val.kerning());
|
---|
5871 | d_ptr->m_settingValue = settingValue;
|
---|
5872 |
|
---|
5873 | emit propertyChanged(property);
|
---|
5874 | emit valueChanged(property, val);
|
---|
5875 | }
|
---|
5876 |
|
---|
5877 | /*!
|
---|
5878 | \reimp
|
---|
5879 | */
|
---|
5880 | void QtFontPropertyManager::initializeProperty(QtProperty *property)
|
---|
5881 | {
|
---|
5882 | QFont val;
|
---|
5883 | d_ptr->m_values[property] = val;
|
---|
5884 |
|
---|
5885 | QtProperty *familyProp = d_ptr->m_enumPropertyManager->addProperty();
|
---|
5886 | familyProp->setPropertyName(tr("Family"));
|
---|
5887 | if (d_ptr->m_familyNames.empty())
|
---|
5888 | d_ptr->m_familyNames = fontDatabase()->families();
|
---|
5889 | d_ptr->m_enumPropertyManager->setEnumNames(familyProp, d_ptr->m_familyNames);
|
---|
5890 | int idx = d_ptr->m_familyNames.indexOf(val.family());
|
---|
5891 | if (idx == -1)
|
---|
5892 | idx = 0;
|
---|
5893 | d_ptr->m_enumPropertyManager->setValue(familyProp, idx);
|
---|
5894 | d_ptr->m_propertyToFamily[property] = familyProp;
|
---|
5895 | d_ptr->m_familyToProperty[familyProp] = property;
|
---|
5896 | property->addSubProperty(familyProp);
|
---|
5897 |
|
---|
5898 | QtProperty *pointSizeProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
5899 | pointSizeProp->setPropertyName(tr("Point Size"));
|
---|
5900 | d_ptr->m_intPropertyManager->setValue(pointSizeProp, val.pointSize());
|
---|
5901 | d_ptr->m_intPropertyManager->setMinimum(pointSizeProp, 1);
|
---|
5902 | d_ptr->m_propertyToPointSize[property] = pointSizeProp;
|
---|
5903 | d_ptr->m_pointSizeToProperty[pointSizeProp] = property;
|
---|
5904 | property->addSubProperty(pointSizeProp);
|
---|
5905 |
|
---|
5906 | QtProperty *boldProp = d_ptr->m_boolPropertyManager->addProperty();
|
---|
5907 | boldProp->setPropertyName(tr("Bold"));
|
---|
5908 | d_ptr->m_boolPropertyManager->setValue(boldProp, val.bold());
|
---|
5909 | d_ptr->m_propertyToBold[property] = boldProp;
|
---|
5910 | d_ptr->m_boldToProperty[boldProp] = property;
|
---|
5911 | property->addSubProperty(boldProp);
|
---|
5912 |
|
---|
5913 | QtProperty *italicProp = d_ptr->m_boolPropertyManager->addProperty();
|
---|
5914 | italicProp->setPropertyName(tr("Italic"));
|
---|
5915 | d_ptr->m_boolPropertyManager->setValue(italicProp, val.italic());
|
---|
5916 | d_ptr->m_propertyToItalic[property] = italicProp;
|
---|
5917 | d_ptr->m_italicToProperty[italicProp] = property;
|
---|
5918 | property->addSubProperty(italicProp);
|
---|
5919 |
|
---|
5920 | QtProperty *underlineProp = d_ptr->m_boolPropertyManager->addProperty();
|
---|
5921 | underlineProp->setPropertyName(tr("Underline"));
|
---|
5922 | d_ptr->m_boolPropertyManager->setValue(underlineProp, val.underline());
|
---|
5923 | d_ptr->m_propertyToUnderline[property] = underlineProp;
|
---|
5924 | d_ptr->m_underlineToProperty[underlineProp] = property;
|
---|
5925 | property->addSubProperty(underlineProp);
|
---|
5926 |
|
---|
5927 | QtProperty *strikeOutProp = d_ptr->m_boolPropertyManager->addProperty();
|
---|
5928 | strikeOutProp->setPropertyName(tr("Strikeout"));
|
---|
5929 | d_ptr->m_boolPropertyManager->setValue(strikeOutProp, val.strikeOut());
|
---|
5930 | d_ptr->m_propertyToStrikeOut[property] = strikeOutProp;
|
---|
5931 | d_ptr->m_strikeOutToProperty[strikeOutProp] = property;
|
---|
5932 | property->addSubProperty(strikeOutProp);
|
---|
5933 |
|
---|
5934 | QtProperty *kerningProp = d_ptr->m_boolPropertyManager->addProperty();
|
---|
5935 | kerningProp->setPropertyName(tr("Kerning"));
|
---|
5936 | d_ptr->m_boolPropertyManager->setValue(kerningProp, val.kerning());
|
---|
5937 | d_ptr->m_propertyToKerning[property] = kerningProp;
|
---|
5938 | d_ptr->m_kerningToProperty[kerningProp] = property;
|
---|
5939 | property->addSubProperty(kerningProp);
|
---|
5940 | }
|
---|
5941 |
|
---|
5942 | /*!
|
---|
5943 | \reimp
|
---|
5944 | */
|
---|
5945 | void QtFontPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
5946 | {
|
---|
5947 | QtProperty *familyProp = d_ptr->m_propertyToFamily[property];
|
---|
5948 | if (familyProp) {
|
---|
5949 | d_ptr->m_familyToProperty.remove(familyProp);
|
---|
5950 | delete familyProp;
|
---|
5951 | }
|
---|
5952 | d_ptr->m_propertyToFamily.remove(property);
|
---|
5953 |
|
---|
5954 | QtProperty *pointSizeProp = d_ptr->m_propertyToPointSize[property];
|
---|
5955 | if (pointSizeProp) {
|
---|
5956 | d_ptr->m_pointSizeToProperty.remove(pointSizeProp);
|
---|
5957 | delete pointSizeProp;
|
---|
5958 | }
|
---|
5959 | d_ptr->m_propertyToPointSize.remove(property);
|
---|
5960 |
|
---|
5961 | QtProperty *boldProp = d_ptr->m_propertyToBold[property];
|
---|
5962 | if (boldProp) {
|
---|
5963 | d_ptr->m_boldToProperty.remove(boldProp);
|
---|
5964 | delete boldProp;
|
---|
5965 | }
|
---|
5966 | d_ptr->m_propertyToBold.remove(property);
|
---|
5967 |
|
---|
5968 | QtProperty *italicProp = d_ptr->m_propertyToItalic[property];
|
---|
5969 | if (italicProp) {
|
---|
5970 | d_ptr->m_italicToProperty.remove(italicProp);
|
---|
5971 | delete italicProp;
|
---|
5972 | }
|
---|
5973 | d_ptr->m_propertyToItalic.remove(property);
|
---|
5974 |
|
---|
5975 | QtProperty *underlineProp = d_ptr->m_propertyToUnderline[property];
|
---|
5976 | if (underlineProp) {
|
---|
5977 | d_ptr->m_underlineToProperty.remove(underlineProp);
|
---|
5978 | delete underlineProp;
|
---|
5979 | }
|
---|
5980 | d_ptr->m_propertyToUnderline.remove(property);
|
---|
5981 |
|
---|
5982 | QtProperty *strikeOutProp = d_ptr->m_propertyToStrikeOut[property];
|
---|
5983 | if (strikeOutProp) {
|
---|
5984 | d_ptr->m_strikeOutToProperty.remove(strikeOutProp);
|
---|
5985 | delete strikeOutProp;
|
---|
5986 | }
|
---|
5987 | d_ptr->m_propertyToStrikeOut.remove(property);
|
---|
5988 |
|
---|
5989 | QtProperty *kerningProp = d_ptr->m_propertyToKerning[property];
|
---|
5990 | if (kerningProp) {
|
---|
5991 | d_ptr->m_kerningToProperty.remove(kerningProp);
|
---|
5992 | delete kerningProp;
|
---|
5993 | }
|
---|
5994 | d_ptr->m_propertyToKerning.remove(property);
|
---|
5995 |
|
---|
5996 | d_ptr->m_values.remove(property);
|
---|
5997 | }
|
---|
5998 |
|
---|
5999 | // QtColorPropertyManager
|
---|
6000 |
|
---|
6001 | class QtColorPropertyManagerPrivate
|
---|
6002 | {
|
---|
6003 | QtColorPropertyManager *q_ptr;
|
---|
6004 | Q_DECLARE_PUBLIC(QtColorPropertyManager)
|
---|
6005 | public:
|
---|
6006 |
|
---|
6007 | void slotIntChanged(QtProperty *property, int value);
|
---|
6008 | void slotPropertyDestroyed(QtProperty *property);
|
---|
6009 |
|
---|
6010 | typedef QMap<const QtProperty *, QColor> PropertyValueMap;
|
---|
6011 | PropertyValueMap m_values;
|
---|
6012 |
|
---|
6013 | QtIntPropertyManager *m_intPropertyManager;
|
---|
6014 |
|
---|
6015 | QMap<const QtProperty *, QtProperty *> m_propertyToR;
|
---|
6016 | QMap<const QtProperty *, QtProperty *> m_propertyToG;
|
---|
6017 | QMap<const QtProperty *, QtProperty *> m_propertyToB;
|
---|
6018 | QMap<const QtProperty *, QtProperty *> m_propertyToA;
|
---|
6019 |
|
---|
6020 | QMap<const QtProperty *, QtProperty *> m_rToProperty;
|
---|
6021 | QMap<const QtProperty *, QtProperty *> m_gToProperty;
|
---|
6022 | QMap<const QtProperty *, QtProperty *> m_bToProperty;
|
---|
6023 | QMap<const QtProperty *, QtProperty *> m_aToProperty;
|
---|
6024 | };
|
---|
6025 |
|
---|
6026 | void QtColorPropertyManagerPrivate::slotIntChanged(QtProperty *property, int value)
|
---|
6027 | {
|
---|
6028 | if (QtProperty *prop = m_rToProperty.value(property, 0)) {
|
---|
6029 | QColor c = m_values[prop];
|
---|
6030 | c.setRed(value);
|
---|
6031 | q_ptr->setValue(prop, c);
|
---|
6032 | } else if (QtProperty *prop = m_gToProperty.value(property, 0)) {
|
---|
6033 | QColor c = m_values[prop];
|
---|
6034 | c.setGreen(value);
|
---|
6035 | q_ptr->setValue(prop, c);
|
---|
6036 | } else if (QtProperty *prop = m_bToProperty.value(property, 0)) {
|
---|
6037 | QColor c = m_values[prop];
|
---|
6038 | c.setBlue(value);
|
---|
6039 | q_ptr->setValue(prop, c);
|
---|
6040 | } else if (QtProperty *prop = m_aToProperty.value(property, 0)) {
|
---|
6041 | QColor c = m_values[prop];
|
---|
6042 | c.setAlpha(value);
|
---|
6043 | q_ptr->setValue(prop, c);
|
---|
6044 | }
|
---|
6045 | }
|
---|
6046 |
|
---|
6047 | void QtColorPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property)
|
---|
6048 | {
|
---|
6049 | if (QtProperty *pointProp = m_rToProperty.value(property, 0)) {
|
---|
6050 | m_propertyToR[pointProp] = 0;
|
---|
6051 | m_rToProperty.remove(property);
|
---|
6052 | } else if (QtProperty *pointProp = m_gToProperty.value(property, 0)) {
|
---|
6053 | m_propertyToG[pointProp] = 0;
|
---|
6054 | m_gToProperty.remove(property);
|
---|
6055 | } else if (QtProperty *pointProp = m_bToProperty.value(property, 0)) {
|
---|
6056 | m_propertyToB[pointProp] = 0;
|
---|
6057 | m_bToProperty.remove(property);
|
---|
6058 | } else if (QtProperty *pointProp = m_aToProperty.value(property, 0)) {
|
---|
6059 | m_propertyToA[pointProp] = 0;
|
---|
6060 | m_aToProperty.remove(property);
|
---|
6061 | }
|
---|
6062 | }
|
---|
6063 |
|
---|
6064 | /*!
|
---|
6065 | \class QtColorPropertyManager
|
---|
6066 | \internal
|
---|
6067 | \inmodule QtDesigner
|
---|
6068 | \since 4.4
|
---|
6069 |
|
---|
6070 | \brief The QtColorPropertyManager provides and manages QColor properties.
|
---|
6071 |
|
---|
6072 | A color property has nested \e red, \e green and \e blue
|
---|
6073 | subproperties. The top-level property's value can be retrieved
|
---|
6074 | using the value() function, and set using the setValue() slot.
|
---|
6075 |
|
---|
6076 | The subproperties are created by a QtIntPropertyManager object. This
|
---|
6077 | manager can be retrieved using the subIntPropertyManager() function. In
|
---|
6078 | order to provide editing widgets for the subproperties in a
|
---|
6079 | property browser widget, this manager must be associated with an
|
---|
6080 | editor factory.
|
---|
6081 |
|
---|
6082 | In addition, QtColorPropertyManager provides the valueChanged() signal
|
---|
6083 | which is emitted whenever a property created by this manager
|
---|
6084 | changes.
|
---|
6085 |
|
---|
6086 | \sa QtAbstractPropertyManager, QtAbstractPropertyBrowser, QtIntPropertyManager
|
---|
6087 | */
|
---|
6088 |
|
---|
6089 | /*!
|
---|
6090 | \fn void QtColorPropertyManager::valueChanged(QtProperty *property, const QColor &value)
|
---|
6091 |
|
---|
6092 | This signal is emitted whenever a property created by this manager
|
---|
6093 | changes its value, passing a pointer to the \a property and the new
|
---|
6094 | \a value as parameters.
|
---|
6095 |
|
---|
6096 | \sa setValue()
|
---|
6097 | */
|
---|
6098 |
|
---|
6099 | /*!
|
---|
6100 | Creates a manager with the given \a parent.
|
---|
6101 | */
|
---|
6102 | QtColorPropertyManager::QtColorPropertyManager(QObject *parent)
|
---|
6103 | : QtAbstractPropertyManager(parent), d_ptr(new QtColorPropertyManagerPrivate)
|
---|
6104 | {
|
---|
6105 | d_ptr->q_ptr = this;
|
---|
6106 |
|
---|
6107 | d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
|
---|
6108 | connect(d_ptr->m_intPropertyManager, SIGNAL(valueChanged(QtProperty*,int)),
|
---|
6109 | this, SLOT(slotIntChanged(QtProperty*,int)));
|
---|
6110 |
|
---|
6111 | connect(d_ptr->m_intPropertyManager, SIGNAL(propertyDestroyed(QtProperty*)),
|
---|
6112 | this, SLOT(slotPropertyDestroyed(QtProperty*)));
|
---|
6113 | }
|
---|
6114 |
|
---|
6115 | /*!
|
---|
6116 | Destroys this manager, and all the properties it has created.
|
---|
6117 | */
|
---|
6118 | QtColorPropertyManager::~QtColorPropertyManager()
|
---|
6119 | {
|
---|
6120 | clear();
|
---|
6121 | }
|
---|
6122 |
|
---|
6123 | /*!
|
---|
6124 | Returns the manager that produces the nested \e red, \e green and
|
---|
6125 | \e blue subproperties.
|
---|
6126 |
|
---|
6127 | In order to provide editing widgets for the subproperties in a
|
---|
6128 | property browser widget, this manager must be associated with an
|
---|
6129 | editor factory.
|
---|
6130 |
|
---|
6131 | \sa QtAbstractPropertyBrowser::setFactoryForManager()
|
---|
6132 | */
|
---|
6133 | QtIntPropertyManager *QtColorPropertyManager::subIntPropertyManager() const
|
---|
6134 | {
|
---|
6135 | return d_ptr->m_intPropertyManager;
|
---|
6136 | }
|
---|
6137 |
|
---|
6138 | /*!
|
---|
6139 | Returns the given \a property's value.
|
---|
6140 |
|
---|
6141 | If the given \a property is not managed by \e this manager, this
|
---|
6142 | function returns an invalid color.
|
---|
6143 |
|
---|
6144 | \sa setValue()
|
---|
6145 | */
|
---|
6146 | QColor QtColorPropertyManager::value(const QtProperty *property) const
|
---|
6147 | {
|
---|
6148 | return d_ptr->m_values.value(property, QColor());
|
---|
6149 | }
|
---|
6150 |
|
---|
6151 | /*!
|
---|
6152 | \reimp
|
---|
6153 | */
|
---|
6154 |
|
---|
6155 | QString QtColorPropertyManager::valueText(const QtProperty *property) const
|
---|
6156 | {
|
---|
6157 | const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
6158 | if (it == d_ptr->m_values.constEnd())
|
---|
6159 | return QString();
|
---|
6160 |
|
---|
6161 | return QtPropertyBrowserUtils::colorValueText(it.value());
|
---|
6162 | }
|
---|
6163 |
|
---|
6164 | /*!
|
---|
6165 | \reimp
|
---|
6166 | */
|
---|
6167 |
|
---|
6168 | QIcon QtColorPropertyManager::valueIcon(const QtProperty *property) const
|
---|
6169 | {
|
---|
6170 | const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
6171 | if (it == d_ptr->m_values.constEnd())
|
---|
6172 | return QIcon();
|
---|
6173 | return QtPropertyBrowserUtils::brushValueIcon(QBrush(it.value()));
|
---|
6174 | }
|
---|
6175 |
|
---|
6176 | /*!
|
---|
6177 | \fn void QtColorPropertyManager::setValue(QtProperty *property, const QColor &value)
|
---|
6178 |
|
---|
6179 | Sets the value of the given \a property to \a value. Nested
|
---|
6180 | properties are updated automatically.
|
---|
6181 |
|
---|
6182 | \sa value(), valueChanged()
|
---|
6183 | */
|
---|
6184 | void QtColorPropertyManager::setValue(QtProperty *property, const QColor &val)
|
---|
6185 | {
|
---|
6186 | const QtColorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
6187 | if (it == d_ptr->m_values.end())
|
---|
6188 | return;
|
---|
6189 |
|
---|
6190 | if (it.value() == val)
|
---|
6191 | return;
|
---|
6192 |
|
---|
6193 | it.value() = val;
|
---|
6194 |
|
---|
6195 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToR[property], val.red());
|
---|
6196 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToG[property], val.green());
|
---|
6197 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToB[property], val.blue());
|
---|
6198 | d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToA[property], val.alpha());
|
---|
6199 |
|
---|
6200 | emit propertyChanged(property);
|
---|
6201 | emit valueChanged(property, val);
|
---|
6202 | }
|
---|
6203 |
|
---|
6204 | /*!
|
---|
6205 | \reimp
|
---|
6206 | */
|
---|
6207 | void QtColorPropertyManager::initializeProperty(QtProperty *property)
|
---|
6208 | {
|
---|
6209 | QColor val;
|
---|
6210 | d_ptr->m_values[property] = val;
|
---|
6211 |
|
---|
6212 | QtProperty *rProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
6213 | rProp->setPropertyName(tr("Red"));
|
---|
6214 | d_ptr->m_intPropertyManager->setValue(rProp, val.red());
|
---|
6215 | d_ptr->m_intPropertyManager->setRange(rProp, 0, 0xFF);
|
---|
6216 | d_ptr->m_propertyToR[property] = rProp;
|
---|
6217 | d_ptr->m_rToProperty[rProp] = property;
|
---|
6218 | property->addSubProperty(rProp);
|
---|
6219 |
|
---|
6220 | QtProperty *gProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
6221 | gProp->setPropertyName(tr("Green"));
|
---|
6222 | d_ptr->m_intPropertyManager->setValue(gProp, val.green());
|
---|
6223 | d_ptr->m_intPropertyManager->setRange(gProp, 0, 0xFF);
|
---|
6224 | d_ptr->m_propertyToG[property] = gProp;
|
---|
6225 | d_ptr->m_gToProperty[gProp] = property;
|
---|
6226 | property->addSubProperty(gProp);
|
---|
6227 |
|
---|
6228 | QtProperty *bProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
6229 | bProp->setPropertyName(tr("Blue"));
|
---|
6230 | d_ptr->m_intPropertyManager->setValue(bProp, val.blue());
|
---|
6231 | d_ptr->m_intPropertyManager->setRange(bProp, 0, 0xFF);
|
---|
6232 | d_ptr->m_propertyToB[property] = bProp;
|
---|
6233 | d_ptr->m_bToProperty[bProp] = property;
|
---|
6234 | property->addSubProperty(bProp);
|
---|
6235 |
|
---|
6236 | QtProperty *aProp = d_ptr->m_intPropertyManager->addProperty();
|
---|
6237 | aProp->setPropertyName(tr("Alpha"));
|
---|
6238 | d_ptr->m_intPropertyManager->setValue(aProp, val.alpha());
|
---|
6239 | d_ptr->m_intPropertyManager->setRange(aProp, 0, 0xFF);
|
---|
6240 | d_ptr->m_propertyToA[property] = aProp;
|
---|
6241 | d_ptr->m_aToProperty[aProp] = property;
|
---|
6242 | property->addSubProperty(aProp);
|
---|
6243 | }
|
---|
6244 |
|
---|
6245 | /*!
|
---|
6246 | \reimp
|
---|
6247 | */
|
---|
6248 | void QtColorPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
6249 | {
|
---|
6250 | QtProperty *rProp = d_ptr->m_propertyToR[property];
|
---|
6251 | if (rProp) {
|
---|
6252 | d_ptr->m_rToProperty.remove(rProp);
|
---|
6253 | delete rProp;
|
---|
6254 | }
|
---|
6255 | d_ptr->m_propertyToR.remove(property);
|
---|
6256 |
|
---|
6257 | QtProperty *gProp = d_ptr->m_propertyToG[property];
|
---|
6258 | if (gProp) {
|
---|
6259 | d_ptr->m_gToProperty.remove(gProp);
|
---|
6260 | delete gProp;
|
---|
6261 | }
|
---|
6262 | d_ptr->m_propertyToG.remove(property);
|
---|
6263 |
|
---|
6264 | QtProperty *bProp = d_ptr->m_propertyToB[property];
|
---|
6265 | if (bProp) {
|
---|
6266 | d_ptr->m_bToProperty.remove(bProp);
|
---|
6267 | delete bProp;
|
---|
6268 | }
|
---|
6269 | d_ptr->m_propertyToB.remove(property);
|
---|
6270 |
|
---|
6271 | QtProperty *aProp = d_ptr->m_propertyToA[property];
|
---|
6272 | if (aProp) {
|
---|
6273 | d_ptr->m_aToProperty.remove(aProp);
|
---|
6274 | delete aProp;
|
---|
6275 | }
|
---|
6276 | d_ptr->m_propertyToA.remove(property);
|
---|
6277 |
|
---|
6278 | d_ptr->m_values.remove(property);
|
---|
6279 | }
|
---|
6280 |
|
---|
6281 | // QtCursorPropertyManager
|
---|
6282 |
|
---|
6283 | Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase)
|
---|
6284 |
|
---|
6285 | class QtCursorPropertyManagerPrivate
|
---|
6286 | {
|
---|
6287 | QtCursorPropertyManager *q_ptr;
|
---|
6288 | Q_DECLARE_PUBLIC(QtCursorPropertyManager)
|
---|
6289 | public:
|
---|
6290 | typedef QMap<const QtProperty *, QCursor> PropertyValueMap;
|
---|
6291 | PropertyValueMap m_values;
|
---|
6292 | };
|
---|
6293 |
|
---|
6294 | /*!
|
---|
6295 | \class QtCursorPropertyManager
|
---|
6296 | \internal
|
---|
6297 | \inmodule QtDesigner
|
---|
6298 | \since 4.4
|
---|
6299 |
|
---|
6300 | \brief The QtCursorPropertyManager provides and manages QCursor properties.
|
---|
6301 |
|
---|
6302 | A cursor property has a current value which can be
|
---|
6303 | retrieved using the value() function, and set using the setValue()
|
---|
6304 | slot. In addition, QtCursorPropertyManager provides the
|
---|
6305 | valueChanged() signal which is emitted whenever a property created
|
---|
6306 | by this manager changes.
|
---|
6307 |
|
---|
6308 | \sa QtAbstractPropertyManager
|
---|
6309 | */
|
---|
6310 |
|
---|
6311 | /*!
|
---|
6312 | \fn void QtCursorPropertyManager::valueChanged(QtProperty *property, const QCursor &value)
|
---|
6313 |
|
---|
6314 | This signal is emitted whenever a property created by this manager
|
---|
6315 | changes its value, passing a pointer to the \a property and the new
|
---|
6316 | \a value as parameters.
|
---|
6317 |
|
---|
6318 | \sa setValue()
|
---|
6319 | */
|
---|
6320 |
|
---|
6321 | /*!
|
---|
6322 | Creates a manager with the given \a parent.
|
---|
6323 | */
|
---|
6324 | QtCursorPropertyManager::QtCursorPropertyManager(QObject *parent)
|
---|
6325 | : QtAbstractPropertyManager(parent), d_ptr(new QtCursorPropertyManagerPrivate)
|
---|
6326 | {
|
---|
6327 | d_ptr->q_ptr = this;
|
---|
6328 | }
|
---|
6329 |
|
---|
6330 | /*!
|
---|
6331 | Destroys this manager, and all the properties it has created.
|
---|
6332 | */
|
---|
6333 | QtCursorPropertyManager::~QtCursorPropertyManager()
|
---|
6334 | {
|
---|
6335 | clear();
|
---|
6336 | }
|
---|
6337 |
|
---|
6338 | /*!
|
---|
6339 | Returns the given \a property's value.
|
---|
6340 |
|
---|
6341 | If the given \a property is not managed by this manager, this
|
---|
6342 | function returns a default QCursor object.
|
---|
6343 |
|
---|
6344 | \sa setValue()
|
---|
6345 | */
|
---|
6346 | #ifndef QT_NO_CURSOR
|
---|
6347 | QCursor QtCursorPropertyManager::value(const QtProperty *property) const
|
---|
6348 | {
|
---|
6349 | return d_ptr->m_values.value(property, QCursor());
|
---|
6350 | }
|
---|
6351 | #endif
|
---|
6352 |
|
---|
6353 | /*!
|
---|
6354 | \reimp
|
---|
6355 | */
|
---|
6356 | QString QtCursorPropertyManager::valueText(const QtProperty *property) const
|
---|
6357 | {
|
---|
6358 | const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
6359 | if (it == d_ptr->m_values.constEnd())
|
---|
6360 | return QString();
|
---|
6361 |
|
---|
6362 | return cursorDatabase()->cursorToShapeName(it.value());
|
---|
6363 | }
|
---|
6364 |
|
---|
6365 | /*!
|
---|
6366 | \reimp
|
---|
6367 | */
|
---|
6368 | QIcon QtCursorPropertyManager::valueIcon(const QtProperty *property) const
|
---|
6369 | {
|
---|
6370 | const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property);
|
---|
6371 | if (it == d_ptr->m_values.constEnd())
|
---|
6372 | return QIcon();
|
---|
6373 |
|
---|
6374 | return cursorDatabase()->cursorToShapeIcon(it.value());
|
---|
6375 | }
|
---|
6376 |
|
---|
6377 | /*!
|
---|
6378 | \fn void QtCursorPropertyManager::setValue(QtProperty *property, const QCursor &value)
|
---|
6379 |
|
---|
6380 | Sets the value of the given \a property to \a value.
|
---|
6381 |
|
---|
6382 | \sa value(), valueChanged()
|
---|
6383 | */
|
---|
6384 | void QtCursorPropertyManager::setValue(QtProperty *property, const QCursor &value)
|
---|
6385 | {
|
---|
6386 | #ifndef QT_NO_CURSOR
|
---|
6387 | const QtCursorPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property);
|
---|
6388 | if (it == d_ptr->m_values.end())
|
---|
6389 | return;
|
---|
6390 |
|
---|
6391 | if (it.value().shape() == value.shape() && value.shape() != Qt::BitmapCursor)
|
---|
6392 | return;
|
---|
6393 |
|
---|
6394 | it.value() = value;
|
---|
6395 |
|
---|
6396 | emit propertyChanged(property);
|
---|
6397 | emit valueChanged(property, value);
|
---|
6398 | #endif
|
---|
6399 | }
|
---|
6400 |
|
---|
6401 | /*!
|
---|
6402 | \reimp
|
---|
6403 | */
|
---|
6404 | void QtCursorPropertyManager::initializeProperty(QtProperty *property)
|
---|
6405 | {
|
---|
6406 | #ifndef QT_NO_CURSOR
|
---|
6407 | d_ptr->m_values[property] = QCursor();
|
---|
6408 | #endif
|
---|
6409 | }
|
---|
6410 |
|
---|
6411 | /*!
|
---|
6412 | \reimp
|
---|
6413 | */
|
---|
6414 | void QtCursorPropertyManager::uninitializeProperty(QtProperty *property)
|
---|
6415 | {
|
---|
6416 | d_ptr->m_values.remove(property);
|
---|
6417 | }
|
---|
6418 |
|
---|
6419 | QT_END_NAMESPACE
|
---|
6420 |
|
---|
6421 | #include "moc_qtpropertymanager.cpp"
|
---|
6422 | #include "qtpropertymanager.moc"
|
---|