qtpropertymanager.cpp
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the Qt Solutions component.
7**
8** $QT_BEGIN_LICENSE:BSD$
9** You may use this file under the terms of the BSD license as follows:
10**
11** "Redistribution and use in source and binary forms, with or without
12** modification, are permitted provided that the following conditions are
13** met:
14** * Redistributions of source code must retain the above copyright
15** notice, this list of conditions and the following disclaimer.
16** * Redistributions in binary form must reproduce the above copyright
17** notice, this list of conditions and the following disclaimer in
18** the documentation and/or other materials provided with the
19** distribution.
20** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21** of its contributors may be used to endorse or promote products derived
22** from this software without specific prior written permission.
23**
24**
25** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41
42#include "qtpropertymanager.h"
43
44#include <float.h>
45#include <limits.h>
46
47#include <QApplication>
48#include <QCheckBox>
49#include <QDateTime>
50#include <QFontDatabase>
51#include <QIcon>
52#include <QLabel>
53#include <QLineEdit>
54#include <QLocale>
55#include <QMap>
56#include <QMetaEnum>
57#include <QPainter>
58#include <QStyle>
59#include <QStyleOption>
60#include <QTimer>
61
63
64#if defined(Q_CC_MSVC)
65#pragma warning(disable : 4786) /* MS VS 6: truncating debug info after 255 characters */
66#endif
67
68QT_BEGIN_NAMESPACE
69
70template <class PrivateData, class Value>
71static void
72setSimpleMinimumData(PrivateData* data, const Value& minVal)
73{
74 data->minVal = minVal;
75
76 if (data->maxVal < data->minVal)
77 {
78 data->maxVal = data->minVal;
79 }
80
81 if (data->val < data->minVal)
82 {
83 data->val = data->minVal;
84 }
85}
86
87template <class PrivateData, class Value>
88static void
89setSimpleMaximumData(PrivateData* data, const Value& maxVal)
90{
91 data->maxVal = maxVal;
92
93 if (data->minVal > data->maxVal)
94 {
95 data->minVal = data->maxVal;
96 }
97
98 if (data->val > data->maxVal)
99 {
100 data->val = data->maxVal;
101 }
102}
103
104template <class PrivateData, class Value>
105static void
106setSizeMinimumData(PrivateData* data, const Value& newMinVal)
107{
108 data->minVal = newMinVal;
109
110 if (data->maxVal.width() < data->minVal.width())
111 {
112 data->maxVal.setWidth(data->minVal.width());
113 }
114
115 if (data->maxVal.height() < data->minVal.height())
116 {
117 data->maxVal.setHeight(data->minVal.height());
118 }
119
120 if (data->val.width() < data->minVal.width())
121 {
122 data->val.setWidth(data->minVal.width());
123 }
124
125 if (data->val.height() < data->minVal.height())
126 {
127 data->val.setHeight(data->minVal.height());
128 }
129}
130
131template <class PrivateData, class Value>
132static void
133setSizeMaximumData(PrivateData* data, const Value& newMaxVal)
134{
135 data->maxVal = newMaxVal;
136
137 if (data->minVal.width() > data->maxVal.width())
138 {
139 data->minVal.setWidth(data->maxVal.width());
140 }
141
142 if (data->minVal.height() > data->maxVal.height())
143 {
144 data->minVal.setHeight(data->maxVal.height());
145 }
146
147 if (data->val.width() > data->maxVal.width())
148 {
149 data->val.setWidth(data->maxVal.width());
150 }
151
152 if (data->val.height() > data->maxVal.height())
153 {
154 data->val.setHeight(data->maxVal.height());
155 }
156}
157
158template <class SizeValue>
159static SizeValue
160qBoundSize(const SizeValue& minVal, const SizeValue& val, const SizeValue& maxVal)
161{
162 SizeValue croppedVal = val;
163
164 if (minVal.width() > val.width())
165 {
166 croppedVal.setWidth(minVal.width());
167 }
168 else if (maxVal.width() < val.width())
169 {
170 croppedVal.setWidth(maxVal.width());
171 }
172
173 if (minVal.height() > val.height())
174 {
175 croppedVal.setHeight(minVal.height());
176 }
177 else if (maxVal.height() < val.height())
178 {
179 croppedVal.setHeight(maxVal.height());
180 }
181
182 return croppedVal;
183}
184
185// Match the exact signature of qBound for VS 6.
186QSize
187qBound(QSize minVal, QSize val, QSize maxVal)
188{
189 return qBoundSize(minVal, val, maxVal);
190}
191
192QSizeF
193qBound(QSizeF minVal, QSizeF val, QSizeF maxVal)
194{
195 return qBoundSize(minVal, val, maxVal);
196}
197
198namespace
199{
200 template <class Value>
201 void
202 orderBorders(Value& minVal, Value& maxVal)
203 {
204 if (minVal > maxVal)
205 {
206 qSwap(minVal, maxVal);
207 }
208 }
209
210 template <class Value>
211 static void
212 orderSizeBorders(Value& minVal, Value& maxVal)
213 {
214 Value fromSize = minVal;
215 Value toSize = maxVal;
216
217 if (fromSize.width() > toSize.width())
218 {
219 fromSize.setWidth(maxVal.width());
220 toSize.setWidth(minVal.width());
221 }
222
223 if (fromSize.height() > toSize.height())
224 {
225 fromSize.setHeight(maxVal.height());
226 toSize.setHeight(minVal.height());
227 }
228
229 minVal = fromSize;
230 maxVal = toSize;
231 }
232
233 void
234 orderBorders(QSize& minVal, QSize& maxVal)
235 {
236 orderSizeBorders(minVal, maxVal);
237 }
238
239 void
240 orderBorders(QSizeF& minVal, QSizeF& maxVal)
241 {
242 orderSizeBorders(minVal, maxVal);
243 }
244
245} // namespace
246
247////////
248
249template <class Value, class PrivateData>
250static Value
251getData(const QMap<const QtProperty*, PrivateData>& propertyMap,
252 Value PrivateData::*data,
253 const QtProperty* property,
254 const Value& defaultValue = Value())
255{
256 using PropertyToData = QMap<const QtProperty*, PrivateData>;
257 using PropertyToDataConstIterator = typename PropertyToData::const_iterator;
258 const PropertyToDataConstIterator it = propertyMap.constFind(property);
259
260 if (it == propertyMap.constEnd())
261 {
262 return defaultValue;
263 }
264
265 return it.value().*data;
266}
267
268template <class Value, class PrivateData>
269static Value
270getValue(const QMap<const QtProperty*, PrivateData>& propertyMap,
271 const QtProperty* property,
272 const Value& defaultValue = Value())
273{
274 return getData<Value>(propertyMap, &PrivateData::val, property, defaultValue);
275}
276
277template <class Value, class PrivateData>
278static Value
279getMinimum(const QMap<const QtProperty*, PrivateData>& propertyMap,
280 const QtProperty* property,
281 const Value& defaultValue = Value())
282{
283 return getData<Value>(propertyMap, &PrivateData::minVal, property, defaultValue);
284}
285
286template <class Value, class PrivateData>
287static Value
288getMaximum(const QMap<const QtProperty*, PrivateData>& propertyMap,
289 const QtProperty* property,
290 const Value& defaultValue = Value())
291{
292 return getData<Value>(propertyMap, &PrivateData::maxVal, property, defaultValue);
293}
294
295template <class ValueChangeParameter, class Value, class PropertyManager>
296static void
297setSimpleValue(QMap<const QtProperty*, Value>& propertyMap,
298 PropertyManager* manager,
299 void (PropertyManager::*propertyChangedSignal)(QtProperty*),
300 void (PropertyManager::*valueChangedSignal)(QtProperty*, ValueChangeParameter),
301 QtProperty* property,
302 const Value& val)
303{
304 using PropertyToData = QMap<const QtProperty*, Value>;
305 using PropertyToDataIterator = typename PropertyToData::iterator;
306 const PropertyToDataIterator it = propertyMap.find(property);
307
308 if (it == propertyMap.end())
309 {
310 return;
311 }
312
313 if (it.value() == val)
314 {
315 return;
316 }
317
318 it.value() = val;
319
320 emit(manager->*propertyChangedSignal)(property);
321 emit(manager->*valueChangedSignal)(property, val);
322}
323
324template <class ValueChangeParameter,
325 class PropertyManagerPrivate,
326 class PropertyManager,
327 class Value>
328static void
329setValueInRange(PropertyManager* manager,
330 PropertyManagerPrivate* managerPrivate,
331 void (PropertyManager::*propertyChangedSignal)(QtProperty*),
332 void (PropertyManager::*valueChangedSignal)(QtProperty*, ValueChangeParameter),
333 QtProperty* property,
334 const Value& val,
335 void (PropertyManagerPrivate::*setSubPropertyValue)(QtProperty*,
336 ValueChangeParameter))
337{
338 using PrivateData = typename PropertyManagerPrivate::Data;
339 using PropertyToData = QMap<const QtProperty*, PrivateData>;
340 using PropertyToDataIterator = typename PropertyToData::iterator;
341 const PropertyToDataIterator it = managerPrivate->m_values.find(property);
342
343 if (it == managerPrivate->m_values.end())
344 {
345 return;
346 }
347
348 PrivateData& data = it.value();
349
350 if (data.val == val)
351 {
352 return;
353 }
354
355 const Value oldVal = data.val;
356
357 data.val = qBound(data.minVal, val, data.maxVal);
358
359 if (data.val == oldVal)
360 {
361 return;
362 }
363
364 if (setSubPropertyValue)
365 {
366 (managerPrivate->*setSubPropertyValue)(property, data.val);
367 }
368
369 emit(manager->*propertyChangedSignal)(property);
370 emit(manager->*valueChangedSignal)(property, data.val);
371}
372
373template <class ValueChangeParameter,
374 class PropertyManagerPrivate,
375 class PropertyManager,
376 class Value>
377static void
378setBorderValues(PropertyManager* manager,
379 PropertyManagerPrivate* managerPrivate,
380 void (PropertyManager::*propertyChangedSignal)(QtProperty*),
381 void (PropertyManager::*valueChangedSignal)(QtProperty*, ValueChangeParameter),
382 void (PropertyManager::*rangeChangedSignal)(QtProperty*,
383 ValueChangeParameter,
384 ValueChangeParameter),
385 QtProperty* property,
386 const Value& minVal,
387 const Value& maxVal,
388 void (PropertyManagerPrivate::*setSubPropertyRange)(QtProperty*,
389 ValueChangeParameter,
390 ValueChangeParameter,
391 ValueChangeParameter))
392{
393 using PrivateData = typename PropertyManagerPrivate::Data;
394 using PropertyToData = QMap<const QtProperty*, PrivateData>;
395 using PropertyToDataIterator = typename PropertyToData::iterator;
396 const PropertyToDataIterator it = managerPrivate->m_values.find(property);
397
398 if (it == managerPrivate->m_values.end())
399 {
400 return;
401 }
402
403 Value fromVal = minVal;
404 Value toVal = maxVal;
405 orderBorders(fromVal, toVal);
406
407 PrivateData& data = it.value();
408
409 if (data.minVal == fromVal && data.maxVal == toVal)
410 {
411 return;
412 }
413
414 const Value oldVal = data.val;
415
416 data.setMinimumValue(fromVal);
417 data.setMaximumValue(toVal);
418
419 emit(manager->*rangeChangedSignal)(property, data.minVal, data.maxVal);
420
421 if (setSubPropertyRange)
422 {
423 (managerPrivate->*setSubPropertyRange)(property, data.minVal, data.maxVal, data.val);
424 }
425
426 if (data.val == oldVal)
427 {
428 return;
429 }
430
431 emit(manager->*propertyChangedSignal)(property);
432 emit(manager->*valueChangedSignal)(property, data.val);
433}
434
435template <class ValueChangeParameter,
436 class PropertyManagerPrivate,
437 class PropertyManager,
438 class Value,
439 class PrivateData>
440static void
441setBorderValue(PropertyManager* manager,
442 PropertyManagerPrivate* managerPrivate,
443 void (PropertyManager::*propertyChangedSignal)(QtProperty*),
444 void (PropertyManager::*valueChangedSignal)(QtProperty*, ValueChangeParameter),
445 void (PropertyManager::*rangeChangedSignal)(QtProperty*,
446 ValueChangeParameter,
447 ValueChangeParameter),
448 QtProperty* property,
449 Value (PrivateData::*getRangeVal)() const,
450 void (PrivateData::*setRangeVal)(ValueChangeParameter),
451 const Value& borderVal,
452 void (PropertyManagerPrivate::*setSubPropertyRange)(QtProperty*,
453 ValueChangeParameter,
454 ValueChangeParameter,
455 ValueChangeParameter))
456{
457 using PropertyToData = QMap<const QtProperty*, PrivateData>;
458 using PropertyToDataIterator = typename PropertyToData::iterator;
459 const PropertyToDataIterator it = managerPrivate->m_values.find(property);
460
461 if (it == managerPrivate->m_values.end())
462 {
463 return;
464 }
465
466 PrivateData& data = it.value();
467
468 if ((data.*getRangeVal)() == borderVal)
469 {
470 return;
471 }
472
473 const Value oldVal = data.val;
474
475 (data.*setRangeVal)(borderVal);
476
477 emit(manager->*rangeChangedSignal)(property, data.minVal, data.maxVal);
478
479 if (setSubPropertyRange)
480 {
481 (managerPrivate->*setSubPropertyRange)(property, data.minVal, data.maxVal, data.val);
482 }
483
484 if (data.val == oldVal)
485 {
486 return;
487 }
488
489 emit(manager->*propertyChangedSignal)(property);
490 emit(manager->*valueChangedSignal)(property, data.val);
491}
492
493template <class ValueChangeParameter,
494 class PropertyManagerPrivate,
495 class PropertyManager,
496 class Value,
497 class PrivateData>
498static void
499setMinimumValue(PropertyManager* manager,
500 PropertyManagerPrivate* managerPrivate,
501 void (PropertyManager::*propertyChangedSignal)(QtProperty*),
502 void (PropertyManager::*valueChangedSignal)(QtProperty*, ValueChangeParameter),
503 void (PropertyManager::*rangeChangedSignal)(QtProperty*,
504 ValueChangeParameter,
505 ValueChangeParameter),
506 QtProperty* property,
507 const Value& minVal)
508{
509 void (PropertyManagerPrivate::*setSubPropertyRange)(
510 QtProperty*, ValueChangeParameter, ValueChangeParameter, ValueChangeParameter) = 0;
511 setBorderValue<ValueChangeParameter,
512 PropertyManagerPrivate,
513 PropertyManager,
514 Value,
515 PrivateData>(manager,
516 managerPrivate,
517 propertyChangedSignal,
518 valueChangedSignal,
519 rangeChangedSignal,
520 property,
521 &PropertyManagerPrivate::Data::minimumValue,
522 &PropertyManagerPrivate::Data::setMinimumValue,
523 minVal,
524 setSubPropertyRange);
525}
526
527template <class ValueChangeParameter,
528 class PropertyManagerPrivate,
529 class PropertyManager,
530 class Value,
531 class PrivateData>
532static void
533setMaximumValue(PropertyManager* manager,
534 PropertyManagerPrivate* managerPrivate,
535 void (PropertyManager::*propertyChangedSignal)(QtProperty*),
536 void (PropertyManager::*valueChangedSignal)(QtProperty*, ValueChangeParameter),
537 void (PropertyManager::*rangeChangedSignal)(QtProperty*,
538 ValueChangeParameter,
539 ValueChangeParameter),
540 QtProperty* property,
541 const Value& maxVal)
542{
543 void (PropertyManagerPrivate::*setSubPropertyRange)(
544 QtProperty*, ValueChangeParameter, ValueChangeParameter, ValueChangeParameter) = 0;
545 setBorderValue<ValueChangeParameter,
546 PropertyManagerPrivate,
547 PropertyManager,
548 Value,
549 PrivateData>(manager,
550 managerPrivate,
551 propertyChangedSignal,
552 valueChangedSignal,
553 rangeChangedSignal,
554 property,
555 &PropertyManagerPrivate::Data::maximumValue,
556 &PropertyManagerPrivate::Data::setMaximumValue,
557 maxVal,
558 setSubPropertyRange);
559}
560
561class QtMetaEnumWrapper : public QObject
562{
563 Q_OBJECT
564 Q_PROPERTY(QSizePolicy::Policy policy READ policy)
565public:
566 QSizePolicy::Policy
567 policy() const
568 {
569 return QSizePolicy::Ignored;
570 }
571
572private:
573 QtMetaEnumWrapper(QObject* parent) : QObject(parent)
574 {
575 }
576};
577
579{
580public:
582
583 QStringList
585 {
586 return m_policyEnumNames;
587 }
588
589 QStringList
591 {
592 return m_languageEnumNames;
593 }
594
595 QStringList
596 countryEnumNames(QLocale::Language language) const
597 {
598 return m_countryEnumNames.value(language);
599 }
600
601 QSizePolicy::Policy indexToSizePolicy(int index) const;
602 int sizePolicyToIndex(QSizePolicy::Policy policy) const;
603
604 void indexToLocale(int languageIndex,
605 int countryIndex,
606 QLocale::Language* language,
607 QLocale::Country* country) const;
608 void localeToIndex(QLocale::Language language,
609 QLocale::Country country,
610 int* languageIndex,
611 int* countryIndex) const;
612
613private:
614 void initLocale();
615
616 QStringList m_policyEnumNames;
617 QStringList m_languageEnumNames;
618 QMap<QLocale::Language, QStringList> m_countryEnumNames;
619 QMap<int, QLocale::Language> m_indexToLanguage;
620 QMap<QLocale::Language, int> m_languageToIndex;
621 QMap<int, QMap<int, QLocale::Country>> m_indexToCountry;
622 QMap<QLocale::Language, QMap<QLocale::Country, int>> m_countryToIndex;
623 QMetaEnum m_policyEnum;
624};
625
626static QList<QLocale::Country>
627sortCountries(const QList<QLocale::Country>& countries)
628{
629 QMultiMap<QString, QLocale::Country> nameToCountry;
630 QListIterator<QLocale::Country> itCountry(countries);
631
632 while (itCountry.hasNext())
633 {
634 QLocale::Country country = itCountry.next();
635 nameToCountry.insert(QLocale::countryToString(country), country);
636 }
637
638 return nameToCountry.values();
639}
640
641void
642QtMetaEnumProvider::initLocale()
643{
644 QMultiMap<QString, QLocale::Language> nameToLanguage;
645 QLocale::Language language = QLocale::C;
646
647 while (language <= QLocale::LastLanguage)
648 {
649 QLocale locale(language);
650
651 if (locale.language() == language)
652 {
653 nameToLanguage.insert(QLocale::languageToString(language), language);
654 }
655
656 language = (QLocale::Language)((uint)language + 1); // ++language
657 }
658
659 const QLocale system = QLocale::system();
660
661 if (!nameToLanguage.contains(QLocale::languageToString(system.language())))
662 {
663 nameToLanguage.insert(QLocale::languageToString(system.language()), system.language());
664 }
665
666 QList<QLocale::Language> languages = nameToLanguage.values();
667 QListIterator<QLocale::Language> itLang(languages);
668
669 while (itLang.hasNext())
670 {
671 QLocale::Language language = itLang.next();
672 QList<QLocale::Country> countries;
673 countries = QLocale::countriesForLanguage(language);
674
675 if (countries.isEmpty() && language == system.language())
676 {
677 countries << system.country();
678 }
679
680 if (!countries.isEmpty() && !m_languageToIndex.contains(language))
681 {
682 countries = sortCountries(countries);
683 int langIdx = m_languageEnumNames.count();
684 m_indexToLanguage[langIdx] = language;
685 m_languageToIndex[language] = langIdx;
686 QStringList countryNames;
687 QListIterator<QLocale::Country> it(countries);
688 int countryIdx = 0;
689
690 while (it.hasNext())
691 {
692 QLocale::Country country = it.next();
693 countryNames << QLocale::countryToString(country);
694 m_indexToCountry[langIdx][countryIdx] = country;
695 m_countryToIndex[language][country] = countryIdx;
696 ++countryIdx;
697 }
698
699 m_languageEnumNames << QLocale::languageToString(language);
700 m_countryEnumNames[language] = countryNames;
701 }
702 }
703}
704
706{
707 QMetaProperty p;
708
709 p = QtMetaEnumWrapper::staticMetaObject.property(
710 QtMetaEnumWrapper::staticMetaObject.propertyOffset() + 0);
711 m_policyEnum = p.enumerator();
712 const int keyCount = m_policyEnum.keyCount();
713
714 for (int i = 0; i < keyCount; i++)
715 {
716 m_policyEnumNames << QLatin1String(m_policyEnum.key(i));
717 }
718
719 initLocale();
720}
721
722QSizePolicy::Policy
724{
725 return static_cast<QSizePolicy::Policy>(m_policyEnum.value(index));
726}
727
728int
729QtMetaEnumProvider::sizePolicyToIndex(QSizePolicy::Policy policy) const
730{
731 const int keyCount = m_policyEnum.keyCount();
732
733 for (int i = 0; i < keyCount; i++)
734 if (indexToSizePolicy(i) == policy)
735 {
736 return i;
737 }
738
739 return -1;
740}
741
742void
744 int countryIndex,
745 QLocale::Language* language,
746 QLocale::Country* country) const
747{
748 QLocale::Language l = QLocale::C;
749 QLocale::Country c = QLocale::AnyCountry;
750
751 if (m_indexToLanguage.contains(languageIndex))
752 {
753 l = m_indexToLanguage[languageIndex];
754
755 if (m_indexToCountry.contains(languageIndex) &&
756 m_indexToCountry[languageIndex].contains(countryIndex))
757 {
758 c = m_indexToCountry[languageIndex][countryIndex];
759 }
760 }
761
762 if (language)
763 {
764 *language = l;
765 }
766
767 if (country)
768 {
769 *country = c;
770 }
771}
772
773void
774QtMetaEnumProvider::localeToIndex(QLocale::Language language,
775 QLocale::Country country,
776 int* languageIndex,
777 int* countryIndex) const
778{
779 int l = -1;
780 int c = -1;
781
782 if (m_languageToIndex.contains(language))
783 {
784 l = m_languageToIndex[language];
785
786 if (m_countryToIndex.contains(language) && m_countryToIndex[language].contains(country))
787 {
788 c = m_countryToIndex[language][country];
789 }
790 }
791
792 if (languageIndex)
793 {
794 *languageIndex = l;
795 }
796
797 if (countryIndex)
798 {
799 *countryIndex = c;
800 }
801}
802
803Q_GLOBAL_STATIC(QtMetaEnumProvider, metaEnumProvider)
804
805// QtGroupPropertyManager
806
807/*!
808 \class QtGroupPropertyManager
809
810 \brief The QtGroupPropertyManager provides and manages group properties.
811
812 This class is intended to provide a grouping element without any value.
813
814 \sa QtAbstractPropertyManager
815*/
816
817/*!
818 Creates a manager with the given \a parent.
819*/
823
824/*!
825 Destroys this manager, and all the properties it has created.
826*/
830
831/*!
832 \reimp
833*/
834bool
836{
837 Q_UNUSED(property)
838 return false;
839}
840
841/*!
842 \reimp
843*/
844void
846{
847 Q_UNUSED(property)
848}
849
850/*!
851 \reimp
852*/
853void
855{
856 Q_UNUSED(property)
857}
858
859// QtIntPropertyManager
860
862{
864 Q_DECLARE_PUBLIC(QtIntPropertyManager)
865public:
866 struct Data
867 {
868 Data() : val(0), minVal(-INT_MAX), maxVal(INT_MAX), singleStep(1), readOnly(false)
869 {
870 }
871
872 int val;
877
878 int
880 {
881 return minVal;
882 }
883
884 int
886 {
887 return maxVal;
888 }
889
890 void
891 setMinimumValue(int newMinVal)
892 {
893 setSimpleMinimumData(this, newMinVal);
894 }
895
896 void
897 setMaximumValue(int newMaxVal)
898 {
899 setSimpleMaximumData(this, newMaxVal);
900 }
901 };
902
903 using PropertyValueMap = QMap<const QtProperty*, Data>;
905};
906
907/*!
908 \class QtIntPropertyManager
909
910 \brief The QtIntPropertyManager provides and manages int properties.
911
912 An int property has a current value, and a range specifying the
913 valid values. The range is defined by a minimum and a maximum
914 value.
915
916 The property's value and range can be retrieved using the value(),
917 minimum() and maximum() functions, and can be set using the
918 setValue(), setMinimum() and setMaximum() slots. Alternatively,
919 the range can be defined in one go using the setRange() slot.
920
921 In addition, QtIntPropertyManager provides the valueChanged() signal which
922 is emitted whenever a property created by this manager changes,
923 and the rangeChanged() signal which is emitted whenever such a
924 property changes its range of valid values.
925
926 \sa QtAbstractPropertyManager, QtSpinBoxFactory, QtSliderFactory, QtScrollBarFactory
927*/
928
929/*!
930 \fn void QtIntPropertyManager::valueChanged(QtProperty *property, int value)
931
932 This signal is emitted whenever a property created by this manager
933 changes its value, passing a pointer to the \a property and the new
934 \a value as parameters.
935
936 \sa setValue()
937*/
938
939/*!
940 \fn void QtIntPropertyManager::rangeChanged(QtProperty *property, int minimum, int maximum)
941
942 This signal is emitted whenever a property created by this manager
943 changes its range of valid values, passing a pointer to the
944 \a property and the new \a minimum and \a maximum values.
945
946 \sa setRange()
947*/
948
949/*!
950 \fn void QtIntPropertyManager::singleStepChanged(QtProperty *property, int step)
951
952 This signal is emitted whenever a property created by this manager
953 changes its single step property, passing a pointer to the
954 \a property and the new \a step value
955
956 \sa setSingleStep()
957*/
958
959/*!
960 Creates a manager with the given \a parent.
961*/
963{
964 d_ptr = new QtIntPropertyManagerPrivate;
965 d_ptr->q_ptr = this;
966}
967
968/*!
969 Destroys this manager, and all the properties it has created.
970*/
972{
973 clear();
974 delete d_ptr;
975}
976
977/*!
978 Returns the given \a property's value.
979
980 If the given property is not managed by this manager, this
981 function returns 0.
982
983 \sa setValue()
984*/
985int
987{
988 return getValue<int>(d_ptr->m_values, property, 0);
989}
990
991/*!
992 Returns the given \a property's minimum value.
993
994 \sa setMinimum(), maximum(), setRange()
995*/
996int
998{
999 return getMinimum<int>(d_ptr->m_values, property, 0);
1000}
1001
1002/*!
1003 Returns the given \a property's maximum value.
1004
1005 \sa setMaximum(), minimum(), setRange()
1006*/
1007int
1009{
1010 return getMaximum<int>(d_ptr->m_values, property, 0);
1011}
1012
1013/*!
1014 Returns the given \a property's step value.
1015
1016 The step is typically used to increment or decrement a property value while pressing an arrow key.
1017
1018 \sa setSingleStep()
1019*/
1020int
1022{
1023 return getData<int>(
1024 d_ptr->m_values, &QtIntPropertyManagerPrivate::Data::singleStep, property, 0);
1025}
1026
1027/*!
1028 Returns read-only status of the property.
1029
1030 When property is read-only it's value can be selected and copied from editor but not modified.
1031
1032 \sa QtIntPropertyManager::setReadOnly
1033*/
1034bool
1036{
1037 return getData<bool>(
1038 d_ptr->m_values, &QtIntPropertyManagerPrivate::Data::readOnly, property, false);
1039}
1040
1041/*!
1042 \reimp
1043*/
1044QString
1046{
1047 const QtIntPropertyManagerPrivate::PropertyValueMap::const_iterator it =
1048 d_ptr->m_values.constFind(property);
1049
1050 if (it == d_ptr->m_values.constEnd())
1051 {
1052 return QString();
1053 }
1054
1055 return QString::number(it.value().val);
1056}
1057
1058/*!
1059 \fn void QtIntPropertyManager::setValue(QtProperty *property, int value)
1060
1061 Sets the value of the given \a property to \a value.
1062
1063 If the specified \a value is not valid according to the given \a
1064 property's range, the \a value is adjusted to the nearest valid
1065 value within the range.
1066
1067 \sa value(), setRange(), valueChanged()
1068*/
1069void
1071{
1072 void (QtIntPropertyManagerPrivate::*setSubPropertyValue)(QtProperty*, int) = 0;
1073 setValueInRange<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(
1074 this,
1075 d_ptr,
1078 property,
1079 val,
1080 setSubPropertyValue);
1081}
1082
1083/*!
1084 Sets the minimum value for the given \a property to \a minVal.
1085
1086 When setting the minimum value, the maximum and current values are
1087 adjusted if necessary (ensuring that the range remains valid and
1088 that the current value is within the range).
1089
1090 \sa minimum(), setRange(), rangeChanged()
1091*/
1092void
1094{
1095 setMinimumValue<int,
1098 int,
1100 d_ptr,
1104 property,
1105 minVal);
1106}
1107
1108/*!
1109 Sets the maximum value for the given \a property to \a maxVal.
1110
1111 When setting maximum value, the minimum and current values are
1112 adjusted if necessary (ensuring that the range remains valid and
1113 that the current value is within the range).
1114
1115 \sa maximum(), setRange(), rangeChanged()
1116*/
1117void
1119{
1120 setMaximumValue<int,
1123 int,
1125 d_ptr,
1129 property,
1130 maxVal);
1131}
1132
1133/*!
1134 \fn void QtIntPropertyManager::setRange(QtProperty *property, int minimum, int maximum)
1135
1136 Sets the range of valid values.
1137
1138 This is a convenience function defining the range of valid values
1139 in one go; setting the \a minimum and \a maximum values for the
1140 given \a property with a single function call.
1141
1142 When setting a new range, the current value is adjusted if
1143 necessary (ensuring that the value remains within range).
1144
1145 \sa setMinimum(), setMaximum(), rangeChanged()
1146*/
1147void
1148QtIntPropertyManager::setRange(QtProperty* property, int minVal, int maxVal)
1149{
1150 void (QtIntPropertyManagerPrivate::*setSubPropertyRange)(QtProperty*, int, int, int) = 0;
1151 setBorderValues<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(
1152 this,
1153 d_ptr,
1157 property,
1158 minVal,
1159 maxVal,
1160 setSubPropertyRange);
1161}
1162
1163/*!
1164 Sets the step value for the given \a property to \a step.
1165
1166 The step is typically used to increment or decrement a property value while pressing an arrow key.
1167
1168 \sa singleStep()
1169*/
1170void
1172{
1173 const QtIntPropertyManagerPrivate::PropertyValueMap::iterator it =
1174 d_ptr->m_values.find(property);
1175
1176 if (it == d_ptr->m_values.end())
1177 {
1178 return;
1179 }
1180
1182
1183 if (step < 0)
1184 {
1185 step = 0;
1186 }
1187
1188 if (data.singleStep == step)
1189 {
1190 return;
1191 }
1192
1193 data.singleStep = step;
1194
1195 it.value() = data;
1196
1197 emit singleStepChanged(property, data.singleStep);
1198}
1199
1200/*!
1201 Sets read-only status of the property.
1202
1203 \sa QtIntPropertyManager::setReadOnly
1204*/
1205void
1207{
1208 const QtIntPropertyManagerPrivate::PropertyValueMap::iterator it =
1209 d_ptr->m_values.find(property);
1210
1211 if (it == d_ptr->m_values.end())
1212 {
1213 return;
1214 }
1215
1217
1218 if (data.readOnly == readOnly)
1219 {
1220 return;
1221 }
1222
1223 data.readOnly = readOnly;
1224 it.value() = data;
1225
1226 emit propertyChanged(property);
1227 emit readOnlyChanged(property, data.readOnly);
1228}
1229
1230/*!
1231 \reimp
1232*/
1233void
1235{
1236 d_ptr->m_values[property] = QtIntPropertyManagerPrivate::Data();
1237}
1238
1239/*!
1240 \reimp
1241*/
1242void
1244{
1245 d_ptr->m_values.remove(property);
1246}
1247
1248// QtDoublePropertyManager
1249
1251{
1253 Q_DECLARE_PUBLIC(QtDoublePropertyManager)
1254public:
1255 struct Data
1256 {
1258 val(0), minVal(-INT_MAX), maxVal(INT_MAX), singleStep(1), decimals(2), readOnly(false)
1259 {
1260 }
1261
1262 double val;
1263 double minVal;
1264 double maxVal;
1268
1269 double
1271 {
1272 return minVal;
1273 }
1274
1275 double
1277 {
1278 return maxVal;
1279 }
1280
1281 void
1282 setMinimumValue(double newMinVal)
1283 {
1284 setSimpleMinimumData(this, newMinVal);
1285 }
1286
1287 void
1288 setMaximumValue(double newMaxVal)
1289 {
1290 setSimpleMaximumData(this, newMaxVal);
1291 }
1292 };
1293
1294 using PropertyValueMap = QMap<const QtProperty*, Data>;
1296};
1297
1298/*!
1299 \class QtDoublePropertyManager
1300
1301 \brief The QtDoublePropertyManager provides and manages double properties.
1302
1303 A double property has a current value, and a range specifying the
1304 valid values. The range is defined by a minimum and a maximum
1305 value.
1306
1307 The property's value and range can be retrieved using the value(),
1308 minimum() and maximum() functions, and can be set using the
1309 setValue(), setMinimum() and setMaximum() slots.
1310 Alternatively, the range can be defined in one go using the
1311 setRange() slot.
1312
1313 In addition, QtDoublePropertyManager provides the valueChanged() signal
1314 which is emitted whenever a property created by this manager
1315 changes, and the rangeChanged() signal which is emitted whenever
1316 such a property changes its range of valid values.
1317
1318 \sa QtAbstractPropertyManager, QtDoubleSpinBoxFactory
1319*/
1320
1321/*!
1322 \fn void QtDoublePropertyManager::valueChanged(QtProperty *property, double value)
1323
1324 This signal is emitted whenever a property created by this manager
1325 changes its value, passing a pointer to the \a property and the new
1326 \a value as parameters.
1327
1328 \sa setValue()
1329*/
1330
1331/*!
1332 \fn void QtDoublePropertyManager::rangeChanged(QtProperty *property, double minimum, double maximum)
1333
1334 This signal is emitted whenever a property created by this manager
1335 changes its range of valid values, passing a pointer to the
1336 \a property and the new \a minimum and \a maximum values
1337
1338 \sa setRange()
1339*/
1340
1341/*!
1342 \fn void QtDoublePropertyManager::decimalsChanged(QtProperty *property, int prec)
1343
1344 This signal is emitted whenever a property created by this manager
1345 changes its precision of value, passing a pointer to the
1346 \a property and the new \a prec value
1347
1348 \sa setDecimals()
1349*/
1350
1351/*!
1352 \fn void QtDoublePropertyManager::singleStepChanged(QtProperty *property, double step)
1353
1354 This signal is emitted whenever a property created by this manager
1355 changes its single step property, passing a pointer to the
1356 \a property and the new \a step value
1357
1358 \sa setSingleStep()
1359*/
1360
1361/*!
1362 Creates a manager with the given \a parent.
1363*/
1366{
1368 d_ptr->q_ptr = this;
1369}
1370
1371/*!
1372 Destroys this manager, and all the properties it has created.
1373*/
1375{
1376 clear();
1377 delete d_ptr;
1378}
1379
1380/*!
1381 Returns the given \a property's value.
1382
1383 If the given property is not managed by this manager, this
1384 function returns 0.
1385
1386 \sa setValue()
1387*/
1388double
1390{
1391 return getValue<double>(d_ptr->m_values, property, 0.0);
1392}
1393
1394/*!
1395 Returns the given \a property's minimum value.
1396
1397 \sa maximum(), setRange()
1398*/
1399double
1401{
1402 return getMinimum<double>(d_ptr->m_values, property, 0.0);
1403}
1404
1405/*!
1406 Returns the given \a property's maximum value.
1407
1408 \sa minimum(), setRange()
1409*/
1410double
1412{
1413 return getMaximum<double>(d_ptr->m_values, property, 0.0);
1414}
1415
1416/*!
1417 Returns the given \a property's step value.
1418
1419 The step is typically used to increment or decrement a property value while pressing an arrow key.
1420
1421 \sa setSingleStep()
1422*/
1423double
1425{
1426 return getData<double>(
1427 d_ptr->m_values, &QtDoublePropertyManagerPrivate::Data::singleStep, property, 0);
1428}
1429
1430/*!
1431 Returns the given \a property's precision, in decimals.
1432
1433 \sa setDecimals()
1434*/
1435int
1437{
1438 return getData<int>(
1439 d_ptr->m_values, &QtDoublePropertyManagerPrivate::Data::decimals, property, 0);
1440}
1441
1442/*!
1443 Returns read-only status of the property.
1444
1445 When property is read-only it's value can be selected and copied from editor but not modified.
1446
1447 \sa QtDoublePropertyManager::setReadOnly
1448*/
1449bool
1451{
1452 return getData<bool>(
1453 d_ptr->m_values, &QtDoublePropertyManagerPrivate::Data::readOnly, property, false);
1454}
1455
1456/*!
1457 \reimp
1458*/
1459QString
1461{
1462 const QtDoublePropertyManagerPrivate::PropertyValueMap::const_iterator it =
1463 d_ptr->m_values.constFind(property);
1464
1465 if (it == d_ptr->m_values.constEnd())
1466 {
1467 return QString();
1468 }
1469
1470 return QLocale::system().toString(it.value().val, 'f', it.value().decimals);
1471}
1472
1473/*!
1474 \fn void QtDoublePropertyManager::setValue(QtProperty *property, double value)
1475
1476 Sets the value of the given \a property to \a value.
1477
1478 If the specified \a value is not valid according to the given
1479 \a property's range, the \a value is adjusted to the nearest valid value
1480 within the range.
1481
1482 \sa value(), setRange(), valueChanged()
1483*/
1484void
1486{
1487 void (QtDoublePropertyManagerPrivate::*setSubPropertyValue)(QtProperty*, double) = 0;
1488 setValueInRange<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(
1489 this,
1490 d_ptr,
1493 property,
1494 val,
1495 setSubPropertyValue);
1496}
1497
1498/*!
1499 Sets the step value for the given \a property to \a step.
1500
1501 The step is typically used to increment or decrement a property value while pressing an arrow key.
1502
1503 \sa singleStep()
1504*/
1505void
1507{
1508 const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it =
1509 d_ptr->m_values.find(property);
1510
1511 if (it == d_ptr->m_values.end())
1512 {
1513 return;
1514 }
1515
1517
1518 if (step < 0)
1519 {
1520 step = 0;
1521 }
1522
1523 if (data.singleStep == step)
1524 {
1525 return;
1526 }
1527
1528 data.singleStep = step;
1529
1530 it.value() = data;
1531
1532 emit singleStepChanged(property, data.singleStep);
1533}
1534
1535/*!
1536 Sets read-only status of the property.
1537
1538 \sa QtDoublePropertyManager::setReadOnly
1539*/
1540void
1542{
1543 const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it =
1544 d_ptr->m_values.find(property);
1545
1546 if (it == d_ptr->m_values.end())
1547 {
1548 return;
1549 }
1550
1552
1553 if (data.readOnly == readOnly)
1554 {
1555 return;
1556 }
1557
1558 data.readOnly = readOnly;
1559 it.value() = data;
1560
1561 emit propertyChanged(property);
1562 emit readOnlyChanged(property, data.readOnly);
1563}
1564
1565/*!
1566 \fn void QtDoublePropertyManager::setDecimals(QtProperty *property, int prec)
1567
1568 Sets the precision of the given \a property to \a prec.
1569
1570 The valid decimal range is 0-13. The default is 2.
1571
1572 \sa decimals()
1573*/
1574void
1576{
1577 const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it =
1578 d_ptr->m_values.find(property);
1579
1580 if (it == d_ptr->m_values.end())
1581 {
1582 return;
1583 }
1584
1586
1587 if (prec > 13)
1588 {
1589 prec = 13;
1590 }
1591 else if (prec < 0)
1592 {
1593 prec = 0;
1594 }
1595
1596 if (data.decimals == prec)
1597 {
1598 return;
1599 }
1600
1601 data.decimals = prec;
1602
1603 it.value() = data;
1604
1605 emit decimalsChanged(property, data.decimals);
1606}
1607
1608/*!
1609 Sets the minimum value for the given \a property to \a minVal.
1610
1611 When setting the minimum value, the maximum and current values are
1612 adjusted if necessary (ensuring that the range remains valid and
1613 that the current value is within in the range).
1614
1615 \sa minimum(), setRange(), rangeChanged()
1616*/
1617void
1619{
1620 setMinimumValue<double,
1623 double,
1625 d_ptr,
1629 property,
1630 minVal);
1631}
1632
1633/*!
1634 Sets the maximum value for the given \a property to \a maxVal.
1635
1636 When setting the maximum value, the minimum and current values are
1637 adjusted if necessary (ensuring that the range remains valid and
1638 that the current value is within in the range).
1639
1640 \sa maximum(), setRange(), rangeChanged()
1641*/
1642void
1644{
1645 setMaximumValue<double,
1648 double,
1650 d_ptr,
1654 property,
1655 maxVal);
1656}
1657
1658/*!
1659 \fn void QtDoublePropertyManager::setRange(QtProperty *property, double minimum, double maximum)
1660
1661 Sets the range of valid values.
1662
1663 This is a convenience function defining the range of valid values
1664 in one go; setting the \a minimum and \a maximum values for the
1665 given \a property with a single function call.
1666
1667 When setting a new range, the current value is adjusted if
1668 necessary (ensuring that the value remains within range).
1669
1670 \sa setMinimum(), setMaximum(), rangeChanged()
1671*/
1672void
1673QtDoublePropertyManager::setRange(QtProperty* property, double minVal, double maxVal)
1674{
1675 void (QtDoublePropertyManagerPrivate::*setSubPropertyRange)(
1676 QtProperty*, double, double, double) = 0;
1677 setBorderValues<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(
1678 this,
1679 d_ptr,
1683 property,
1684 minVal,
1685 maxVal,
1686 setSubPropertyRange);
1687}
1688
1689/*!
1690 \reimp
1691*/
1692void
1697
1698/*!
1699 \reimp
1700*/
1701void
1703{
1704 d_ptr->m_values.remove(property);
1705}
1706
1707// QtStringPropertyManager
1708
1710{
1712 Q_DECLARE_PUBLIC(QtStringPropertyManager)
1713public:
1714 struct Data
1715 {
1717 regExp(QString(QLatin1Char('*')), Qt::CaseSensitive, QRegExp::Wildcard),
1718 echoMode(QLineEdit::Normal),
1719 readOnly(false)
1720 {
1721 }
1722
1723 QString val;
1724 QRegExp regExp;
1727 };
1728
1729 using PropertyValueMap = QMap<const QtProperty*, Data>;
1730 QMap<const QtProperty*, Data> m_values;
1731};
1732
1733/*!
1734 \class QtStringPropertyManager
1735
1736 \brief The QtStringPropertyManager provides and manages QString properties.
1737
1738 A string property's value can be retrieved using the value()
1739 function, and set using the setValue() slot.
1740
1741 The current value can be checked against a regular expression. To
1742 set the regular expression use the setRegExp() slot, use the
1743 regExp() function to retrieve the currently set expression.
1744
1745 In addition, QtStringPropertyManager provides the valueChanged() signal
1746 which is emitted whenever a property created by this manager
1747 changes, and the regExpChanged() signal which is emitted whenever
1748 such a property changes its currently set regular expression.
1749
1750 \sa QtAbstractPropertyManager, QtLineEditFactory
1751*/
1752
1753/*!
1754 \fn void QtStringPropertyManager::valueChanged(QtProperty *property, const QString &value)
1755
1756 This signal is emitted whenever a property created by this manager
1757 changes its value, passing a pointer to the \a property and the
1758 new \a value as parameters.
1759
1760 \sa setValue()
1761*/
1762
1763/*!
1764 \fn void QtStringPropertyManager::regExpChanged(QtProperty *property, const QRegExp &regExp)
1765
1766 This signal is emitted whenever a property created by this manager
1767 changes its currenlty set regular expression, passing a pointer to
1768 the \a property and the new \a regExp as parameters.
1769
1770 \sa setRegExp()
1771*/
1772
1773/*!
1774 Creates a manager with the given \a parent.
1775*/
1778{
1780 d_ptr->q_ptr = this;
1781}
1782
1783/*!
1784 Destroys this manager, and all the properties it has created.
1785*/
1787{
1788 clear();
1789 delete d_ptr;
1790}
1791
1792/*!
1793 Returns the given \a property's value.
1794
1795 If the given property is not managed by this manager, this
1796 function returns an empty string.
1797
1798 \sa setValue()
1799*/
1800QString
1802{
1803 return getValue<QString>(d_ptr->m_values, property);
1804}
1805
1806/*!
1807 Returns the given \a property's currently set regular expression.
1808
1809 If the given \a property is not managed by this manager, this
1810 function returns an empty expression.
1811
1812 \sa setRegExp()
1813*/
1814QRegExp
1816{
1817 return getData<QRegExp>(
1818 d_ptr->m_values, &QtStringPropertyManagerPrivate::Data::regExp, property, QRegExp());
1819}
1820
1821/*!
1822 \reimp
1823*/
1826{
1827 return (EchoMode)getData<int>(
1828 d_ptr->m_values, &QtStringPropertyManagerPrivate::Data::echoMode, property, 0);
1829}
1830
1831/*!
1832 Returns read-only status of the property.
1833
1834 When property is read-only it's value can be selected and copied from editor but not modified.
1835
1836 \sa QtStringPropertyManager::setReadOnly
1837*/
1838bool
1840{
1841 return getData<bool>(
1842 d_ptr->m_values, &QtStringPropertyManagerPrivate::Data::readOnly, property, false);
1843}
1844
1845/*!
1846 \reimp
1847*/
1848QString
1850{
1851 const QtStringPropertyManagerPrivate::PropertyValueMap::const_iterator it =
1852 d_ptr->m_values.constFind(property);
1853
1854 if (it == d_ptr->m_values.constEnd())
1855 {
1856 return QString();
1857 }
1858
1859 return it.value().val;
1860}
1861
1862/*!
1863 \reimp
1864*/
1865QString
1867{
1868 const QtStringPropertyManagerPrivate::PropertyValueMap::const_iterator it =
1869 d_ptr->m_values.constFind(property);
1870
1871 if (it == d_ptr->m_values.constEnd())
1872 {
1873 return QString();
1874 }
1875
1876 QLineEdit edit;
1877 edit.setEchoMode((EchoMode)it.value().echoMode);
1878 edit.setText(it.value().val);
1879 return edit.displayText();
1880}
1881
1882/*!
1883 \fn void QtStringPropertyManager::setValue(QtProperty *property, const QString &value)
1884
1885 Sets the value of the given \a property to \a value.
1886
1887 If the specified \a value doesn't match the given \a property's
1888 regular expression, this function does nothing.
1889
1890 \sa value(), setRegExp(), valueChanged()
1891*/
1892void
1893QtStringPropertyManager::setValue(QtProperty* property, const QString& val)
1894{
1895 const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it =
1896 d_ptr->m_values.find(property);
1897
1898 if (it == d_ptr->m_values.end())
1899 {
1900 return;
1901 }
1902
1904
1905 if (data.val == val)
1906 {
1907 return;
1908 }
1909
1910 if (data.regExp.isValid() && !data.regExp.exactMatch(val))
1911 {
1912 return;
1913 }
1914
1915 data.val = val;
1916
1917 it.value() = data;
1918
1919 emit propertyChanged(property);
1920 emit valueChanged(property, data.val);
1921}
1922
1923/*!
1924 Sets the regular expression of the given \a property to \a regExp.
1925
1926 \sa regExp(), setValue(), regExpChanged()
1927*/
1928void
1930{
1931 const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it =
1932 d_ptr->m_values.find(property);
1933
1934 if (it == d_ptr->m_values.end())
1935 {
1936 return;
1937 }
1938
1940
1941 if (data.regExp == regExp)
1942 {
1943 return;
1944 }
1945
1946 data.regExp = regExp;
1947
1948 it.value() = data;
1949
1950 emit regExpChanged(property, data.regExp);
1951}
1952
1953void
1955{
1956 const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it =
1957 d_ptr->m_values.find(property);
1958
1959 if (it == d_ptr->m_values.end())
1960 {
1961 return;
1962 }
1963
1965
1966 if (data.echoMode == echoMode)
1967 {
1968 return;
1969 }
1970
1971 data.echoMode = echoMode;
1972 it.value() = data;
1973
1974 emit propertyChanged(property);
1975 emit echoModeChanged(property, data.echoMode);
1976}
1977
1978/*!
1979 Sets read-only status of the property.
1980
1981 \sa QtStringPropertyManager::setReadOnly
1982*/
1983void
1985{
1986 const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it =
1987 d_ptr->m_values.find(property);
1988
1989 if (it == d_ptr->m_values.end())
1990 {
1991 return;
1992 }
1993
1995
1996 if (data.readOnly == readOnly)
1997 {
1998 return;
1999 }
2000
2001 data.readOnly = readOnly;
2002 it.value() = data;
2003
2004 emit propertyChanged(property);
2005 emit readOnlyChanged(property, data.readOnly);
2006}
2007
2008/*!
2009 \reimp
2010*/
2011void
2016
2017/*!
2018 \reimp
2019*/
2020void
2022{
2023 d_ptr->m_values.remove(property);
2024}
2025
2026// QtBoolPropertyManager
2027// Return an icon containing a check box indicator
2028static QIcon
2029drawCheckBox(bool value)
2030{
2031 QStyleOptionButton opt;
2032 opt.state |= value ? QStyle::State_On : QStyle::State_Off;
2033 opt.state |= QStyle::State_Enabled;
2034 const QStyle* style = QApplication::style();
2035 // Figure out size of an indicator and make sure it is not scaled down in a list view item
2036 // by making the pixmap as big as a list view icon and centering the indicator in it.
2037 // (if it is smaller, it can't be helped)
2038 const int indicatorWidth = style->pixelMetric(QStyle::PM_IndicatorWidth, &opt);
2039 const int indicatorHeight = style->pixelMetric(QStyle::PM_IndicatorHeight, &opt);
2040 const int listViewIconSize = indicatorWidth;
2041 const int pixmapWidth = indicatorWidth;
2042 const int pixmapHeight = qMax(indicatorHeight, listViewIconSize);
2043
2044 opt.rect = QRect(0, 0, indicatorWidth, indicatorHeight);
2045 QPixmap pixmap = QPixmap(pixmapWidth, pixmapHeight);
2046 pixmap.fill(Qt::transparent);
2047 {
2048 // Center?
2049 const int xoff = (pixmapWidth > indicatorWidth) ? (pixmapWidth - indicatorWidth) / 2 : 0;
2050 const int yoff =
2051 (pixmapHeight > indicatorHeight) ? (pixmapHeight - indicatorHeight) / 2 : 0;
2052 QPainter painter(&pixmap);
2053 painter.translate(xoff, yoff);
2054 style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter);
2055 }
2056 return QIcon(pixmap);
2057}
2058
2060{
2061 QtBoolPropertyManager* q_ptr;
2062 Q_DECLARE_PUBLIC(QtBoolPropertyManager)
2063public:
2065
2066 struct Data
2067 {
2068 Data() : val(false), textVisible(true)
2069 {
2070 }
2071
2072 bool val;
2074 };
2075
2076 using PropertyValueMap = QMap<const QtProperty*, Data>;
2078
2079 const QIcon m_checkedIcon;
2080 const QIcon m_uncheckedIcon;
2081};
2082
2084 m_checkedIcon(drawCheckBox(true)), m_uncheckedIcon(drawCheckBox(false))
2085{
2086}
2087
2088/*!
2089 \class QtBoolPropertyManager
2090
2091 \brief The QtBoolPropertyManager class provides and manages boolean properties.
2092
2093 The property's value can be retrieved using the value() function,
2094 and set using the setValue() slot.
2095
2096 In addition, QtBoolPropertyManager provides the valueChanged() signal
2097 which is emitted whenever a property created by this manager
2098 changes.
2099
2100 \sa QtAbstractPropertyManager, QtCheckBoxFactory
2101*/
2102
2103/*!
2104 \fn void QtBoolPropertyManager::valueChanged(QtProperty *property, bool value)
2105
2106 This signal is emitted whenever a property created by this manager
2107 changes its value, passing a pointer to the \a property and the
2108 new \a value as parameters.
2109*/
2110
2111/*!
2112 Creates a manager with the given \a parent.
2113*/
2115{
2116 d_ptr = new QtBoolPropertyManagerPrivate;
2117 d_ptr->q_ptr = this;
2118}
2119
2120/*!
2121 Destroys this manager, and all the properties it has created.
2122*/
2124{
2125 clear();
2126 delete d_ptr;
2127}
2128
2129/*!
2130 Returns the given \a property's value.
2131
2132 If the given \a property is not managed by \e this manager, this
2133 function returns false.
2134
2135 \sa setValue()
2136*/
2137bool
2139{
2140 return getValue<bool>(d_ptr->m_values, property, false);
2141}
2142
2143bool
2145{
2146 return getData<bool>(
2147 d_ptr->m_values, &QtBoolPropertyManagerPrivate::Data::textVisible, property, false);
2148}
2149
2150/*!
2151 \reimp
2152*/
2153QString
2155{
2156 const QtBoolPropertyManagerPrivate::PropertyValueMap::const_iterator it =
2157 d_ptr->m_values.constFind(property);
2158
2159 if (it == d_ptr->m_values.constEnd())
2160 {
2161 return QString();
2162 }
2163
2164 const QtBoolPropertyManagerPrivate::Data& data = it.value();
2165
2166 if (!data.textVisible)
2167 {
2168 return QString();
2169 }
2170
2171 static const QString trueText = tr("True");
2172 static const QString falseText = tr("False");
2173 return data.val ? trueText : falseText;
2174}
2175
2176/*!
2177 \reimp
2178*/
2179QIcon
2181{
2182 const QtBoolPropertyManagerPrivate::PropertyValueMap::const_iterator it =
2183 d_ptr->m_values.constFind(property);
2184
2185 if (it == d_ptr->m_values.constEnd())
2186 {
2187 return QIcon();
2188 }
2189
2190 return it.value().val ? d_ptr->m_checkedIcon : d_ptr->m_uncheckedIcon;
2191}
2192
2193/*!
2194 \fn void QtBoolPropertyManager::setValue(QtProperty *property, bool value)
2195
2196 Sets the value of the given \a property to \a value.
2197
2198 \sa value()
2199*/
2200void
2202{
2203 const QtBoolPropertyManagerPrivate::PropertyValueMap::iterator it =
2204 d_ptr->m_values.find(property);
2205
2206 if (it == d_ptr->m_values.end())
2207 {
2208 return;
2209 }
2210
2212
2213 if (data.val == val)
2214 {
2215 return;
2216 }
2217
2218 data.val = val;
2219 it.value() = data;
2220
2221 emit propertyChanged(property);
2222 emit valueChanged(property, data.val);
2223}
2224
2225void
2227{
2228 const QtBoolPropertyManagerPrivate::PropertyValueMap::iterator it =
2229 d_ptr->m_values.find(property);
2230
2231 if (it == d_ptr->m_values.end())
2232 {
2233 return;
2234 }
2235
2237
2238 if (data.textVisible == textVisible)
2239 {
2240 return;
2241 }
2242
2243 data.textVisible = textVisible;
2244 it.value() = data;
2245
2246 emit propertyChanged(property);
2247 emit textVisibleChanged(property, data.textVisible);
2248}
2249
2250/*!
2251 \reimp
2252*/
2253void
2255{
2256 d_ptr->m_values[property] = QtBoolPropertyManagerPrivate::Data();
2257}
2258
2259/*!
2260 \reimp
2261*/
2262void
2264{
2265 d_ptr->m_values.remove(property);
2266}
2267
2268// QtDatePropertyManager
2269
2271{
2272 QtDatePropertyManager* q_ptr;
2273 Q_DECLARE_PUBLIC(QtDatePropertyManager)
2274public:
2275 struct Data
2276 {
2277 Data() : val(QDate::currentDate()), minVal(QDate(1752, 9, 14)), maxVal(QDate(7999, 12, 31))
2278 {
2279 }
2280
2281 QDate val;
2282 QDate minVal;
2283 QDate maxVal;
2284
2285 QDate
2287 {
2288 return minVal;
2289 }
2290
2291 QDate
2293 {
2294 return maxVal;
2295 }
2296
2297 void
2298 setMinimumValue(const QDate& newMinVal)
2299 {
2300 setSimpleMinimumData(this, newMinVal);
2301 }
2302
2303 void
2304 setMaximumValue(const QDate& newMaxVal)
2305 {
2306 setSimpleMaximumData(this, newMaxVal);
2307 }
2308 };
2309
2310 QString m_format;
2311
2312 using PropertyValueMap = QMap<const QtProperty*, Data>;
2313 QMap<const QtProperty*, Data> m_values;
2314};
2315
2316/*!
2317 \class QtDatePropertyManager
2318
2319 \brief The QtDatePropertyManager provides and manages QDate properties.
2320
2321 A date property has a current value, and a range specifying the
2322 valid dates. The range is defined by a minimum and a maximum
2323 value.
2324
2325 The property's values can be retrieved using the minimum(),
2326 maximum() and value() functions, and can be set using the
2327 setMinimum(), setMaximum() and setValue() slots. Alternatively,
2328 the range can be defined in one go using the setRange() slot.
2329
2330 In addition, QtDatePropertyManager provides the valueChanged() signal
2331 which is emitted whenever a property created by this manager
2332 changes, and the rangeChanged() signal which is emitted whenever
2333 such a property changes its range of valid dates.
2334
2335 \sa QtAbstractPropertyManager, QtDateEditFactory, QtDateTimePropertyManager
2336*/
2337
2338/*!
2339 \fn void QtDatePropertyManager::valueChanged(QtProperty *property, const QDate &value)
2340
2341 This signal is emitted whenever a property created by this manager
2342 changes its value, passing a pointer to the \a property and the new
2343 \a value as parameters.
2344
2345 \sa setValue()
2346*/
2347
2348/*!
2349 \fn void QtDatePropertyManager::rangeChanged(QtProperty *property, const QDate &minimum, const QDate &maximum)
2350
2351 This signal is emitted whenever a property created by this manager
2352 changes its range of valid dates, passing a pointer to the \a
2353 property and the new \a minimum and \a maximum dates.
2354
2355 \sa setRange()
2356*/
2357
2358/*!
2359 Creates a manager with the given \a parent.
2360*/
2362{
2363 d_ptr = new QtDatePropertyManagerPrivate;
2364 d_ptr->q_ptr = this;
2365
2366 QLocale loc;
2367 d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat);
2368}
2369
2370/*!
2371 Destroys this manager, and all the properties it has created.
2372*/
2374{
2375 clear();
2376 delete d_ptr;
2377}
2378
2379/*!
2380 Returns the given \a property's value.
2381
2382 If the given \a property is not managed by \e this manager, this
2383 function returns an invalid date.
2384
2385 \sa setValue()
2386*/
2387QDate
2389{
2390 return getValue<QDate>(d_ptr->m_values, property);
2391}
2392
2393/*!
2394 Returns the given \a property's minimum date.
2395
2396 \sa maximum(), setRange()
2397*/
2398QDate
2400{
2401 return getMinimum<QDate>(d_ptr->m_values, property);
2402}
2403
2404/*!
2405 Returns the given \a property's maximum date.
2406
2407 \sa minimum(), setRange()
2408*/
2409QDate
2411{
2412 return getMaximum<QDate>(d_ptr->m_values, property);
2413}
2414
2415/*!
2416 \reimp
2417*/
2418QString
2420{
2421 const QtDatePropertyManagerPrivate::PropertyValueMap::const_iterator it =
2422 d_ptr->m_values.constFind(property);
2423
2424 if (it == d_ptr->m_values.constEnd())
2425 {
2426 return QString();
2427 }
2428
2429 return it.value().val.toString(d_ptr->m_format);
2430}
2431
2432/*!
2433 \fn void QtDatePropertyManager::setValue(QtProperty *property, const QDate &value)
2434
2435 Sets the value of the given \a property to \a value.
2436
2437 If the specified \a value is not a valid date according to the
2438 given \a property's range, the value is adjusted to the nearest
2439 valid value within the range.
2440
2441 \sa value(), setRange(), valueChanged()
2442*/
2443void
2445{
2446 void (QtDatePropertyManagerPrivate::*setSubPropertyValue)(QtProperty*, const QDate&) = 0;
2447 setValueInRange<const QDate&, QtDatePropertyManagerPrivate, QtDatePropertyManager, const QDate>(
2448 this,
2449 d_ptr,
2452 property,
2453 val,
2454 setSubPropertyValue);
2455}
2456
2457/*!
2458 Sets the minimum value for the given \a property to \a minVal.
2459
2460 When setting the minimum value, the maximum and current values are
2461 adjusted if necessary (ensuring that the range remains valid and
2462 that the current value is within in the range).
2463
2464 \sa minimum(), setRange()
2465*/
2466void
2467QtDatePropertyManager::setMinimum(QtProperty* property, const QDate& minVal)
2468{
2469 setMinimumValue<const QDate&,
2472 QDate,
2474 d_ptr,
2478 property,
2479 minVal);
2480}
2481
2482/*!
2483 Sets the maximum value for the given \a property to \a maxVal.
2484
2485 When setting the maximum value, the minimum and current
2486 values are adjusted if necessary (ensuring that the range remains
2487 valid and that the current value is within in the range).
2488
2489 \sa maximum(), setRange()
2490*/
2491void
2492QtDatePropertyManager::setMaximum(QtProperty* property, const QDate& maxVal)
2493{
2494 setMaximumValue<const QDate&,
2497 QDate,
2499 d_ptr,
2503 property,
2504 maxVal);
2505}
2506
2507/*!
2508 \fn void QtDatePropertyManager::setRange(QtProperty *property, const QDate &minimum, const QDate &maximum)
2509
2510 Sets the range of valid dates.
2511
2512 This is a convenience function defining the range of valid dates
2513 in one go; setting the \a minimum and \a maximum values for the
2514 given \a property with a single function call.
2515
2516 When setting a new date range, the current value is adjusted if
2517 necessary (ensuring that the value remains in date range).
2518
2519 \sa setMinimum(), setMaximum(), rangeChanged()
2520*/
2521void
2522QtDatePropertyManager::setRange(QtProperty* property, const QDate& minVal, const QDate& maxVal)
2523{
2524 void (QtDatePropertyManagerPrivate::*setSubPropertyRange)(
2525 QtProperty*, const QDate&, const QDate&, const QDate&) = 0;
2526 setBorderValues<const QDate&, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate>(
2527 this,
2528 d_ptr,
2532 property,
2533 minVal,
2534 maxVal,
2535 setSubPropertyRange);
2536}
2537
2538/*!
2539 \reimp
2540*/
2541void
2543{
2544 d_ptr->m_values[property] = QtDatePropertyManagerPrivate::Data();
2545}
2546
2547/*!
2548 \reimp
2549*/
2550void
2552{
2553 d_ptr->m_values.remove(property);
2554}
2555
2556// QtTimePropertyManager
2557
2559{
2560 QtTimePropertyManager* q_ptr;
2561 Q_DECLARE_PUBLIC(QtTimePropertyManager)
2562public:
2563 QString m_format;
2564
2565 using PropertyValueMap = QMap<const QtProperty*, QTime>;
2567};
2568
2569/*!
2570 \class QtTimePropertyManager
2571
2572 \brief The QtTimePropertyManager provides and manages QTime properties.
2573
2574 A time property's value can be retrieved using the value()
2575 function, and set using the setValue() slot.
2576
2577 In addition, QtTimePropertyManager provides the valueChanged() signal
2578 which is emitted whenever a property created by this manager
2579 changes.
2580
2581 \sa QtAbstractPropertyManager, QtTimeEditFactory
2582*/
2583
2584/*!
2585 \fn void QtTimePropertyManager::valueChanged(QtProperty *property, const QTime &value)
2586
2587 This signal is emitted whenever a property created by this manager
2588 changes its value, passing a pointer to the \a property and the
2589 new \a value as parameters.
2590
2591 \sa setValue()
2592*/
2593
2594/*!
2595 Creates a manager with the given \a parent.
2596*/
2598{
2599 d_ptr = new QtTimePropertyManagerPrivate;
2600 d_ptr->q_ptr = this;
2601
2602 QLocale loc;
2603 d_ptr->m_format = loc.timeFormat(QLocale::ShortFormat);
2604}
2605
2606/*!
2607 Destroys this manager, and all the properties it has created.
2608*/
2610{
2611 clear();
2612 delete d_ptr;
2613}
2614
2615/*!
2616 Returns the given \a property's value.
2617
2618 If the given property is not managed by this manager, this
2619 function returns an invalid time object.
2620
2621 \sa setValue()
2622*/
2623QTime
2625{
2626 return d_ptr->m_values.value(property, QTime());
2627}
2628
2629/*!
2630 \reimp
2631*/
2632QString
2634{
2635 const QtTimePropertyManagerPrivate::PropertyValueMap::const_iterator it =
2636 d_ptr->m_values.constFind(property);
2637
2638 if (it == d_ptr->m_values.constEnd())
2639 {
2640 return QString();
2641 }
2642
2643 return it.value().toString(d_ptr->m_format);
2644}
2645
2646/*!
2647 \fn void QtTimePropertyManager::setValue(QtProperty *property, const QTime &value)
2648
2649 Sets the value of the given \a property to \a value.
2650
2651 \sa value(), valueChanged()
2652*/
2653void
2655{
2656 setSimpleValue<const QTime&, QTime, QtTimePropertyManager>(
2657 d_ptr->m_values,
2658 this,
2661 property,
2662 val);
2663}
2664
2665/*!
2666 \reimp
2667*/
2668void
2670{
2671 d_ptr->m_values[property] = QTime::currentTime();
2672}
2673
2674/*!
2675 \reimp
2676*/
2677void
2679{
2680 d_ptr->m_values.remove(property);
2681}
2682
2683// QtDateTimePropertyManager
2684
2686{
2688 Q_DECLARE_PUBLIC(QtDateTimePropertyManager)
2689public:
2690 QString m_format;
2691
2692 using PropertyValueMap = QMap<const QtProperty*, QDateTime>;
2694};
2695
2696/*! \class QtDateTimePropertyManager
2697
2698 \brief The QtDateTimePropertyManager provides and manages QDateTime properties.
2699
2700 A date and time property has a current value which can be
2701 retrieved using the value() function, and set using the setValue()
2702 slot. In addition, QtDateTimePropertyManager provides the
2703 valueChanged() signal which is emitted whenever a property created
2704 by this manager changes.
2705
2706 \sa QtAbstractPropertyManager, QtDateTimeEditFactory, QtDatePropertyManager
2707*/
2708
2709/*!
2710 \fn void QtDateTimePropertyManager::valueChanged(QtProperty *property, const QDateTime &value)
2711
2712 This signal is emitted whenever a property created by this manager
2713 changes its value, passing a pointer to the \a property and the new
2714 \a value as parameters.
2715*/
2716
2717/*!
2718 Creates a manager with the given \a parent.
2719*/
2722{
2724 d_ptr->q_ptr = this;
2725
2726 QLocale loc;
2727 d_ptr->m_format = loc.dateFormat(QLocale::ShortFormat);
2728 d_ptr->m_format += QLatin1Char(' ');
2729 d_ptr->m_format += loc.timeFormat(QLocale::ShortFormat);
2730}
2731
2732/*!
2733 Destroys this manager, and all the properties it has created.
2734*/
2736{
2737 clear();
2738 delete d_ptr;
2739}
2740
2741/*!
2742 Returns the given \a property's value.
2743
2744 If the given \a property is not managed by this manager, this
2745 function returns an invalid QDateTime object.
2746
2747 \sa setValue()
2748*/
2749QDateTime
2751{
2752 return d_ptr->m_values.value(property, QDateTime());
2753}
2754
2755/*!
2756 \reimp
2757*/
2758QString
2760{
2761 const QtDateTimePropertyManagerPrivate::PropertyValueMap::const_iterator it =
2762 d_ptr->m_values.constFind(property);
2763
2764 if (it == d_ptr->m_values.constEnd())
2765 {
2766 return QString();
2767 }
2768
2769 return it.value().toString(d_ptr->m_format);
2770}
2771
2772/*!
2773 \fn void QtDateTimePropertyManager::setValue(QtProperty *property, const QDateTime &value)
2774
2775 Sets the value of the given \a property to \a value.
2776
2777 \sa value(), valueChanged()
2778*/
2779void
2780QtDateTimePropertyManager::setValue(QtProperty* property, const QDateTime& val)
2781{
2782 setSimpleValue<const QDateTime&, QDateTime, QtDateTimePropertyManager>(
2783 d_ptr->m_values,
2784 this,
2787 property,
2788 val);
2789}
2790
2791/*!
2792 \reimp
2793*/
2794void
2796{
2797 d_ptr->m_values[property] = QDateTime::currentDateTime();
2798}
2799
2800/*!
2801 \reimp
2802*/
2803void
2805{
2806 d_ptr->m_values.remove(property);
2807}
2808
2809// QtKeySequencePropertyManager
2810
2812{
2814 Q_DECLARE_PUBLIC(QtKeySequencePropertyManager)
2815public:
2816 QString m_format;
2817
2818 using PropertyValueMap = QMap<const QtProperty*, QKeySequence>;
2820};
2821
2822/*! \class QtKeySequencePropertyManager
2823
2824 \brief The QtKeySequencePropertyManager provides and manages QKeySequence properties.
2825
2826 A key sequence's value can be retrieved using the value()
2827 function, and set using the setValue() slot.
2828
2829 In addition, QtKeySequencePropertyManager provides the valueChanged() signal
2830 which is emitted whenever a property created by this manager
2831 changes.
2832
2833 \sa QtAbstractPropertyManager
2834*/
2835
2836/*!
2837 \fn void QtKeySequencePropertyManager::valueChanged(QtProperty *property, const QKeySequence &value)
2838
2839 This signal is emitted whenever a property created by this manager
2840 changes its value, passing a pointer to the \a property and the new
2841 \a value as parameters.
2842*/
2843
2844/*!
2845 Creates a manager with the given \a parent.
2846*/
2849{
2851 d_ptr->q_ptr = this;
2852}
2853
2854/*!
2855 Destroys this manager, and all the properties it has created.
2856*/
2862
2863/*!
2864 Returns the given \a property's value.
2865
2866 If the given \a property is not managed by this manager, this
2867 function returns an empty QKeySequence object.
2868
2869 \sa setValue()
2870*/
2871QKeySequence
2873{
2874 return d_ptr->m_values.value(property, QKeySequence());
2875}
2876
2877/*!
2878 \reimp
2879*/
2880QString
2882{
2883 const QtKeySequencePropertyManagerPrivate::PropertyValueMap::const_iterator it =
2884 d_ptr->m_values.constFind(property);
2885
2886 if (it == d_ptr->m_values.constEnd())
2887 {
2888 return QString();
2889 }
2890
2891 return it.value().toString(QKeySequence::NativeText);
2892}
2893
2894/*!
2895 \fn void QtKeySequencePropertyManager::setValue(QtProperty *property, const QKeySequence &value)
2896
2897 Sets the value of the given \a property to \a value.
2898
2899 \sa value(), valueChanged()
2900*/
2901void
2902QtKeySequencePropertyManager::setValue(QtProperty* property, const QKeySequence& val)
2903{
2904 setSimpleValue<const QKeySequence&, QKeySequence, QtKeySequencePropertyManager>(
2905 d_ptr->m_values,
2906 this,
2909 property,
2910 val);
2911}
2912
2913/*!
2914 \reimp
2915*/
2916void
2918{
2919 d_ptr->m_values[property] = QKeySequence();
2920}
2921
2922/*!
2923 \reimp
2924*/
2925void
2927{
2928 d_ptr->m_values.remove(property);
2929}
2930
2931// QtCharPropertyManager
2932
2934{
2935 QtCharPropertyManager* q_ptr;
2936 Q_DECLARE_PUBLIC(QtCharPropertyManager)
2937public:
2938 using PropertyValueMap = QMap<const QtProperty*, QChar>;
2940};
2941
2942/*! \class QtCharPropertyManager
2943
2944 \brief The QtCharPropertyManager provides and manages QChar properties.
2945
2946 A char's value can be retrieved using the value()
2947 function, and set using the setValue() slot.
2948
2949 In addition, QtCharPropertyManager provides the valueChanged() signal
2950 which is emitted whenever a property created by this manager
2951 changes.
2952
2953 \sa QtAbstractPropertyManager
2954*/
2955
2956/*!
2957 \fn void QtCharPropertyManager::valueChanged(QtProperty *property, const QChar &value)
2958
2959 This signal is emitted whenever a property created by this manager
2960 changes its value, passing a pointer to the \a property and the new
2961 \a value as parameters.
2962*/
2963
2964/*!
2965 Creates a manager with the given \a parent.
2966*/
2968{
2969 d_ptr = new QtCharPropertyManagerPrivate;
2970 d_ptr->q_ptr = this;
2971}
2972
2973/*!
2974 Destroys this manager, and all the properties it has created.
2975*/
2977{
2978 clear();
2979 delete d_ptr;
2980}
2981
2982/*!
2983 Returns the given \a property's value.
2984
2985 If the given \a property is not managed by this manager, this
2986 function returns an null QChar object.
2987
2988 \sa setValue()
2989*/
2990QChar
2992{
2993 return d_ptr->m_values.value(property, QChar());
2994}
2995
2996/*!
2997 \reimp
2998*/
2999QString
3001{
3002 const QtCharPropertyManagerPrivate::PropertyValueMap::const_iterator it =
3003 d_ptr->m_values.constFind(property);
3004
3005 if (it == d_ptr->m_values.constEnd())
3006 {
3007 return QString();
3008 }
3009
3010 const QChar c = it.value();
3011 return c.isNull() ? QString() : QString(c);
3012}
3013
3014/*!
3015 \fn void QtCharPropertyManager::setValue(QtProperty *property, const QChar &value)
3016
3017 Sets the value of the given \a property to \a value.
3018
3019 \sa value(), valueChanged()
3020*/
3021void
3023{
3024 setSimpleValue<const QChar&, QChar, QtCharPropertyManager>(
3025 d_ptr->m_values,
3026 this,
3029 property,
3030 val);
3031}
3032
3033/*!
3034 \reimp
3035*/
3036void
3038{
3039 d_ptr->m_values[property] = QChar();
3040}
3041
3042/*!
3043 \reimp
3044*/
3045void
3047{
3048 d_ptr->m_values.remove(property);
3049}
3050
3051// QtLocalePropertyManager
3052
3054{
3056 Q_DECLARE_PUBLIC(QtLocalePropertyManager)
3057public:
3059
3060 void slotEnumChanged(QtProperty* property, int value);
3061 void slotPropertyDestroyed(QtProperty* property);
3062
3063 using PropertyValueMap = QMap<const QtProperty*, QLocale>;
3065
3067
3068 QMap<const QtProperty*, QtProperty*> m_propertyToLanguage;
3069 QMap<const QtProperty*, QtProperty*> m_propertyToCountry;
3070
3071 QMap<const QtProperty*, QtProperty*> m_languageToProperty;
3072 QMap<const QtProperty*, QtProperty*> m_countryToProperty;
3073};
3074
3078
3079void
3081{
3082 if (QtProperty* prop = m_languageToProperty.value(property, 0))
3083 {
3084 const QLocale loc = m_values[prop];
3085 QLocale::Language newLanguage = loc.language();
3086 QLocale::Country newCountry = loc.country();
3087 metaEnumProvider()->indexToLocale(value, 0, &newLanguage, 0);
3088 QLocale newLoc(newLanguage, newCountry);
3089 q_ptr->setValue(prop, newLoc);
3090 }
3091 else if (QtProperty* prop = m_countryToProperty.value(property, 0))
3092 {
3093 const QLocale loc = m_values[prop];
3094 QLocale::Language newLanguage = loc.language();
3095 QLocale::Country newCountry = loc.country();
3096 metaEnumProvider()->indexToLocale(
3097 m_enumPropertyManager->value(m_propertyToLanguage.value(prop)),
3098 value,
3099 &newLanguage,
3100 &newCountry);
3101 QLocale newLoc(newLanguage, newCountry);
3102 q_ptr->setValue(prop, newLoc);
3103 }
3104}
3105
3106void
3108{
3109 if (QtProperty* subProp = m_languageToProperty.value(property, 0))
3110 {
3111 m_propertyToLanguage[subProp] = 0;
3112 m_languageToProperty.remove(property);
3113 }
3114 else if (QtProperty* subProp = m_countryToProperty.value(property, 0))
3115 {
3116 m_propertyToCountry[subProp] = 0;
3117 m_countryToProperty.remove(property);
3118 }
3119}
3120
3121/*!
3122 \class QtLocalePropertyManager
3123
3124 \brief The QtLocalePropertyManager provides and manages QLocale properties.
3125
3126 A locale property has nested \e language and \e country
3127 subproperties. The top-level property's value can be retrieved
3128 using the value() function, and set using the setValue() slot.
3129
3130 The subproperties are created by QtEnumPropertyManager object.
3131 These submanager can be retrieved using the subEnumPropertyManager()
3132 function. In order to provide editing widgets for the subproperties
3133 in a property browser widget, this manager must be associated with editor factory.
3134
3135 In addition, QtLocalePropertyManager provides the valueChanged()
3136 signal which is emitted whenever a property created by this
3137 manager changes.
3138
3139 \sa QtAbstractPropertyManager, QtEnumPropertyManager
3140*/
3141
3142/*!
3143 \fn void QtLocalePropertyManager::valueChanged(QtProperty *property, const QLocale &value)
3144
3145 This signal is emitted whenever a property created by this manager
3146 changes its value, passing a pointer to the \a property and the
3147 new \a value as parameters.
3148
3149 \sa setValue()
3150*/
3151
3152/*!
3153 Creates a manager with the given \a parent.
3154*/
3157{
3159 d_ptr->q_ptr = this;
3160
3161 d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
3162 connect(d_ptr->m_enumPropertyManager,
3163 SIGNAL(valueChanged(QtProperty*, int)),
3164 this,
3165 SLOT(slotEnumChanged(QtProperty*, int)));
3166
3167 connect(d_ptr->m_enumPropertyManager,
3168 SIGNAL(propertyDestroyed(QtProperty*)),
3169 this,
3170 SLOT(slotPropertyDestroyed(QtProperty*)));
3171}
3172
3173/*!
3174 Destroys this manager, and all the properties it has created.
3175*/
3177{
3178 clear();
3179 delete d_ptr;
3180}
3181
3182/*!
3183 Returns the manager that creates the nested \e language
3184 and \e country subproperties.
3185
3186 In order to provide editing widgets for the mentioned subproperties
3187 in a property browser widget, this manager must be associated with
3188 an editor factory.
3189
3190 \sa QtAbstractPropertyBrowser::setFactoryForManager()
3191*/
3194{
3195 return d_ptr->m_enumPropertyManager;
3196}
3197
3198/*!
3199 Returns the given \a property's value.
3200
3201 If the given property is not managed by this manager, this
3202 function returns the default locale.
3203
3204 \sa setValue()
3205*/
3206QLocale
3208{
3209 return d_ptr->m_values.value(property, QLocale());
3210}
3211
3212/*!
3213 \reimp
3214*/
3215QString
3217{
3218 const QtLocalePropertyManagerPrivate::PropertyValueMap::const_iterator it =
3219 d_ptr->m_values.constFind(property);
3220
3221 if (it == d_ptr->m_values.constEnd())
3222 {
3223 return QString();
3224 }
3225
3226 QLocale loc = it.value();
3227
3228 int langIdx = 0;
3229 int countryIdx = 0;
3230 metaEnumProvider()->localeToIndex(loc.language(), loc.country(), &langIdx, &countryIdx);
3231 QString str = tr("%1, %2")
3232 .arg(metaEnumProvider()->languageEnumNames().at(langIdx))
3233 .arg(metaEnumProvider()->countryEnumNames(loc.language()).at(countryIdx));
3234 return str;
3235}
3236
3237/*!
3238 \fn void QtLocalePropertyManager::setValue(QtProperty *property, const QLocale &value)
3239
3240 Sets the value of the given \a property to \a value. Nested
3241 properties are updated automatically.
3242
3243 \sa value(), valueChanged()
3244*/
3245void
3246QtLocalePropertyManager::setValue(QtProperty* property, const QLocale& val)
3247{
3248 const QtLocalePropertyManagerPrivate::PropertyValueMap::iterator it =
3249 d_ptr->m_values.find(property);
3250
3251 if (it == d_ptr->m_values.end())
3252 {
3253 return;
3254 }
3255
3256 const QLocale loc = it.value();
3257
3258 if (loc == val)
3259 {
3260 return;
3261 }
3262
3263 it.value() = val;
3264
3265 int langIdx = 0;
3266 int countryIdx = 0;
3267 metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx);
3268
3269 if (loc.language() != val.language())
3270 {
3271 d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToLanguage.value(property),
3272 langIdx);
3273 d_ptr->m_enumPropertyManager->setEnumNames(
3274 d_ptr->m_propertyToCountry.value(property),
3275 metaEnumProvider()->countryEnumNames(val.language()));
3276 }
3277
3278 d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToCountry.value(property), countryIdx);
3279
3280 emit propertyChanged(property);
3281 emit valueChanged(property, val);
3282}
3283
3284/*!
3285 \reimp
3286*/
3287void
3289{
3290 QLocale val;
3291 d_ptr->m_values[property] = val;
3292
3293 int langIdx = 0;
3294 int countryIdx = 0;
3295 metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx);
3296
3297 QtProperty* languageProp = d_ptr->m_enumPropertyManager->addProperty();
3298 languageProp->setPropertyName(tr("Language"));
3299 d_ptr->m_enumPropertyManager->setEnumNames(languageProp,
3300 metaEnumProvider()->languageEnumNames());
3301 d_ptr->m_enumPropertyManager->setValue(languageProp, langIdx);
3302 d_ptr->m_propertyToLanguage[property] = languageProp;
3303 d_ptr->m_languageToProperty[languageProp] = property;
3304 property->addSubProperty(languageProp);
3305
3306 QtProperty* countryProp = d_ptr->m_enumPropertyManager->addProperty();
3307 countryProp->setPropertyName(tr("Country"));
3308 d_ptr->m_enumPropertyManager->setEnumNames(
3309 countryProp, metaEnumProvider()->countryEnumNames(val.language()));
3310 d_ptr->m_enumPropertyManager->setValue(countryProp, countryIdx);
3311 d_ptr->m_propertyToCountry[property] = countryProp;
3312 d_ptr->m_countryToProperty[countryProp] = property;
3313 property->addSubProperty(countryProp);
3314}
3315
3316/*!
3317 \reimp
3318*/
3319void
3321{
3322 QtProperty* languageProp = d_ptr->m_propertyToLanguage[property];
3323
3324 if (languageProp)
3325 {
3326 d_ptr->m_languageToProperty.remove(languageProp);
3327 delete languageProp;
3328 }
3329
3330 d_ptr->m_propertyToLanguage.remove(property);
3331
3332 QtProperty* countryProp = d_ptr->m_propertyToCountry[property];
3333
3334 if (countryProp)
3335 {
3336 d_ptr->m_countryToProperty.remove(countryProp);
3337 delete countryProp;
3338 }
3339
3340 d_ptr->m_propertyToCountry.remove(property);
3341
3342 d_ptr->m_values.remove(property);
3343}
3344
3345// QtPointPropertyManager
3346
3348{
3350 Q_DECLARE_PUBLIC(QtPointPropertyManager)
3351public:
3352 void slotIntChanged(QtProperty* property, int value);
3353 void slotPropertyDestroyed(QtProperty* property);
3354
3355 using PropertyValueMap = QMap<const QtProperty*, QPoint>;
3357
3359
3360 QMap<const QtProperty*, QtProperty*> m_propertyToX;
3361 QMap<const QtProperty*, QtProperty*> m_propertyToY;
3362
3363 QMap<const QtProperty*, QtProperty*> m_xToProperty;
3364 QMap<const QtProperty*, QtProperty*> m_yToProperty;
3365};
3366
3367void
3369{
3370 if (QtProperty* xprop = m_xToProperty.value(property, 0))
3371 {
3372 QPoint p = m_values[xprop];
3373 p.setX(value);
3374 q_ptr->setValue(xprop, p);
3375 }
3376 else if (QtProperty* yprop = m_yToProperty.value(property, 0))
3377 {
3378 QPoint p = m_values[yprop];
3379 p.setY(value);
3380 q_ptr->setValue(yprop, p);
3381 }
3382}
3383
3384void
3386{
3387 if (QtProperty* pointProp = m_xToProperty.value(property, 0))
3388 {
3389 m_propertyToX[pointProp] = 0;
3390 m_xToProperty.remove(property);
3391 }
3392 else if (QtProperty* pointProp = m_yToProperty.value(property, 0))
3393 {
3394 m_propertyToY[pointProp] = 0;
3395 m_yToProperty.remove(property);
3396 }
3397}
3398
3399/*! \class QtPointPropertyManager
3400
3401 \brief The QtPointPropertyManager provides and manages QPoint properties.
3402
3403 A point property has nested \e x and \e y subproperties. The
3404 top-level property's value can be retrieved using the value()
3405 function, and set using the setValue() slot.
3406
3407 The subproperties are created by a QtIntPropertyManager object. This
3408 manager can be retrieved using the subIntPropertyManager() function. In
3409 order to provide editing widgets for the subproperties in a
3410 property browser widget, this manager must be associated with an
3411 editor factory.
3412
3413 In addition, QtPointPropertyManager provides the valueChanged() signal which
3414 is emitted whenever a property created by this manager changes.
3415
3416 \sa QtAbstractPropertyManager, QtIntPropertyManager, QtPointFPropertyManager
3417*/
3418
3419/*!
3420 \fn void QtPointPropertyManager::valueChanged(QtProperty *property, const QPoint &value)
3421
3422 This signal is emitted whenever a property created by this manager
3423 changes its value, passing a pointer to the \a property and the
3424 new \a value as parameters.
3425
3426 \sa setValue()
3427*/
3428
3429/*!
3430 Creates a manager with the given \a parent.
3431*/
3433{
3435 d_ptr->q_ptr = this;
3436
3437 d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
3438 connect(d_ptr->m_intPropertyManager,
3439 SIGNAL(valueChanged(QtProperty*, int)),
3440 this,
3441 SLOT(slotIntChanged(QtProperty*, int)));
3442 connect(d_ptr->m_intPropertyManager,
3443 SIGNAL(propertyDestroyed(QtProperty*)),
3444 this,
3445 SLOT(slotPropertyDestroyed(QtProperty*)));
3446}
3447
3448/*!
3449 Destroys this manager, and all the properties it has created.
3450*/
3452{
3453 clear();
3454 delete d_ptr;
3455}
3456
3457/*!
3458 Returns the manager that creates the nested \e x and \e y
3459 subproperties.
3460
3461 In order to provide editing widgets for the subproperties in a
3462 property browser widget, this manager must be associated with an
3463 editor factory.
3464
3465 \sa QtAbstractPropertyBrowser::setFactoryForManager()
3466*/
3469{
3470 return d_ptr->m_intPropertyManager;
3471}
3472
3473/*!
3474 Returns the given \a property's value.
3475
3476 If the given \a property is not managed by this manager, this
3477 function returns a point with coordinates (0, 0).
3478
3479 \sa setValue()
3480*/
3481QPoint
3483{
3484 return d_ptr->m_values.value(property, QPoint());
3485}
3486
3487/*!
3488 \reimp
3489*/
3490QString
3492{
3493 const QtPointPropertyManagerPrivate::PropertyValueMap::const_iterator it =
3494 d_ptr->m_values.constFind(property);
3495
3496 if (it == d_ptr->m_values.constEnd())
3497 {
3498 return QString();
3499 }
3500
3501 const QPoint v = it.value();
3502 return QString(tr("(%1, %2)").arg(QString::number(v.x())).arg(QString::number(v.y())));
3503}
3504
3505/*!
3506 \fn void QtPointPropertyManager::setValue(QtProperty *property, const QPoint &value)
3507
3508 Sets the value of the given \a property to \a value. Nested
3509 properties are updated automatically.
3510
3511 \sa value(), valueChanged()
3512*/
3513void
3515{
3516 const QtPointPropertyManagerPrivate::PropertyValueMap::iterator it =
3517 d_ptr->m_values.find(property);
3518
3519 if (it == d_ptr->m_values.end())
3520 {
3521 return;
3522 }
3523
3524 if (it.value() == val)
3525 {
3526 return;
3527 }
3528
3529 it.value() = val;
3530 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToX[property], val.x());
3531 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToY[property], val.y());
3532
3533 emit propertyChanged(property);
3534 emit valueChanged(property, val);
3535}
3536
3537/*!
3538 \reimp
3539*/
3540void
3542{
3543 d_ptr->m_values[property] = QPoint(0, 0);
3544
3545 QtProperty* xProp = d_ptr->m_intPropertyManager->addProperty();
3546 xProp->setPropertyName(tr("X"));
3547 d_ptr->m_intPropertyManager->setValue(xProp, 0);
3548 d_ptr->m_propertyToX[property] = xProp;
3549 d_ptr->m_xToProperty[xProp] = property;
3550 property->addSubProperty(xProp);
3551
3552 QtProperty* yProp = d_ptr->m_intPropertyManager->addProperty();
3553 yProp->setPropertyName(tr("Y"));
3554 d_ptr->m_intPropertyManager->setValue(yProp, 0);
3555 d_ptr->m_propertyToY[property] = yProp;
3556 d_ptr->m_yToProperty[yProp] = property;
3557 property->addSubProperty(yProp);
3558}
3559
3560/*!
3561 \reimp
3562*/
3563void
3565{
3566 QtProperty* xProp = d_ptr->m_propertyToX[property];
3567
3568 if (xProp)
3569 {
3570 d_ptr->m_xToProperty.remove(xProp);
3571 delete xProp;
3572 }
3573
3574 d_ptr->m_propertyToX.remove(property);
3575
3576 QtProperty* yProp = d_ptr->m_propertyToY[property];
3577
3578 if (yProp)
3579 {
3580 d_ptr->m_yToProperty.remove(yProp);
3581 delete yProp;
3582 }
3583
3584 d_ptr->m_propertyToY.remove(property);
3585
3586 d_ptr->m_values.remove(property);
3587}
3588
3589// QtPointFPropertyManager
3590
3592{
3594 Q_DECLARE_PUBLIC(QtPointFPropertyManager)
3595public:
3596 struct Data
3597 {
3599 {
3600 }
3601
3602 QPointF val;
3604 };
3605
3606 void slotDoubleChanged(QtProperty* property, double value);
3607 void slotPropertyDestroyed(QtProperty* property);
3608
3609 using PropertyValueMap = QMap<const QtProperty*, Data>;
3611
3613
3614 QMap<const QtProperty*, QtProperty*> m_propertyToX;
3615 QMap<const QtProperty*, QtProperty*> m_propertyToY;
3616
3617 QMap<const QtProperty*, QtProperty*> m_xToProperty;
3618 QMap<const QtProperty*, QtProperty*> m_yToProperty;
3619};
3620
3621void
3623{
3624 if (QtProperty* prop = m_xToProperty.value(property, 0))
3625 {
3626 QPointF p = m_values[prop].val;
3627 p.setX(value);
3628 q_ptr->setValue(prop, p);
3629 }
3630 else if (QtProperty* prop = m_yToProperty.value(property, 0))
3631 {
3632 QPointF p = m_values[prop].val;
3633 p.setY(value);
3634 q_ptr->setValue(prop, p);
3635 }
3636}
3637
3638void
3640{
3641 if (QtProperty* pointProp = m_xToProperty.value(property, 0))
3642 {
3643 m_propertyToX[pointProp] = 0;
3644 m_xToProperty.remove(property);
3645 }
3646 else if (QtProperty* pointProp = m_yToProperty.value(property, 0))
3647 {
3648 m_propertyToY[pointProp] = 0;
3649 m_yToProperty.remove(property);
3650 }
3651}
3652
3653/*! \class QtPointFPropertyManager
3654
3655 \brief The QtPointFPropertyManager provides and manages QPointF properties.
3656
3657 A point property has nested \e x and \e y subproperties. The
3658 top-level property's value can be retrieved using the value()
3659 function, and set using the setValue() slot.
3660
3661 The subproperties are created by a QtDoublePropertyManager object. This
3662 manager can be retrieved using the subDoublePropertyManager() function. In
3663 order to provide editing widgets for the subproperties in a
3664 property browser widget, this manager must be associated with an
3665 editor factory.
3666
3667 In addition, QtPointFPropertyManager provides the valueChanged() signal which
3668 is emitted whenever a property created by this manager changes.
3669
3670 \sa QtAbstractPropertyManager, QtDoublePropertyManager, QtPointPropertyManager
3671*/
3672
3673/*!
3674 \fn void QtPointFPropertyManager::valueChanged(QtProperty *property, const QPointF &value)
3675
3676 This signal is emitted whenever a property created by this manager
3677 changes its value, passing a pointer to the \a property and the
3678 new \a value as parameters.
3679
3680 \sa setValue()
3681*/
3682
3683/*!
3684 \fn void QtPointFPropertyManager::decimalsChanged(QtProperty *property, int prec)
3685
3686 This signal is emitted whenever a property created by this manager
3687 changes its precision of value, passing a pointer to the
3688 \a property and the new \a prec value
3689
3690 \sa setDecimals()
3691*/
3692
3693/*!
3694 Creates a manager with the given \a parent.
3695*/
3698{
3700 d_ptr->q_ptr = this;
3701
3702 d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this);
3703 connect(d_ptr->m_doublePropertyManager,
3704 SIGNAL(valueChanged(QtProperty*, double)),
3705 this,
3706 SLOT(slotDoubleChanged(QtProperty*, double)));
3707 connect(d_ptr->m_doublePropertyManager,
3708 SIGNAL(propertyDestroyed(QtProperty*)),
3709 this,
3710 SLOT(slotPropertyDestroyed(QtProperty*)));
3711}
3712
3713/*!
3714 Destroys this manager, and all the properties it has created.
3715*/
3717{
3718 clear();
3719 delete d_ptr;
3720}
3721
3722/*!
3723 Returns the manager that creates the nested \e x and \e y
3724 subproperties.
3725
3726 In order to provide editing widgets for the subproperties in a
3727 property browser widget, this manager must be associated with an
3728 editor factory.
3729
3730 \sa QtAbstractPropertyBrowser::setFactoryForManager()
3731*/
3734{
3735 return d_ptr->m_doublePropertyManager;
3736}
3737
3738/*!
3739 Returns the given \a property's value.
3740
3741 If the given \a property is not managed by this manager, this
3742 function returns a point with coordinates (0, 0).
3743
3744 \sa setValue()
3745*/
3746QPointF
3748{
3749 return getValue<QPointF>(d_ptr->m_values, property);
3750}
3751
3752/*!
3753 Returns the given \a property's precision, in decimals.
3754
3755 \sa setDecimals()
3756*/
3757int
3759{
3760 return getData<int>(
3761 d_ptr->m_values, &QtPointFPropertyManagerPrivate::Data::decimals, property, 0);
3762}
3763
3764/*!
3765 \reimp
3766*/
3767QString
3769{
3770 const QtPointFPropertyManagerPrivate::PropertyValueMap::const_iterator it =
3771 d_ptr->m_values.constFind(property);
3772
3773 if (it == d_ptr->m_values.constEnd())
3774 {
3775 return QString();
3776 }
3777
3778 const QPointF v = it.value().val;
3779 const int dec = it.value().decimals;
3780 return QString(
3781 tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec)).arg(QString::number(v.y(), 'f', dec)));
3782}
3783
3784/*!
3785 \fn void QtPointFPropertyManager::setValue(QtProperty *property, const QPointF &value)
3786
3787 Sets the value of the given \a property to \a value. Nested
3788 properties are updated automatically.
3789
3790 \sa value(), valueChanged()
3791*/
3792void
3793QtPointFPropertyManager::setValue(QtProperty* property, const QPointF& val)
3794{
3795 const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it =
3796 d_ptr->m_values.find(property);
3797
3798 if (it == d_ptr->m_values.end())
3799 {
3800 return;
3801 }
3802
3803 if (it.value().val == val)
3804 {
3805 return;
3806 }
3807
3808 it.value().val = val;
3809 d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], val.x());
3810 d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], val.y());
3811
3812 emit propertyChanged(property);
3813 emit valueChanged(property, val);
3814}
3815
3816/*!
3817 \fn void QtPointFPropertyManager::setDecimals(QtProperty *property, int prec)
3818
3819 Sets the precision of the given \a property to \a prec.
3820
3821 The valid decimal range is 0-13. The default is 2.
3822
3823 \sa decimals()
3824*/
3825void
3827{
3828 const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it =
3829 d_ptr->m_values.find(property);
3830
3831 if (it == d_ptr->m_values.end())
3832 {
3833 return;
3834 }
3835
3837
3838 if (prec > 13)
3839 {
3840 prec = 13;
3841 }
3842 else if (prec < 0)
3843 {
3844 prec = 0;
3845 }
3846
3847 if (data.decimals == prec)
3848 {
3849 return;
3850 }
3851
3852 data.decimals = prec;
3853 d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], prec);
3854 d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], prec);
3855
3856 it.value() = data;
3857
3858 emit decimalsChanged(property, data.decimals);
3859}
3860
3861/*!
3862 \reimp
3863*/
3864void
3866{
3867 d_ptr->m_values[property] = QtPointFPropertyManagerPrivate::Data();
3868
3869 QtProperty* xProp = d_ptr->m_doublePropertyManager->addProperty();
3870 xProp->setPropertyName(tr("X"));
3871 d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property));
3872 d_ptr->m_doublePropertyManager->setValue(xProp, 0);
3873 d_ptr->m_propertyToX[property] = xProp;
3874 d_ptr->m_xToProperty[xProp] = property;
3875 property->addSubProperty(xProp);
3876
3877 QtProperty* yProp = d_ptr->m_doublePropertyManager->addProperty();
3878 yProp->setPropertyName(tr("Y"));
3879 d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property));
3880 d_ptr->m_doublePropertyManager->setValue(yProp, 0);
3881 d_ptr->m_propertyToY[property] = yProp;
3882 d_ptr->m_yToProperty[yProp] = property;
3883 property->addSubProperty(yProp);
3884}
3885
3886/*!
3887 \reimp
3888*/
3889void
3891{
3892 QtProperty* xProp = d_ptr->m_propertyToX[property];
3893
3894 if (xProp)
3895 {
3896 d_ptr->m_xToProperty.remove(xProp);
3897 delete xProp;
3898 }
3899
3900 d_ptr->m_propertyToX.remove(property);
3901
3902 QtProperty* yProp = d_ptr->m_propertyToY[property];
3903
3904 if (yProp)
3905 {
3906 d_ptr->m_yToProperty.remove(yProp);
3907 delete yProp;
3908 }
3909
3910 d_ptr->m_propertyToY.remove(property);
3911
3912 d_ptr->m_values.remove(property);
3913}
3914
3915// QtSizePropertyManager
3916
3918{
3919 QtSizePropertyManager* q_ptr;
3920 Q_DECLARE_PUBLIC(QtSizePropertyManager)
3921public:
3922 void slotIntChanged(QtProperty* property, int value);
3923 void slotPropertyDestroyed(QtProperty* property);
3924 void setValue(QtProperty* property, const QSize& val);
3925 void setRange(QtProperty* property, const QSize& minVal, const QSize& maxVal, const QSize& val);
3926
3927 struct Data
3928 {
3929 Data() : val(QSize(0, 0)), minVal(QSize(0, 0)), maxVal(QSize(INT_MAX, INT_MAX))
3930 {
3931 }
3932
3933 QSize val;
3934 QSize minVal;
3935 QSize maxVal;
3936
3937 QSize
3939 {
3940 return minVal;
3941 }
3942
3943 QSize
3945 {
3946 return maxVal;
3947 }
3948
3949 void
3950 setMinimumValue(const QSize& newMinVal)
3951 {
3952 setSizeMinimumData(this, newMinVal);
3953 }
3954
3955 void
3956 setMaximumValue(const QSize& newMaxVal)
3957 {
3958 setSizeMaximumData(this, newMaxVal);
3959 }
3960 };
3961
3962 using PropertyValueMap = QMap<const QtProperty*, Data>;
3964
3966
3967 QMap<const QtProperty*, QtProperty*> m_propertyToW;
3968 QMap<const QtProperty*, QtProperty*> m_propertyToH;
3969
3970 QMap<const QtProperty*, QtProperty*> m_wToProperty;
3971 QMap<const QtProperty*, QtProperty*> m_hToProperty;
3972};
3973
3974void
3976{
3977 if (QtProperty* prop = m_wToProperty.value(property, 0))
3978 {
3979 QSize s = m_values[prop].val;
3980 s.setWidth(value);
3981 q_ptr->setValue(prop, s);
3982 }
3983 else if (QtProperty* prop = m_hToProperty.value(property, 0))
3984 {
3985 QSize s = m_values[prop].val;
3986 s.setHeight(value);
3987 q_ptr->setValue(prop, s);
3988 }
3989}
3990
3991void
3993{
3994 if (QtProperty* pointProp = m_wToProperty.value(property, 0))
3995 {
3996 m_propertyToW[pointProp] = 0;
3997 m_wToProperty.remove(property);
3998 }
3999 else if (QtProperty* pointProp = m_hToProperty.value(property, 0))
4000 {
4001 m_propertyToH[pointProp] = 0;
4002 m_hToProperty.remove(property);
4003 }
4004}
4005
4006void
4008{
4009 m_intPropertyManager->setValue(m_propertyToW.value(property), val.width());
4010 m_intPropertyManager->setValue(m_propertyToH.value(property), val.height());
4011}
4012
4013void
4015 const QSize& minVal,
4016 const QSize& maxVal,
4017 const QSize& val)
4018{
4019 QtProperty* wProperty = m_propertyToW.value(property);
4020 QtProperty* hProperty = m_propertyToH.value(property);
4021 m_intPropertyManager->setRange(wProperty, minVal.width(), maxVal.width());
4022 m_intPropertyManager->setValue(wProperty, val.width());
4023 m_intPropertyManager->setRange(hProperty, minVal.height(), maxVal.height());
4024 m_intPropertyManager->setValue(hProperty, val.height());
4025}
4026
4027/*!
4028 \class QtSizePropertyManager
4029
4030 \brief The QtSizePropertyManager provides and manages QSize properties.
4031
4032 A size property has nested \e width and \e height
4033 subproperties. The top-level property's value can be retrieved
4034 using the value() function, and set using the setValue() slot.
4035
4036 The subproperties are created by a QtIntPropertyManager object. This
4037 manager can be retrieved using the subIntPropertyManager() function. In
4038 order to provide editing widgets for the subproperties in a
4039 property browser widget, this manager must be associated with an
4040 editor factory.
4041
4042 A size property also has a range of valid values defined by a
4043 minimum size and a maximum size. These sizes can be retrieved
4044 using the minimum() and the maximum() functions, and set using the
4045 setMinimum() and setMaximum() slots. Alternatively, the range can
4046 be defined in one go using the setRange() slot.
4047
4048 In addition, QtSizePropertyManager provides the valueChanged() signal
4049 which is emitted whenever a property created by this manager
4050 changes, and the rangeChanged() signal which is emitted whenever
4051 such a property changes its range of valid sizes.
4052
4053 \sa QtAbstractPropertyManager, QtIntPropertyManager, QtSizeFPropertyManager
4054*/
4055
4056/*!
4057 \fn void QtSizePropertyManager::valueChanged(QtProperty *property, const QSize &value)
4058
4059 This signal is emitted whenever a property created by this manager
4060 changes its value, passing a pointer to the \a property and the new
4061 \a value as parameters.
4062
4063 \sa setValue()
4064*/
4065
4066/*!
4067 \fn void QtSizePropertyManager::rangeChanged(QtProperty *property, const QSize &minimum, const QSize &maximum)
4068
4069 This signal is emitted whenever a property created by this manager
4070 changes its range of valid sizes, passing a pointer to the \a
4071 property and the new \a minimum and \a maximum sizes.
4072
4073 \sa setRange()
4074*/
4075
4076/*!
4077 Creates a manager with the given \a parent.
4078*/
4080{
4081 d_ptr = new QtSizePropertyManagerPrivate;
4082 d_ptr->q_ptr = this;
4083
4084 d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
4085 connect(d_ptr->m_intPropertyManager,
4086 SIGNAL(valueChanged(QtProperty*, int)),
4087 this,
4088 SLOT(slotIntChanged(QtProperty*, int)));
4089 connect(d_ptr->m_intPropertyManager,
4090 SIGNAL(propertyDestroyed(QtProperty*)),
4091 this,
4092 SLOT(slotPropertyDestroyed(QtProperty*)));
4093}
4094
4095/*!
4096 Destroys this manager, and all the properties it has created.
4097*/
4099{
4100 clear();
4101 delete d_ptr;
4102}
4103
4104/*!
4105 Returns the manager that creates the nested \e width and \e height
4106 subproperties.
4107
4108 In order to provide editing widgets for the \e width and \e height
4109 properties in a property browser widget, this manager must be
4110 associated with an editor factory.
4111
4112 \sa QtAbstractPropertyBrowser::setFactoryForManager()
4113*/
4116{
4117 return d_ptr->m_intPropertyManager;
4118}
4119
4120/*!
4121 Returns the given \a property's value.
4122
4123 If the given \a property is not managed by this manager, this
4124 function returns an invalid size
4125
4126 \sa setValue()
4127*/
4128QSize
4130{
4131 return getValue<QSize>(d_ptr->m_values, property);
4132}
4133
4134/*!
4135 Returns the given \a property's minimum size value.
4136
4137 \sa setMinimum(), maximum(), setRange()
4138*/
4139QSize
4141{
4142 return getMinimum<QSize>(d_ptr->m_values, property);
4143}
4144
4145/*!
4146 Returns the given \a property's maximum size value.
4147
4148 \sa setMaximum(), minimum(), setRange()
4149*/
4150QSize
4152{
4153 return getMaximum<QSize>(d_ptr->m_values, property);
4154}
4155
4156/*!
4157 \reimp
4158*/
4159QString
4161{
4162 const QtSizePropertyManagerPrivate::PropertyValueMap::const_iterator it =
4163 d_ptr->m_values.constFind(property);
4164
4165 if (it == d_ptr->m_values.constEnd())
4166 {
4167 return QString();
4168 }
4169
4170 const QSize v = it.value().val;
4171 return QString(tr("%1 x %2").arg(QString::number(v.width())).arg(QString::number(v.height())));
4172}
4173
4174/*!
4175 \fn void QtSizePropertyManager::setValue(QtProperty *property, const QSize &value)
4176
4177 Sets the value of the given \a property to \a value.
4178
4179 If the specified \a value is not valid according to the given \a
4180 property's size range, the \a value is adjusted to the nearest
4181 valid value within the size range.
4182
4183 \sa value(), setRange(), valueChanged()
4184*/
4185void
4187{
4188 setValueInRange<const QSize&, QtSizePropertyManagerPrivate, QtSizePropertyManager, const QSize>(
4189 this,
4190 d_ptr,
4193 property,
4194 val,
4196}
4197
4198/*!
4199 Sets the minimum size value for the given \a property to \a minVal.
4200
4201 When setting the minimum size value, the maximum and current
4202 values are adjusted if necessary (ensuring that the size range
4203 remains valid and that the current value is within the range).
4204
4205 \sa minimum(), setRange(), rangeChanged()
4206*/
4207void
4226
4227/*!
4228 Sets the maximum size value for the given \a property to \a maxVal.
4229
4230 When setting the maximum size value, the minimum and current
4231 values are adjusted if necessary (ensuring that the size range
4232 remains valid and that the current value is within the range).
4233
4234 \sa maximum(), setRange(), rangeChanged()
4235*/
4236void
4255
4256/*!
4257 \fn void QtSizePropertyManager::setRange(QtProperty *property, const QSize &minimum, const QSize &maximum)
4258
4259 Sets the range of valid values.
4260
4261 This is a convenience function defining the range of valid values
4262 in one go; setting the \a minimum and \a maximum values for the
4263 given \a property with a single function call.
4264
4265 When setting a new range, the current value is adjusted if
4266 necessary (ensuring that the value remains within the range).
4267
4268 \sa setMinimum(), setMaximum(), rangeChanged()
4269*/
4270void
4271QtSizePropertyManager::setRange(QtProperty* property, const QSize& minVal, const QSize& maxVal)
4272{
4273 setBorderValues<const QSize&, QtSizePropertyManagerPrivate, QtSizePropertyManager, QSize>(
4274 this,
4275 d_ptr,
4279 property,
4280 minVal,
4281 maxVal,
4283}
4284
4285/*!
4286 \reimp
4287*/
4288void
4290{
4291 d_ptr->m_values[property] = QtSizePropertyManagerPrivate::Data();
4292
4293 QtProperty* wProp = d_ptr->m_intPropertyManager->addProperty();
4294 wProp->setPropertyName(tr("Width"));
4295 d_ptr->m_intPropertyManager->setValue(wProp, 0);
4296 d_ptr->m_intPropertyManager->setMinimum(wProp, 0);
4297 d_ptr->m_propertyToW[property] = wProp;
4298 d_ptr->m_wToProperty[wProp] = property;
4299 property->addSubProperty(wProp);
4300
4301 QtProperty* hProp = d_ptr->m_intPropertyManager->addProperty();
4302 hProp->setPropertyName(tr("Height"));
4303 d_ptr->m_intPropertyManager->setValue(hProp, 0);
4304 d_ptr->m_intPropertyManager->setMinimum(hProp, 0);
4305 d_ptr->m_propertyToH[property] = hProp;
4306 d_ptr->m_hToProperty[hProp] = property;
4307 property->addSubProperty(hProp);
4308}
4309
4310/*!
4311 \reimp
4312*/
4313void
4315{
4316 QtProperty* wProp = d_ptr->m_propertyToW[property];
4317
4318 if (wProp)
4319 {
4320 d_ptr->m_wToProperty.remove(wProp);
4321 delete wProp;
4322 }
4323
4324 d_ptr->m_propertyToW.remove(property);
4325
4326 QtProperty* hProp = d_ptr->m_propertyToH[property];
4327
4328 if (hProp)
4329 {
4330 d_ptr->m_hToProperty.remove(hProp);
4331 delete hProp;
4332 }
4333
4334 d_ptr->m_propertyToH.remove(property);
4335
4336 d_ptr->m_values.remove(property);
4337}
4338
4339// QtSizeFPropertyManager
4340
4342{
4344 Q_DECLARE_PUBLIC(QtSizeFPropertyManager)
4345public:
4346 void slotDoubleChanged(QtProperty* property, double value);
4347 void slotPropertyDestroyed(QtProperty* property);
4348 void setValue(QtProperty* property, const QSizeF& val);
4349 void
4350 setRange(QtProperty* property, const QSizeF& minVal, const QSizeF& maxVal, const QSizeF& val);
4351
4352 struct Data
4353 {
4355 val(QSizeF(0, 0)), minVal(QSizeF(0, 0)), maxVal(QSizeF(INT_MAX, INT_MAX)), decimals(2)
4356 {
4357 }
4358
4359 QSizeF val;
4360 QSizeF minVal;
4361 QSizeF maxVal;
4363
4364 QSizeF
4366 {
4367 return minVal;
4368 }
4369
4370 QSizeF
4372 {
4373 return maxVal;
4374 }
4375
4376 void
4377 setMinimumValue(const QSizeF& newMinVal)
4378 {
4379 setSizeMinimumData(this, newMinVal);
4380 }
4381
4382 void
4383 setMaximumValue(const QSizeF& newMaxVal)
4384 {
4385 setSizeMaximumData(this, newMaxVal);
4386 }
4387 };
4388
4389 using PropertyValueMap = QMap<const QtProperty*, Data>;
4391
4393
4394 QMap<const QtProperty*, QtProperty*> m_propertyToW;
4395 QMap<const QtProperty*, QtProperty*> m_propertyToH;
4396
4397 QMap<const QtProperty*, QtProperty*> m_wToProperty;
4398 QMap<const QtProperty*, QtProperty*> m_hToProperty;
4399};
4400
4401void
4403{
4404 if (QtProperty* prop = m_wToProperty.value(property, 0))
4405 {
4406 QSizeF s = m_values[prop].val;
4407 s.setWidth(value);
4408 q_ptr->setValue(prop, s);
4409 }
4410 else if (QtProperty* prop = m_hToProperty.value(property, 0))
4411 {
4412 QSizeF s = m_values[prop].val;
4413 s.setHeight(value);
4414 q_ptr->setValue(prop, s);
4415 }
4416}
4417
4418void
4420{
4421 if (QtProperty* pointProp = m_wToProperty.value(property, 0))
4422 {
4423 m_propertyToW[pointProp] = 0;
4424 m_wToProperty.remove(property);
4425 }
4426 else if (QtProperty* pointProp = m_hToProperty.value(property, 0))
4427 {
4428 m_propertyToH[pointProp] = 0;
4429 m_hToProperty.remove(property);
4430 }
4431}
4432
4433void
4435{
4436 m_doublePropertyManager->setValue(m_propertyToW.value(property), val.width());
4437 m_doublePropertyManager->setValue(m_propertyToH.value(property), val.height());
4438}
4439
4440void
4442 const QSizeF& minVal,
4443 const QSizeF& maxVal,
4444 const QSizeF& val)
4445{
4446 m_doublePropertyManager->setRange(m_propertyToW[property], minVal.width(), maxVal.width());
4447 m_doublePropertyManager->setValue(m_propertyToW[property], val.width());
4448 m_doublePropertyManager->setRange(m_propertyToH[property], minVal.height(), maxVal.height());
4449 m_doublePropertyManager->setValue(m_propertyToH[property], val.height());
4450}
4451
4452/*!
4453 \class QtSizeFPropertyManager
4454
4455 \brief The QtSizeFPropertyManager provides and manages QSizeF properties.
4456
4457 A size property has nested \e width and \e height
4458 subproperties. The top-level property's value can be retrieved
4459 using the value() function, and set using the setValue() slot.
4460
4461 The subproperties are created by a QtDoublePropertyManager object. This
4462 manager can be retrieved using the subDoublePropertyManager() function. In
4463 order to provide editing widgets for the subproperties in a
4464 property browser widget, this manager must be associated with an
4465 editor factory.
4466
4467 A size property also has a range of valid values defined by a
4468 minimum size and a maximum size. These sizes can be retrieved
4469 using the minimum() and the maximum() functions, and set using the
4470 setMinimum() and setMaximum() slots. Alternatively, the range can
4471 be defined in one go using the setRange() slot.
4472
4473 In addition, QtSizeFPropertyManager provides the valueChanged() signal
4474 which is emitted whenever a property created by this manager
4475 changes, and the rangeChanged() signal which is emitted whenever
4476 such a property changes its range of valid sizes.
4477
4478 \sa QtAbstractPropertyManager, QtDoublePropertyManager, QtSizePropertyManager
4479*/
4480
4481/*!
4482 \fn void QtSizeFPropertyManager::valueChanged(QtProperty *property, const QSizeF &value)
4483
4484 This signal is emitted whenever a property created by this manager
4485 changes its value, passing a pointer to the \a property and the new
4486 \a value as parameters.
4487
4488 \sa setValue()
4489*/
4490
4491/*!
4492 \fn void QtSizeFPropertyManager::rangeChanged(QtProperty *property, const QSizeF &minimum, const QSizeF &maximum)
4493
4494 This signal is emitted whenever a property created by this manager
4495 changes its range of valid sizes, passing a pointer to the \a
4496 property and the new \a minimum and \a maximum sizes.
4497
4498 \sa setRange()
4499*/
4500
4501/*!
4502 \fn void QtSizeFPropertyManager::decimalsChanged(QtProperty *property, int prec)
4503
4504 This signal is emitted whenever a property created by this manager
4505 changes its precision of value, passing a pointer to the
4506 \a property and the new \a prec value
4507
4508 \sa setDecimals()
4509*/
4510
4511/*!
4512 Creates a manager with the given \a parent.
4513*/
4515{
4517 d_ptr->q_ptr = this;
4518
4519 d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this);
4520 connect(d_ptr->m_doublePropertyManager,
4521 SIGNAL(valueChanged(QtProperty*, double)),
4522 this,
4523 SLOT(slotDoubleChanged(QtProperty*, double)));
4524 connect(d_ptr->m_doublePropertyManager,
4525 SIGNAL(propertyDestroyed(QtProperty*)),
4526 this,
4527 SLOT(slotPropertyDestroyed(QtProperty*)));
4528}
4529
4530/*!
4531 Destroys this manager, and all the properties it has created.
4532*/
4534{
4535 clear();
4536 delete d_ptr;
4537}
4538
4539/*!
4540 Returns the manager that creates the nested \e width and \e height
4541 subproperties.
4542
4543 In order to provide editing widgets for the \e width and \e height
4544 properties in a property browser widget, this manager must be
4545 associated with an editor factory.
4546
4547 \sa QtAbstractPropertyBrowser::setFactoryForManager()
4548*/
4551{
4552 return d_ptr->m_doublePropertyManager;
4553}
4554
4555/*!
4556 Returns the given \a property's value.
4557
4558 If the given \a property is not managed by this manager, this
4559 function returns an invalid size
4560
4561 \sa setValue()
4562*/
4563QSizeF
4565{
4566 return getValue<QSizeF>(d_ptr->m_values, property);
4567}
4568
4569/*!
4570 Returns the given \a property's precision, in decimals.
4571
4572 \sa setDecimals()
4573*/
4574int
4576{
4577 return getData<int>(
4578 d_ptr->m_values, &QtSizeFPropertyManagerPrivate::Data::decimals, property, 0);
4579}
4580
4581/*!
4582 Returns the given \a property's minimum size value.
4583
4584 \sa setMinimum(), maximum(), setRange()
4585*/
4586QSizeF
4588{
4589 return getMinimum<QSizeF>(d_ptr->m_values, property);
4590}
4591
4592/*!
4593 Returns the given \a property's maximum size value.
4594
4595 \sa setMaximum(), minimum(), setRange()
4596*/
4597QSizeF
4599{
4600 return getMaximum<QSizeF>(d_ptr->m_values, property);
4601}
4602
4603/*!
4604 \reimp
4605*/
4606QString
4608{
4609 const QtSizeFPropertyManagerPrivate::PropertyValueMap::const_iterator it =
4610 d_ptr->m_values.constFind(property);
4611
4612 if (it == d_ptr->m_values.constEnd())
4613 {
4614 return QString();
4615 }
4616
4617 const QSizeF v = it.value().val;
4618 const int dec = it.value().decimals;
4619 return QString(tr("%1 x %2")
4620 .arg(QString::number(v.width(), 'f', dec))
4621 .arg(QString::number(v.height(), 'f', dec)));
4622}
4623
4624/*!
4625 \fn void QtSizeFPropertyManager::setValue(QtProperty *property, const QSizeF &value)
4626
4627 Sets the value of the given \a property to \a value.
4628
4629 If the specified \a value is not valid according to the given \a
4630 property's size range, the \a value is adjusted to the nearest
4631 valid value within the size range.
4632
4633 \sa value(), setRange(), valueChanged()
4634*/
4635void
4637{
4638 setValueInRange<const QSizeF&, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF>(
4639 this,
4640 d_ptr,
4643 property,
4644 val,
4646}
4647
4648/*!
4649 \fn void QtSizeFPropertyManager::setDecimals(QtProperty *property, int prec)
4650
4651 Sets the precision of the given \a property to \a prec.
4652
4653 The valid decimal range is 0-13. The default is 2.
4654
4655 \sa decimals()
4656*/
4657void
4659{
4660 const QtSizeFPropertyManagerPrivate::PropertyValueMap::iterator it =
4661 d_ptr->m_values.find(property);
4662
4663 if (it == d_ptr->m_values.end())
4664 {
4665 return;
4666 }
4667
4669
4670 if (prec > 13)
4671 {
4672 prec = 13;
4673 }
4674 else if (prec < 0)
4675 {
4676 prec = 0;
4677 }
4678
4679 if (data.decimals == prec)
4680 {
4681 return;
4682 }
4683
4684 data.decimals = prec;
4685 d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], prec);
4686 d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], prec);
4687
4688 it.value() = data;
4689
4690 emit decimalsChanged(property, data.decimals);
4691}
4692
4693/*!
4694 Sets the minimum size value for the given \a property to \a minVal.
4695
4696 When setting the minimum size value, the maximum and current
4697 values are adjusted if necessary (ensuring that the size range
4698 remains valid and that the current value is within the range).
4699
4700 \sa minimum(), setRange(), rangeChanged()
4701*/
4702void
4721
4722/*!
4723 Sets the maximum size value for the given \a property to \a maxVal.
4724
4725 When setting the maximum size value, the minimum and current
4726 values are adjusted if necessary (ensuring that the size range
4727 remains valid and that the current value is within the range).
4728
4729 \sa maximum(), setRange(), rangeChanged()
4730*/
4731void
4750
4751/*!
4752 \fn void QtSizeFPropertyManager::setRange(QtProperty *property, const QSizeF &minimum, const QSizeF &maximum)
4753
4754 Sets the range of valid values.
4755
4756 This is a convenience function defining the range of valid values
4757 in one go; setting the \a minimum and \a maximum values for the
4758 given \a property with a single function call.
4759
4760 When setting a new range, the current value is adjusted if
4761 necessary (ensuring that the value remains within the range).
4762
4763 \sa setMinimum(), setMaximum(), rangeChanged()
4764*/
4765void
4766QtSizeFPropertyManager::setRange(QtProperty* property, const QSizeF& minVal, const QSizeF& maxVal)
4767{
4768 setBorderValues<const QSizeF&, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF>(
4769 this,
4770 d_ptr,
4774 property,
4775 minVal,
4776 maxVal,
4778}
4779
4780/*!
4781 \reimp
4782*/
4783void
4785{
4786 d_ptr->m_values[property] = QtSizeFPropertyManagerPrivate::Data();
4787
4788 QtProperty* wProp = d_ptr->m_doublePropertyManager->addProperty();
4789 wProp->setPropertyName(tr("Width"));
4790 d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property));
4791 d_ptr->m_doublePropertyManager->setValue(wProp, 0);
4792 d_ptr->m_doublePropertyManager->setMinimum(wProp, 0);
4793 d_ptr->m_propertyToW[property] = wProp;
4794 d_ptr->m_wToProperty[wProp] = property;
4795 property->addSubProperty(wProp);
4796
4797 QtProperty* hProp = d_ptr->m_doublePropertyManager->addProperty();
4798 hProp->setPropertyName(tr("Height"));
4799 d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property));
4800 d_ptr->m_doublePropertyManager->setValue(hProp, 0);
4801 d_ptr->m_doublePropertyManager->setMinimum(hProp, 0);
4802 d_ptr->m_propertyToH[property] = hProp;
4803 d_ptr->m_hToProperty[hProp] = property;
4804 property->addSubProperty(hProp);
4805}
4806
4807/*!
4808 \reimp
4809*/
4810void
4812{
4813 QtProperty* wProp = d_ptr->m_propertyToW[property];
4814
4815 if (wProp)
4816 {
4817 d_ptr->m_wToProperty.remove(wProp);
4818 delete wProp;
4819 }
4820
4821 d_ptr->m_propertyToW.remove(property);
4822
4823 QtProperty* hProp = d_ptr->m_propertyToH[property];
4824
4825 if (hProp)
4826 {
4827 d_ptr->m_hToProperty.remove(hProp);
4828 delete hProp;
4829 }
4830
4831 d_ptr->m_propertyToH.remove(property);
4832
4833 d_ptr->m_values.remove(property);
4834}
4835
4836// QtRectPropertyManager
4837
4839{
4840 QtRectPropertyManager* q_ptr;
4841 Q_DECLARE_PUBLIC(QtRectPropertyManager)
4842public:
4843 void slotIntChanged(QtProperty* property, int value);
4844 void slotPropertyDestroyed(QtProperty* property);
4845 void setConstraint(QtProperty* property, const QRect& constraint, const QRect& val);
4846
4847 struct Data
4848 {
4849 Data() : val(0, 0, 0, 0)
4850 {
4851 }
4852
4853 QRect val;
4855 };
4856
4857 using PropertyValueMap = QMap<const QtProperty*, Data>;
4859
4861
4862 QMap<const QtProperty*, QtProperty*> m_propertyToX;
4863 QMap<const QtProperty*, QtProperty*> m_propertyToY;
4864 QMap<const QtProperty*, QtProperty*> m_propertyToW;
4865 QMap<const QtProperty*, QtProperty*> m_propertyToH;
4866
4867 QMap<const QtProperty*, QtProperty*> m_xToProperty;
4868 QMap<const QtProperty*, QtProperty*> m_yToProperty;
4869 QMap<const QtProperty*, QtProperty*> m_wToProperty;
4870 QMap<const QtProperty*, QtProperty*> m_hToProperty;
4871};
4872
4873void
4875{
4876 if (QtProperty* prop = m_xToProperty.value(property, 0))
4877 {
4878 QRect r = m_values[prop].val;
4879 r.moveLeft(value);
4880 q_ptr->setValue(prop, r);
4881 }
4882 else if (QtProperty* prop = m_yToProperty.value(property))
4883 {
4884 QRect r = m_values[prop].val;
4885 r.moveTop(value);
4886 q_ptr->setValue(prop, r);
4887 }
4888 else if (QtProperty* prop = m_wToProperty.value(property, 0))
4889 {
4890 Data data = m_values[prop];
4891 QRect r = data.val;
4892 r.setWidth(value);
4893
4894 if (!data.constraint.isNull() &&
4895 data.constraint.x() + data.constraint.width() < r.x() + r.width())
4896 {
4897 r.moveLeft(data.constraint.left() + data.constraint.width() - r.width());
4898 }
4899
4900 q_ptr->setValue(prop, r);
4901 }
4902 else if (QtProperty* prop = m_hToProperty.value(property, 0))
4903 {
4904 Data data = m_values[prop];
4905 QRect r = data.val;
4906 r.setHeight(value);
4907
4908 if (!data.constraint.isNull() &&
4909 data.constraint.y() + data.constraint.height() < r.y() + r.height())
4910 {
4911 r.moveTop(data.constraint.top() + data.constraint.height() - r.height());
4912 }
4913
4914 q_ptr->setValue(prop, r);
4915 }
4916}
4917
4918void
4920{
4921 if (QtProperty* pointProp = m_xToProperty.value(property, 0))
4922 {
4923 m_propertyToX[pointProp] = 0;
4924 m_xToProperty.remove(property);
4925 }
4926 else if (QtProperty* pointProp = m_yToProperty.value(property, 0))
4927 {
4928 m_propertyToY[pointProp] = 0;
4929 m_yToProperty.remove(property);
4930 }
4931 else if (QtProperty* pointProp = m_wToProperty.value(property, 0))
4932 {
4933 m_propertyToW[pointProp] = 0;
4934 m_wToProperty.remove(property);
4935 }
4936 else if (QtProperty* pointProp = m_hToProperty.value(property, 0))
4937 {
4938 m_propertyToH[pointProp] = 0;
4939 m_hToProperty.remove(property);
4940 }
4941}
4942
4943void
4945 const QRect& constraint,
4946 const QRect& val)
4947{
4948 const bool isNull = constraint.isNull();
4949 const int left = isNull ? INT_MIN : constraint.left();
4950 const int right = isNull ? INT_MAX : constraint.left() + constraint.width();
4951 const int top = isNull ? INT_MIN : constraint.top();
4952 const int bottom = isNull ? INT_MAX : constraint.top() + constraint.height();
4953 const int width = isNull ? INT_MAX : constraint.width();
4954 const int height = isNull ? INT_MAX : constraint.height();
4955
4956 m_intPropertyManager->setRange(m_propertyToX[property], left, right);
4957 m_intPropertyManager->setRange(m_propertyToY[property], top, bottom);
4958 m_intPropertyManager->setRange(m_propertyToW[property], 0, width);
4959 m_intPropertyManager->setRange(m_propertyToH[property], 0, height);
4960
4961 m_intPropertyManager->setValue(m_propertyToX[property], val.x());
4962 m_intPropertyManager->setValue(m_propertyToY[property], val.y());
4963 m_intPropertyManager->setValue(m_propertyToW[property], val.width());
4964 m_intPropertyManager->setValue(m_propertyToH[property], val.height());
4965}
4966
4967/*!
4968 \class QtRectPropertyManager
4969
4970 \brief The QtRectPropertyManager provides and manages QRect properties.
4971
4972 A rectangle property has nested \e x, \e y, \e width and \e height
4973 subproperties. The top-level property's value can be retrieved
4974 using the value() function, and set using the setValue() slot.
4975
4976 The subproperties are created by a QtIntPropertyManager object. This
4977 manager can be retrieved using the subIntPropertyManager() function. In
4978 order to provide editing widgets for the subproperties in a
4979 property browser widget, this manager must be associated with an
4980 editor factory.
4981
4982 A rectangle property also has a constraint rectangle which can be
4983 retrieved using the constraint() function, and set using the
4984 setConstraint() slot.
4985
4986 In addition, QtRectPropertyManager provides the valueChanged() signal
4987 which is emitted whenever a property created by this manager
4988 changes, and the constraintChanged() signal which is emitted
4989 whenever such a property changes its constraint rectangle.
4990
4991 \sa QtAbstractPropertyManager, QtIntPropertyManager, QtRectFPropertyManager
4992*/
4993
4994/*!
4995 \fn void QtRectPropertyManager::valueChanged(QtProperty *property, const QRect &value)
4996
4997 This signal is emitted whenever a property created by this manager
4998 changes its value, passing a pointer to the \a property and the new
4999 \a value as parameters.
5000
5001 \sa setValue()
5002*/
5003
5004/*!
5005 \fn void QtRectPropertyManager::constraintChanged(QtProperty *property, const QRect &constraint)
5006
5007 This signal is emitted whenever property changes its constraint
5008 rectangle, passing a pointer to the \a property and the new \a
5009 constraint rectangle as parameters.
5010
5011 \sa setConstraint()
5012*/
5013
5014/*!
5015 Creates a manager with the given \a parent.
5016*/
5018{
5019 d_ptr = new QtRectPropertyManagerPrivate;
5020 d_ptr->q_ptr = this;
5021
5022 d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
5023 connect(d_ptr->m_intPropertyManager,
5024 SIGNAL(valueChanged(QtProperty*, int)),
5025 this,
5026 SLOT(slotIntChanged(QtProperty*, int)));
5027 connect(d_ptr->m_intPropertyManager,
5028 SIGNAL(propertyDestroyed(QtProperty*)),
5029 this,
5030 SLOT(slotPropertyDestroyed(QtProperty*)));
5031}
5032
5033/*!
5034 Destroys this manager, and all the properties it has created.
5035*/
5037{
5038 clear();
5039 delete d_ptr;
5040}
5041
5042/*!
5043 Returns the manager that creates the nested \e x, \e y, \e width
5044 and \e height subproperties.
5045
5046 In order to provide editing widgets for the mentioned
5047 subproperties in a property browser widget, this manager must be
5048 associated with an editor factory.
5049
5050 \sa QtAbstractPropertyBrowser::setFactoryForManager()
5051*/
5054{
5055 return d_ptr->m_intPropertyManager;
5056}
5057
5058/*!
5059 Returns the given \a property's value.
5060
5061 If the given \a property is not managed by this manager, this
5062 function returns an invalid rectangle.
5063
5064 \sa setValue(), constraint()
5065*/
5066QRect
5068{
5069 return getValue<QRect>(d_ptr->m_values, property);
5070}
5071
5072/*!
5073 Returns the given \a property's constraining rectangle. If returned value is null QRect it means there is no constraint applied.
5074
5075 \sa value(), setConstraint()
5076*/
5077QRect
5079{
5080 return getData<QRect>(
5081 d_ptr->m_values, &QtRectPropertyManagerPrivate::Data::constraint, property, QRect());
5082}
5083
5084/*!
5085 \reimp
5086*/
5087QString
5089{
5090 const QtRectPropertyManagerPrivate::PropertyValueMap::const_iterator it =
5091 d_ptr->m_values.constFind(property);
5092
5093 if (it == d_ptr->m_values.constEnd())
5094 {
5095 return QString();
5096 }
5097
5098 const QRect v = it.value().val;
5099 return QString(tr("[(%1, %2), %3 x %4]")
5100 .arg(QString::number(v.x()))
5101 .arg(QString::number(v.y()))
5102 .arg(QString::number(v.width()))
5103 .arg(QString::number(v.height())));
5104}
5105
5106/*!
5107 \fn void QtRectPropertyManager::setValue(QtProperty *property, const QRect &value)
5108
5109 Sets the value of the given \a property to \a value. Nested
5110 properties are updated automatically.
5111
5112 If the specified \a value is not inside the given \a property's
5113 constraining rectangle, the value is adjusted accordingly to fit
5114 within the constraint.
5115
5116 \sa value(), setConstraint(), valueChanged()
5117*/
5118void
5120{
5121 const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it =
5122 d_ptr->m_values.find(property);
5123
5124 if (it == d_ptr->m_values.end())
5125 {
5126 return;
5127 }
5128
5130
5131 QRect newRect = val.normalized();
5132
5133 if (!data.constraint.isNull() && !data.constraint.contains(newRect))
5134 {
5135 const QRect r1 = data.constraint;
5136 const QRect r2 = newRect;
5137 newRect.setLeft(qMax(r1.left(), r2.left()));
5138 newRect.setRight(qMin(r1.right(), r2.right()));
5139 newRect.setTop(qMax(r1.top(), r2.top()));
5140 newRect.setBottom(qMin(r1.bottom(), r2.bottom()));
5141
5142 if (newRect.width() < 0 || newRect.height() < 0)
5143 {
5144 return;
5145 }
5146 }
5147
5148 if (data.val == newRect)
5149 {
5150 return;
5151 }
5152
5153 data.val = newRect;
5154
5155 it.value() = data;
5156 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToX[property], newRect.x());
5157 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToY[property], newRect.y());
5158 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToW[property], newRect.width());
5159 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToH[property], newRect.height());
5160
5161 emit propertyChanged(property);
5162 emit valueChanged(property, data.val);
5163}
5164
5165/*!
5166 Sets the given \a property's constraining rectangle to \a
5167 constraint.
5168
5169 When setting the constraint, the current value is adjusted if
5170 necessary (ensuring that the current rectangle value is inside the
5171 constraint). In order to reset the constraint pass a null QRect value.
5172
5173 \sa setValue(), constraint(), constraintChanged()
5174*/
5175void
5177{
5178 const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it =
5179 d_ptr->m_values.find(property);
5180
5181 if (it == d_ptr->m_values.end())
5182 {
5183 return;
5184 }
5185
5187
5188 QRect newConstraint = constraint.normalized();
5189
5190 if (data.constraint == newConstraint)
5191 {
5192 return;
5193 }
5194
5195 const QRect oldVal = data.val;
5196
5197 data.constraint = newConstraint;
5198
5199 if (!data.constraint.isNull() && !data.constraint.contains(oldVal))
5200 {
5201 QRect r1 = data.constraint;
5202 QRect r2 = data.val;
5203
5204 if (r2.width() > r1.width())
5205 {
5206 r2.setWidth(r1.width());
5207 }
5208
5209 if (r2.height() > r1.height())
5210 {
5211 r2.setHeight(r1.height());
5212 }
5213
5214 if (r2.left() < r1.left())
5215 {
5216 r2.moveLeft(r1.left());
5217 }
5218 else if (r2.right() > r1.right())
5219 {
5220 r2.moveRight(r1.right());
5221 }
5222
5223 if (r2.top() < r1.top())
5224 {
5225 r2.moveTop(r1.top());
5226 }
5227 else if (r2.bottom() > r1.bottom())
5228 {
5229 r2.moveBottom(r1.bottom());
5230 }
5231
5232 data.val = r2;
5233 }
5234
5235 it.value() = data;
5236
5237 emit constraintChanged(property, data.constraint);
5238
5239 d_ptr->setConstraint(property, data.constraint, data.val);
5240
5241 if (data.val == oldVal)
5242 {
5243 return;
5244 }
5245
5246 emit propertyChanged(property);
5247 emit valueChanged(property, data.val);
5248}
5249
5250/*!
5251 \reimp
5252*/
5253void
5255{
5256 d_ptr->m_values[property] = QtRectPropertyManagerPrivate::Data();
5257
5258 QtProperty* xProp = d_ptr->m_intPropertyManager->addProperty();
5259 xProp->setPropertyName(tr("X"));
5260 d_ptr->m_intPropertyManager->setValue(xProp, 0);
5261 d_ptr->m_propertyToX[property] = xProp;
5262 d_ptr->m_xToProperty[xProp] = property;
5263 property->addSubProperty(xProp);
5264
5265 QtProperty* yProp = d_ptr->m_intPropertyManager->addProperty();
5266 yProp->setPropertyName(tr("Y"));
5267 d_ptr->m_intPropertyManager->setValue(yProp, 0);
5268 d_ptr->m_propertyToY[property] = yProp;
5269 d_ptr->m_yToProperty[yProp] = property;
5270 property->addSubProperty(yProp);
5271
5272 QtProperty* wProp = d_ptr->m_intPropertyManager->addProperty();
5273 wProp->setPropertyName(tr("Width"));
5274 d_ptr->m_intPropertyManager->setValue(wProp, 0);
5275 d_ptr->m_intPropertyManager->setMinimum(wProp, 0);
5276 d_ptr->m_propertyToW[property] = wProp;
5277 d_ptr->m_wToProperty[wProp] = property;
5278 property->addSubProperty(wProp);
5279
5280 QtProperty* hProp = d_ptr->m_intPropertyManager->addProperty();
5281 hProp->setPropertyName(tr("Height"));
5282 d_ptr->m_intPropertyManager->setValue(hProp, 0);
5283 d_ptr->m_intPropertyManager->setMinimum(hProp, 0);
5284 d_ptr->m_propertyToH[property] = hProp;
5285 d_ptr->m_hToProperty[hProp] = property;
5286 property->addSubProperty(hProp);
5287}
5288
5289/*!
5290 \reimp
5291*/
5292void
5294{
5295 QtProperty* xProp = d_ptr->m_propertyToX[property];
5296
5297 if (xProp)
5298 {
5299 d_ptr->m_xToProperty.remove(xProp);
5300 delete xProp;
5301 }
5302
5303 d_ptr->m_propertyToX.remove(property);
5304
5305 QtProperty* yProp = d_ptr->m_propertyToY[property];
5306
5307 if (yProp)
5308 {
5309 d_ptr->m_yToProperty.remove(yProp);
5310 delete yProp;
5311 }
5312
5313 d_ptr->m_propertyToY.remove(property);
5314
5315 QtProperty* wProp = d_ptr->m_propertyToW[property];
5316
5317 if (wProp)
5318 {
5319 d_ptr->m_wToProperty.remove(wProp);
5320 delete wProp;
5321 }
5322
5323 d_ptr->m_propertyToW.remove(property);
5324
5325 QtProperty* hProp = d_ptr->m_propertyToH[property];
5326
5327 if (hProp)
5328 {
5329 d_ptr->m_hToProperty.remove(hProp);
5330 delete hProp;
5331 }
5332
5333 d_ptr->m_propertyToH.remove(property);
5334
5335 d_ptr->m_values.remove(property);
5336}
5337
5338// QtRectFPropertyManager
5339
5341{
5343 Q_DECLARE_PUBLIC(QtRectFPropertyManager)
5344public:
5345 void slotDoubleChanged(QtProperty* property, double value);
5346 void slotPropertyDestroyed(QtProperty* property);
5347 void setConstraint(QtProperty* property, const QRectF& constraint, const QRectF& val);
5348
5349 struct Data
5350 {
5351 Data() : val(0, 0, 0, 0), decimals(2)
5352 {
5353 }
5354
5355 QRectF val;
5358 };
5359
5360 using PropertyValueMap = QMap<const QtProperty*, Data>;
5362
5364
5365 QMap<const QtProperty*, QtProperty*> m_propertyToX;
5366 QMap<const QtProperty*, QtProperty*> m_propertyToY;
5367 QMap<const QtProperty*, QtProperty*> m_propertyToW;
5368 QMap<const QtProperty*, QtProperty*> m_propertyToH;
5369
5370 QMap<const QtProperty*, QtProperty*> m_xToProperty;
5371 QMap<const QtProperty*, QtProperty*> m_yToProperty;
5372 QMap<const QtProperty*, QtProperty*> m_wToProperty;
5373 QMap<const QtProperty*, QtProperty*> m_hToProperty;
5374};
5375
5376void
5378{
5379 if (QtProperty* prop = m_xToProperty.value(property, 0))
5380 {
5381 QRectF r = m_values[prop].val;
5382 r.moveLeft(value);
5383 q_ptr->setValue(prop, r);
5384 }
5385 else if (QtProperty* prop = m_yToProperty.value(property, 0))
5386 {
5387 QRectF r = m_values[prop].val;
5388 r.moveTop(value);
5389 q_ptr->setValue(prop, r);
5390 }
5391 else if (QtProperty* prop = m_wToProperty.value(property, 0))
5392 {
5393 Data data = m_values[prop];
5394 QRectF r = data.val;
5395 r.setWidth(value);
5396
5397 if (!data.constraint.isNull() &&
5398 data.constraint.x() + data.constraint.width() < r.x() + r.width())
5399 {
5400 r.moveLeft(data.constraint.left() + data.constraint.width() - r.width());
5401 }
5402
5403 q_ptr->setValue(prop, r);
5404 }
5405 else if (QtProperty* prop = m_hToProperty.value(property, 0))
5406 {
5407 Data data = m_values[prop];
5408 QRectF r = data.val;
5409 r.setHeight(value);
5410
5411 if (!data.constraint.isNull() &&
5412 data.constraint.y() + data.constraint.height() < r.y() + r.height())
5413 {
5414 r.moveTop(data.constraint.top() + data.constraint.height() - r.height());
5415 }
5416
5417 q_ptr->setValue(prop, r);
5418 }
5419}
5420
5421void
5423{
5424 if (QtProperty* pointProp = m_xToProperty.value(property, 0))
5425 {
5426 m_propertyToX[pointProp] = 0;
5427 m_xToProperty.remove(property);
5428 }
5429 else if (QtProperty* pointProp = m_yToProperty.value(property, 0))
5430 {
5431 m_propertyToY[pointProp] = 0;
5432 m_yToProperty.remove(property);
5433 }
5434 else if (QtProperty* pointProp = m_wToProperty.value(property, 0))
5435 {
5436 m_propertyToW[pointProp] = 0;
5437 m_wToProperty.remove(property);
5438 }
5439 else if (QtProperty* pointProp = m_hToProperty.value(property, 0))
5440 {
5441 m_propertyToH[pointProp] = 0;
5442 m_hToProperty.remove(property);
5443 }
5444}
5445
5446void
5448 const QRectF& constraint,
5449 const QRectF& val)
5450{
5451 const bool isNull = constraint.isNull();
5452 const float left = isNull ? FLT_MIN : constraint.left();
5453 const float right = isNull ? FLT_MAX : constraint.left() + constraint.width();
5454 const float top = isNull ? FLT_MIN : constraint.top();
5455 const float bottom = isNull ? FLT_MAX : constraint.top() + constraint.height();
5456 const float width = isNull ? FLT_MAX : constraint.width();
5457 const float height = isNull ? FLT_MAX : constraint.height();
5458
5459 m_doublePropertyManager->setRange(m_propertyToX[property], left, right);
5460 m_doublePropertyManager->setRange(m_propertyToY[property], top, bottom);
5461 m_doublePropertyManager->setRange(m_propertyToW[property], 0, width);
5462 m_doublePropertyManager->setRange(m_propertyToH[property], 0, height);
5463
5464 m_doublePropertyManager->setValue(m_propertyToX[property], val.x());
5465 m_doublePropertyManager->setValue(m_propertyToY[property], val.y());
5466 m_doublePropertyManager->setValue(m_propertyToW[property], val.width());
5467 m_doublePropertyManager->setValue(m_propertyToH[property], val.height());
5468}
5469
5470/*!
5471 \class QtRectFPropertyManager
5472
5473 \brief The QtRectFPropertyManager provides and manages QRectF properties.
5474
5475 A rectangle property has nested \e x, \e y, \e width and \e height
5476 subproperties. The top-level property's value can be retrieved
5477 using the value() function, and set using the setValue() slot.
5478
5479 The subproperties are created by a QtDoublePropertyManager object. This
5480 manager can be retrieved using the subDoublePropertyManager() function. In
5481 order to provide editing widgets for the subproperties in a
5482 property browser widget, this manager must be associated with an
5483 editor factory.
5484
5485 A rectangle property also has a constraint rectangle which can be
5486 retrieved using the constraint() function, and set using the
5487 setConstraint() slot.
5488
5489 In addition, QtRectFPropertyManager provides the valueChanged() signal
5490 which is emitted whenever a property created by this manager
5491 changes, and the constraintChanged() signal which is emitted
5492 whenever such a property changes its constraint rectangle.
5493
5494 \sa QtAbstractPropertyManager, QtDoublePropertyManager, QtRectPropertyManager
5495*/
5496
5497/*!
5498 \fn void QtRectFPropertyManager::valueChanged(QtProperty *property, const QRectF &value)
5499
5500 This signal is emitted whenever a property created by this manager
5501 changes its value, passing a pointer to the \a property and the new
5502 \a value as parameters.
5503
5504 \sa setValue()
5505*/
5506
5507/*!
5508 \fn void QtRectFPropertyManager::constraintChanged(QtProperty *property, const QRectF &constraint)
5509
5510 This signal is emitted whenever property changes its constraint
5511 rectangle, passing a pointer to the \a property and the new \a
5512 constraint rectangle as parameters.
5513
5514 \sa setConstraint()
5515*/
5516
5517/*!
5518 \fn void QtRectFPropertyManager::decimalsChanged(QtProperty *property, int prec)
5519
5520 This signal is emitted whenever a property created by this manager
5521 changes its precision of value, passing a pointer to the
5522 \a property and the new \a prec value
5523
5524 \sa setDecimals()
5525*/
5526
5527/*!
5528 Creates a manager with the given \a parent.
5529*/
5531{
5533 d_ptr->q_ptr = this;
5534
5535 d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this);
5536 connect(d_ptr->m_doublePropertyManager,
5537 SIGNAL(valueChanged(QtProperty*, double)),
5538 this,
5539 SLOT(slotDoubleChanged(QtProperty*, double)));
5540 connect(d_ptr->m_doublePropertyManager,
5541 SIGNAL(propertyDestroyed(QtProperty*)),
5542 this,
5543 SLOT(slotPropertyDestroyed(QtProperty*)));
5544}
5545
5546/*!
5547 Destroys this manager, and all the properties it has created.
5548*/
5550{
5551 clear();
5552 delete d_ptr;
5553}
5554
5555/*!
5556 Returns the manager that creates the nested \e x, \e y, \e width
5557 and \e height subproperties.
5558
5559 In order to provide editing widgets for the mentioned
5560 subproperties in a property browser widget, this manager must be
5561 associated with an editor factory.
5562
5563 \sa QtAbstractPropertyBrowser::setFactoryForManager()
5564*/
5567{
5568 return d_ptr->m_doublePropertyManager;
5569}
5570
5571/*!
5572 Returns the given \a property's value.
5573
5574 If the given \a property is not managed by this manager, this
5575 function returns an invalid rectangle.
5576
5577 \sa setValue(), constraint()
5578*/
5579QRectF
5581{
5582 return getValue<QRectF>(d_ptr->m_values, property);
5583}
5584
5585/*!
5586 Returns the given \a property's precision, in decimals.
5587
5588 \sa setDecimals()
5589*/
5590int
5592{
5593 return getData<int>(
5594 d_ptr->m_values, &QtRectFPropertyManagerPrivate::Data::decimals, property, 0);
5595}
5596
5597/*!
5598 Returns the given \a property's constraining rectangle. If returned value is null QRectF it means there is no constraint applied.
5599
5600 \sa value(), setConstraint()
5601*/
5602QRectF
5604{
5605 return getData<QRectF>(
5606 d_ptr->m_values, &QtRectFPropertyManagerPrivate::Data::constraint, property, QRect());
5607}
5608
5609/*!
5610 \reimp
5611*/
5612QString
5614{
5615 const QtRectFPropertyManagerPrivate::PropertyValueMap::const_iterator it =
5616 d_ptr->m_values.constFind(property);
5617
5618 if (it == d_ptr->m_values.constEnd())
5619 {
5620 return QString();
5621 }
5622
5623 const QRectF v = it.value().val;
5624 const int dec = it.value().decimals;
5625 return QString(tr("[(%1, %2), %3 x %4]")
5626 .arg(QString::number(v.x(), 'f', dec))
5627 .arg(QString::number(v.y(), 'f', dec))
5628 .arg(QString::number(v.width(), 'f', dec))
5629 .arg(QString::number(v.height(), 'f', dec)));
5630}
5631
5632/*!
5633 \fn void QtRectFPropertyManager::setValue(QtProperty *property, const QRectF &value)
5634
5635 Sets the value of the given \a property to \a value. Nested
5636 properties are updated automatically.
5637
5638 If the specified \a value is not inside the given \a property's
5639 constraining rectangle, the value is adjusted accordingly to fit
5640 within the constraint.
5641
5642 \sa value(), setConstraint(), valueChanged()
5643*/
5644void
5646{
5647 const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it =
5648 d_ptr->m_values.find(property);
5649
5650 if (it == d_ptr->m_values.end())
5651 {
5652 return;
5653 }
5654
5656
5657 QRectF newRect = val.normalized();
5658
5659 if (!data.constraint.isNull() && !data.constraint.contains(newRect))
5660 {
5661 const QRectF r1 = data.constraint;
5662 const QRectF r2 = newRect;
5663 newRect.setLeft(qMax(r1.left(), r2.left()));
5664 newRect.setRight(qMin(r1.right(), r2.right()));
5665 newRect.setTop(qMax(r1.top(), r2.top()));
5666 newRect.setBottom(qMin(r1.bottom(), r2.bottom()));
5667
5668 if (newRect.width() < 0 || newRect.height() < 0)
5669 {
5670 return;
5671 }
5672 }
5673
5674 if (data.val == newRect)
5675 {
5676 return;
5677 }
5678
5679 data.val = newRect;
5680
5681 it.value() = data;
5682 d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], newRect.x());
5683 d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], newRect.y());
5684 d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToW[property], newRect.width());
5685 d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToH[property], newRect.height());
5686
5687 emit propertyChanged(property);
5688 emit valueChanged(property, data.val);
5689}
5690
5691/*!
5692 Sets the given \a property's constraining rectangle to \a
5693 constraint.
5694
5695 When setting the constraint, the current value is adjusted if
5696 necessary (ensuring that the current rectangle value is inside the
5697 constraint). In order to reset the constraint pass a null QRectF value.
5698
5699 \sa setValue(), constraint(), constraintChanged()
5700*/
5701void
5703{
5704 const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it =
5705 d_ptr->m_values.find(property);
5706
5707 if (it == d_ptr->m_values.end())
5708 {
5709 return;
5710 }
5711
5713
5714 QRectF newConstraint = constraint.normalized();
5715
5716 if (data.constraint == newConstraint)
5717 {
5718 return;
5719 }
5720
5721 const QRectF oldVal = data.val;
5722
5723 data.constraint = newConstraint;
5724
5725 if (!data.constraint.isNull() && !data.constraint.contains(oldVal))
5726 {
5727 QRectF r1 = data.constraint;
5728 QRectF r2 = data.val;
5729
5730 if (r2.width() > r1.width())
5731 {
5732 r2.setWidth(r1.width());
5733 }
5734
5735 if (r2.height() > r1.height())
5736 {
5737 r2.setHeight(r1.height());
5738 }
5739
5740 if (r2.left() < r1.left())
5741 {
5742 r2.moveLeft(r1.left());
5743 }
5744 else if (r2.right() > r1.right())
5745 {
5746 r2.moveRight(r1.right());
5747 }
5748
5749 if (r2.top() < r1.top())
5750 {
5751 r2.moveTop(r1.top());
5752 }
5753 else if (r2.bottom() > r1.bottom())
5754 {
5755 r2.moveBottom(r1.bottom());
5756 }
5757
5758 data.val = r2;
5759 }
5760
5761 it.value() = data;
5762
5763 emit constraintChanged(property, data.constraint);
5764
5765 d_ptr->setConstraint(property, data.constraint, data.val);
5766
5767 if (data.val == oldVal)
5768 {
5769 return;
5770 }
5771
5772 emit propertyChanged(property);
5773 emit valueChanged(property, data.val);
5774}
5775
5776/*!
5777 \fn void QtRectFPropertyManager::setDecimals(QtProperty *property, int prec)
5778
5779 Sets the precision of the given \a property to \a prec.
5780
5781 The valid decimal range is 0-13. The default is 2.
5782
5783 \sa decimals()
5784*/
5785void
5787{
5788 const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it =
5789 d_ptr->m_values.find(property);
5790
5791 if (it == d_ptr->m_values.end())
5792 {
5793 return;
5794 }
5795
5797
5798 if (prec > 13)
5799 {
5800 prec = 13;
5801 }
5802 else if (prec < 0)
5803 {
5804 prec = 0;
5805 }
5806
5807 if (data.decimals == prec)
5808 {
5809 return;
5810 }
5811
5812 data.decimals = prec;
5813 d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], prec);
5814 d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], prec);
5815 d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToW[property], prec);
5816 d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToH[property], prec);
5817
5818 it.value() = data;
5819
5820 emit decimalsChanged(property, data.decimals);
5821}
5822
5823/*!
5824 \reimp
5825*/
5826void
5828{
5829 d_ptr->m_values[property] = QtRectFPropertyManagerPrivate::Data();
5830
5831 QtProperty* xProp = d_ptr->m_doublePropertyManager->addProperty();
5832 xProp->setPropertyName(tr("X"));
5833 d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property));
5834 d_ptr->m_doublePropertyManager->setValue(xProp, 0);
5835 d_ptr->m_propertyToX[property] = xProp;
5836 d_ptr->m_xToProperty[xProp] = property;
5837 property->addSubProperty(xProp);
5838
5839 QtProperty* yProp = d_ptr->m_doublePropertyManager->addProperty();
5840 yProp->setPropertyName(tr("Y"));
5841 d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property));
5842 d_ptr->m_doublePropertyManager->setValue(yProp, 0);
5843 d_ptr->m_propertyToY[property] = yProp;
5844 d_ptr->m_yToProperty[yProp] = property;
5845 property->addSubProperty(yProp);
5846
5847 QtProperty* wProp = d_ptr->m_doublePropertyManager->addProperty();
5848 wProp->setPropertyName(tr("Width"));
5849 d_ptr->m_doublePropertyManager->setDecimals(wProp, decimals(property));
5850 d_ptr->m_doublePropertyManager->setValue(wProp, 0);
5851 d_ptr->m_doublePropertyManager->setMinimum(wProp, 0);
5852 d_ptr->m_propertyToW[property] = wProp;
5853 d_ptr->m_wToProperty[wProp] = property;
5854 property->addSubProperty(wProp);
5855
5856 QtProperty* hProp = d_ptr->m_doublePropertyManager->addProperty();
5857 hProp->setPropertyName(tr("Height"));
5858 d_ptr->m_doublePropertyManager->setDecimals(hProp, decimals(property));
5859 d_ptr->m_doublePropertyManager->setValue(hProp, 0);
5860 d_ptr->m_doublePropertyManager->setMinimum(hProp, 0);
5861 d_ptr->m_propertyToH[property] = hProp;
5862 d_ptr->m_hToProperty[hProp] = property;
5863 property->addSubProperty(hProp);
5864}
5865
5866/*!
5867 \reimp
5868*/
5869void
5871{
5872 QtProperty* xProp = d_ptr->m_propertyToX[property];
5873
5874 if (xProp)
5875 {
5876 d_ptr->m_xToProperty.remove(xProp);
5877 delete xProp;
5878 }
5879
5880 d_ptr->m_propertyToX.remove(property);
5881
5882 QtProperty* yProp = d_ptr->m_propertyToY[property];
5883
5884 if (yProp)
5885 {
5886 d_ptr->m_yToProperty.remove(yProp);
5887 delete yProp;
5888 }
5889
5890 d_ptr->m_propertyToY.remove(property);
5891
5892 QtProperty* wProp = d_ptr->m_propertyToW[property];
5893
5894 if (wProp)
5895 {
5896 d_ptr->m_wToProperty.remove(wProp);
5897 delete wProp;
5898 }
5899
5900 d_ptr->m_propertyToW.remove(property);
5901
5902 QtProperty* hProp = d_ptr->m_propertyToH[property];
5903
5904 if (hProp)
5905 {
5906 d_ptr->m_hToProperty.remove(hProp);
5907 delete hProp;
5908 }
5909
5910 d_ptr->m_propertyToH.remove(property);
5911
5912 d_ptr->m_values.remove(property);
5913}
5914
5915// QtEnumPropertyManager
5916
5918{
5919 QtEnumPropertyManager* q_ptr;
5920 Q_DECLARE_PUBLIC(QtEnumPropertyManager)
5921public:
5922 struct Data
5923 {
5924 Data() : val(-1)
5925 {
5926 }
5927
5928 int val;
5929 QStringList enumNames;
5930 QMap<int, QIcon> enumIcons;
5931 };
5932
5933 using PropertyValueMap = QMap<const QtProperty*, Data>;
5935};
5936
5937/*!
5938 \class QtEnumPropertyManager
5939
5940 \brief The QtEnumPropertyManager provides and manages enum properties.
5941
5942 Each enum property has an associated list of enum names which can
5943 be retrieved using the enumNames() function, and set using the
5944 corresponding setEnumNames() function. An enum property's value is
5945 represented by an index in this list, and can be retrieved and set
5946 using the value() and setValue() slots respectively.
5947
5948 Each enum value can also have an associated icon. The mapping from
5949 values to icons can be set using the setEnumIcons() function and
5950 queried with the enumIcons() function.
5951
5952 In addition, QtEnumPropertyManager provides the valueChanged() signal
5953 which is emitted whenever a property created by this manager
5954 changes. The enumNamesChanged() or enumIconsChanged() signal is emitted
5955 whenever the list of enum names or icons is altered.
5956
5957 \sa QtAbstractPropertyManager, QtEnumEditorFactory
5958*/
5959
5960/*!
5961 \fn void QtEnumPropertyManager::valueChanged(QtProperty *property, int value)
5962
5963 This signal is emitted whenever a property created by this manager
5964 changes its value, passing a pointer to the \a property and the new
5965 \a value as parameters.
5966
5967 \sa setValue()
5968*/
5969
5970/*!
5971 \fn void QtEnumPropertyManager::enumNamesChanged(QtProperty *property, const QStringList &names)
5972
5973 This signal is emitted whenever a property created by this manager
5974 changes its enum names, passing a pointer to the \a property and
5975 the new \a names as parameters.
5976
5977 \sa setEnumNames()
5978*/
5979
5980/*!
5981 \fn void QtEnumPropertyManager::enumIconsChanged(QtProperty *property, const QMap<int, QIcon> &icons)
5982
5983 This signal is emitted whenever a property created by this manager
5984 changes its enum icons, passing a pointer to the \a property and
5985 the new mapping of values to \a icons as parameters.
5986
5987 \sa setEnumIcons()
5988*/
5989
5990/*!
5991 Creates a manager with the given \a parent.
5992*/
5994{
5995 d_ptr = new QtEnumPropertyManagerPrivate;
5996 d_ptr->q_ptr = this;
5997}
5998
5999/*!
6000 Destroys this manager, and all the properties it has created.
6001*/
6003{
6004 clear();
6005 delete d_ptr;
6006}
6007
6008/*!
6009 Returns the given \a property's value which is an index in the
6010 list returned by enumNames()
6011
6012 If the given property is not managed by this manager, this
6013 function returns -1.
6014
6015 \sa enumNames(), setValue()
6016*/
6017int
6019{
6020 return getValue<int>(d_ptr->m_values, property, -1);
6021}
6022
6023/*!
6024 Returns the given \a property's list of enum names.
6025
6026 \sa value(), setEnumNames()
6027*/
6028QStringList
6030{
6031 return getData<QStringList>(
6032 d_ptr->m_values, &QtEnumPropertyManagerPrivate::Data::enumNames, property, QStringList());
6033}
6034
6035/*!
6036 Returns the given \a property's map of enum values to their icons.
6037
6038 \sa value(), setEnumIcons()
6039*/
6040QMap<int, QIcon>
6042{
6043 return getData<QMap<int, QIcon>>(d_ptr->m_values,
6045 property,
6046 QMap<int, QIcon>());
6047}
6048
6049/*!
6050 \reimp
6051*/
6052QString
6054{
6055 const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it =
6056 d_ptr->m_values.constFind(property);
6057
6058 if (it == d_ptr->m_values.constEnd())
6059 {
6060 return QString();
6061 }
6062
6063 const QtEnumPropertyManagerPrivate::Data& data = it.value();
6064
6065 const int v = data.val;
6066
6067 if (v >= 0 && v < data.enumNames.count())
6068 {
6069 return data.enumNames.at(v);
6070 }
6071
6072 return QString();
6073}
6074
6075/*!
6076 \reimp
6077*/
6078QIcon
6080{
6081 const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it =
6082 d_ptr->m_values.constFind(property);
6083
6084 if (it == d_ptr->m_values.constEnd())
6085 {
6086 return QIcon();
6087 }
6088
6089 const QtEnumPropertyManagerPrivate::Data& data = it.value();
6090
6091 const int v = data.val;
6092 return data.enumIcons.value(v);
6093}
6094
6095/*!
6096 \fn void QtEnumPropertyManager::setValue(QtProperty *property, int value)
6097
6098 Sets the value of the given \a property to \a value.
6099
6100 The specified \a value must be less than the size of the given \a
6101 property's enumNames() list, and larger than (or equal to) 0.
6102
6103 \sa value(), valueChanged()
6104*/
6105void
6107{
6108 const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it =
6109 d_ptr->m_values.find(property);
6110
6111 if (it == d_ptr->m_values.end())
6112 {
6113 return;
6114 }
6115
6117
6118 if (val >= data.enumNames.count())
6119 {
6120 return;
6121 }
6122
6123 if (val < 0 && data.enumNames.count() > 0)
6124 {
6125 return;
6126 }
6127
6128 if (val < 0)
6129 {
6130 val = -1;
6131 }
6132
6133 if (data.val == val)
6134 {
6135 return;
6136 }
6137
6138 data.val = val;
6139
6140 it.value() = data;
6141
6142 emit propertyChanged(property);
6143 emit valueChanged(property, data.val);
6144}
6145
6146/*!
6147 Sets the given \a property's list of enum names to \a
6148 enumNames. The \a property's current value is reset to 0
6149 indicating the first item of the list.
6150
6151 If the specified \a enumNames list is empty, the \a property's
6152 current value is set to -1.
6153
6154 \sa enumNames(), enumNamesChanged()
6155*/
6156void
6158{
6159 const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it =
6160 d_ptr->m_values.find(property);
6161
6162 if (it == d_ptr->m_values.end())
6163 {
6164 return;
6165 }
6166
6168
6169 if (data.enumNames == enumNames)
6170 {
6171 return;
6172 }
6173
6174 data.enumNames = enumNames;
6175
6176 data.val = -1;
6177
6178 if (enumNames.count() > 0)
6179 {
6180 data.val = 0;
6181 }
6182
6183 it.value() = data;
6184
6185 emit enumNamesChanged(property, data.enumNames);
6186
6187 emit propertyChanged(property);
6188 emit valueChanged(property, data.val);
6189}
6190
6191/*!
6192 Sets the given \a property's map of enum values to their icons to \a
6193 enumIcons.
6194
6195 Each enum value can have associated icon. This association is represented with passed \a enumIcons map.
6196
6197 \sa enumNames(), enumNamesChanged()
6198*/
6199void
6201{
6202 const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it =
6203 d_ptr->m_values.find(property);
6204
6205 if (it == d_ptr->m_values.end())
6206 {
6207 return;
6208 }
6209
6210 it.value().enumIcons = enumIcons;
6211
6212 emit enumIconsChanged(property, it.value().enumIcons);
6213
6214 emit propertyChanged(property);
6215}
6216
6217/*!
6218 \reimp
6219*/
6220void
6222{
6223 d_ptr->m_values[property] = QtEnumPropertyManagerPrivate::Data();
6224}
6225
6226/*!
6227 \reimp
6228*/
6229void
6231{
6232 d_ptr->m_values.remove(property);
6233}
6234
6235// QtFlagPropertyManager
6236
6238{
6239 QtFlagPropertyManager* q_ptr;
6240 Q_DECLARE_PUBLIC(QtFlagPropertyManager)
6241public:
6242 void slotBoolChanged(QtProperty* property, bool value);
6243 void slotPropertyDestroyed(QtProperty* property);
6244
6245 struct Data
6246 {
6247 Data() : val(-1)
6248 {
6249 }
6250
6251 int val;
6252 QStringList flagNames;
6253 };
6254
6255 using PropertyValueMap = QMap<const QtProperty*, Data>;
6257
6259
6260 QMap<const QtProperty*, QList<QtProperty*>> m_propertyToFlags;
6261
6262 QMap<const QtProperty*, QtProperty*> m_flagToProperty;
6263};
6264
6265void
6267{
6268 QtProperty* prop = m_flagToProperty.value(property, 0);
6269
6270 if (prop == 0)
6271 {
6272 return;
6273 }
6274
6275 QListIterator<QtProperty*> itProp(m_propertyToFlags[prop]);
6276 int level = 0;
6277
6278 while (itProp.hasNext())
6279 {
6280 QtProperty* p = itProp.next();
6281
6282 if (p == property)
6283 {
6284 int v = m_values[prop].val;
6285
6286 if (value)
6287 {
6288 v |= (1 << level);
6289 }
6290 else
6291 {
6292 v &= ~(1 << level);
6293 }
6294
6295 q_ptr->setValue(prop, v);
6296 return;
6297 }
6298
6299 level++;
6300 }
6301}
6302
6303void
6305{
6306 QtProperty* flagProperty = m_flagToProperty.value(property, 0);
6307
6308 if (flagProperty == 0)
6309 {
6310 return;
6311 }
6312
6313 m_propertyToFlags[flagProperty].replace(m_propertyToFlags[flagProperty].indexOf(property), 0);
6314 m_flagToProperty.remove(property);
6315}
6316
6317/*!
6318 \class QtFlagPropertyManager
6319
6320 \brief The QtFlagPropertyManager provides and manages flag properties.
6321
6322 Each flag property has an associated list of flag names which can
6323 be retrieved using the flagNames() function, and set using the
6324 corresponding setFlagNames() function.
6325
6326 The flag manager provides properties with nested boolean
6327 subproperties representing each flag, i.e. a flag property's value
6328 is the binary combination of the subproperties' values. A
6329 property's value can be retrieved and set using the value() and
6330 setValue() slots respectively. The combination of flags is represented
6331 by single int value - that's why it's possible to store up to
6332 32 independent flags in one flag property.
6333
6334 The subproperties are created by a QtBoolPropertyManager object. This
6335 manager can be retrieved using the subBoolPropertyManager() function. In
6336 order to provide editing widgets for the subproperties in a
6337 property browser widget, this manager must be associated with an
6338 editor factory.
6339
6340 In addition, QtFlagPropertyManager provides the valueChanged() signal
6341 which is emitted whenever a property created by this manager
6342 changes, and the flagNamesChanged() signal which is emitted
6343 whenever the list of flag names is altered.
6344
6345 \sa QtAbstractPropertyManager, QtBoolPropertyManager
6346*/
6347
6348/*!
6349 \fn void QtFlagPropertyManager::valueChanged(QtProperty *property, int value)
6350
6351 This signal is emitted whenever a property created by this manager
6352 changes its value, passing a pointer to the \a property and the new
6353 \a value as parameters.
6354
6355 \sa setValue()
6356*/
6357
6358/*!
6359 \fn void QtFlagPropertyManager::flagNamesChanged(QtProperty *property, const QStringList &names)
6360
6361 This signal is emitted whenever a property created by this manager
6362 changes its flag names, passing a pointer to the \a property and the
6363 new \a names as parameters.
6364
6365 \sa setFlagNames()
6366*/
6367
6368/*!
6369 Creates a manager with the given \a parent.
6370*/
6372{
6373 d_ptr = new QtFlagPropertyManagerPrivate;
6374 d_ptr->q_ptr = this;
6375
6376 d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this);
6377 connect(d_ptr->m_boolPropertyManager,
6378 SIGNAL(valueChanged(QtProperty*, bool)),
6379 this,
6380 SLOT(slotBoolChanged(QtProperty*, bool)));
6381 connect(d_ptr->m_boolPropertyManager,
6382 SIGNAL(propertyDestroyed(QtProperty*)),
6383 this,
6384 SLOT(slotPropertyDestroyed(QtProperty*)));
6385}
6386
6387/*!
6388 Destroys this manager, and all the properties it has created.
6389*/
6391{
6392 clear();
6393 delete d_ptr;
6394}
6395
6396/*!
6397 Returns the manager that produces the nested boolean subproperties
6398 representing each flag.
6399
6400 In order to provide editing widgets for the subproperties in a
6401 property browser widget, this manager must be associated with an
6402 editor factory.
6403
6404 \sa QtAbstractPropertyBrowser::setFactoryForManager()
6405*/
6408{
6409 return d_ptr->m_boolPropertyManager;
6410}
6411
6412/*!
6413 Returns the given \a property's value.
6414
6415 If the given property is not managed by this manager, this
6416 function returns 0.
6417
6418 \sa flagNames(), setValue()
6419*/
6420int
6422{
6423 return getValue<int>(d_ptr->m_values, property, 0);
6424}
6425
6426/*!
6427 Returns the given \a property's list of flag names.
6428
6429 \sa value(), setFlagNames()
6430*/
6431QStringList
6433{
6434 return getData<QStringList>(
6435 d_ptr->m_values, &QtFlagPropertyManagerPrivate::Data::flagNames, property, QStringList());
6436}
6437
6438/*!
6439 \reimp
6440*/
6441QString
6443{
6444 const QtFlagPropertyManagerPrivate::PropertyValueMap::const_iterator it =
6445 d_ptr->m_values.constFind(property);
6446
6447 if (it == d_ptr->m_values.constEnd())
6448 {
6449 return QString();
6450 }
6451
6452 const QtFlagPropertyManagerPrivate::Data& data = it.value();
6453
6454 QString str;
6455 int level = 0;
6456 const QChar bar = QLatin1Char('|');
6457 const QStringList::const_iterator fncend = data.flagNames.constEnd();
6458
6459 for (QStringList::const_iterator it = data.flagNames.constBegin(); it != fncend; ++it)
6460 {
6461 if (data.val & (1 << level))
6462 {
6463 if (!str.isEmpty())
6464 {
6465 str += bar;
6466 }
6467
6468 str += *it;
6469 }
6470
6471 level++;
6472 }
6473
6474 return str;
6475}
6476
6477/*!
6478 \fn void QtFlagPropertyManager::setValue(QtProperty *property, int value)
6479
6480 Sets the value of the given \a property to \a value. Nested
6481 properties are updated automatically.
6482
6483 The specified \a value must be less than the binary combination of
6484 the property's flagNames() list size (i.e. less than 2\sup n,
6485 where \c n is the size of the list) and larger than (or equal to)
6486 0.
6487
6488 \sa value(), valueChanged()
6489*/
6490void
6492{
6493 const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it =
6494 d_ptr->m_values.find(property);
6495
6496 if (it == d_ptr->m_values.end())
6497 {
6498 return;
6499 }
6500
6502
6503 if (data.val == val)
6504 {
6505 return;
6506 }
6507
6508 if (val > (1 << data.flagNames.count()) - 1)
6509 {
6510 return;
6511 }
6512
6513 if (val < 0)
6514 {
6515 return;
6516 }
6517
6518 data.val = val;
6519
6520 it.value() = data;
6521
6522 QListIterator<QtProperty*> itProp(d_ptr->m_propertyToFlags[property]);
6523 int level = 0;
6524
6525 while (itProp.hasNext())
6526 {
6527 QtProperty* prop = itProp.next();
6528
6529 if (prop)
6530 {
6531 d_ptr->m_boolPropertyManager->setValue(prop, val & (1 << level));
6532 }
6533
6534 level++;
6535 }
6536
6537 emit propertyChanged(property);
6538 emit valueChanged(property, data.val);
6539}
6540
6541/*!
6542 Sets the given \a property's list of flag names to \a flagNames. The
6543 property's current value is reset to 0 indicating the first item
6544 of the list.
6545
6546 \sa flagNames(), flagNamesChanged()
6547*/
6548void
6550{
6551 const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it =
6552 d_ptr->m_values.find(property);
6553
6554 if (it == d_ptr->m_values.end())
6555 {
6556 return;
6557 }
6558
6560
6561 if (data.flagNames == flagNames)
6562 {
6563 return;
6564 }
6565
6566 data.flagNames = flagNames;
6567 data.val = 0;
6568
6569 it.value() = data;
6570
6571 QListIterator<QtProperty*> itProp(d_ptr->m_propertyToFlags[property]);
6572
6573 while (itProp.hasNext())
6574 {
6575 QtProperty* prop = itProp.next();
6576
6577 if (prop)
6578 {
6579 delete prop;
6580 d_ptr->m_flagToProperty.remove(prop);
6581 }
6582 }
6583
6584 d_ptr->m_propertyToFlags[property].clear();
6585
6586 QStringListIterator itFlag(flagNames);
6587
6588 while (itFlag.hasNext())
6589 {
6590 const QString flagName = itFlag.next();
6591 QtProperty* prop = d_ptr->m_boolPropertyManager->addProperty();
6592 prop->setPropertyName(flagName);
6593 property->addSubProperty(prop);
6594 d_ptr->m_propertyToFlags[property].append(prop);
6595 d_ptr->m_flagToProperty[prop] = property;
6596 }
6597
6598 emit flagNamesChanged(property, data.flagNames);
6599
6600 emit propertyChanged(property);
6601 emit valueChanged(property, data.val);
6602}
6603
6604/*!
6605 \reimp
6606*/
6607void
6609{
6610 d_ptr->m_values[property] = QtFlagPropertyManagerPrivate::Data();
6611
6612 d_ptr->m_propertyToFlags[property] = QList<QtProperty*>();
6613}
6614
6615/*!
6616 \reimp
6617*/
6618void
6620{
6621 QListIterator<QtProperty*> itProp(d_ptr->m_propertyToFlags[property]);
6622
6623 while (itProp.hasNext())
6624 {
6625 QtProperty* prop = itProp.next();
6626
6627 if (prop)
6628 {
6629 delete prop;
6630 d_ptr->m_flagToProperty.remove(prop);
6631 }
6632 }
6633
6634 d_ptr->m_propertyToFlags.remove(property);
6635
6636 d_ptr->m_values.remove(property);
6637}
6638
6639// QtSizePolicyPropertyManager
6640
6642{
6644 Q_DECLARE_PUBLIC(QtSizePolicyPropertyManager)
6645public:
6647
6648 void slotIntChanged(QtProperty* property, int value);
6649 void slotEnumChanged(QtProperty* property, int value);
6650 void slotPropertyDestroyed(QtProperty* property);
6651
6652 using PropertyValueMap = QMap<const QtProperty*, QSizePolicy>;
6654
6657
6658 QMap<const QtProperty*, QtProperty*> m_propertyToHPolicy;
6659 QMap<const QtProperty*, QtProperty*> m_propertyToVPolicy;
6660 QMap<const QtProperty*, QtProperty*> m_propertyToHStretch;
6661 QMap<const QtProperty*, QtProperty*> m_propertyToVStretch;
6662
6663 QMap<const QtProperty*, QtProperty*> m_hPolicyToProperty;
6664 QMap<const QtProperty*, QtProperty*> m_vPolicyToProperty;
6665 QMap<const QtProperty*, QtProperty*> m_hStretchToProperty;
6666 QMap<const QtProperty*, QtProperty*> m_vStretchToProperty;
6667};
6668
6672
6673void
6675{
6676 if (QtProperty* prop = m_hStretchToProperty.value(property, 0))
6677 {
6678 QSizePolicy sp = m_values[prop];
6679 sp.setHorizontalStretch(value);
6680 q_ptr->setValue(prop, sp);
6681 }
6682 else if (QtProperty* prop = m_vStretchToProperty.value(property, 0))
6683 {
6684 QSizePolicy sp = m_values[prop];
6685 sp.setVerticalStretch(value);
6686 q_ptr->setValue(prop, sp);
6687 }
6688}
6689
6690void
6692{
6693 if (QtProperty* prop = m_hPolicyToProperty.value(property, 0))
6694 {
6695 QSizePolicy sp = m_values[prop];
6696 sp.setHorizontalPolicy(metaEnumProvider()->indexToSizePolicy(value));
6697 q_ptr->setValue(prop, sp);
6698 }
6699 else if (QtProperty* prop = m_vPolicyToProperty.value(property, 0))
6700 {
6701 QSizePolicy sp = m_values[prop];
6702 sp.setVerticalPolicy(metaEnumProvider()->indexToSizePolicy(value));
6703 q_ptr->setValue(prop, sp);
6704 }
6705}
6706
6707void
6709{
6710 if (QtProperty* pointProp = m_hStretchToProperty.value(property, 0))
6711 {
6712 m_propertyToHStretch[pointProp] = 0;
6713 m_hStretchToProperty.remove(property);
6714 }
6715 else if (QtProperty* pointProp = m_vStretchToProperty.value(property, 0))
6716 {
6717 m_propertyToVStretch[pointProp] = 0;
6718 m_vStretchToProperty.remove(property);
6719 }
6720 else if (QtProperty* pointProp = m_hPolicyToProperty.value(property, 0))
6721 {
6722 m_propertyToHPolicy[pointProp] = 0;
6723 m_hPolicyToProperty.remove(property);
6724 }
6725 else if (QtProperty* pointProp = m_vPolicyToProperty.value(property, 0))
6726 {
6727 m_propertyToVPolicy[pointProp] = 0;
6728 m_vPolicyToProperty.remove(property);
6729 }
6730}
6731
6732/*!
6733 \class QtSizePolicyPropertyManager
6734
6735 \brief The QtSizePolicyPropertyManager provides and manages QSizePolicy properties.
6736
6737 A size policy property has nested \e horizontalPolicy, \e
6738 verticalPolicy, \e horizontalStretch and \e verticalStretch
6739 subproperties. The top-level property's value can be retrieved
6740 using the value() function, and set using the setValue() slot.
6741
6742 The subproperties are created by QtIntPropertyManager and QtEnumPropertyManager
6743 objects. These managers can be retrieved using the subIntPropertyManager()
6744 and subEnumPropertyManager() functions respectively. In order to provide
6745 editing widgets for the subproperties in a property browser widget,
6746 these managers must be associated with editor factories.
6747
6748 In addition, QtSizePolicyPropertyManager provides the valueChanged()
6749 signal which is emitted whenever a property created by this
6750 manager changes.
6751
6752 \sa QtAbstractPropertyManager, QtIntPropertyManager, QtEnumPropertyManager
6753*/
6754
6755/*!
6756 \fn void QtSizePolicyPropertyManager::valueChanged(QtProperty *property, const QSizePolicy &value)
6757
6758 This signal is emitted whenever a property created by this manager
6759 changes its value, passing a pointer to the \a property and the
6760 new \a value as parameters.
6761
6762 \sa setValue()
6763*/
6764
6765/*!
6766 Creates a manager with the given \a parent.
6767*/
6770{
6772 d_ptr->q_ptr = this;
6773
6774 d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
6775 connect(d_ptr->m_intPropertyManager,
6776 SIGNAL(valueChanged(QtProperty*, int)),
6777 this,
6778 SLOT(slotIntChanged(QtProperty*, int)));
6779 d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
6780 connect(d_ptr->m_enumPropertyManager,
6781 SIGNAL(valueChanged(QtProperty*, int)),
6782 this,
6783 SLOT(slotEnumChanged(QtProperty*, int)));
6784
6785 connect(d_ptr->m_intPropertyManager,
6786 SIGNAL(propertyDestroyed(QtProperty*)),
6787 this,
6788 SLOT(slotPropertyDestroyed(QtProperty*)));
6789 connect(d_ptr->m_enumPropertyManager,
6790 SIGNAL(propertyDestroyed(QtProperty*)),
6791 this,
6792 SLOT(slotPropertyDestroyed(QtProperty*)));
6793}
6794
6795/*!
6796 Destroys this manager, and all the properties it has created.
6797*/
6803
6804/*!
6805 Returns the manager that creates the nested \e horizontalStretch
6806 and \e verticalStretch subproperties.
6807
6808 In order to provide editing widgets for the mentioned subproperties
6809 in a property browser widget, this manager must be associated with
6810 an editor factory.
6811
6812 \sa QtAbstractPropertyBrowser::setFactoryForManager()
6813*/
6816{
6817 return d_ptr->m_intPropertyManager;
6818}
6819
6820/*!
6821 Returns the manager that creates the nested \e horizontalPolicy
6822 and \e verticalPolicy subproperties.
6823
6824 In order to provide editing widgets for the mentioned subproperties
6825 in a property browser widget, this manager must be associated with
6826 an editor factory.
6827
6828 \sa QtAbstractPropertyBrowser::setFactoryForManager()
6829*/
6832{
6833 return d_ptr->m_enumPropertyManager;
6834}
6835
6836/*!
6837 Returns the given \a property's value.
6838
6839 If the given property is not managed by this manager, this
6840 function returns the default size policy.
6841
6842 \sa setValue()
6843*/
6844QSizePolicy
6846{
6847 return d_ptr->m_values.value(property, QSizePolicy());
6848}
6849
6850/*!
6851 \reimp
6852*/
6853QString
6855{
6856 const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::const_iterator it =
6857 d_ptr->m_values.constFind(property);
6858
6859 if (it == d_ptr->m_values.constEnd())
6860 {
6861 return QString();
6862 }
6863
6864 const QSizePolicy sp = it.value();
6865 const QtMetaEnumProvider* mep = metaEnumProvider();
6866 const int hIndex = mep->sizePolicyToIndex(sp.horizontalPolicy());
6867 const int vIndex = mep->sizePolicyToIndex(sp.verticalPolicy());
6868 //! Unknown size policy on reading invalid uic3 files
6869 const QString hPolicy = hIndex != -1 ? mep->policyEnumNames().at(hIndex) : tr("<Invalid>");
6870 const QString vPolicy = vIndex != -1 ? mep->policyEnumNames().at(vIndex) : tr("<Invalid>");
6871 const QString str = tr("[%1, %2, %3, %4]")
6872 .arg(hPolicy, vPolicy)
6873 .arg(sp.horizontalStretch())
6874 .arg(sp.verticalStretch());
6875 return str;
6876}
6877
6878/*!
6879 \fn void QtSizePolicyPropertyManager::setValue(QtProperty *property, const QSizePolicy &value)
6880
6881 Sets the value of the given \a property to \a value. Nested
6882 properties are updated automatically.
6883
6884 \sa value(), valueChanged()
6885*/
6886void
6887QtSizePolicyPropertyManager::setValue(QtProperty* property, const QSizePolicy& val)
6888{
6889 const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::iterator it =
6890 d_ptr->m_values.find(property);
6891
6892 if (it == d_ptr->m_values.end())
6893 {
6894 return;
6895 }
6896
6897 if (it.value() == val)
6898 {
6899 return;
6900 }
6901
6902 it.value() = val;
6903
6904 d_ptr->m_enumPropertyManager->setValue(
6905 d_ptr->m_propertyToHPolicy[property],
6906 metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy()));
6907 d_ptr->m_enumPropertyManager->setValue(
6908 d_ptr->m_propertyToVPolicy[property],
6909 metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy()));
6910 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToHStretch[property],
6911 val.horizontalStretch());
6912 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToVStretch[property],
6913 val.verticalStretch());
6914
6915 emit propertyChanged(property);
6916 emit valueChanged(property, val);
6917}
6918
6919/*!
6920 \reimp
6921*/
6922void
6924{
6925 QSizePolicy val;
6926 d_ptr->m_values[property] = val;
6927
6928 QtProperty* hPolicyProp = d_ptr->m_enumPropertyManager->addProperty();
6929 hPolicyProp->setPropertyName(tr("Horizontal Policy"));
6930 d_ptr->m_enumPropertyManager->setEnumNames(hPolicyProp, metaEnumProvider()->policyEnumNames());
6931 d_ptr->m_enumPropertyManager->setValue(
6932 hPolicyProp, metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy()));
6933 d_ptr->m_propertyToHPolicy[property] = hPolicyProp;
6934 d_ptr->m_hPolicyToProperty[hPolicyProp] = property;
6935 property->addSubProperty(hPolicyProp);
6936
6937 QtProperty* vPolicyProp = d_ptr->m_enumPropertyManager->addProperty();
6938 vPolicyProp->setPropertyName(tr("Vertical Policy"));
6939 d_ptr->m_enumPropertyManager->setEnumNames(vPolicyProp, metaEnumProvider()->policyEnumNames());
6940 d_ptr->m_enumPropertyManager->setValue(
6941 vPolicyProp, metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy()));
6942 d_ptr->m_propertyToVPolicy[property] = vPolicyProp;
6943 d_ptr->m_vPolicyToProperty[vPolicyProp] = property;
6944 property->addSubProperty(vPolicyProp);
6945
6946 QtProperty* hStretchProp = d_ptr->m_intPropertyManager->addProperty();
6947 hStretchProp->setPropertyName(tr("Horizontal Stretch"));
6948 d_ptr->m_intPropertyManager->setValue(hStretchProp, val.horizontalStretch());
6949 d_ptr->m_intPropertyManager->setRange(hStretchProp, 0, 0xff);
6950 d_ptr->m_propertyToHStretch[property] = hStretchProp;
6951 d_ptr->m_hStretchToProperty[hStretchProp] = property;
6952 property->addSubProperty(hStretchProp);
6953
6954 QtProperty* vStretchProp = d_ptr->m_intPropertyManager->addProperty();
6955 vStretchProp->setPropertyName(tr("Vertical Stretch"));
6956 d_ptr->m_intPropertyManager->setValue(vStretchProp, val.verticalStretch());
6957 d_ptr->m_intPropertyManager->setRange(vStretchProp, 0, 0xff);
6958 d_ptr->m_propertyToVStretch[property] = vStretchProp;
6959 d_ptr->m_vStretchToProperty[vStretchProp] = property;
6960 property->addSubProperty(vStretchProp);
6961}
6962
6963/*!
6964 \reimp
6965*/
6966void
6968{
6969 QtProperty* hPolicyProp = d_ptr->m_propertyToHPolicy[property];
6970
6971 if (hPolicyProp)
6972 {
6973 d_ptr->m_hPolicyToProperty.remove(hPolicyProp);
6974 delete hPolicyProp;
6975 }
6976
6977 d_ptr->m_propertyToHPolicy.remove(property);
6978
6979 QtProperty* vPolicyProp = d_ptr->m_propertyToVPolicy[property];
6980
6981 if (vPolicyProp)
6982 {
6983 d_ptr->m_vPolicyToProperty.remove(vPolicyProp);
6984 delete vPolicyProp;
6985 }
6986
6987 d_ptr->m_propertyToVPolicy.remove(property);
6988
6989 QtProperty* hStretchProp = d_ptr->m_propertyToHStretch[property];
6990
6991 if (hStretchProp)
6992 {
6993 d_ptr->m_hStretchToProperty.remove(hStretchProp);
6994 delete hStretchProp;
6995 }
6996
6997 d_ptr->m_propertyToHStretch.remove(property);
6998
6999 QtProperty* vStretchProp = d_ptr->m_propertyToVStretch[property];
7000
7001 if (vStretchProp)
7002 {
7003 d_ptr->m_vStretchToProperty.remove(vStretchProp);
7004 delete vStretchProp;
7005 }
7006
7007 d_ptr->m_propertyToVStretch.remove(property);
7008
7009 d_ptr->m_values.remove(property);
7010}
7011
7012// QtFontPropertyManager:
7013// QtFontPropertyManagerPrivate has a mechanism for reacting
7014// to QApplication::fontDatabaseChanged() [4.5], which is emitted
7015// when someone loads an application font. The signals are compressed
7016// using a timer with interval 0, which then causes the family
7017// enumeration manager to re-set its strings and index values
7018// for each property.
7019
7020Q_GLOBAL_STATIC(QFontDatabase, fontDatabase)
7021
7023{
7024 QtFontPropertyManager* q_ptr;
7025 Q_DECLARE_PUBLIC(QtFontPropertyManager)
7026public:
7028
7029 void slotIntChanged(QtProperty* property, int value);
7030 void slotEnumChanged(QtProperty* property, int value);
7031 void slotBoolChanged(QtProperty* property, bool value);
7032 void slotPropertyDestroyed(QtProperty* property);
7035
7036 QStringList m_familyNames;
7037
7038 using PropertyValueMap = QMap<const QtProperty*, QFont>;
7040
7044
7045 QMap<const QtProperty*, QtProperty*> m_propertyToFamily;
7046 QMap<const QtProperty*, QtProperty*> m_propertyToPointSize;
7047 QMap<const QtProperty*, QtProperty*> m_propertyToBold;
7048 QMap<const QtProperty*, QtProperty*> m_propertyToItalic;
7049 QMap<const QtProperty*, QtProperty*> m_propertyToUnderline;
7050 QMap<const QtProperty*, QtProperty*> m_propertyToStrikeOut;
7051 QMap<const QtProperty*, QtProperty*> m_propertyToKerning;
7052
7053 QMap<const QtProperty*, QtProperty*> m_familyToProperty;
7054 QMap<const QtProperty*, QtProperty*> m_pointSizeToProperty;
7055 QMap<const QtProperty*, QtProperty*> m_boldToProperty;
7056 QMap<const QtProperty*, QtProperty*> m_italicToProperty;
7057 QMap<const QtProperty*, QtProperty*> m_underlineToProperty;
7058 QMap<const QtProperty*, QtProperty*> m_strikeOutToProperty;
7059 QMap<const QtProperty*, QtProperty*> m_kerningToProperty;
7060
7063};
7064
7069
7070void
7072{
7073 if (m_settingValue)
7074 {
7075 return;
7076 }
7077
7078 if (QtProperty* prop = m_pointSizeToProperty.value(property, 0))
7079 {
7080 QFont f = m_values[prop];
7081 f.setPointSize(value);
7082 q_ptr->setValue(prop, f);
7083 }
7084}
7085
7086void
7088{
7089 if (m_settingValue)
7090 {
7091 return;
7092 }
7093
7094 if (QtProperty* prop = m_familyToProperty.value(property, 0))
7095 {
7096 QFont f = m_values[prop];
7097 f.setFamily(m_familyNames.at(value));
7098 q_ptr->setValue(prop, f);
7099 }
7100}
7101
7102void
7104{
7105 if (m_settingValue)
7106 {
7107 return;
7108 }
7109
7110 if (QtProperty* prop = m_boldToProperty.value(property, 0))
7111 {
7112 QFont f = m_values[prop];
7113 f.setBold(value);
7114 q_ptr->setValue(prop, f);
7115 }
7116 else if (QtProperty* prop = m_italicToProperty.value(property, 0))
7117 {
7118 QFont f = m_values[prop];
7119 f.setItalic(value);
7120 q_ptr->setValue(prop, f);
7121 }
7122 else if (QtProperty* prop = m_underlineToProperty.value(property, 0))
7123 {
7124 QFont f = m_values[prop];
7125 f.setUnderline(value);
7126 q_ptr->setValue(prop, f);
7127 }
7128 else if (QtProperty* prop = m_strikeOutToProperty.value(property, 0))
7129 {
7130 QFont f = m_values[prop];
7131 f.setStrikeOut(value);
7132 q_ptr->setValue(prop, f);
7133 }
7134 else if (QtProperty* prop = m_kerningToProperty.value(property, 0))
7135 {
7136 QFont f = m_values[prop];
7137 f.setKerning(value);
7138 q_ptr->setValue(prop, f);
7139 }
7140}
7141
7142void
7144{
7145 if (QtProperty* pointProp = m_pointSizeToProperty.value(property, 0))
7146 {
7147 m_propertyToPointSize[pointProp] = 0;
7148 m_pointSizeToProperty.remove(property);
7149 }
7150 else if (QtProperty* pointProp = m_familyToProperty.value(property, 0))
7151 {
7152 m_propertyToFamily[pointProp] = 0;
7153 m_familyToProperty.remove(property);
7154 }
7155 else if (QtProperty* pointProp = m_boldToProperty.value(property, 0))
7156 {
7157 m_propertyToBold[pointProp] = 0;
7158 m_boldToProperty.remove(property);
7159 }
7160 else if (QtProperty* pointProp = m_italicToProperty.value(property, 0))
7161 {
7162 m_propertyToItalic[pointProp] = 0;
7163 m_italicToProperty.remove(property);
7164 }
7165 else if (QtProperty* pointProp = m_underlineToProperty.value(property, 0))
7166 {
7167 m_propertyToUnderline[pointProp] = 0;
7168 m_underlineToProperty.remove(property);
7169 }
7170 else if (QtProperty* pointProp = m_strikeOutToProperty.value(property, 0))
7171 {
7172 m_propertyToStrikeOut[pointProp] = 0;
7173 m_strikeOutToProperty.remove(property);
7174 }
7175 else if (QtProperty* pointProp = m_kerningToProperty.value(property, 0))
7176 {
7177 m_propertyToKerning[pointProp] = 0;
7178 m_kerningToProperty.remove(property);
7179 }
7180}
7181
7182void
7184{
7186 {
7187 m_fontDatabaseChangeTimer = new QTimer(q_ptr);
7188 m_fontDatabaseChangeTimer->setInterval(0);
7189 m_fontDatabaseChangeTimer->setSingleShot(true);
7190 QObject::connect(m_fontDatabaseChangeTimer,
7191 SIGNAL(timeout()),
7192 q_ptr,
7194 }
7195
7196 if (!m_fontDatabaseChangeTimer->isActive())
7197 {
7199 }
7200}
7201
7202void
7204{
7205 using PropertyPropertyMap = QMap<const QtProperty*, QtProperty*>;
7206 // rescan available font names
7207 const QStringList oldFamilies = m_familyNames;
7208 m_familyNames = fontDatabase()->families();
7209
7210 // Adapt all existing properties
7211 if (!m_propertyToFamily.empty())
7212 {
7213 PropertyPropertyMap::const_iterator cend = m_propertyToFamily.constEnd();
7214
7215 for (PropertyPropertyMap::const_iterator it = m_propertyToFamily.constBegin(); it != cend;
7216 ++it)
7217 {
7218 QtProperty* familyProp = it.value();
7219 const int oldIdx = m_enumPropertyManager->value(familyProp);
7220 int newIdx = m_familyNames.indexOf(oldFamilies.at(oldIdx));
7221
7222 if (newIdx < 0)
7223 {
7224 newIdx = 0;
7225 }
7226
7227 m_enumPropertyManager->setEnumNames(familyProp, m_familyNames);
7228 m_enumPropertyManager->setValue(familyProp, newIdx);
7229 }
7230 }
7231}
7232
7233/*!
7234 \class QtFontPropertyManager
7235
7236 \brief The QtFontPropertyManager provides and manages QFont properties.
7237
7238 A font property has nested \e family, \e pointSize, \e bold, \e
7239 italic, \e underline, \e strikeOut and \e kerning subproperties. The top-level
7240 property's value can be retrieved using the value() function, and
7241 set using the setValue() slot.
7242
7243 The subproperties are created by QtIntPropertyManager, QtEnumPropertyManager and
7244 QtBoolPropertyManager objects. These managers can be retrieved using the
7245 corresponding subIntPropertyManager(), subEnumPropertyManager() and
7246 subBoolPropertyManager() functions. In order to provide editing widgets
7247 for the subproperties in a property browser widget, these managers
7248 must be associated with editor factories.
7249
7250 In addition, QtFontPropertyManager provides the valueChanged() signal
7251 which is emitted whenever a property created by this manager
7252 changes.
7253
7254 \sa QtAbstractPropertyManager, QtEnumPropertyManager, QtIntPropertyManager, QtBoolPropertyManager
7255*/
7256
7257/*!
7258 \fn void QtFontPropertyManager::valueChanged(QtProperty *property, const QFont &value)
7259
7260 This signal is emitted whenever a property created by this manager
7261 changes its value, passing a pointer to the \a property and the
7262 new \a value as parameters.
7263
7264 \sa setValue()
7265*/
7266
7267/*!
7268 Creates a manager with the given \a parent.
7269*/
7271{
7272 d_ptr = new QtFontPropertyManagerPrivate;
7273 d_ptr->q_ptr = this;
7274 QObject::connect(qApp, SIGNAL(fontDatabaseChanged()), this, SLOT(slotFontDatabaseChanged()));
7275
7276 d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
7277 connect(d_ptr->m_intPropertyManager,
7278 SIGNAL(valueChanged(QtProperty*, int)),
7279 this,
7280 SLOT(slotIntChanged(QtProperty*, int)));
7281 d_ptr->m_enumPropertyManager = new QtEnumPropertyManager(this);
7282 connect(d_ptr->m_enumPropertyManager,
7283 SIGNAL(valueChanged(QtProperty*, int)),
7284 this,
7285 SLOT(slotEnumChanged(QtProperty*, int)));
7286 d_ptr->m_boolPropertyManager = new QtBoolPropertyManager(this);
7287 connect(d_ptr->m_boolPropertyManager,
7288 SIGNAL(valueChanged(QtProperty*, bool)),
7289 this,
7290 SLOT(slotBoolChanged(QtProperty*, bool)));
7291
7292 connect(d_ptr->m_intPropertyManager,
7293 SIGNAL(propertyDestroyed(QtProperty*)),
7294 this,
7295 SLOT(slotPropertyDestroyed(QtProperty*)));
7296 connect(d_ptr->m_enumPropertyManager,
7297 SIGNAL(propertyDestroyed(QtProperty*)),
7298 this,
7299 SLOT(slotPropertyDestroyed(QtProperty*)));
7300 connect(d_ptr->m_boolPropertyManager,
7301 SIGNAL(propertyDestroyed(QtProperty*)),
7302 this,
7303 SLOT(slotPropertyDestroyed(QtProperty*)));
7304}
7305
7306/*!
7307 Destroys this manager, and all the properties it has created.
7308*/
7310{
7311 clear();
7312 delete d_ptr;
7313}
7314
7315/*!
7316 Returns the manager that creates the \e pointSize subproperty.
7317
7318 In order to provide editing widgets for the \e pointSize property
7319 in a property browser widget, this manager must be associated
7320 with an editor factory.
7321
7322 \sa QtAbstractPropertyBrowser::setFactoryForManager()
7323*/
7326{
7327 return d_ptr->m_intPropertyManager;
7328}
7329
7330/*!
7331 Returns the manager that create the \e family subproperty.
7332
7333 In order to provide editing widgets for the \e family property
7334 in a property browser widget, this manager must be associated
7335 with an editor factory.
7336
7337 \sa QtAbstractPropertyBrowser::setFactoryForManager()
7338*/
7341{
7342 return d_ptr->m_enumPropertyManager;
7343}
7344
7345/*!
7346 Returns the manager that creates the \e bold, \e italic, \e underline,
7347 \e strikeOut and \e kerning subproperties.
7348
7349 In order to provide editing widgets for the mentioned properties
7350 in a property browser widget, this manager must be associated with
7351 an editor factory.
7352
7353 \sa QtAbstractPropertyBrowser::setFactoryForManager()
7354*/
7357{
7358 return d_ptr->m_boolPropertyManager;
7359}
7360
7361/*!
7362 Returns the given \a property's value.
7363
7364 If the given property is not managed by this manager, this
7365 function returns a font object that uses the application's default
7366 font.
7367
7368 \sa setValue()
7369*/
7370QFont
7372{
7373 return d_ptr->m_values.value(property, QFont());
7374}
7375
7376/*!
7377 \reimp
7378*/
7379QString
7381{
7382 const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it =
7383 d_ptr->m_values.constFind(property);
7384
7385 if (it == d_ptr->m_values.constEnd())
7386 {
7387 return QString();
7388 }
7389
7390 return QtPropertyBrowserUtils::fontValueText(it.value());
7391}
7392
7393/*!
7394 \reimp
7395*/
7396QIcon
7398{
7399 const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it =
7400 d_ptr->m_values.constFind(property);
7401
7402 if (it == d_ptr->m_values.constEnd())
7403 {
7404 return QIcon();
7405 }
7406
7407 return QtPropertyBrowserUtils::fontValueIcon(it.value());
7408}
7409
7410/*!
7411 \fn void QtFontPropertyManager::setValue(QtProperty *property, const QFont &value)
7412
7413 Sets the value of the given \a property to \a value. Nested
7414 properties are updated automatically.
7415
7416 \sa value(), valueChanged()
7417*/
7418void
7420{
7421 const QtFontPropertyManagerPrivate::PropertyValueMap::iterator it =
7422 d_ptr->m_values.find(property);
7423
7424 if (it == d_ptr->m_values.end())
7425 {
7426 return;
7427 }
7428
7429 const QFont oldVal = it.value();
7430
7431 if (oldVal == val && oldVal.resolve() == val.resolve())
7432 {
7433 return;
7434 }
7435
7436 it.value() = val;
7437
7438 int idx = d_ptr->m_familyNames.indexOf(val.family());
7439
7440 if (idx == -1)
7441 {
7442 idx = 0;
7443 }
7444
7445 bool settingValue = d_ptr->m_settingValue;
7446 d_ptr->m_settingValue = true;
7447 d_ptr->m_enumPropertyManager->setValue(d_ptr->m_propertyToFamily[property], idx);
7448 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToPointSize[property], val.pointSize());
7449 d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToBold[property], val.bold());
7450 d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToItalic[property], val.italic());
7451 d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToUnderline[property], val.underline());
7452 d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToStrikeOut[property], val.strikeOut());
7453 d_ptr->m_boolPropertyManager->setValue(d_ptr->m_propertyToKerning[property], val.kerning());
7454 d_ptr->m_settingValue = settingValue;
7455
7456 emit propertyChanged(property);
7457 emit valueChanged(property, val);
7458}
7459
7460/*!
7461 \reimp
7462*/
7463void
7465{
7466 QFont val;
7467 d_ptr->m_values[property] = val;
7468
7469 QtProperty* familyProp = d_ptr->m_enumPropertyManager->addProperty();
7470 familyProp->setPropertyName(tr("Family"));
7471
7472 if (d_ptr->m_familyNames.empty())
7473 {
7474 d_ptr->m_familyNames = fontDatabase()->families();
7475 }
7476
7477 d_ptr->m_enumPropertyManager->setEnumNames(familyProp, d_ptr->m_familyNames);
7478 int idx = d_ptr->m_familyNames.indexOf(val.family());
7479
7480 if (idx == -1)
7481 {
7482 idx = 0;
7483 }
7484
7485 d_ptr->m_enumPropertyManager->setValue(familyProp, idx);
7486 d_ptr->m_propertyToFamily[property] = familyProp;
7487 d_ptr->m_familyToProperty[familyProp] = property;
7488 property->addSubProperty(familyProp);
7489
7490 QtProperty* pointSizeProp = d_ptr->m_intPropertyManager->addProperty();
7491 pointSizeProp->setPropertyName(tr("Point Size"));
7492 d_ptr->m_intPropertyManager->setValue(pointSizeProp, val.pointSize());
7493 d_ptr->m_intPropertyManager->setMinimum(pointSizeProp, 1);
7494 d_ptr->m_propertyToPointSize[property] = pointSizeProp;
7495 d_ptr->m_pointSizeToProperty[pointSizeProp] = property;
7496 property->addSubProperty(pointSizeProp);
7497
7498 QtProperty* boldProp = d_ptr->m_boolPropertyManager->addProperty();
7499 boldProp->setPropertyName(tr("Bold"));
7500 d_ptr->m_boolPropertyManager->setValue(boldProp, val.bold());
7501 d_ptr->m_propertyToBold[property] = boldProp;
7502 d_ptr->m_boldToProperty[boldProp] = property;
7503 property->addSubProperty(boldProp);
7504
7505 QtProperty* italicProp = d_ptr->m_boolPropertyManager->addProperty();
7506 italicProp->setPropertyName(tr("Italic"));
7507 d_ptr->m_boolPropertyManager->setValue(italicProp, val.italic());
7508 d_ptr->m_propertyToItalic[property] = italicProp;
7509 d_ptr->m_italicToProperty[italicProp] = property;
7510 property->addSubProperty(italicProp);
7511
7512 QtProperty* underlineProp = d_ptr->m_boolPropertyManager->addProperty();
7513 underlineProp->setPropertyName(tr("Underline"));
7514 d_ptr->m_boolPropertyManager->setValue(underlineProp, val.underline());
7515 d_ptr->m_propertyToUnderline[property] = underlineProp;
7516 d_ptr->m_underlineToProperty[underlineProp] = property;
7517 property->addSubProperty(underlineProp);
7518
7519 QtProperty* strikeOutProp = d_ptr->m_boolPropertyManager->addProperty();
7520 strikeOutProp->setPropertyName(tr("Strikeout"));
7521 d_ptr->m_boolPropertyManager->setValue(strikeOutProp, val.strikeOut());
7522 d_ptr->m_propertyToStrikeOut[property] = strikeOutProp;
7523 d_ptr->m_strikeOutToProperty[strikeOutProp] = property;
7524 property->addSubProperty(strikeOutProp);
7525
7526 QtProperty* kerningProp = d_ptr->m_boolPropertyManager->addProperty();
7527 kerningProp->setPropertyName(tr("Kerning"));
7528 d_ptr->m_boolPropertyManager->setValue(kerningProp, val.kerning());
7529 d_ptr->m_propertyToKerning[property] = kerningProp;
7530 d_ptr->m_kerningToProperty[kerningProp] = property;
7531 property->addSubProperty(kerningProp);
7532}
7533
7534/*!
7535 \reimp
7536*/
7537void
7539{
7540 QtProperty* familyProp = d_ptr->m_propertyToFamily[property];
7541
7542 if (familyProp)
7543 {
7544 d_ptr->m_familyToProperty.remove(familyProp);
7545 delete familyProp;
7546 }
7547
7548 d_ptr->m_propertyToFamily.remove(property);
7549
7550 QtProperty* pointSizeProp = d_ptr->m_propertyToPointSize[property];
7551
7552 if (pointSizeProp)
7553 {
7554 d_ptr->m_pointSizeToProperty.remove(pointSizeProp);
7555 delete pointSizeProp;
7556 }
7557
7558 d_ptr->m_propertyToPointSize.remove(property);
7559
7560 QtProperty* boldProp = d_ptr->m_propertyToBold[property];
7561
7562 if (boldProp)
7563 {
7564 d_ptr->m_boldToProperty.remove(boldProp);
7565 delete boldProp;
7566 }
7567
7568 d_ptr->m_propertyToBold.remove(property);
7569
7570 QtProperty* italicProp = d_ptr->m_propertyToItalic[property];
7571
7572 if (italicProp)
7573 {
7574 d_ptr->m_italicToProperty.remove(italicProp);
7575 delete italicProp;
7576 }
7577
7578 d_ptr->m_propertyToItalic.remove(property);
7579
7580 QtProperty* underlineProp = d_ptr->m_propertyToUnderline[property];
7581
7582 if (underlineProp)
7583 {
7584 d_ptr->m_underlineToProperty.remove(underlineProp);
7585 delete underlineProp;
7586 }
7587
7588 d_ptr->m_propertyToUnderline.remove(property);
7589
7590 QtProperty* strikeOutProp = d_ptr->m_propertyToStrikeOut[property];
7591
7592 if (strikeOutProp)
7593 {
7594 d_ptr->m_strikeOutToProperty.remove(strikeOutProp);
7595 delete strikeOutProp;
7596 }
7597
7598 d_ptr->m_propertyToStrikeOut.remove(property);
7599
7600 QtProperty* kerningProp = d_ptr->m_propertyToKerning[property];
7601
7602 if (kerningProp)
7603 {
7604 d_ptr->m_kerningToProperty.remove(kerningProp);
7605 delete kerningProp;
7606 }
7607
7608 d_ptr->m_propertyToKerning.remove(property);
7609
7610 d_ptr->m_values.remove(property);
7611}
7612
7613// QtColorPropertyManager
7614
7616{
7618 Q_DECLARE_PUBLIC(QtColorPropertyManager)
7619public:
7620 void slotIntChanged(QtProperty* property, int value);
7621 void slotPropertyDestroyed(QtProperty* property);
7622
7623 using PropertyValueMap = QMap<const QtProperty*, QColor>;
7625
7627
7628 QMap<const QtProperty*, QtProperty*> m_propertyToR;
7629 QMap<const QtProperty*, QtProperty*> m_propertyToG;
7630 QMap<const QtProperty*, QtProperty*> m_propertyToB;
7631 QMap<const QtProperty*, QtProperty*> m_propertyToA;
7632
7633 QMap<const QtProperty*, QtProperty*> m_rToProperty;
7634 QMap<const QtProperty*, QtProperty*> m_gToProperty;
7635 QMap<const QtProperty*, QtProperty*> m_bToProperty;
7636 QMap<const QtProperty*, QtProperty*> m_aToProperty;
7637};
7638
7639void
7641{
7642 if (QtProperty* prop = m_rToProperty.value(property, 0))
7643 {
7644 QColor c = m_values[prop];
7645 c.setRed(value);
7646 q_ptr->setValue(prop, c);
7647 }
7648 else if (QtProperty* prop = m_gToProperty.value(property, 0))
7649 {
7650 QColor c = m_values[prop];
7651 c.setGreen(value);
7652 q_ptr->setValue(prop, c);
7653 }
7654 else if (QtProperty* prop = m_bToProperty.value(property, 0))
7655 {
7656 QColor c = m_values[prop];
7657 c.setBlue(value);
7658 q_ptr->setValue(prop, c);
7659 }
7660 else if (QtProperty* prop = m_aToProperty.value(property, 0))
7661 {
7662 QColor c = m_values[prop];
7663 c.setAlpha(value);
7664 q_ptr->setValue(prop, c);
7665 }
7666}
7667
7668void
7670{
7671 if (QtProperty* pointProp = m_rToProperty.value(property, 0))
7672 {
7673 m_propertyToR[pointProp] = 0;
7674 m_rToProperty.remove(property);
7675 }
7676 else if (QtProperty* pointProp = m_gToProperty.value(property, 0))
7677 {
7678 m_propertyToG[pointProp] = 0;
7679 m_gToProperty.remove(property);
7680 }
7681 else if (QtProperty* pointProp = m_bToProperty.value(property, 0))
7682 {
7683 m_propertyToB[pointProp] = 0;
7684 m_bToProperty.remove(property);
7685 }
7686 else if (QtProperty* pointProp = m_aToProperty.value(property, 0))
7687 {
7688 m_propertyToA[pointProp] = 0;
7689 m_aToProperty.remove(property);
7690 }
7691}
7692
7693/*!
7694 \class QtColorPropertyManager
7695
7696 \brief The QtColorPropertyManager provides and manages QColor properties.
7697
7698 A color property has nested \e red, \e green and \e blue
7699 subproperties. The top-level property's value can be retrieved
7700 using the value() function, and set using the setValue() slot.
7701
7702 The subproperties are created by a QtIntPropertyManager object. This
7703 manager can be retrieved using the subIntPropertyManager() function. In
7704 order to provide editing widgets for the subproperties in a
7705 property browser widget, this manager must be associated with an
7706 editor factory.
7707
7708 In addition, QtColorPropertyManager provides the valueChanged() signal
7709 which is emitted whenever a property created by this manager
7710 changes.
7711
7712 \sa QtAbstractPropertyManager, QtAbstractPropertyBrowser, QtIntPropertyManager
7713*/
7714
7715/*!
7716 \fn void QtColorPropertyManager::valueChanged(QtProperty *property, const QColor &value)
7717
7718 This signal is emitted whenever a property created by this manager
7719 changes its value, passing a pointer to the \a property and the new
7720 \a value as parameters.
7721
7722 \sa setValue()
7723*/
7724
7725/*!
7726 Creates a manager with the given \a parent.
7727*/
7729{
7731 d_ptr->q_ptr = this;
7732
7733 d_ptr->m_intPropertyManager = new QtIntPropertyManager(this);
7734 connect(d_ptr->m_intPropertyManager,
7735 SIGNAL(valueChanged(QtProperty*, int)),
7736 this,
7737 SLOT(slotIntChanged(QtProperty*, int)));
7738
7739 connect(d_ptr->m_intPropertyManager,
7740 SIGNAL(propertyDestroyed(QtProperty*)),
7741 this,
7742 SLOT(slotPropertyDestroyed(QtProperty*)));
7743}
7744
7745/*!
7746 Destroys this manager, and all the properties it has created.
7747*/
7749{
7750 clear();
7751 delete d_ptr;
7752}
7753
7754/*!
7755 Returns the manager that produces the nested \e red, \e green and
7756 \e blue subproperties.
7757
7758 In order to provide editing widgets for the subproperties in a
7759 property browser widget, this manager must be associated with an
7760 editor factory.
7761
7762 \sa QtAbstractPropertyBrowser::setFactoryForManager()
7763*/
7766{
7767 return d_ptr->m_intPropertyManager;
7768}
7769
7770/*!
7771 Returns the given \a property's value.
7772
7773 If the given \a property is not managed by \e this manager, this
7774 function returns an invalid color.
7775
7776 \sa setValue()
7777*/
7778QColor
7780{
7781 return d_ptr->m_values.value(property, QColor());
7782}
7783
7784/*!
7785 \reimp
7786*/
7787
7788QString
7790{
7791 const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it =
7792 d_ptr->m_values.constFind(property);
7793
7794 if (it == d_ptr->m_values.constEnd())
7795 {
7796 return QString();
7797 }
7798
7799 return QtPropertyBrowserUtils::colorValueText(it.value());
7800}
7801
7802/*!
7803 \reimp
7804*/
7805
7806QIcon
7808{
7809 const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it =
7810 d_ptr->m_values.constFind(property);
7811
7812 if (it == d_ptr->m_values.constEnd())
7813 {
7814 return QIcon();
7815 }
7816
7817 return QtPropertyBrowserUtils::brushValueIcon(QBrush(it.value()));
7818}
7819
7820/*!
7821 \fn void QtColorPropertyManager::setValue(QtProperty *property, const QColor &value)
7822
7823 Sets the value of the given \a property to \a value. Nested
7824 properties are updated automatically.
7825
7826 \sa value(), valueChanged()
7827*/
7828void
7830{
7831 const QtColorPropertyManagerPrivate::PropertyValueMap::iterator it =
7832 d_ptr->m_values.find(property);
7833
7834 if (it == d_ptr->m_values.end())
7835 {
7836 return;
7837 }
7838
7839 if (it.value() == val)
7840 {
7841 return;
7842 }
7843
7844 it.value() = val;
7845
7846 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToR[property], val.red());
7847 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToG[property], val.green());
7848 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToB[property], val.blue());
7849 d_ptr->m_intPropertyManager->setValue(d_ptr->m_propertyToA[property], val.alpha());
7850
7851 emit propertyChanged(property);
7852 emit valueChanged(property, val);
7853}
7854
7855/*!
7856 \reimp
7857*/
7858void
7860{
7861 QColor val;
7862 d_ptr->m_values[property] = val;
7863
7864 QtProperty* rProp = d_ptr->m_intPropertyManager->addProperty();
7865 rProp->setPropertyName(tr("Red"));
7866 d_ptr->m_intPropertyManager->setValue(rProp, val.red());
7867 d_ptr->m_intPropertyManager->setRange(rProp, 0, 0xFF);
7868 d_ptr->m_propertyToR[property] = rProp;
7869 d_ptr->m_rToProperty[rProp] = property;
7870 property->addSubProperty(rProp);
7871
7872 QtProperty* gProp = d_ptr->m_intPropertyManager->addProperty();
7873 gProp->setPropertyName(tr("Green"));
7874 d_ptr->m_intPropertyManager->setValue(gProp, val.green());
7875 d_ptr->m_intPropertyManager->setRange(gProp, 0, 0xFF);
7876 d_ptr->m_propertyToG[property] = gProp;
7877 d_ptr->m_gToProperty[gProp] = property;
7878 property->addSubProperty(gProp);
7879
7880 QtProperty* bProp = d_ptr->m_intPropertyManager->addProperty();
7881 bProp->setPropertyName(tr("Blue"));
7882 d_ptr->m_intPropertyManager->setValue(bProp, val.blue());
7883 d_ptr->m_intPropertyManager->setRange(bProp, 0, 0xFF);
7884 d_ptr->m_propertyToB[property] = bProp;
7885 d_ptr->m_bToProperty[bProp] = property;
7886 property->addSubProperty(bProp);
7887
7888 QtProperty* aProp = d_ptr->m_intPropertyManager->addProperty();
7889 aProp->setPropertyName(tr("Alpha"));
7890 d_ptr->m_intPropertyManager->setValue(aProp, val.alpha());
7891 d_ptr->m_intPropertyManager->setRange(aProp, 0, 0xFF);
7892 d_ptr->m_propertyToA[property] = aProp;
7893 d_ptr->m_aToProperty[aProp] = property;
7894 property->addSubProperty(aProp);
7895}
7896
7897/*!
7898 \reimp
7899*/
7900void
7902{
7903 QtProperty* rProp = d_ptr->m_propertyToR[property];
7904
7905 if (rProp)
7906 {
7907 d_ptr->m_rToProperty.remove(rProp);
7908 delete rProp;
7909 }
7910
7911 d_ptr->m_propertyToR.remove(property);
7912
7913 QtProperty* gProp = d_ptr->m_propertyToG[property];
7914
7915 if (gProp)
7916 {
7917 d_ptr->m_gToProperty.remove(gProp);
7918 delete gProp;
7919 }
7920
7921 d_ptr->m_propertyToG.remove(property);
7922
7923 QtProperty* bProp = d_ptr->m_propertyToB[property];
7924
7925 if (bProp)
7926 {
7927 d_ptr->m_bToProperty.remove(bProp);
7928 delete bProp;
7929 }
7930
7931 d_ptr->m_propertyToB.remove(property);
7932
7933 QtProperty* aProp = d_ptr->m_propertyToA[property];
7934
7935 if (aProp)
7936 {
7937 d_ptr->m_aToProperty.remove(aProp);
7938 delete aProp;
7939 }
7940
7941 d_ptr->m_propertyToA.remove(property);
7942
7943 d_ptr->m_values.remove(property);
7944}
7945
7946// QtCursorPropertyManager
7947
7948// Make sure icons are removed as soon as QApplication is destroyed, otherwise,
7949// handles are leaked on X11.
7950static void clearCursorDatabase();
7951
7952namespace
7953{
7954 struct CursorDatabase : public QtCursorDatabase
7955 {
7956 CursorDatabase()
7957 {
7958 qAddPostRoutine(clearCursorDatabase);
7959 }
7960 };
7961} // namespace
7962Q_GLOBAL_STATIC(QtCursorDatabase, cursorDatabase2)
7963
7964static void
7965clearCursorDatabase()
7966{
7967 cursorDatabase2()->clear();
7968}
7969
7971{
7973 Q_DECLARE_PUBLIC(QtCursorPropertyManager)
7974public:
7975 using PropertyValueMap = QMap<const QtProperty*, QCursor>;
7977};
7978
7979/*!
7980 \class QtCursorPropertyManager
7981
7982 \brief The QtCursorPropertyManager provides and manages QCursor properties.
7983
7984 A cursor property has a current value which can be
7985 retrieved using the value() function, and set using the setValue()
7986 slot. In addition, QtCursorPropertyManager provides the
7987 valueChanged() signal which is emitted whenever a property created
7988 by this manager changes.
7989
7990 \sa QtAbstractPropertyManager
7991*/
7992
7993/*!
7994 \fn void QtCursorPropertyManager::valueChanged(QtProperty *property, const QCursor &value)
7995
7996 This signal is emitted whenever a property created by this manager
7997 changes its value, passing a pointer to the \a property and the new
7998 \a value as parameters.
7999
8000 \sa setValue()
8001*/
8002
8003/*!
8004 Creates a manager with the given \a parent.
8005*/
8008{
8010 d_ptr->q_ptr = this;
8011}
8012
8013/*!
8014 Destroys this manager, and all the properties it has created.
8015*/
8017{
8018 clear();
8019 delete d_ptr;
8020}
8021
8022/*!
8023 Returns the given \a property's value.
8024
8025 If the given \a property is not managed by this manager, this
8026 function returns a default QCursor object.
8027
8028 \sa setValue()
8029*/
8030#ifndef QT_NO_CURSOR
8031QCursor
8033{
8034 return d_ptr->m_values.value(property, QCursor());
8035}
8036#endif
8037
8038/*!
8039 \reimp
8040*/
8041QString
8043{
8044 const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it =
8045 d_ptr->m_values.constFind(property);
8046
8047 if (it == d_ptr->m_values.constEnd())
8048 {
8049 return QString();
8050 }
8051
8052 return cursorDatabase2()->cursorToShapeName(it.value());
8053}
8054
8055/*!
8056 \reimp
8057*/
8058QIcon
8060{
8061 const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it =
8062 d_ptr->m_values.constFind(property);
8063
8064 if (it == d_ptr->m_values.constEnd())
8065 {
8066 return QIcon();
8067 }
8068
8069 return cursorDatabase2()->cursorToShapeIcon(it.value());
8070}
8071
8072/*!
8073 \fn void QtCursorPropertyManager::setValue(QtProperty *property, const QCursor &value)
8074
8075 Sets the value of the given \a property to \a value.
8076
8077 \sa value(), valueChanged()
8078*/
8079void
8081{
8082#ifndef QT_NO_CURSOR
8083 const QtCursorPropertyManagerPrivate::PropertyValueMap::iterator it =
8084 d_ptr->m_values.find(property);
8085
8086 if (it == d_ptr->m_values.end())
8087 {
8088 return;
8089 }
8090
8091 if (it.value().shape() == value.shape() && value.shape() != Qt::BitmapCursor)
8092 {
8093 return;
8094 }
8095
8096 it.value() = value;
8097
8098 emit propertyChanged(property);
8099 emit valueChanged(property, value);
8100#endif
8101}
8102
8103/*!
8104 \reimp
8105*/
8106void
8108{
8109#ifndef QT_NO_CURSOR
8110 d_ptr->m_values[property] = QCursor();
8111#endif
8112}
8113
8114/*!
8115 \reimp
8116*/
8117void
8119{
8120 d_ptr->m_values.remove(property);
8121}
8122
8123QT_END_NAMESPACE
8124
8125#include "moc_qtpropertymanager.cpp"
8126#include "qtpropertymanager.moc"
uint8_t data[1]
uint8_t index
constexpr T c
std::string str(const T &t)
void propertyDestroyed(QtProperty *property)
void propertyChanged(QtProperty *property)
QtAbstractPropertyManager(QObject *parent=0)
QMap< const QtProperty *, Data > PropertyValueMap
The QtBoolPropertyManager class provides and manages boolean properties.
void initializeProperty(QtProperty *property) override
void textVisibleChanged(QtProperty *property, bool)
void setValue(QtProperty *property, bool val)
bool textVisible(const QtProperty *property) const
void setTextVisible(QtProperty *property, bool textVisible)
QIcon valueIcon(const QtProperty *property) const override
void valueChanged(QtProperty *property, bool val)
bool value(const QtProperty *property) const
void uninitializeProperty(QtProperty *property) override
QtBoolPropertyManager(QObject *parent=0)
QString valueText(const QtProperty *property) const override
QMap< const QtProperty *, QChar > PropertyValueMap
The QtCharPropertyManager provides and manages QChar properties.
void initializeProperty(QtProperty *property) override
QChar value(const QtProperty *property) const
QtCharPropertyManager(QObject *parent=0)
void uninitializeProperty(QtProperty *property) override
void valueChanged(QtProperty *property, const QChar &val)
QString valueText(const QtProperty *property) const override
void setValue(QtProperty *property, const QChar &val)
void slotPropertyDestroyed(QtProperty *property)
QMap< const QtProperty *, QtProperty * > m_rToProperty
QMap< const QtProperty *, QtProperty * > m_propertyToA
QtIntPropertyManager * m_intPropertyManager
QMap< const QtProperty *, QtProperty * > m_propertyToG
void slotIntChanged(QtProperty *property, int value)
QMap< const QtProperty *, QtProperty * > m_bToProperty
QMap< const QtProperty *, QtProperty * > m_gToProperty
QMap< const QtProperty *, QtProperty * > m_propertyToB
QMap< const QtProperty *, QColor > PropertyValueMap
QMap< const QtProperty *, QtProperty * > m_propertyToR
QMap< const QtProperty *, QtProperty * > m_aToProperty
The QtColorPropertyManager provides and manages QColor properties.
void initializeProperty(QtProperty *property) override
QtIntPropertyManager * subIntPropertyManager() const
void setValue(QtProperty *property, const QColor &val)
QtColorPropertyManager(QObject *parent=0)
QIcon valueIcon(const QtProperty *property) const override
void valueChanged(QtProperty *property, const QColor &val)
void uninitializeProperty(QtProperty *property) override
QColor value(const QtProperty *property) const
QString valueText(const QtProperty *property) const override
QMap< const QtProperty *, QCursor > PropertyValueMap
The QtCursorPropertyManager provides and manages QCursor properties.
void initializeProperty(QtProperty *property) override
void setValue(QtProperty *property, const QCursor &val)
void valueChanged(QtProperty *property, const QCursor &val)
QtCursorPropertyManager(QObject *parent=0)
QCursor value(const QtProperty *property) const
QIcon valueIcon(const QtProperty *property) const override
void uninitializeProperty(QtProperty *property) override
QString valueText(const QtProperty *property) const override
QMap< const QtProperty *, Data > m_values
QMap< const QtProperty *, Data > PropertyValueMap
The QtDatePropertyManager provides and manages QDate properties.
void setValue(QtProperty *property, const QDate &val)
void initializeProperty(QtProperty *property) override
QDate minimum(const QtProperty *property) const
QtDatePropertyManager(QObject *parent=0)
QDate value(const QtProperty *property) const
void rangeChanged(QtProperty *property, const QDate &minVal, const QDate &maxVal)
void valueChanged(QtProperty *property, const QDate &val)
void setMinimum(QtProperty *property, const QDate &minVal)
void setRange(QtProperty *property, const QDate &minVal, const QDate &maxVal)
void uninitializeProperty(QtProperty *property) override
QDate maximum(const QtProperty *property) const
QString valueText(const QtProperty *property) const override
void setMaximum(QtProperty *property, const QDate &maxVal)
QMap< const QtProperty *, QDateTime > PropertyValueMap
The QtDateTimePropertyManager provides and manages QDateTime properties.
void initializeProperty(QtProperty *property) override
void valueChanged(QtProperty *property, const QDateTime &val)
QDateTime value(const QtProperty *property) const
void uninitializeProperty(QtProperty *property) override
void setValue(QtProperty *property, const QDateTime &val)
QtDateTimePropertyManager(QObject *parent=0)
QString valueText(const QtProperty *property) const override
QMap< const QtProperty *, Data > PropertyValueMap
The QtDoublePropertyManager provides and manages double properties.
int decimals(const QtProperty *property) const
void initializeProperty(QtProperty *property) override
void setSingleStep(QtProperty *property, double step)
void setMaximum(QtProperty *property, double maxVal)
void setDecimals(QtProperty *property, int prec)
double maximum(const QtProperty *property) const
double minimum(const QtProperty *property) const
bool isReadOnly(const QtProperty *property) const
void singleStepChanged(QtProperty *property, double step)
void readOnlyChanged(QtProperty *property, bool readOnly)
void valueChanged(QtProperty *property, double val)
void setValue(QtProperty *property, double val)
double value(const QtProperty *property) const
void setMinimum(QtProperty *property, double minVal)
double singleStep(const QtProperty *property) const
void rangeChanged(QtProperty *property, double minVal, double maxVal)
void setRange(QtProperty *property, double minVal, double maxVal)
void uninitializeProperty(QtProperty *property) override
void decimalsChanged(QtProperty *property, int prec)
QtDoublePropertyManager(QObject *parent=0)
QString valueText(const QtProperty *property) const override
void setReadOnly(QtProperty *property, bool readOnly)
QMap< const QtProperty *, Data > PropertyValueMap
The QtEnumPropertyManager provides and manages enum properties.
void initializeProperty(QtProperty *property) override
void setEnumNames(QtProperty *property, const QStringList &names)
void valueChanged(QtProperty *property, int val)
QMap< int, QIcon > enumIcons(const QtProperty *property) const
QStringList enumNames(const QtProperty *property) const
void setValue(QtProperty *property, int val)
void enumNamesChanged(QtProperty *property, const QStringList &names)
void enumIconsChanged(QtProperty *property, const QMap< int, QIcon > &icons)
QtEnumPropertyManager(QObject *parent=0)
QIcon valueIcon(const QtProperty *property) const override
void setEnumIcons(QtProperty *property, const QMap< int, QIcon > &icons)
void uninitializeProperty(QtProperty *property) override
QString valueText(const QtProperty *property) const override
int value(const QtProperty *property) const
QMap< const QtProperty *, QtProperty * > m_flagToProperty
void slotPropertyDestroyed(QtProperty *property)
QMap< const QtProperty *, Data > PropertyValueMap
QtBoolPropertyManager * m_boolPropertyManager
QMap< const QtProperty *, QList< QtProperty * > > m_propertyToFlags
void slotBoolChanged(QtProperty *property, bool value)
The QtFlagPropertyManager provides and manages flag properties.
void initializeProperty(QtProperty *property) override
void flagNamesChanged(QtProperty *property, const QStringList &names)
void valueChanged(QtProperty *property, int val)
void setValue(QtProperty *property, int val)
QtFlagPropertyManager(QObject *parent=0)
void uninitializeProperty(QtProperty *property) override
QStringList flagNames(const QtProperty *property) const
void setFlagNames(QtProperty *property, const QStringList &names)
QString valueText(const QtProperty *property) const override
QtBoolPropertyManager * subBoolPropertyManager() const
int value(const QtProperty *property) const
QMap< const QtProperty *, QtProperty * > m_boldToProperty
QMap< const QtProperty *, QtProperty * > m_pointSizeToProperty
QMap< const QtProperty *, QtProperty * > m_propertyToKerning
void slotPropertyDestroyed(QtProperty *property)
QMap< const QtProperty *, QtProperty * > m_italicToProperty
QMap< const QtProperty *, QtProperty * > m_propertyToUnderline
QMap< const QtProperty *, QtProperty * > m_propertyToFamily
QtIntPropertyManager * m_intPropertyManager
QMap< const QtProperty *, QtProperty * > m_propertyToItalic
QMap< const QtProperty *, QtProperty * > m_kerningToProperty
void slotIntChanged(QtProperty *property, int value)
QtBoolPropertyManager * m_boolPropertyManager
void slotEnumChanged(QtProperty *property, int value)
QMap< const QtProperty *, QtProperty * > m_propertyToPointSize
QMap< const QtProperty *, QtProperty * > m_strikeOutToProperty
QtEnumPropertyManager * m_enumPropertyManager
QMap< const QtProperty *, QtProperty * > m_propertyToStrikeOut
QMap< const QtProperty *, QtProperty * > m_propertyToBold
void slotBoolChanged(QtProperty *property, bool value)
QMap< const QtProperty *, QtProperty * > m_familyToProperty
QMap< const QtProperty *, QFont > PropertyValueMap
QMap< const QtProperty *, QtProperty * > m_underlineToProperty
The QtFontPropertyManager provides and manages QFont properties.
void initializeProperty(QtProperty *property) override
QtIntPropertyManager * subIntPropertyManager() const
QtFontPropertyManager(QObject *parent=0)
QtEnumPropertyManager * subEnumPropertyManager() const
QIcon valueIcon(const QtProperty *property) const override
void uninitializeProperty(QtProperty *property) override
void valueChanged(QtProperty *property, const QFont &val)
QFont value(const QtProperty *property) const
void setValue(QtProperty *property, const QFont &val)
QString valueText(const QtProperty *property) const override
QtBoolPropertyManager * subBoolPropertyManager() const
void initializeProperty(QtProperty *property) override
bool hasValue(const QtProperty *property) const override
QtGroupPropertyManager(QObject *parent=0)
void uninitializeProperty(QtProperty *property) override
QMap< const QtProperty *, Data > PropertyValueMap
The QtIntPropertyManager provides and manages int properties.
void initializeProperty(QtProperty *property) override
int minimum(const QtProperty *property) const
void valueChanged(QtProperty *property, int val)
void setMaximum(QtProperty *property, int maxVal)
void setRange(QtProperty *property, int minVal, int maxVal)
void setValue(QtProperty *property, int val)
void rangeChanged(QtProperty *property, int minVal, int maxVal)
bool isReadOnly(const QtProperty *property) const
void setMinimum(QtProperty *property, int minVal)
void readOnlyChanged(QtProperty *property, bool readOnly)
void singleStepChanged(QtProperty *property, int step)
int singleStep(const QtProperty *property) const
void setSingleStep(QtProperty *property, int step)
void uninitializeProperty(QtProperty *property) override
QtIntPropertyManager(QObject *parent=0)
QString valueText(const QtProperty *property) const override
int maximum(const QtProperty *property) const
void setReadOnly(QtProperty *property, bool readOnly)
int value(const QtProperty *property) const
QMap< const QtProperty *, QKeySequence > PropertyValueMap
The QtKeySequencePropertyManager provides and manages QKeySequence properties.
void initializeProperty(QtProperty *property) override
QKeySequence value(const QtProperty *property) const
void uninitializeProperty(QtProperty *property) override
QString valueText(const QtProperty *property) const override
void setValue(QtProperty *property, const QKeySequence &val)
void valueChanged(QtProperty *property, const QKeySequence &val)
QtKeySequencePropertyManager(QObject *parent=0)
void slotPropertyDestroyed(QtProperty *property)
QMap< const QtProperty *, QtProperty * > m_languageToProperty
QMap< const QtProperty *, QtProperty * > m_propertyToCountry
void slotEnumChanged(QtProperty *property, int value)
QMap< const QtProperty *, QLocale > PropertyValueMap
QtEnumPropertyManager * m_enumPropertyManager
QMap< const QtProperty *, QtProperty * > m_propertyToLanguage
QMap< const QtProperty *, QtProperty * > m_countryToProperty
The QtLocalePropertyManager provides and manages QLocale properties.
void setValue(QtProperty *property, const QLocale &val)
void initializeProperty(QtProperty *property) override
QtEnumPropertyManager * subEnumPropertyManager() const
QLocale value(const QtProperty *property) const
void valueChanged(QtProperty *property, const QLocale &val)
void uninitializeProperty(QtProperty *property) override
QtLocalePropertyManager(QObject *parent=0)
QString valueText(const QtProperty *property) const override
void localeToIndex(QLocale::Language language, QLocale::Country country, int *languageIndex, int *countryIndex) const
QStringList policyEnumNames() const
QSizePolicy::Policy indexToSizePolicy(int index) const
QStringList languageEnumNames() const
void indexToLocale(int languageIndex, int countryIndex, QLocale::Language *language, QLocale::Country *country) const
int sizePolicyToIndex(QSizePolicy::Policy policy) const
QStringList countryEnumNames(QLocale::Language language) const
QSizePolicy::Policy policy
QSizePolicy::Policy policy() const
void slotDoubleChanged(QtProperty *property, double value)
QMap< const QtProperty *, QtProperty * > m_propertyToX
void slotPropertyDestroyed(QtProperty *property)
QMap< const QtProperty *, Data > PropertyValueMap
QMap< const QtProperty *, QtProperty * > m_yToProperty
QtDoublePropertyManager * m_doublePropertyManager
QMap< const QtProperty *, QtProperty * > m_propertyToY
QMap< const QtProperty *, QtProperty * > m_xToProperty
The QtPointFPropertyManager provides and manages QPointF properties.
int decimals(const QtProperty *property) const
void initializeProperty(QtProperty *property) override
QtPointFPropertyManager(QObject *parent=0)
QPointF value(const QtProperty *property) const
void valueChanged(QtProperty *property, const QPointF &val)
void setDecimals(QtProperty *property, int prec)
void uninitializeProperty(QtProperty *property) override
void decimalsChanged(QtProperty *property, int prec)
QString valueText(const QtProperty *property) const override
void setValue(QtProperty *property, const QPointF &val)
QtDoublePropertyManager * subDoublePropertyManager() const
QMap< const QtProperty *, QtProperty * > m_propertyToX
void slotPropertyDestroyed(QtProperty *property)
QMap< const QtProperty *, QPoint > PropertyValueMap
QtIntPropertyManager * m_intPropertyManager
void slotIntChanged(QtProperty *property, int value)
QMap< const QtProperty *, QtProperty * > m_yToProperty
QMap< const QtProperty *, QtProperty * > m_propertyToY
QMap< const QtProperty *, QtProperty * > m_xToProperty
The QtPointPropertyManager provides and manages QPoint properties.
void valueChanged(QtProperty *property, const QPoint &val)
void initializeProperty(QtProperty *property) override
QtPointPropertyManager(QObject *parent=0)
QtIntPropertyManager * subIntPropertyManager() const
void setValue(QtProperty *property, const QPoint &val)
QPoint value(const QtProperty *property) const
void uninitializeProperty(QtProperty *property) override
QString valueText(const QtProperty *property) const override
static QString fontValueText(const QFont &f)
static QIcon fontValueIcon(const QFont &f)
static QIcon brushValueIcon(const QBrush &b)
static QString colorValueText(const QColor &c)
The QtProperty class encapsulates an instance of a property.
void setPropertyName(const QString &text)
void addSubProperty(QtProperty *property)
void slotDoubleChanged(QtProperty *property, double value)
QMap< const QtProperty *, QtProperty * > m_propertyToH
QMap< const QtProperty *, QtProperty * > m_propertyToX
void slotPropertyDestroyed(QtProperty *property)
QMap< const QtProperty *, QtProperty * > m_propertyToW
QMap< const QtProperty *, Data > PropertyValueMap
QMap< const QtProperty *, QtProperty * > m_hToProperty
void setConstraint(QtProperty *property, const QRectF &constraint, const QRectF &val)
QMap< const QtProperty *, QtProperty * > m_yToProperty
QMap< const QtProperty *, QtProperty * > m_wToProperty
QtDoublePropertyManager * m_doublePropertyManager
QMap< const QtProperty *, QtProperty * > m_propertyToY
QMap< const QtProperty *, QtProperty * > m_xToProperty
The QtRectFPropertyManager provides and manages QRectF properties.
int decimals(const QtProperty *property) const
void initializeProperty(QtProperty *property) override
QRectF constraint(const QtProperty *property) const
void setConstraint(QtProperty *property, const QRectF &constraint)
void constraintChanged(QtProperty *property, const QRectF &constraint)
void setDecimals(QtProperty *property, int prec)
void valueChanged(QtProperty *property, const QRectF &val)
QRectF value(const QtProperty *property) const
void uninitializeProperty(QtProperty *property) override
QtRectFPropertyManager(QObject *parent=0)
void decimalsChanged(QtProperty *property, int prec)
void setValue(QtProperty *property, const QRectF &val)
QString valueText(const QtProperty *property) const override
QtDoublePropertyManager * subDoublePropertyManager() const
QMap< const QtProperty *, QtProperty * > m_propertyToH
QMap< const QtProperty *, QtProperty * > m_propertyToX
void slotPropertyDestroyed(QtProperty *property)
void setConstraint(QtProperty *property, const QRect &constraint, const QRect &val)
QMap< const QtProperty *, QtProperty * > m_propertyToW
QMap< const QtProperty *, Data > PropertyValueMap
QtIntPropertyManager * m_intPropertyManager
void slotIntChanged(QtProperty *property, int value)
QMap< const QtProperty *, QtProperty * > m_hToProperty
QMap< const QtProperty *, QtProperty * > m_yToProperty
QMap< const QtProperty *, QtProperty * > m_wToProperty
QMap< const QtProperty *, QtProperty * > m_propertyToY
QMap< const QtProperty *, QtProperty * > m_xToProperty
The QtRectPropertyManager provides and manages QRect properties.
void valueChanged(QtProperty *property, const QRect &val)
void initializeProperty(QtProperty *property) override
QtIntPropertyManager * subIntPropertyManager() const
QtRectPropertyManager(QObject *parent=0)
QRect constraint(const QtProperty *property) const
void setValue(QtProperty *property, const QRect &val)
void constraintChanged(QtProperty *property, const QRect &constraint)
void uninitializeProperty(QtProperty *property) override
QRect value(const QtProperty *property) const
QString valueText(const QtProperty *property) const override
void setConstraint(QtProperty *property, const QRect &constraint)
void slotDoubleChanged(QtProperty *property, double value)
QMap< const QtProperty *, QtProperty * > m_propertyToH
void slotPropertyDestroyed(QtProperty *property)
QMap< const QtProperty *, QtProperty * > m_propertyToW
QMap< const QtProperty *, Data > PropertyValueMap
void setValue(QtProperty *property, const QSizeF &val)
QMap< const QtProperty *, QtProperty * > m_hToProperty
QMap< const QtProperty *, QtProperty * > m_wToProperty
void setRange(QtProperty *property, const QSizeF &minVal, const QSizeF &maxVal, const QSizeF &val)
QtDoublePropertyManager * m_doublePropertyManager
The QtSizeFPropertyManager provides and manages QSizeF properties.
int decimals(const QtProperty *property) const
void initializeProperty(QtProperty *property) override
void setMaximum(QtProperty *property, const QSizeF &maxVal)
QSizeF value(const QtProperty *property) const
void setMinimum(QtProperty *property, const QSizeF &minVal)
QSizeF maximum(const QtProperty *property) const
void setDecimals(QtProperty *property, int prec)
void setValue(QtProperty *property, const QSizeF &val)
void uninitializeProperty(QtProperty *property) override
QtSizeFPropertyManager(QObject *parent=0)
QSizeF minimum(const QtProperty *property) const
void decimalsChanged(QtProperty *property, int prec)
void setRange(QtProperty *property, const QSizeF &minVal, const QSizeF &maxVal)
QString valueText(const QtProperty *property) const override
void valueChanged(QtProperty *property, const QSizeF &val)
QtDoublePropertyManager * subDoublePropertyManager() const
void rangeChanged(QtProperty *property, const QSizeF &minVal, const QSizeF &maxVal)
QMap< const QtProperty *, QtProperty * > m_hPolicyToProperty
QMap< const QtProperty *, QtProperty * > m_propertyToHPolicy
QMap< const QtProperty *, QtProperty * > m_vStretchToProperty
void slotPropertyDestroyed(QtProperty *property)
QMap< const QtProperty *, QtProperty * > m_propertyToHStretch
void slotIntChanged(QtProperty *property, int value)
void slotEnumChanged(QtProperty *property, int value)
QMap< const QtProperty *, QtProperty * > m_propertyToVPolicy
QMap< const QtProperty *, QtProperty * > m_vPolicyToProperty
QtEnumPropertyManager * m_enumPropertyManager
QMap< const QtProperty *, QtProperty * > m_hStretchToProperty
QMap< const QtProperty *, QSizePolicy > PropertyValueMap
QMap< const QtProperty *, QtProperty * > m_propertyToVStretch
The QtSizePolicyPropertyManager provides and manages QSizePolicy properties.
void initializeProperty(QtProperty *property) override
QtIntPropertyManager * subIntPropertyManager() const
void valueChanged(QtProperty *property, const QSizePolicy &val)
QtEnumPropertyManager * subEnumPropertyManager() const
void setValue(QtProperty *property, const QSizePolicy &val)
void uninitializeProperty(QtProperty *property) override
QSizePolicy value(const QtProperty *property) const
QtSizePolicyPropertyManager(QObject *parent=0)
QString valueText(const QtProperty *property) const override
QMap< const QtProperty *, QtProperty * > m_propertyToH
void slotPropertyDestroyed(QtProperty *property)
void setValue(QtProperty *property, const QSize &val)
QMap< const QtProperty *, QtProperty * > m_propertyToW
QMap< const QtProperty *, Data > PropertyValueMap
QtIntPropertyManager * m_intPropertyManager
void slotIntChanged(QtProperty *property, int value)
void setRange(QtProperty *property, const QSize &minVal, const QSize &maxVal, const QSize &val)
QMap< const QtProperty *, QtProperty * > m_hToProperty
QMap< const QtProperty *, QtProperty * > m_wToProperty
The QtSizePropertyManager provides and manages QSize properties.
void initializeProperty(QtProperty *property) override
QtIntPropertyManager * subIntPropertyManager() const
void valueChanged(QtProperty *property, const QSize &val)
void setValue(QtProperty *property, const QSize &val)
void setMinimum(QtProperty *property, const QSize &minVal)
void setRange(QtProperty *property, const QSize &minVal, const QSize &maxVal)
QSize minimum(const QtProperty *property) const
void setMaximum(QtProperty *property, const QSize &maxVal)
void uninitializeProperty(QtProperty *property) override
QtSizePropertyManager(QObject *parent=0)
QSize value(const QtProperty *property) const
void rangeChanged(QtProperty *property, const QSize &minVal, const QSize &maxVal)
QString valueText(const QtProperty *property) const override
QSize maximum(const QtProperty *property) const
QMap< const QtProperty *, Data > m_values
QMap< const QtProperty *, Data > PropertyValueMap
The QtStringPropertyManager provides and manages QString properties.
void initializeProperty(QtProperty *property) override
QRegExp regExp(const QtProperty *property) const
void setRegExp(QtProperty *property, const QRegExp &regExp)
QString displayText(const QtProperty *property) const override
void regExpChanged(QtProperty *property, const QRegExp &regExp)
bool isReadOnly(const QtProperty *property) const
QtStringPropertyManager(QObject *parent=0)
QString value(const QtProperty *property) const
void setEchoMode(QtProperty *property, EchoMode echoMode)
void valueChanged(QtProperty *property, const QString &val)
void setValue(QtProperty *property, const QString &val)
void uninitializeProperty(QtProperty *property) override
void readOnlyChanged(QtProperty *property, bool)
void echoModeChanged(QtProperty *property, const int)
QString valueText(const QtProperty *property) const override
void setReadOnly(QtProperty *property, bool readOnly)
EchoMode echoMode(const QtProperty *property) const override
QMap< const QtProperty *, QTime > PropertyValueMap
The QtTimePropertyManager provides and manages QTime properties.
void initializeProperty(QtProperty *property) override
QTime value(const QtProperty *property) const
void valueChanged(QtProperty *property, const QTime &val)
QtTimePropertyManager(QObject *parent=0)
void setValue(QtProperty *property, const QTime &val)
void uninitializeProperty(QtProperty *property) override
QString valueText(const QtProperty *property) const override
Value
Color maps that associate a color to every float from [0..1].
Definition color.h:17
QLineEdit::EchoMode EchoMode
QSize qBound(QSize minVal, QSize val, QSize maxVal)
void setMinimumValue(const QDate &newMinVal)
void setMaximumValue(const QDate &newMaxVal)
void setMaximumValue(const QSizeF &newMaxVal)
void setMinimumValue(const QSizeF &newMinVal)
void setMinimumValue(const QSize &newMinVal)
void setMaximumValue(const QSize &newMaxVal)