47 #include <QApplication>
50 #include <QFontDatabase>
59 #include <QStyleOption>
64 #if defined(Q_CC_MSVC)
65 #pragma warning(disable : 4786)
70 template <
class PrivateData,
class Value>
72 setSimpleMinimumData(PrivateData*
data,
const Value& minVal)
74 data->minVal = minVal;
87 template <
class PrivateData,
class Value>
89 setSimpleMaximumData(PrivateData*
data,
const Value& maxVal)
91 data->maxVal = maxVal;
104 template <
class PrivateData,
class Value>
106 setSizeMinimumData(PrivateData*
data,
const Value& newMinVal)
108 data->minVal = newMinVal;
110 if (
data->maxVal.width() <
data->minVal.width())
112 data->maxVal.setWidth(
data->minVal.width());
115 if (
data->maxVal.height() <
data->minVal.height())
117 data->maxVal.setHeight(
data->minVal.height());
120 if (
data->val.width() <
data->minVal.width())
122 data->val.setWidth(
data->minVal.width());
125 if (
data->val.height() <
data->minVal.height())
127 data->val.setHeight(
data->minVal.height());
131 template <
class PrivateData,
class Value>
133 setSizeMaximumData(PrivateData*
data,
const Value& newMaxVal)
135 data->maxVal = newMaxVal;
137 if (
data->minVal.width() >
data->maxVal.width())
139 data->minVal.setWidth(
data->maxVal.width());
142 if (
data->minVal.height() >
data->maxVal.height())
144 data->minVal.setHeight(
data->maxVal.height());
147 if (
data->val.width() >
data->maxVal.width())
149 data->val.setWidth(
data->maxVal.width());
152 if (
data->val.height() >
data->maxVal.height())
154 data->val.setHeight(
data->maxVal.height());
158 template <
class SizeValue>
160 qBoundSize(
const SizeValue& minVal,
const SizeValue& val,
const SizeValue& maxVal)
162 SizeValue croppedVal = val;
164 if (minVal.width() > val.width())
166 croppedVal.setWidth(minVal.width());
168 else if (maxVal.width() < val.width())
170 croppedVal.setWidth(maxVal.width());
173 if (minVal.height() > val.height())
175 croppedVal.setHeight(minVal.height());
177 else if (maxVal.height() < val.height())
179 croppedVal.setHeight(maxVal.height());
187 qBound(QSize minVal, QSize val, QSize maxVal)
189 return qBoundSize(minVal, val, maxVal);
193 qBound(QSizeF minVal, QSizeF val, QSizeF maxVal)
195 return qBoundSize(minVal, val, maxVal);
200 template <
class Value>
206 qSwap(minVal, maxVal);
210 template <
class Value>
212 orderSizeBorders(
Value& minVal,
Value& maxVal)
214 Value fromSize = minVal;
215 Value toSize = maxVal;
217 if (fromSize.width() > toSize.width())
219 fromSize.setWidth(maxVal.width());
220 toSize.setWidth(minVal.width());
223 if (fromSize.height() > toSize.height())
225 fromSize.setHeight(maxVal.height());
226 toSize.setHeight(minVal.height());
234 orderBorders(QSize& minVal, QSize& maxVal)
236 orderSizeBorders(minVal, maxVal);
240 orderBorders(QSizeF& minVal, QSizeF& maxVal)
242 orderSizeBorders(minVal, maxVal);
249 template <
class Value,
class PrivateData>
251 getData(
const QMap<const QtProperty*, PrivateData>& propertyMap,
256 using PropertyToData = QMap<const QtProperty*, PrivateData>;
257 using PropertyToDataConstIterator =
typename PropertyToData::const_iterator;
258 const PropertyToDataConstIterator it = propertyMap.constFind(property);
260 if (it == propertyMap.constEnd())
265 return it.value().*
data;
268 template <
class Value,
class PrivateData>
270 getValue(
const QMap<const QtProperty*, PrivateData>& propertyMap,
274 return getData<Value>(propertyMap, &PrivateData::val, property, defaultValue);
277 template <
class Value,
class PrivateData>
279 getMinimum(
const QMap<const QtProperty*, PrivateData>& propertyMap,
283 return getData<Value>(propertyMap, &PrivateData::minVal, property, defaultValue);
286 template <
class Value,
class PrivateData>
288 getMaximum(
const QMap<const QtProperty*, PrivateData>& propertyMap,
292 return getData<Value>(propertyMap, &PrivateData::maxVal, property, defaultValue);
295 template <
class ValueChangeParameter,
class Value,
class PropertyManager>
297 setSimpleValue(QMap<const QtProperty*, Value>& propertyMap,
298 PropertyManager* manager,
299 void (PropertyManager::*propertyChangedSignal)(
QtProperty*),
300 void (PropertyManager::*valueChangedSignal)(
QtProperty*, ValueChangeParameter),
304 using PropertyToData = QMap<const QtProperty*, Value>;
305 using PropertyToDataIterator =
typename PropertyToData::iterator;
306 const PropertyToDataIterator it = propertyMap.find(property);
308 if (it == propertyMap.end())
313 if (it.value() == val)
320 emit(manager->*propertyChangedSignal)(property);
321 emit(manager->*valueChangedSignal)(property, val);
324 template <
class ValueChangeParameter,
325 class PropertyManagerPrivate,
326 class PropertyManager,
329 setValueInRange(PropertyManager* manager,
330 PropertyManagerPrivate* managerPrivate,
331 void (PropertyManager::*propertyChangedSignal)(
QtProperty*),
332 void (PropertyManager::*valueChangedSignal)(
QtProperty*, ValueChangeParameter),
335 void (PropertyManagerPrivate::*setSubPropertyValue)(
QtProperty*,
336 ValueChangeParameter))
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);
343 if (it == managerPrivate->m_values.end())
348 PrivateData&
data = it.value();
359 if (
data.val == oldVal)
364 if (setSubPropertyValue)
366 (managerPrivate->*setSubPropertyValue)(property,
data.val);
369 emit(manager->*propertyChangedSignal)(property);
370 emit(manager->*valueChangedSignal)(property,
data.val);
373 template <
class ValueChangeParameter,
374 class PropertyManagerPrivate,
375 class PropertyManager,
378 setBorderValues(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),
388 void (PropertyManagerPrivate::*setSubPropertyRange)(
QtProperty*,
389 ValueChangeParameter,
390 ValueChangeParameter,
391 ValueChangeParameter))
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);
398 if (it == managerPrivate->m_values.end())
403 Value fromVal = minVal;
404 Value toVal = maxVal;
405 orderBorders(fromVal, toVal);
407 PrivateData&
data = it.value();
409 if (
data.minVal == fromVal &&
data.maxVal == toVal)
416 data.setMinimumValue(fromVal);
417 data.setMaximumValue(toVal);
419 emit(manager->*rangeChangedSignal)(property,
data.minVal,
data.maxVal);
421 if (setSubPropertyRange)
423 (managerPrivate->*setSubPropertyRange)(property,
data.minVal,
data.maxVal,
data.val);
426 if (
data.val == oldVal)
431 emit(manager->*propertyChangedSignal)(property);
432 emit(manager->*valueChangedSignal)(property,
data.val);
435 template <
class ValueChangeParameter,
436 class PropertyManagerPrivate,
437 class PropertyManager,
441 setBorderValue(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),
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))
457 using PropertyToData = QMap<const QtProperty*, PrivateData>;
458 using PropertyToDataIterator =
typename PropertyToData::iterator;
459 const PropertyToDataIterator it = managerPrivate->m_values.find(property);
461 if (it == managerPrivate->m_values.end())
466 PrivateData&
data = it.value();
468 if ((
data.*getRangeVal)() == borderVal)
475 (
data.*setRangeVal)(borderVal);
477 emit(manager->*rangeChangedSignal)(property,
data.minVal,
data.maxVal);
479 if (setSubPropertyRange)
481 (managerPrivate->*setSubPropertyRange)(property,
data.minVal,
data.maxVal,
data.val);
484 if (
data.val == oldVal)
489 emit(manager->*propertyChangedSignal)(property);
490 emit(manager->*valueChangedSignal)(property,
data.val);
493 template <
class ValueChangeParameter,
494 class PropertyManagerPrivate,
495 class PropertyManager,
499 setMinimumValue(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),
509 void (PropertyManagerPrivate::*setSubPropertyRange)(
510 QtProperty*, ValueChangeParameter, ValueChangeParameter, ValueChangeParameter) = 0;
511 setBorderValue<ValueChangeParameter,
512 PropertyManagerPrivate,
515 PrivateData>(manager,
517 propertyChangedSignal,
521 &PropertyManagerPrivate::Data::minimumValue,
522 &PropertyManagerPrivate::Data::setMinimumValue,
524 setSubPropertyRange);
527 template <
class ValueChangeParameter,
528 class PropertyManagerPrivate,
529 class PropertyManager,
533 setMaximumValue(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),
543 void (PropertyManagerPrivate::*setSubPropertyRange)(
544 QtProperty*, ValueChangeParameter, ValueChangeParameter, ValueChangeParameter) = 0;
545 setBorderValue<ValueChangeParameter,
546 PropertyManagerPrivate,
549 PrivateData>(manager,
551 propertyChangedSignal,
555 &PropertyManagerPrivate::Data::maximumValue,
556 &PropertyManagerPrivate::Data::setMaximumValue,
558 setSubPropertyRange);
569 return QSizePolicy::Ignored;
586 return m_policyEnumNames;
592 return m_languageEnumNames;
598 return m_countryEnumNames.value(language);
606 QLocale::Language* language,
607 QLocale::Country* country)
const;
609 QLocale::Country country,
611 int* countryIndex)
const;
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;
626 static QList<QLocale::Country>
627 sortCountries(
const QList<QLocale::Country>& countries)
629 QMultiMap<QString, QLocale::Country> nameToCountry;
630 QListIterator<QLocale::Country> itCountry(countries);
632 while (itCountry.hasNext())
634 QLocale::Country country = itCountry.next();
635 nameToCountry.insert(QLocale::countryToString(country), country);
638 return nameToCountry.values();
642 QtMetaEnumProvider::initLocale()
644 QMultiMap<QString, QLocale::Language> nameToLanguage;
645 QLocale::Language language = QLocale::C;
647 while (language <= QLocale::LastLanguage)
649 QLocale locale(language);
651 if (locale.language() == language)
653 nameToLanguage.insert(QLocale::languageToString(language), language);
656 language = (QLocale::Language)((uint)language + 1);
659 const QLocale system = QLocale::system();
661 if (!nameToLanguage.contains(QLocale::languageToString(system.language())))
663 nameToLanguage.insert(QLocale::languageToString(system.language()), system.language());
666 QList<QLocale::Language> languages = nameToLanguage.values();
667 QListIterator<QLocale::Language> itLang(languages);
669 while (itLang.hasNext())
671 QLocale::Language language = itLang.next();
672 QList<QLocale::Country> countries;
673 countries = QLocale::countriesForLanguage(language);
675 if (countries.isEmpty() && language == system.language())
677 countries << system.country();
680 if (!countries.isEmpty() && !m_languageToIndex.contains(language))
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);
692 QLocale::Country country = it.next();
693 countryNames << QLocale::countryToString(country);
694 m_indexToCountry[langIdx][countryIdx] = country;
695 m_countryToIndex[language][country] = countryIdx;
699 m_languageEnumNames << QLocale::languageToString(language);
700 m_countryEnumNames[language] = countryNames;
709 p = QtMetaEnumWrapper::staticMetaObject.property(
710 QtMetaEnumWrapper::staticMetaObject.propertyOffset() + 0);
711 m_policyEnum = p.enumerator();
712 const int keyCount = m_policyEnum.keyCount();
714 for (
int i = 0; i < keyCount; i++)
716 m_policyEnumNames << QLatin1String(m_policyEnum.key(i));
725 return static_cast<QSizePolicy::Policy
>(m_policyEnum.value(
index));
731 const int keyCount = m_policyEnum.keyCount();
733 for (
int i = 0; i < keyCount; i++)
745 QLocale::Language* language,
746 QLocale::Country* country)
const
748 QLocale::Language l = QLocale::C;
749 QLocale::Country
c = QLocale::AnyCountry;
751 if (m_indexToLanguage.contains(languageIndex))
753 l = m_indexToLanguage[languageIndex];
755 if (m_indexToCountry.contains(languageIndex) &&
756 m_indexToCountry[languageIndex].contains(countryIndex))
758 c = m_indexToCountry[languageIndex][countryIndex];
775 QLocale::Country country,
777 int* countryIndex)
const
782 if (m_languageToIndex.contains(language))
784 l = m_languageToIndex[language];
786 if (m_countryToIndex.contains(language) && m_countryToIndex[language].contains(country))
788 c = m_countryToIndex[language][country];
893 setSimpleMinimumData(
this, newMinVal);
899 setSimpleMaximumData(
this, newMaxVal);
988 return getValue<int>(d_ptr->
m_values, property, 0);
999 return getMinimum<int>(d_ptr->
m_values, property, 0);
1010 return getMaximum<int>(d_ptr->
m_values, property, 0);
1023 return getData<int>(
1037 return getData<bool>(
1047 const QtIntPropertyManagerPrivate::PropertyValueMap::const_iterator it =
1048 d_ptr->
m_values.constFind(property);
1050 if (it == d_ptr->
m_values.constEnd())
1055 return QString::number(it.value().val);
1073 setValueInRange<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(
1080 setSubPropertyValue);
1095 setMinimumValue<int,
1120 setMaximumValue<int,
1151 setBorderValues<int, QtIntPropertyManagerPrivate, QtIntPropertyManager, int>(
1160 setSubPropertyRange);
1173 const QtIntPropertyManagerPrivate::PropertyValueMap::iterator it =
1188 if (
data.singleStep == step)
1193 data.singleStep = step;
1208 const QtIntPropertyManagerPrivate::PropertyValueMap::iterator it =
1218 if (
data.readOnly == readOnly)
1223 data.readOnly = readOnly;
1284 setSimpleMinimumData(
this, newMinVal);
1290 setSimpleMaximumData(
this, newMaxVal);
1368 d_ptr->q_ptr =
this;
1391 return getValue<double>(d_ptr->
m_values, property, 0.0);
1402 return getMinimum<double>(d_ptr->
m_values, property, 0.0);
1413 return getMaximum<double>(d_ptr->
m_values, property, 0.0);
1426 return getData<double>(
1438 return getData<int>(
1452 return getData<bool>(
1462 const QtDoublePropertyManagerPrivate::PropertyValueMap::const_iterator it =
1463 d_ptr->
m_values.constFind(property);
1465 if (it == d_ptr->
m_values.constEnd())
1470 return QLocale::system().toString(it.value().val,
'f', it.value().decimals);
1488 setValueInRange<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(
1495 setSubPropertyValue);
1508 const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it =
1523 if (
data.singleStep == step)
1528 data.singleStep = step;
1543 const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it =
1553 if (
data.readOnly == readOnly)
1558 data.readOnly = readOnly;
1577 const QtDoublePropertyManagerPrivate::PropertyValueMap::iterator it =
1596 if (
data.decimals == prec)
1601 data.decimals = prec;
1620 setMinimumValue<double,
1645 setMaximumValue<double,
1677 setBorderValues<double, QtDoublePropertyManagerPrivate, QtDoublePropertyManager, double>(
1686 setSubPropertyRange);
1717 regExp(QString(QLatin1Char(
'*')), Qt::CaseSensitive, QRegExp::Wildcard),
1780 d_ptr->q_ptr =
this;
1803 return getValue<QString>(d_ptr->
m_values, property);
1817 return getData<QRegExp>(
1841 return getData<bool>(
1851 const QtStringPropertyManagerPrivate::PropertyValueMap::const_iterator it =
1852 d_ptr->
m_values.constFind(property);
1854 if (it == d_ptr->
m_values.constEnd())
1859 return it.value().val;
1868 const QtStringPropertyManagerPrivate::PropertyValueMap::const_iterator it =
1869 d_ptr->
m_values.constFind(property);
1871 if (it == d_ptr->
m_values.constEnd())
1877 edit.setEchoMode((
EchoMode)it.value().echoMode);
1878 edit.setText(it.value().val);
1879 return edit.displayText();
1895 const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it =
1905 if (
data.val == val)
1910 if (
data.regExp.isValid() && !
data.regExp.exactMatch(val))
1931 const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it =
1956 const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it =
1986 const QtStringPropertyManagerPrivate::PropertyValueMap::iterator it =
1996 if (
data.readOnly == readOnly)
2001 data.readOnly = readOnly;
2029 drawCheckBox(
bool value)
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();
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);
2044 opt.rect = QRect(0, 0, indicatorWidth, indicatorHeight);
2045 QPixmap pixmap = QPixmap(pixmapWidth, pixmapHeight);
2049 const int xoff = (pixmapWidth > indicatorWidth) ? (pixmapWidth - indicatorWidth) / 2 : 0;
2051 (pixmapHeight > indicatorHeight) ? (pixmapHeight - indicatorHeight) / 2 : 0;
2052 QPainter painter(&pixmap);
2053 painter.translate(xoff, yoff);
2054 style->drawPrimitive(QStyle::PE_IndicatorCheckBox, &opt, &painter);
2056 return QIcon(pixmap);
2084 m_checkedIcon(drawCheckBox(true)), m_uncheckedIcon(drawCheckBox(false))
2117 d_ptr->q_ptr =
this;
2140 return getValue<bool>(d_ptr->
m_values, property,
false);
2146 return getData<bool>(
2156 const QtBoolPropertyManagerPrivate::PropertyValueMap::const_iterator it =
2157 d_ptr->
m_values.constFind(property);
2159 if (it == d_ptr->
m_values.constEnd())
2166 if (!
data.textVisible)
2171 static const QString trueText = tr(
"True");
2172 static const QString falseText = tr(
"False");
2173 return data.val ? trueText : falseText;
2182 const QtBoolPropertyManagerPrivate::PropertyValueMap::const_iterator it =
2183 d_ptr->
m_values.constFind(property);
2185 if (it == d_ptr->
m_values.constEnd())
2203 const QtBoolPropertyManagerPrivate::PropertyValueMap::iterator it =
2213 if (
data.val == val)
2228 const QtBoolPropertyManagerPrivate::PropertyValueMap::iterator it =
2300 setSimpleMinimumData(
this, newMinVal);
2306 setSimpleMaximumData(
this, newMaxVal);
2364 d_ptr->q_ptr =
this;
2367 d_ptr->
m_format = loc.dateFormat(QLocale::ShortFormat);
2390 return getValue<QDate>(d_ptr->
m_values, property);
2401 return getMinimum<QDate>(d_ptr->
m_values, property);
2412 return getMaximum<QDate>(d_ptr->
m_values, property);
2421 const QtDatePropertyManagerPrivate::PropertyValueMap::const_iterator it =
2422 d_ptr->
m_values.constFind(property);
2424 if (it == d_ptr->
m_values.constEnd())
2429 return it.value().val.toString(d_ptr->
m_format);
2447 setValueInRange<const QDate&, QtDatePropertyManagerPrivate, QtDatePropertyManager, const QDate>(
2454 setSubPropertyValue);
2469 setMinimumValue<
const QDate&,
2494 setMaximumValue<
const QDate&,
2525 QtProperty*,
const QDate&,
const QDate&,
const QDate&) = 0;
2526 setBorderValues<const QDate&, QtDatePropertyManagerPrivate, QtDatePropertyManager, QDate>(
2535 setSubPropertyRange);
2600 d_ptr->q_ptr =
this;
2603 d_ptr->
m_format = loc.timeFormat(QLocale::ShortFormat);
2626 return d_ptr->
m_values.value(property, QTime());
2635 const QtTimePropertyManagerPrivate::PropertyValueMap::const_iterator it =
2636 d_ptr->
m_values.constFind(property);
2638 if (it == d_ptr->
m_values.constEnd())
2643 return it.value().toString(d_ptr->
m_format);
2656 setSimpleValue<const QTime&, QTime, QtTimePropertyManager>(
2671 d_ptr->
m_values[property] = QTime::currentTime();
2724 d_ptr->q_ptr =
this;
2727 d_ptr->
m_format = loc.dateFormat(QLocale::ShortFormat);
2728 d_ptr->
m_format += QLatin1Char(
' ');
2729 d_ptr->
m_format += loc.timeFormat(QLocale::ShortFormat);
2752 return d_ptr->
m_values.value(property, QDateTime());
2761 const QtDateTimePropertyManagerPrivate::PropertyValueMap::const_iterator it =
2762 d_ptr->
m_values.constFind(property);
2764 if (it == d_ptr->
m_values.constEnd())
2769 return it.value().toString(d_ptr->
m_format);
2782 setSimpleValue<const QDateTime&, QDateTime, QtDateTimePropertyManager>(
2851 d_ptr->q_ptr =
this;
2874 return d_ptr->
m_values.value(property, QKeySequence());
2883 const QtKeySequencePropertyManagerPrivate::PropertyValueMap::const_iterator it =
2884 d_ptr->
m_values.constFind(property);
2886 if (it == d_ptr->
m_values.constEnd())
2891 return it.value().toString(QKeySequence::NativeText);
2904 setSimpleValue<const QKeySequence&, QKeySequence, QtKeySequencePropertyManager>(
2919 d_ptr->
m_values[property] = QKeySequence();
2970 d_ptr->q_ptr =
this;
2993 return d_ptr->
m_values.value(property, QChar());
3002 const QtCharPropertyManagerPrivate::PropertyValueMap::const_iterator it =
3003 d_ptr->
m_values.constFind(property);
3005 if (it == d_ptr->
m_values.constEnd())
3010 const QChar
c = it.value();
3011 return c.isNull() ? QString() : QString(
c);
3024 setSimpleValue<const QChar&, QChar, QtCharPropertyManager>(
3039 d_ptr->
m_values[property] = QChar();
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);
3093 const QLocale loc =
m_values[prop];
3094 QLocale::Language newLanguage = loc.language();
3095 QLocale::Country newCountry = loc.country();
3096 metaEnumProvider()->indexToLocale(
3101 QLocale newLoc(newLanguage, newCountry);
3159 d_ptr->q_ptr =
this;
3209 return d_ptr->
m_values.value(property, QLocale());
3218 const QtLocalePropertyManagerPrivate::PropertyValueMap::const_iterator it =
3219 d_ptr->
m_values.constFind(property);
3221 if (it == d_ptr->
m_values.constEnd())
3226 QLocale loc = it.value();
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));
3248 const QtLocalePropertyManagerPrivate::PropertyValueMap::iterator it =
3256 const QLocale loc = it.value();
3267 metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx);
3269 if (loc.language() != val.language())
3275 metaEnumProvider()->countryEnumNames(val.language()));
3295 metaEnumProvider()->localeToIndex(val.language(), val.country(), &langIdx, &countryIdx);
3300 metaEnumProvider()->languageEnumNames());
3309 countryProp, metaEnumProvider()->countryEnumNames(val.language()));
3327 delete languageProp;
3435 d_ptr->q_ptr =
this;
3484 return d_ptr->
m_values.value(property, QPoint());
3493 const QtPointPropertyManagerPrivate::PropertyValueMap::const_iterator it =
3494 d_ptr->
m_values.constFind(property);
3496 if (it == d_ptr->
m_values.constEnd())
3501 const QPoint
v = it.value();
3502 return QString(tr(
"(%1, %2)").arg(QString::number(
v.x())).arg(QString::number(
v.y())));
3516 const QtPointPropertyManagerPrivate::PropertyValueMap::iterator it =
3524 if (it.value() == val)
3543 d_ptr->
m_values[property] = QPoint(0, 0);
3700 d_ptr->q_ptr =
this;
3706 SLOT(slotDoubleChanged(
QtProperty*,
double)));
3749 return getValue<QPointF>(d_ptr->
m_values, property);
3760 return getData<int>(
3770 const QtPointFPropertyManagerPrivate::PropertyValueMap::const_iterator it =
3771 d_ptr->
m_values.constFind(property);
3773 if (it == d_ptr->
m_values.constEnd())
3778 const QPointF
v = it.value().val;
3779 const int dec = it.value().decimals;
3781 tr(
"(%1, %2)").arg(QString::number(
v.x(),
'f', dec)).arg(QString::number(
v.y(),
'f', dec)));
3795 const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it =
3803 if (it.value().val == val)
3808 it.value().val = val;
3828 const QtPointFPropertyManagerPrivate::PropertyValueMap::iterator it =
3847 if (
data.decimals == prec)
3852 data.decimals = prec;
3925 void setRange(
QtProperty* property,
const QSize& minVal,
const QSize& maxVal,
const QSize& val);
3952 setSizeMinimumData(
this, newMinVal);
3958 setSizeMaximumData(
this, newMaxVal);
4015 const QSize& minVal,
4016 const QSize& maxVal,
4082 d_ptr->q_ptr =
this;
4131 return getValue<QSize>(d_ptr->
m_values, property);
4142 return getMinimum<QSize>(d_ptr->
m_values, property);
4153 return getMaximum<QSize>(d_ptr->
m_values, property);
4162 const QtSizePropertyManagerPrivate::PropertyValueMap::const_iterator it =
4163 d_ptr->
m_values.constFind(property);
4165 if (it == d_ptr->
m_values.constEnd())
4170 const QSize
v = it.value().val;
4171 return QString(tr(
"%1 x %2").arg(QString::number(
v.width())).arg(QString::number(
v.height())));
4188 setValueInRange<const QSize&, QtSizePropertyManagerPrivate, QtSizePropertyManager, const QSize>(
4210 setBorderValue<
const QSize&,
4239 setBorderValue<
const QSize&,
4273 setBorderValues<const QSize&, QtSizePropertyManagerPrivate, QtSizePropertyManager, QSize>(
4350 setRange(
QtProperty* property,
const QSizeF& minVal,
const QSizeF& maxVal,
const QSizeF& val);
4379 setSizeMinimumData(
this, newMinVal);
4385 setSizeMaximumData(
this, newMaxVal);
4442 const QSizeF& minVal,
4443 const QSizeF& maxVal,
4517 d_ptr->q_ptr =
this;
4523 SLOT(slotDoubleChanged(
QtProperty*,
double)));
4566 return getValue<QSizeF>(d_ptr->
m_values, property);
4577 return getData<int>(
4589 return getMinimum<QSizeF>(d_ptr->
m_values, property);
4600 return getMaximum<QSizeF>(d_ptr->
m_values, property);
4609 const QtSizeFPropertyManagerPrivate::PropertyValueMap::const_iterator it =
4610 d_ptr->
m_values.constFind(property);
4612 if (it == d_ptr->
m_values.constEnd())
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)));
4638 setValueInRange<const QSizeF&, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF>(
4660 const QtSizeFPropertyManagerPrivate::PropertyValueMap::iterator it =
4679 if (
data.decimals == prec)
4684 data.decimals = prec;
4705 setBorderValue<
const QSizeF&,
4734 setBorderValue<
const QSizeF&,
4768 setBorderValues<const QSizeF&, QtSizeFPropertyManagerPrivate, QtSizeFPropertyManager, QSizeF>(
4894 if (!
data.constraint.isNull() &&
4895 data.constraint.x() +
data.constraint.width() < r.x() + r.width())
4897 r.moveLeft(
data.constraint.left() +
data.constraint.width() - r.width());
4908 if (!
data.constraint.isNull() &&
4909 data.constraint.y() +
data.constraint.height() < r.y() + r.height())
4911 r.moveTop(
data.constraint.top() +
data.constraint.height() - r.height());
4945 const QRect& constraint,
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();
5020 d_ptr->q_ptr =
this;
5069 return getValue<QRect>(d_ptr->
m_values, property);
5080 return getData<QRect>(
5090 const QtRectPropertyManagerPrivate::PropertyValueMap::const_iterator it =
5091 d_ptr->
m_values.constFind(property);
5093 if (it == d_ptr->
m_values.constEnd())
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())));
5121 const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it =
5131 QRect newRect = val.normalized();
5133 if (!
data.constraint.isNull() && !
data.constraint.contains(newRect))
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()));
5142 if (newRect.width() < 0 || newRect.height() < 0)
5148 if (
data.val == newRect)
5178 const QtRectPropertyManagerPrivate::PropertyValueMap::iterator it =
5188 QRect newConstraint =
constraint.normalized();
5190 if (
data.constraint == newConstraint)
5195 const QRect oldVal =
data.val;
5197 data.constraint = newConstraint;
5199 if (!
data.constraint.isNull() && !
data.constraint.contains(oldVal))
5201 QRect r1 =
data.constraint;
5202 QRect r2 =
data.val;
5204 if (r2.width() > r1.width())
5206 r2.setWidth(r1.width());
5209 if (r2.height() > r1.height())
5211 r2.setHeight(r1.height());
5214 if (r2.left() < r1.left())
5216 r2.moveLeft(r1.left());
5218 else if (r2.right() > r1.right())
5220 r2.moveRight(r1.right());
5223 if (r2.top() < r1.top())
5225 r2.moveTop(r1.top());
5227 else if (r2.bottom() > r1.bottom())
5229 r2.moveBottom(r1.bottom());
5241 if (
data.val == oldVal)
5394 QRectF r =
data.val;
5397 if (!
data.constraint.isNull() &&
5398 data.constraint.x() +
data.constraint.width() < r.x() + r.width())
5400 r.moveLeft(
data.constraint.left() +
data.constraint.width() - r.width());
5408 QRectF r =
data.val;
5411 if (!
data.constraint.isNull() &&
5412 data.constraint.y() +
data.constraint.height() < r.y() + r.height())
5414 r.moveTop(
data.constraint.top() +
data.constraint.height() - r.height());
5448 const QRectF& constraint,
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();
5533 d_ptr->q_ptr =
this;
5539 SLOT(slotDoubleChanged(
QtProperty*,
double)));
5582 return getValue<QRectF>(d_ptr->
m_values, property);
5593 return getData<int>(
5605 return getData<QRectF>(
5615 const QtRectFPropertyManagerPrivate::PropertyValueMap::const_iterator it =
5616 d_ptr->
m_values.constFind(property);
5618 if (it == d_ptr->
m_values.constEnd())
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)));
5647 const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it =
5657 QRectF newRect = val.normalized();
5659 if (!
data.constraint.isNull() && !
data.constraint.contains(newRect))
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()));
5668 if (newRect.width() < 0 || newRect.height() < 0)
5674 if (
data.val == newRect)
5704 const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it =
5714 QRectF newConstraint =
constraint.normalized();
5716 if (
data.constraint == newConstraint)
5721 const QRectF oldVal =
data.val;
5723 data.constraint = newConstraint;
5725 if (!
data.constraint.isNull() && !
data.constraint.contains(oldVal))
5727 QRectF r1 =
data.constraint;
5728 QRectF r2 =
data.val;
5730 if (r2.width() > r1.width())
5732 r2.setWidth(r1.width());
5735 if (r2.height() > r1.height())
5737 r2.setHeight(r1.height());
5740 if (r2.left() < r1.left())
5742 r2.moveLeft(r1.left());
5744 else if (r2.right() > r1.right())
5746 r2.moveRight(r1.right());
5749 if (r2.top() < r1.top())
5751 r2.moveTop(r1.top());
5753 else if (r2.bottom() > r1.bottom())
5755 r2.moveBottom(r1.bottom());
5767 if (
data.val == oldVal)
5788 const QtRectFPropertyManagerPrivate::PropertyValueMap::iterator it =
5807 if (
data.decimals == prec)
5812 data.decimals = prec;
5996 d_ptr->q_ptr =
this;
6020 return getValue<int>(d_ptr->
m_values, property, -1);
6031 return getData<QStringList>(
6043 return getData<QMap<int, QIcon>>(d_ptr->
m_values,
6046 QMap<int, QIcon>());
6055 const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it =
6056 d_ptr->
m_values.constFind(property);
6058 if (it == d_ptr->
m_values.constEnd())
6065 const int v =
data.val;
6067 if (
v >= 0 &&
v <
data.enumNames.count())
6069 return data.enumNames.at(
v);
6081 const QtEnumPropertyManagerPrivate::PropertyValueMap::const_iterator it =
6082 d_ptr->
m_values.constFind(property);
6084 if (it == d_ptr->
m_values.constEnd())
6091 const int v =
data.val;
6092 return data.enumIcons.value(
v);
6108 const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it =
6118 if (val >=
data.enumNames.count())
6123 if (val < 0 &&
data.enumNames.count() > 0)
6133 if (
data.val == val)
6159 const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it =
6202 const QtEnumPropertyManagerPrivate::PropertyValueMap::iterator it =
6278 while (itProp.hasNext())
6308 if (flagProperty == 0)
6374 d_ptr->q_ptr =
this;
6423 return getValue<int>(d_ptr->
m_values, property, 0);
6434 return getData<QStringList>(
6444 const QtFlagPropertyManagerPrivate::PropertyValueMap::const_iterator it =
6445 d_ptr->
m_values.constFind(property);
6447 if (it == d_ptr->
m_values.constEnd())
6456 const QChar bar = QLatin1Char(
'|');
6457 const QStringList::const_iterator fncend =
data.flagNames.constEnd();
6459 for (QStringList::const_iterator it =
data.flagNames.constBegin(); it != fncend; ++it)
6461 if (
data.val & (1 << level))
6493 const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it =
6503 if (
data.val == val)
6508 if (val > (1 <<
data.flagNames.count()) - 1)
6525 while (itProp.hasNext())
6551 const QtFlagPropertyManagerPrivate::PropertyValueMap::iterator it =
6573 while (itProp.hasNext())
6588 while (itFlag.hasNext())
6590 const QString flagName = itFlag.next();
6593 property->addSubProperty(prop);
6623 while (itProp.hasNext())
6679 sp.setHorizontalStretch(
value);
6685 sp.setVerticalStretch(
value);
6696 sp.setHorizontalPolicy(metaEnumProvider()->indexToSizePolicy(
value));
6702 sp.setVerticalPolicy(metaEnumProvider()->indexToSizePolicy(
value));
6772 d_ptr->q_ptr =
this;
6847 return d_ptr->
m_values.value(property, QSizePolicy());
6856 const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::const_iterator it =
6857 d_ptr->
m_values.constFind(property);
6859 if (it == d_ptr->
m_values.constEnd())
6864 const QSizePolicy sp = it.value();
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());
6889 const QtSizePolicyPropertyManagerPrivate::PropertyValueMap::iterator it =
6897 if (it.value() == val)
6906 metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy()));
6909 metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy()));
6911 val.horizontalStretch());
6913 val.verticalStretch());
6932 hPolicyProp, metaEnumProvider()->sizePolicyToIndex(val.horizontalPolicy()));
6941 vPolicyProp, metaEnumProvider()->sizePolicyToIndex(val.verticalPolicy()));
6994 delete hStretchProp;
7004 delete vStretchProp;
7020 Q_GLOBAL_STATIC(QFontDatabase, fontDatabase)
7032 void slotPropertyDestroyed(
QtProperty* property);
7033 void slotFontDatabaseChanged();
7034 void slotFontDatabaseDelayedChange();
7066 m_settingValue(false), m_fontDatabaseChangeTimer(0)
7081 f.setPointSize(
value);
7125 f.setUnderline(
value);
7131 f.setStrikeOut(
value);
7137 f.setKerning(
value);
7205 using PropertyPropertyMap = QMap<const QtProperty*, QtProperty*>;
7215 for (PropertyPropertyMap::const_iterator it =
m_propertyToFamily.constBegin(); it != cend;
7273 d_ptr->q_ptr =
this;
7274 QObject::connect(qApp, SIGNAL(fontDatabaseChanged()),
this, SLOT(slotFontDatabaseChanged()));
7373 return d_ptr->
m_values.value(property, QFont());
7382 const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it =
7383 d_ptr->
m_values.constFind(property);
7385 if (it == d_ptr->
m_values.constEnd())
7399 const QtFontPropertyManagerPrivate::PropertyValueMap::const_iterator it =
7400 d_ptr->
m_values.constFind(property);
7402 if (it == d_ptr->
m_values.constEnd())
7421 const QtFontPropertyManagerPrivate::PropertyValueMap::iterator it =
7429 const QFont oldVal = it.value();
7431 if (oldVal == val && oldVal.resolve() == val.resolve())
7555 delete pointSizeProp;
7585 delete underlineProp;
7595 delete strikeOutProp;
7731 d_ptr->q_ptr =
this;
7781 return d_ptr->
m_values.value(property, QColor());
7791 const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it =
7792 d_ptr->
m_values.constFind(property);
7794 if (it == d_ptr->
m_values.constEnd())
7809 const QtColorPropertyManagerPrivate::PropertyValueMap::const_iterator it =
7810 d_ptr->
m_values.constFind(property);
7812 if (it == d_ptr->
m_values.constEnd())
7831 const QtColorPropertyManagerPrivate::PropertyValueMap::iterator it =
7839 if (it.value() == val)
7950 static void clearCursorDatabase();
7958 qAddPostRoutine(clearCursorDatabase);
7965 clearCursorDatabase()
7967 cursorDatabase2()->clear();
8010 d_ptr->q_ptr =
this;
8030 #ifndef QT_NO_CURSOR
8034 return d_ptr->
m_values.value(property, QCursor());
8044 const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it =
8045 d_ptr->
m_values.constFind(property);
8047 if (it == d_ptr->
m_values.constEnd())
8052 return cursorDatabase2()->cursorToShapeName(it.value());
8061 const QtCursorPropertyManagerPrivate::PropertyValueMap::const_iterator it =
8062 d_ptr->
m_values.constFind(property);
8064 if (it == d_ptr->
m_values.constEnd())
8069 return cursorDatabase2()->cursorToShapeIcon(it.value());
8082 #ifndef QT_NO_CURSOR
8083 const QtCursorPropertyManagerPrivate::PropertyValueMap::iterator it =
8091 if (it.value().shape() ==
value.shape() &&
value.shape() != Qt::BitmapCursor)
8109 #ifndef QT_NO_CURSOR
8110 d_ptr->
m_values[property] = QCursor();
8125 #include "moc_qtpropertymanager.cpp"
8126 #include "qtpropertymanager.moc"