qtvariantproperty.cpp 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332
  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. #pragma execution_character_set("utf-8")
  41. #include "qtvariantproperty.h"
  42. #include "qtpropertymanager.h"
  43. #include "qteditorfactory.h"
  44. #include <QVariant>
  45. #include <QIcon>
  46. #include <QDate>
  47. #include <QLocale>
  48. #if defined(Q_CC_MSVC)
  49. # pragma warning(disable: 4786) /* MS VS 6: truncating debug info after 255 characters */
  50. #endif
  51. #if QT_VERSION >= 0x040400
  52. QT_BEGIN_NAMESPACE
  53. #endif
  54. class QtEnumPropertyType
  55. {
  56. };
  57. class QtFlagPropertyType
  58. {
  59. };
  60. class QtGroupPropertyType
  61. {
  62. };
  63. #if QT_VERSION >= 0x040400
  64. QT_END_NAMESPACE
  65. #endif
  66. Q_DECLARE_METATYPE(QtEnumPropertyType)
  67. Q_DECLARE_METATYPE(QtFlagPropertyType)
  68. Q_DECLARE_METATYPE(QtGroupPropertyType)
  69. #if QT_VERSION >= 0x040400
  70. QT_BEGIN_NAMESPACE
  71. #endif
  72. /*!
  73. Returns the type id for an enum property.
  74. Note that the property's value type can be retrieved using the
  75. valueType() function (which is QVariant::Int for the enum property
  76. type).
  77. \sa propertyType(), valueType()
  78. */
  79. int QtVariantPropertyManager::enumTypeId()
  80. {
  81. return qMetaTypeId<QtEnumPropertyType>();
  82. }
  83. /*!
  84. Returns the type id for a flag property.
  85. Note that the property's value type can be retrieved using the
  86. valueType() function (which is QVariant::Int for the flag property
  87. type).
  88. \sa propertyType(), valueType()
  89. */
  90. int QtVariantPropertyManager::flagTypeId()
  91. {
  92. return qMetaTypeId<QtFlagPropertyType>();
  93. }
  94. /*!
  95. Returns the type id for a group property.
  96. Note that the property's value type can be retrieved using the
  97. valueType() function (which is QVariant::Invalid for the group
  98. property type, since it doesn't provide any value).
  99. \sa propertyType(), valueType()
  100. */
  101. int QtVariantPropertyManager::groupTypeId()
  102. {
  103. return qMetaTypeId<QtGroupPropertyType>();
  104. }
  105. /*!
  106. Returns the type id for a icon map attribute.
  107. Note that the property's attribute type can be retrieved using the
  108. attributeType() function.
  109. \sa attributeType(), QtEnumPropertyManager::enumIcons()
  110. */
  111. int QtVariantPropertyManager::iconMapTypeId()
  112. {
  113. return qMetaTypeId<QtIconMap>();
  114. }
  115. typedef QMap<const QtProperty *, QtProperty *> PropertyMap;
  116. Q_GLOBAL_STATIC(PropertyMap, propertyToWrappedProperty)
  117. static QtProperty *wrappedProperty(QtProperty *property)
  118. {
  119. return propertyToWrappedProperty()->value(property, 0);
  120. }
  121. class QtVariantPropertyPrivate
  122. {
  123. QtVariantProperty *q_ptr = nullptr;
  124. public:
  125. QtVariantPropertyPrivate(QtVariantPropertyManager *m) : manager(m) {}
  126. QtVariantPropertyManager *manager;
  127. };
  128. /*!
  129. \class QtVariantProperty
  130. \brief The QtVariantProperty class is a convenience class handling
  131. QVariant based properties.
  132. QtVariantProperty provides additional API: A property's type,
  133. value type, attribute values and current value can easily be
  134. retrieved using the propertyType(), valueType(), attributeValue()
  135. and value() functions respectively. In addition, the attribute
  136. values and the current value can be set using the corresponding
  137. setValue() and setAttribute() functions.
  138. For example, instead of writing:
  139. \code
  140. QtVariantPropertyManager *variantPropertyManager;
  141. QtProperty *property;
  142. variantPropertyManager->setValue(property, 10);
  143. \endcode
  144. you can write:
  145. \code
  146. QtVariantPropertyManager *variantPropertyManager;
  147. QtVariantProperty *property;
  148. property->setValue(10);
  149. \endcode
  150. QtVariantProperty instances can only be created by the
  151. QtVariantPropertyManager class.
  152. \sa QtProperty, QtVariantPropertyManager, QtVariantEditorFactory
  153. */
  154. /*!
  155. Creates a variant property using the given \a manager.
  156. Do not use this constructor to create variant property instances;
  157. use the QtVariantPropertyManager::addProperty() function
  158. instead. This constructor is used internally by the
  159. QtVariantPropertyManager::createProperty() function.
  160. \sa QtVariantPropertyManager
  161. */
  162. QtVariantProperty::QtVariantProperty(QtVariantPropertyManager *manager)
  163. : QtProperty(manager), d_ptr(new QtVariantPropertyPrivate(manager))
  164. {
  165. }
  166. /*!
  167. Destroys this property.
  168. \sa QtProperty::~QtProperty()
  169. */
  170. QtVariantProperty::~QtVariantProperty()
  171. {
  172. delete d_ptr;
  173. }
  174. /*!
  175. Returns the property's current value.
  176. \sa valueType(), setValue()
  177. */
  178. QVariant QtVariantProperty::value() const
  179. {
  180. return d_ptr->manager->value(this);
  181. }
  182. /*!
  183. Returns this property's value for the specified \a attribute.
  184. QtVariantPropertyManager provides a couple of related functions:
  185. \l{QtVariantPropertyManager::attributes()}{attributes()} and
  186. \l{QtVariantPropertyManager::attributeType()}{attributeType()}.
  187. \sa setAttribute()
  188. */
  189. QVariant QtVariantProperty::attributeValue(const QString &attribute) const
  190. {
  191. return d_ptr->manager->attributeValue(this, attribute);
  192. }
  193. /*!
  194. Returns the type of this property's value.
  195. \sa propertyType()
  196. */
  197. int QtVariantProperty::valueType() const
  198. {
  199. return d_ptr->manager->valueType(this);
  200. }
  201. /*!
  202. Returns this property's type.
  203. QtVariantPropertyManager provides several related functions:
  204. \l{QtVariantPropertyManager::enumTypeId()}{enumTypeId()},
  205. \l{QtVariantPropertyManager::flagTypeId()}{flagTypeId()} and
  206. \l{QtVariantPropertyManager::groupTypeId()}{groupTypeId()}.
  207. \sa valueType()
  208. */
  209. int QtVariantProperty::propertyType() const
  210. {
  211. return d_ptr->manager->propertyType(this);
  212. }
  213. /*!
  214. Sets the value of this property to \a value.
  215. The specified \a value must be of the type returned by
  216. valueType(), or of a type that can be converted to valueType()
  217. using the QVariant::canConvert() function; otherwise this function
  218. does nothing.
  219. \sa value()
  220. */
  221. #include <QDebug>
  222. void QtVariantProperty::setValue(const QVariant &value)
  223. {
  224. d_ptr->manager->setValue(this, value);
  225. }
  226. /*!
  227. Sets the \a attribute of property to \a value.
  228. QtVariantPropertyManager provides the related
  229. \l{QtVariantPropertyManager::setAttribute()}{setAttribute()}
  230. function.
  231. \sa attributeValue()
  232. */
  233. void QtVariantProperty::setAttribute(const QString &attribute, const QVariant &value)
  234. {
  235. d_ptr->manager->setAttribute(this, attribute, value);
  236. }
  237. class QtVariantPropertyManagerPrivate
  238. {
  239. QtVariantPropertyManager *q_ptr = nullptr;
  240. Q_DECLARE_PUBLIC(QtVariantPropertyManager)
  241. public:
  242. QtVariantPropertyManagerPrivate();
  243. bool m_creatingProperty = false;
  244. bool m_creatingSubProperties = false;
  245. bool m_destroyingSubProperties = false;
  246. int m_propertyType = 0;
  247. void slotValueChanged(QtProperty *property, int val);
  248. void slotRangeChanged(QtProperty *property, int min, int max);
  249. void slotSingleStepChanged(QtProperty *property, int step);
  250. void slotValueChanged(QtProperty *property, double val);
  251. void slotRangeChanged(QtProperty *property, double min, double max);
  252. void slotSingleStepChanged(QtProperty *property, double step);
  253. void slotDecimalsChanged(QtProperty *property, int prec);
  254. void slotValueChanged(QtProperty *property, bool val);
  255. void slotValueChanged(QtProperty *property, const QString &val);
  256. void slotRegExpChanged(QtProperty *property, const QRegExp &regExp);
  257. void slotEchoModeChanged(QtProperty *property, int);
  258. void slotValueChanged(QtProperty *property, const QDate &val);
  259. void slotRangeChanged(QtProperty *property, const QDate &min, const QDate &max);
  260. void slotValueChanged(QtProperty *property, const QTime &val);
  261. void slotValueChanged(QtProperty *property, const QDateTime &val);
  262. void slotValueChanged(QtProperty *property, const QKeySequence &val);
  263. void slotValueChanged(QtProperty *property, const QChar &val);
  264. void slotValueChanged(QtProperty *property, const QLocale &val);
  265. void slotValueChanged(QtProperty *property, const QPoint &val);
  266. void slotValueChanged(QtProperty *property, const QPointF &val);
  267. void slotValueChanged(QtProperty *property, const QSize &val);
  268. void slotRangeChanged(QtProperty *property, const QSize &min, const QSize &max);
  269. void slotValueChanged(QtProperty *property, const QSizeF &val);
  270. void slotRangeChanged(QtProperty *property, const QSizeF &min, const QSizeF &max);
  271. void slotValueChanged(QtProperty *property, const QRect &val);
  272. void slotConstraintChanged(QtProperty *property, const QRect &val);
  273. void slotValueChanged(QtProperty *property, const QRectF &val);
  274. void slotConstraintChanged(QtProperty *property, const QRectF &val);
  275. void slotValueChanged(QtProperty *property, const QColor &val);
  276. void slotEnumChanged(QtProperty *property, int val);
  277. void slotEnumNamesChanged(QtProperty *property, const QStringList &enumNames);
  278. void slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &enumIcons);
  279. void slotValueChanged(QtProperty *property, const QSizePolicy &val);
  280. void slotValueChanged(QtProperty *property, const QFont &val);
  281. void slotValueChanged(QtProperty *property, const QCursor &val);
  282. void slotFlagChanged(QtProperty *property, int val);
  283. void slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames);
  284. void slotReadOnlyChanged(QtProperty *property, bool readOnly);
  285. void slotTextVisibleChanged(QtProperty *property, bool textVisible);
  286. void slotPropertyInserted(QtProperty *property, QtProperty *parent, QtProperty *after);
  287. void slotPropertyRemoved(QtProperty *property, QtProperty *parent);
  288. void valueChanged(QtProperty *property, const QVariant &val);
  289. int internalPropertyToType(QtProperty *property) const;
  290. QtVariantProperty *createSubProperty(QtVariantProperty *parent, QtVariantProperty *after,
  291. QtProperty *internal);
  292. void removeSubProperty(QtVariantProperty *property);
  293. QMap<int, QtAbstractPropertyManager *> m_typeToPropertyManager;
  294. QMap<int, QMap<QString, int> > m_typeToAttributeToAttributeType;
  295. QMap<const QtProperty *, QPair<QtVariantProperty *, int> > m_propertyToType;
  296. QMap<int, int> m_typeToValueType;
  297. QMap<QtProperty *, QtVariantProperty *> m_internalToProperty;
  298. const QString m_constraintAttribute;
  299. const QString m_singleStepAttribute;
  300. const QString m_decimalsAttribute;
  301. const QString m_enumIconsAttribute;
  302. const QString m_enumNamesAttribute;
  303. const QString m_flagNamesAttribute;
  304. const QString m_maximumAttribute;
  305. const QString m_minimumAttribute;
  306. const QString m_regExpAttribute;
  307. const QString m_echoModeAttribute;
  308. const QString m_readOnlyAttribute;
  309. const QString m_textVisibleAttribute;
  310. };
  311. QtVariantPropertyManagerPrivate::QtVariantPropertyManagerPrivate() :
  312. m_constraintAttribute(QLatin1String("constraint")),
  313. m_singleStepAttribute(QLatin1String("singleStep")),
  314. m_decimalsAttribute(QLatin1String("decimals")),
  315. m_enumIconsAttribute(QLatin1String("enumIcons")),
  316. m_enumNamesAttribute(QLatin1String("enumNames")),
  317. m_flagNamesAttribute(QLatin1String("flagNames")),
  318. m_maximumAttribute(QLatin1String("maximum")),
  319. m_minimumAttribute(QLatin1String("minimum")),
  320. m_regExpAttribute(QLatin1String("regExp")),
  321. m_echoModeAttribute(QLatin1String("echoMode")),
  322. m_readOnlyAttribute(QLatin1String("readOnly")),
  323. m_textVisibleAttribute(QLatin1String("textVisible"))
  324. {
  325. }
  326. int QtVariantPropertyManagerPrivate::internalPropertyToType(QtProperty *property) const
  327. {
  328. int type = 0;
  329. QtAbstractPropertyManager *internPropertyManager = property->propertyManager();
  330. if (qobject_cast<QtIntPropertyManager *>(internPropertyManager))
  331. type = QVariant::Int;
  332. else if (qobject_cast<QtEnumPropertyManager *>(internPropertyManager))
  333. type = QtVariantPropertyManager::enumTypeId();
  334. else if (qobject_cast<QtBoolPropertyManager *>(internPropertyManager))
  335. type = QVariant::Bool;
  336. else if (qobject_cast<QtDoublePropertyManager *>(internPropertyManager))
  337. type = QVariant::Double;
  338. return type;
  339. }
  340. QtVariantProperty *QtVariantPropertyManagerPrivate::createSubProperty(QtVariantProperty *parent,
  341. QtVariantProperty *after, QtProperty *internal)
  342. {
  343. int type = internalPropertyToType(internal);
  344. if (!type)
  345. return 0;
  346. bool wasCreatingSubProperties = m_creatingSubProperties;
  347. m_creatingSubProperties = true;
  348. QtVariantProperty *varChild = q_ptr->addProperty(type, internal->propertyName());
  349. m_creatingSubProperties = wasCreatingSubProperties;
  350. varChild->setPropertyName(internal->propertyName());
  351. varChild->setToolTip(internal->toolTip());
  352. varChild->setStatusTip(internal->statusTip());
  353. varChild->setWhatsThis(internal->whatsThis());
  354. parent->insertSubProperty(varChild, after);
  355. m_internalToProperty[internal] = varChild;
  356. propertyToWrappedProperty()->insert(varChild, internal);
  357. return varChild;
  358. }
  359. void QtVariantPropertyManagerPrivate::removeSubProperty(QtVariantProperty *property)
  360. {
  361. QtProperty *internChild = wrappedProperty(property);
  362. bool wasDestroyingSubProperties = m_destroyingSubProperties;
  363. m_destroyingSubProperties = true;
  364. delete property;
  365. m_destroyingSubProperties = wasDestroyingSubProperties;
  366. m_internalToProperty.remove(internChild);
  367. propertyToWrappedProperty()->remove(property);
  368. }
  369. void QtVariantPropertyManagerPrivate::slotPropertyInserted(QtProperty *property,
  370. QtProperty *parent, QtProperty *after)
  371. {
  372. if (m_creatingProperty)
  373. return;
  374. QtVariantProperty *varParent = m_internalToProperty.value(parent, 0);
  375. if (!varParent)
  376. return;
  377. QtVariantProperty *varAfter = 0;
  378. if (after) {
  379. varAfter = m_internalToProperty.value(after, 0);
  380. if (!varAfter)
  381. return;
  382. }
  383. createSubProperty(varParent, varAfter, property);
  384. }
  385. void QtVariantPropertyManagerPrivate::slotPropertyRemoved(QtProperty *property, QtProperty *parent)
  386. {
  387. Q_UNUSED(parent)
  388. QtVariantProperty *varProperty = m_internalToProperty.value(property, 0);
  389. if (!varProperty)
  390. return;
  391. removeSubProperty(varProperty);
  392. }
  393. void QtVariantPropertyManagerPrivate::valueChanged(QtProperty *property, const QVariant &val)
  394. {
  395. QtVariantProperty *varProp = m_internalToProperty.value(property, 0);
  396. if (!varProp)
  397. return;
  398. emit q_ptr->valueChanged(varProp, val);
  399. emit q_ptr->propertyChanged(varProp);
  400. }
  401. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, int val)
  402. {
  403. valueChanged(property, QVariant(val));
  404. }
  405. void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, int min, int max)
  406. {
  407. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
  408. emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
  409. emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
  410. }
  411. }
  412. void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty *property, int step)
  413. {
  414. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  415. emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step));
  416. }
  417. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, double val)
  418. {
  419. valueChanged(property, QVariant(val));
  420. }
  421. void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, double min, double max)
  422. {
  423. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
  424. emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
  425. emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
  426. }
  427. }
  428. void QtVariantPropertyManagerPrivate::slotSingleStepChanged(QtProperty *property, double step)
  429. {
  430. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  431. emit q_ptr->attributeChanged(varProp, m_singleStepAttribute, QVariant(step));
  432. }
  433. void QtVariantPropertyManagerPrivate::slotDecimalsChanged(QtProperty *property, int prec)
  434. {
  435. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  436. emit q_ptr->attributeChanged(varProp, m_decimalsAttribute, QVariant(prec));
  437. }
  438. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, bool val)
  439. {
  440. valueChanged(property, QVariant(val));
  441. }
  442. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QString &val)
  443. {
  444. valueChanged(property, QVariant(val));
  445. }
  446. void QtVariantPropertyManagerPrivate::slotRegExpChanged(QtProperty *property, const QRegExp &regExp)
  447. {
  448. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  449. emit q_ptr->attributeChanged(varProp, m_regExpAttribute, QVariant(regExp));
  450. }
  451. void QtVariantPropertyManagerPrivate::slotEchoModeChanged(QtProperty *property, int mode)
  452. {
  453. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  454. emit q_ptr->attributeChanged(varProp, m_echoModeAttribute, QVariant(mode));
  455. }
  456. void QtVariantPropertyManagerPrivate::slotReadOnlyChanged(QtProperty *property, bool readOnly)
  457. {
  458. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  459. emit q_ptr->attributeChanged(varProp, m_readOnlyAttribute, QVariant(readOnly));
  460. }
  461. void QtVariantPropertyManagerPrivate::slotTextVisibleChanged(QtProperty *property, bool textVisible)
  462. {
  463. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  464. emit q_ptr->attributeChanged(varProp, m_textVisibleAttribute, QVariant(textVisible));
  465. }
  466. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QDate &val)
  467. {
  468. valueChanged(property, QVariant(val));
  469. }
  470. void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QDate &min, const QDate &max)
  471. {
  472. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
  473. emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
  474. emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
  475. }
  476. }
  477. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QTime &val)
  478. {
  479. valueChanged(property, QVariant(val));
  480. }
  481. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QDateTime &val)
  482. {
  483. valueChanged(property, QVariant(val));
  484. }
  485. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QKeySequence &val)
  486. {
  487. QVariant v;
  488. qVariantSetValue(v, val);
  489. valueChanged(property, v);
  490. }
  491. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QChar &val)
  492. {
  493. valueChanged(property, QVariant(val));
  494. }
  495. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QLocale &val)
  496. {
  497. valueChanged(property, QVariant(val));
  498. }
  499. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QPoint &val)
  500. {
  501. valueChanged(property, QVariant(val));
  502. }
  503. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QPointF &val)
  504. {
  505. valueChanged(property, QVariant(val));
  506. }
  507. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QSize &val)
  508. {
  509. valueChanged(property, QVariant(val));
  510. }
  511. void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QSize &min, const QSize &max)
  512. {
  513. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
  514. emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
  515. emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
  516. }
  517. }
  518. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QSizeF &val)
  519. {
  520. valueChanged(property, QVariant(val));
  521. }
  522. void QtVariantPropertyManagerPrivate::slotRangeChanged(QtProperty *property, const QSizeF &min, const QSizeF &max)
  523. {
  524. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
  525. emit q_ptr->attributeChanged(varProp, m_minimumAttribute, QVariant(min));
  526. emit q_ptr->attributeChanged(varProp, m_maximumAttribute, QVariant(max));
  527. }
  528. }
  529. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QRect &val)
  530. {
  531. valueChanged(property, QVariant(val));
  532. }
  533. void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty *property, const QRect &constraint)
  534. {
  535. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  536. emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint));
  537. }
  538. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QRectF &val)
  539. {
  540. valueChanged(property, QVariant(val));
  541. }
  542. void QtVariantPropertyManagerPrivate::slotConstraintChanged(QtProperty *property, const QRectF &constraint)
  543. {
  544. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  545. emit q_ptr->attributeChanged(varProp, m_constraintAttribute, QVariant(constraint));
  546. }
  547. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QColor &val)
  548. {
  549. valueChanged(property, QVariant(val));
  550. }
  551. void QtVariantPropertyManagerPrivate::slotEnumNamesChanged(QtProperty *property, const QStringList &enumNames)
  552. {
  553. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  554. emit q_ptr->attributeChanged(varProp, m_enumNamesAttribute, QVariant(enumNames));
  555. }
  556. void QtVariantPropertyManagerPrivate::slotEnumIconsChanged(QtProperty *property, const QMap<int, QIcon> &enumIcons)
  557. {
  558. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0)) {
  559. QVariant v;
  560. qVariantSetValue(v, enumIcons);
  561. emit q_ptr->attributeChanged(varProp, m_enumIconsAttribute, v);
  562. }
  563. }
  564. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QSizePolicy &val)
  565. {
  566. valueChanged(property, QVariant(val));
  567. }
  568. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QFont &val)
  569. {
  570. valueChanged(property, QVariant(val));
  571. }
  572. void QtVariantPropertyManagerPrivate::slotValueChanged(QtProperty *property, const QCursor &val)
  573. {
  574. #ifndef QT_NO_CURSOR
  575. valueChanged(property, QVariant(val));
  576. #endif
  577. }
  578. void QtVariantPropertyManagerPrivate::slotFlagNamesChanged(QtProperty *property, const QStringList &flagNames)
  579. {
  580. if (QtVariantProperty *varProp = m_internalToProperty.value(property, 0))
  581. emit q_ptr->attributeChanged(varProp, m_flagNamesAttribute, QVariant(flagNames));
  582. }
  583. /*!
  584. \class QtVariantPropertyManager
  585. \brief The QtVariantPropertyManager class provides and manages QVariant based properties.
  586. QtVariantPropertyManager provides the addProperty() function which
  587. creates QtVariantProperty objects. The QtVariantProperty class is
  588. a convenience class handling QVariant based properties inheriting
  589. QtProperty. A QtProperty object created by a
  590. QtVariantPropertyManager instance can be converted into a
  591. QtVariantProperty object using the variantProperty() function.
  592. The property's value can be retrieved using the value(), and set
  593. using the setValue() slot. In addition the property's type, and
  594. the type of its value, can be retrieved using the propertyType()
  595. and valueType() functions respectively.
  596. A property's type is a QVariant::Type enumerator value, and
  597. usually a property's type is the same as its value type. But for
  598. some properties the types differ, for example for enums, flags and
  599. group types in which case QtVariantPropertyManager provides the
  600. enumTypeId(), flagTypeId() and groupTypeId() functions,
  601. respectively, to identify their property type (the value types are
  602. QVariant::Int for the enum and flag types, and QVariant::Invalid
  603. for the group type).
  604. Use the isPropertyTypeSupported() function to check if a particular
  605. property type is supported. The currently supported property types
  606. are:
  607. \table
  608. \header
  609. \o Property Type
  610. \o Property Type Id
  611. \row
  612. \o int
  613. \o QVariant::Int
  614. \row
  615. \o double
  616. \o QVariant::Double
  617. \row
  618. \o bool
  619. \o QVariant::Bool
  620. \row
  621. \o QString
  622. \o QVariant::String
  623. \row
  624. \o QDate
  625. \o QVariant::Date
  626. \row
  627. \o QTime
  628. \o QVariant::Time
  629. \row
  630. \o QDateTime
  631. \o QVariant::DateTime
  632. \row
  633. \o QKeySequence
  634. \o QVariant::KeySequence
  635. \row
  636. \o QChar
  637. \o QVariant::Char
  638. \row
  639. \o QLocale
  640. \o QVariant::Locale
  641. \row
  642. \o QPoint
  643. \o QVariant::Point
  644. \row
  645. \o QPointF
  646. \o QVariant::PointF
  647. \row
  648. \o QSize
  649. \o QVariant::Size
  650. \row
  651. \o QSizeF
  652. \o QVariant::SizeF
  653. \row
  654. \o QRect
  655. \o QVariant::Rect
  656. \row
  657. \o QRectF
  658. \o QVariant::RectF
  659. \row
  660. \o QColor
  661. \o QVariant::Color
  662. \row
  663. \o QSizePolicy
  664. \o QVariant::SizePolicy
  665. \row
  666. \o QFont
  667. \o QVariant::Font
  668. \row
  669. \o QCursor
  670. \o QVariant::Cursor
  671. \row
  672. \o enum
  673. \o enumTypeId()
  674. \row
  675. \o flag
  676. \o flagTypeId()
  677. \row
  678. \o group
  679. \o groupTypeId()
  680. \endtable
  681. Each property type can provide additional attributes,
  682. e.g. QVariant::Int and QVariant::Double provides minimum and
  683. maximum values. The currently supported attributes are:
  684. \table
  685. \header
  686. \o Property Type
  687. \o Attribute Name
  688. \o Attribute Type
  689. \row
  690. \o \c int
  691. \o minimum
  692. \o QVariant::Int
  693. \row
  694. \o
  695. \o maximum
  696. \o QVariant::Int
  697. \row
  698. \o
  699. \o singleStep
  700. \o QVariant::Int
  701. \row
  702. \o \c double
  703. \o minimum
  704. \o QVariant::Double
  705. \row
  706. \o
  707. \o maximum
  708. \o QVariant::Double
  709. \row
  710. \o
  711. \o singleStep
  712. \o QVariant::Double
  713. \row
  714. \o
  715. \o decimals
  716. \o QVariant::Int
  717. \row
  718. \o \c bool
  719. \o textVisible
  720. \o QVariant::Bool
  721. \row
  722. \o QString
  723. \o regExp
  724. \o QVariant::RegExp
  725. \row
  726. \o
  727. \o echoMode
  728. \o QVariant::Int
  729. \row
  730. \o QDate
  731. \o minimum
  732. \o QVariant::Date
  733. \row
  734. \o
  735. \o maximum
  736. \o QVariant::Date
  737. \row
  738. \o QPointF
  739. \o decimals
  740. \o QVariant::Int
  741. \row
  742. \o QSize
  743. \o minimum
  744. \o QVariant::Size
  745. \row
  746. \o
  747. \o maximum
  748. \o QVariant::Size
  749. \row
  750. \o QSizeF
  751. \o minimum
  752. \o QVariant::SizeF
  753. \row
  754. \o
  755. \o maximum
  756. \o QVariant::SizeF
  757. \row
  758. \o
  759. \o decimals
  760. \o QVariant::Int
  761. \row
  762. \o QRect
  763. \o constraint
  764. \o QVariant::Rect
  765. \row
  766. \o QRectF
  767. \o constraint
  768. \o QVariant::RectF
  769. \row
  770. \o
  771. \o decimals
  772. \o QVariant::Int
  773. \row
  774. \o \c enum
  775. \o enumNames
  776. \o QVariant::StringList
  777. \row
  778. \o
  779. \o enumIcons
  780. \o iconMapTypeId()
  781. \row
  782. \o \c flag
  783. \o flagNames
  784. \o QVariant::StringList
  785. \endtable
  786. The attributes for a given property type can be retrieved using
  787. the attributes() function. Each attribute has a value type which
  788. can be retrieved using the attributeType() function, and a value
  789. accessible through the attributeValue() function. In addition, the
  790. value can be set using the setAttribute() slot.
  791. QtVariantManager also provides the valueChanged() signal which is
  792. emitted whenever a property created by this manager change, and
  793. the attributeChanged() signal which is emitted whenever an
  794. attribute of such a property changes.
  795. \sa QtVariantProperty, QtVariantEditorFactory
  796. */
  797. /*!
  798. \fn void QtVariantPropertyManager::valueChanged(QtProperty *property, const QVariant &value)
  799. This signal is emitted whenever a property created by this manager
  800. changes its value, passing a pointer to the \a property and the
  801. new \a value as parameters.
  802. \sa setValue()
  803. */
  804. /*!
  805. \fn void QtVariantPropertyManager::attributeChanged(QtProperty *property,
  806. const QString &attribute, const QVariant &value)
  807. This signal is emitted whenever an attribute of a property created
  808. by this manager changes its value, passing a pointer to the \a
  809. property, the \a attribute and the new \a value as parameters.
  810. \sa setAttribute()
  811. */
  812. /*!
  813. Creates a manager with the given \a parent.
  814. */
  815. QtVariantPropertyManager::QtVariantPropertyManager(QObject *parent)
  816. : QtAbstractPropertyManager(parent)
  817. {
  818. d_ptr = new QtVariantPropertyManagerPrivate;
  819. d_ptr->q_ptr = this;
  820. d_ptr->m_creatingProperty = false;
  821. d_ptr->m_creatingSubProperties = false;
  822. d_ptr->m_destroyingSubProperties = false;
  823. d_ptr->m_propertyType = 0;
  824. // IntPropertyManager
  825. QtIntPropertyManager *intPropertyManager = new QtIntPropertyManager(this);
  826. d_ptr->m_typeToPropertyManager[QVariant::Int] = intPropertyManager;
  827. d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_minimumAttribute] = QVariant::Int;
  828. d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_maximumAttribute] = QVariant::Int;
  829. d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_singleStepAttribute] = QVariant::Int;
  830. d_ptr->m_typeToAttributeToAttributeType[QVariant::Int][d_ptr->m_readOnlyAttribute] = QVariant::Bool;
  831. d_ptr->m_typeToValueType[QVariant::Int] = QVariant::Int;
  832. connect(intPropertyManager, SIGNAL(valueChanged(QtProperty *, int)),
  833. this, SLOT(slotValueChanged(QtProperty *, int)));
  834. connect(intPropertyManager, SIGNAL(rangeChanged(QtProperty *, int, int)),
  835. this, SLOT(slotRangeChanged(QtProperty *, int, int)));
  836. connect(intPropertyManager, SIGNAL(singleStepChanged(QtProperty *, int)),
  837. this, SLOT(slotSingleStepChanged(QtProperty *, int)));
  838. // DoublePropertyManager
  839. QtDoublePropertyManager *doublePropertyManager = new QtDoublePropertyManager(this);
  840. d_ptr->m_typeToPropertyManager[QVariant::Double] = doublePropertyManager;
  841. d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_minimumAttribute] =
  842. QVariant::Double;
  843. d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_maximumAttribute] =
  844. QVariant::Double;
  845. d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_singleStepAttribute] =
  846. QVariant::Double;
  847. d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_decimalsAttribute] =
  848. QVariant::Int;
  849. d_ptr->m_typeToAttributeToAttributeType[QVariant::Double][d_ptr->m_readOnlyAttribute] =
  850. QVariant::Bool;
  851. d_ptr->m_typeToValueType[QVariant::Double] = QVariant::Double;
  852. connect(doublePropertyManager, SIGNAL(valueChanged(QtProperty *, double)),
  853. this, SLOT(slotValueChanged(QtProperty *, double)));
  854. connect(doublePropertyManager, SIGNAL(rangeChanged(QtProperty *, double, double)),
  855. this, SLOT(slotRangeChanged(QtProperty *, double, double)));
  856. connect(doublePropertyManager, SIGNAL(singleStepChanged(QtProperty *, double)),
  857. this, SLOT(slotSingleStepChanged(QtProperty *, double)));
  858. connect(doublePropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)),
  859. this, SLOT(slotDecimalsChanged(QtProperty *, int)));
  860. // BoolPropertyManager
  861. QtBoolPropertyManager *boolPropertyManager = new QtBoolPropertyManager(this);
  862. d_ptr->m_typeToPropertyManager[QVariant::Bool] = boolPropertyManager;
  863. d_ptr->m_typeToAttributeToAttributeType[QVariant::Bool][d_ptr->m_textVisibleAttribute] = QVariant::Bool;
  864. d_ptr->m_typeToValueType[QVariant::Bool] = QVariant::Bool;
  865. connect(boolPropertyManager, SIGNAL(valueChanged(QtProperty *, bool)),
  866. this, SLOT(slotValueChanged(QtProperty *, bool)));
  867. connect(boolPropertyManager, SIGNAL(textVisibleChanged(QtProperty*, bool)),
  868. this, SLOT(slotTextVisibleChanged(QtProperty*, bool)));
  869. // StringPropertyManager
  870. QtStringPropertyManager *stringPropertyManager = new QtStringPropertyManager(this);
  871. d_ptr->m_typeToPropertyManager[QVariant::String] = stringPropertyManager;
  872. d_ptr->m_typeToValueType[QVariant::String] = QVariant::String;
  873. d_ptr->m_typeToAttributeToAttributeType[QVariant::String][d_ptr->m_regExpAttribute] =
  874. QVariant::RegExp;
  875. d_ptr->m_typeToAttributeToAttributeType[QVariant::String][d_ptr->m_echoModeAttribute] =
  876. QVariant::Int;
  877. d_ptr->m_typeToAttributeToAttributeType[QVariant::String][d_ptr->m_readOnlyAttribute] =
  878. QVariant::Bool;
  879. connect(stringPropertyManager, SIGNAL(valueChanged(QtProperty *, const QString &)),
  880. this, SLOT(slotValueChanged(QtProperty *, const QString &)));
  881. connect(stringPropertyManager, SIGNAL(regExpChanged(QtProperty *, const QRegExp &)),
  882. this, SLOT(slotRegExpChanged(QtProperty *, const QRegExp &)));
  883. connect(stringPropertyManager, SIGNAL(echoModeChanged(QtProperty*,int)),
  884. this, SLOT(slotEchoModeChanged(QtProperty*, int)));
  885. connect(stringPropertyManager, SIGNAL(readOnlyChanged(QtProperty*, bool)),
  886. this, SLOT(slotReadOnlyChanged(QtProperty*, bool)));
  887. // DatePropertyManager
  888. QtDatePropertyManager *datePropertyManager = new QtDatePropertyManager(this);
  889. d_ptr->m_typeToPropertyManager[QVariant::Date] = datePropertyManager;
  890. d_ptr->m_typeToValueType[QVariant::Date] = QVariant::Date;
  891. d_ptr->m_typeToAttributeToAttributeType[QVariant::Date][d_ptr->m_minimumAttribute] =
  892. QVariant::Date;
  893. d_ptr->m_typeToAttributeToAttributeType[QVariant::Date][d_ptr->m_maximumAttribute] =
  894. QVariant::Date;
  895. connect(datePropertyManager, SIGNAL(valueChanged(QtProperty *, const QDate &)),
  896. this, SLOT(slotValueChanged(QtProperty *, const QDate &)));
  897. connect(datePropertyManager, SIGNAL(rangeChanged(QtProperty *, const QDate &, const QDate &)),
  898. this, SLOT(slotRangeChanged(QtProperty *, const QDate &, const QDate &)));
  899. // TimePropertyManager
  900. QtTimePropertyManager *timePropertyManager = new QtTimePropertyManager(this);
  901. d_ptr->m_typeToPropertyManager[QVariant::Time] = timePropertyManager;
  902. d_ptr->m_typeToValueType[QVariant::Time] = QVariant::Time;
  903. connect(timePropertyManager, SIGNAL(valueChanged(QtProperty *, const QTime &)),
  904. this, SLOT(slotValueChanged(QtProperty *, const QTime &)));
  905. // DateTimePropertyManager
  906. QtDateTimePropertyManager *dateTimePropertyManager = new QtDateTimePropertyManager(this);
  907. d_ptr->m_typeToPropertyManager[QVariant::DateTime] = dateTimePropertyManager;
  908. d_ptr->m_typeToValueType[QVariant::DateTime] = QVariant::DateTime;
  909. connect(dateTimePropertyManager, SIGNAL(valueChanged(QtProperty *, const QDateTime &)),
  910. this, SLOT(slotValueChanged(QtProperty *, const QDateTime &)));
  911. // KeySequencePropertyManager
  912. QtKeySequencePropertyManager *keySequencePropertyManager = new QtKeySequencePropertyManager(this);
  913. d_ptr->m_typeToPropertyManager[QVariant::KeySequence] = keySequencePropertyManager;
  914. d_ptr->m_typeToValueType[QVariant::KeySequence] = QVariant::KeySequence;
  915. connect(keySequencePropertyManager, SIGNAL(valueChanged(QtProperty *, const QKeySequence &)),
  916. this, SLOT(slotValueChanged(QtProperty *, const QKeySequence &)));
  917. // CharPropertyManager
  918. QtCharPropertyManager *charPropertyManager = new QtCharPropertyManager(this);
  919. d_ptr->m_typeToPropertyManager[QVariant::Char] = charPropertyManager;
  920. d_ptr->m_typeToValueType[QVariant::Char] = QVariant::Char;
  921. connect(charPropertyManager, SIGNAL(valueChanged(QtProperty *, const QChar &)),
  922. this, SLOT(slotValueChanged(QtProperty *, const QChar &)));
  923. // LocalePropertyManager
  924. QtLocalePropertyManager *localePropertyManager = new QtLocalePropertyManager(this);
  925. d_ptr->m_typeToPropertyManager[QVariant::Locale] = localePropertyManager;
  926. d_ptr->m_typeToValueType[QVariant::Locale] = QVariant::Locale;
  927. connect(localePropertyManager, SIGNAL(valueChanged(QtProperty *, const QLocale &)),
  928. this, SLOT(slotValueChanged(QtProperty *, const QLocale &)));
  929. connect(localePropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
  930. this, SLOT(slotValueChanged(QtProperty *, int)));
  931. connect(localePropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  932. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  933. connect(localePropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  934. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  935. // PointPropertyManager
  936. QtPointPropertyManager *pointPropertyManager = new QtPointPropertyManager(this);
  937. d_ptr->m_typeToPropertyManager[QVariant::Point] = pointPropertyManager;
  938. d_ptr->m_typeToValueType[QVariant::Point] = QVariant::Point;
  939. connect(pointPropertyManager, SIGNAL(valueChanged(QtProperty *, const QPoint &)),
  940. this, SLOT(slotValueChanged(QtProperty *, const QPoint &)));
  941. connect(pointPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
  942. this, SLOT(slotValueChanged(QtProperty *, int)));
  943. connect(pointPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  944. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  945. connect(pointPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  946. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  947. // PointFPropertyManager
  948. QtPointFPropertyManager *pointFPropertyManager = new QtPointFPropertyManager(this);
  949. d_ptr->m_typeToPropertyManager[QVariant::PointF] = pointFPropertyManager;
  950. d_ptr->m_typeToValueType[QVariant::PointF] = QVariant::PointF;
  951. d_ptr->m_typeToAttributeToAttributeType[QVariant::PointF][d_ptr->m_decimalsAttribute] =
  952. QVariant::Int;
  953. connect(pointFPropertyManager, SIGNAL(valueChanged(QtProperty *, const QPointF &)),
  954. this, SLOT(slotValueChanged(QtProperty *, const QPointF &)));
  955. connect(pointFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)),
  956. this, SLOT(slotDecimalsChanged(QtProperty *, int)));
  957. connect(pointFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty *, double)),
  958. this, SLOT(slotValueChanged(QtProperty *, double)));
  959. connect(pointFPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  960. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  961. connect(pointFPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  962. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  963. // SizePropertyManager
  964. QtSizePropertyManager *sizePropertyManager = new QtSizePropertyManager(this);
  965. d_ptr->m_typeToPropertyManager[QVariant::Size] = sizePropertyManager;
  966. d_ptr->m_typeToValueType[QVariant::Size] = QVariant::Size;
  967. d_ptr->m_typeToAttributeToAttributeType[QVariant::Size][d_ptr->m_minimumAttribute] =
  968. QVariant::Size;
  969. d_ptr->m_typeToAttributeToAttributeType[QVariant::Size][d_ptr->m_maximumAttribute] =
  970. QVariant::Size;
  971. connect(sizePropertyManager, SIGNAL(valueChanged(QtProperty *, const QSize &)),
  972. this, SLOT(slotValueChanged(QtProperty *, const QSize &)));
  973. connect(sizePropertyManager, SIGNAL(rangeChanged(QtProperty *, const QSize &, const QSize &)),
  974. this, SLOT(slotRangeChanged(QtProperty *, const QSize &, const QSize &)));
  975. connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
  976. this, SLOT(slotValueChanged(QtProperty *, int)));
  977. connect(sizePropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)),
  978. this, SLOT(slotRangeChanged(QtProperty *, int, int)));
  979. connect(sizePropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  980. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  981. connect(sizePropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  982. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  983. // SizeFPropertyManager
  984. QtSizeFPropertyManager *sizeFPropertyManager = new QtSizeFPropertyManager(this);
  985. d_ptr->m_typeToPropertyManager[QVariant::SizeF] = sizeFPropertyManager;
  986. d_ptr->m_typeToValueType[QVariant::SizeF] = QVariant::SizeF;
  987. d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_minimumAttribute] =
  988. QVariant::SizeF;
  989. d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_maximumAttribute] =
  990. QVariant::SizeF;
  991. d_ptr->m_typeToAttributeToAttributeType[QVariant::SizeF][d_ptr->m_decimalsAttribute] =
  992. QVariant::Int;
  993. connect(sizeFPropertyManager, SIGNAL(valueChanged(QtProperty *, const QSizeF &)),
  994. this, SLOT(slotValueChanged(QtProperty *, const QSizeF &)));
  995. connect(sizeFPropertyManager, SIGNAL(rangeChanged(QtProperty *, const QSizeF &, const QSizeF &)),
  996. this, SLOT(slotRangeChanged(QtProperty *, const QSizeF &, const QSizeF &)));
  997. connect(sizeFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)),
  998. this, SLOT(slotDecimalsChanged(QtProperty *, int)));
  999. connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty *, double)),
  1000. this, SLOT(slotValueChanged(QtProperty *, double)));
  1001. connect(sizeFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty *, double, double)),
  1002. this, SLOT(slotRangeChanged(QtProperty *, double, double)));
  1003. connect(sizeFPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  1004. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  1005. connect(sizeFPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  1006. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  1007. // RectPropertyManager
  1008. QtRectPropertyManager *rectPropertyManager = new QtRectPropertyManager(this);
  1009. d_ptr->m_typeToPropertyManager[QVariant::Rect] = rectPropertyManager;
  1010. d_ptr->m_typeToValueType[QVariant::Rect] = QVariant::Rect;
  1011. d_ptr->m_typeToAttributeToAttributeType[QVariant::Rect][d_ptr->m_constraintAttribute] =
  1012. QVariant::Rect;
  1013. connect(rectPropertyManager, SIGNAL(valueChanged(QtProperty *, const QRect &)),
  1014. this, SLOT(slotValueChanged(QtProperty *, const QRect &)));
  1015. connect(rectPropertyManager, SIGNAL(constraintChanged(QtProperty *, const QRect &)),
  1016. this, SLOT(slotConstraintChanged(QtProperty *, const QRect &)));
  1017. connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
  1018. this, SLOT(slotValueChanged(QtProperty *, int)));
  1019. connect(rectPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)),
  1020. this, SLOT(slotRangeChanged(QtProperty *, int, int)));
  1021. connect(rectPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  1022. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  1023. connect(rectPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  1024. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  1025. // RectFPropertyManager
  1026. QtRectFPropertyManager *rectFPropertyManager = new QtRectFPropertyManager(this);
  1027. d_ptr->m_typeToPropertyManager[QVariant::RectF] = rectFPropertyManager;
  1028. d_ptr->m_typeToValueType[QVariant::RectF] = QVariant::RectF;
  1029. d_ptr->m_typeToAttributeToAttributeType[QVariant::RectF][d_ptr->m_constraintAttribute] =
  1030. QVariant::RectF;
  1031. d_ptr->m_typeToAttributeToAttributeType[QVariant::RectF][d_ptr->m_decimalsAttribute] =
  1032. QVariant::Int;
  1033. connect(rectFPropertyManager, SIGNAL(valueChanged(QtProperty *, const QRectF &)),
  1034. this, SLOT(slotValueChanged(QtProperty *, const QRectF &)));
  1035. connect(rectFPropertyManager, SIGNAL(constraintChanged(QtProperty *, const QRectF &)),
  1036. this, SLOT(slotConstraintChanged(QtProperty *, const QRectF &)));
  1037. connect(rectFPropertyManager, SIGNAL(decimalsChanged(QtProperty *, int)),
  1038. this, SLOT(slotDecimalsChanged(QtProperty *, int)));
  1039. connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(valueChanged(QtProperty *, double)),
  1040. this, SLOT(slotValueChanged(QtProperty *, double)));
  1041. connect(rectFPropertyManager->subDoublePropertyManager(), SIGNAL(rangeChanged(QtProperty *, double, double)),
  1042. this, SLOT(slotRangeChanged(QtProperty *, double, double)));
  1043. connect(rectFPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  1044. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  1045. connect(rectFPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  1046. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  1047. // ColorPropertyManager
  1048. QtColorPropertyManager *colorPropertyManager = new QtColorPropertyManager(this);
  1049. d_ptr->m_typeToPropertyManager[QVariant::Color] = colorPropertyManager;
  1050. d_ptr->m_typeToValueType[QVariant::Color] = QVariant::Color;
  1051. connect(colorPropertyManager, SIGNAL(valueChanged(QtProperty *, const QColor &)),
  1052. this, SLOT(slotValueChanged(QtProperty *, const QColor &)));
  1053. connect(colorPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
  1054. this, SLOT(slotValueChanged(QtProperty *, int)));
  1055. connect(colorPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  1056. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  1057. connect(colorPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  1058. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  1059. // EnumPropertyManager
  1060. int enumId = enumTypeId();
  1061. QtEnumPropertyManager *enumPropertyManager = new QtEnumPropertyManager(this);
  1062. d_ptr->m_typeToPropertyManager[enumId] = enumPropertyManager;
  1063. d_ptr->m_typeToValueType[enumId] = QVariant::Int;
  1064. d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumNamesAttribute] =
  1065. QVariant::StringList;
  1066. d_ptr->m_typeToAttributeToAttributeType[enumId][d_ptr->m_enumIconsAttribute] =
  1067. iconMapTypeId();
  1068. connect(enumPropertyManager, SIGNAL(valueChanged(QtProperty *, int)),
  1069. this, SLOT(slotValueChanged(QtProperty *, int)));
  1070. connect(enumPropertyManager, SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)),
  1071. this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &)));
  1072. connect(enumPropertyManager, SIGNAL(enumIconsChanged(QtProperty *, const QMap<int, QIcon> &)),
  1073. this, SLOT(slotEnumIconsChanged(QtProperty *, const QMap<int, QIcon> &)));
  1074. // SizePolicyPropertyManager
  1075. QtSizePolicyPropertyManager *sizePolicyPropertyManager = new QtSizePolicyPropertyManager(this);
  1076. d_ptr->m_typeToPropertyManager[QVariant::SizePolicy] = sizePolicyPropertyManager;
  1077. d_ptr->m_typeToValueType[QVariant::SizePolicy] = QVariant::SizePolicy;
  1078. connect(sizePolicyPropertyManager, SIGNAL(valueChanged(QtProperty *, const QSizePolicy &)),
  1079. this, SLOT(slotValueChanged(QtProperty *, const QSizePolicy &)));
  1080. connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
  1081. this, SLOT(slotValueChanged(QtProperty *, int)));
  1082. connect(sizePolicyPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)),
  1083. this, SLOT(slotRangeChanged(QtProperty *, int, int)));
  1084. connect(sizePolicyPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
  1085. this, SLOT(slotValueChanged(QtProperty *, int)));
  1086. connect(sizePolicyPropertyManager->subEnumPropertyManager(),
  1087. SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)),
  1088. this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &)));
  1089. connect(sizePolicyPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  1090. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  1091. connect(sizePolicyPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  1092. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  1093. // FontPropertyManager
  1094. QtFontPropertyManager *fontPropertyManager = new QtFontPropertyManager(this);
  1095. d_ptr->m_typeToPropertyManager[QVariant::Font] = fontPropertyManager;
  1096. d_ptr->m_typeToValueType[QVariant::Font] = QVariant::Font;
  1097. connect(fontPropertyManager, SIGNAL(valueChanged(QtProperty *, const QFont &)),
  1098. this, SLOT(slotValueChanged(QtProperty *, const QFont &)));
  1099. connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
  1100. this, SLOT(slotValueChanged(QtProperty *, int)));
  1101. connect(fontPropertyManager->subIntPropertyManager(), SIGNAL(rangeChanged(QtProperty *, int, int)),
  1102. this, SLOT(slotRangeChanged(QtProperty *, int, int)));
  1103. connect(fontPropertyManager->subEnumPropertyManager(), SIGNAL(valueChanged(QtProperty *, int)),
  1104. this, SLOT(slotValueChanged(QtProperty *, int)));
  1105. connect(fontPropertyManager->subEnumPropertyManager(),
  1106. SIGNAL(enumNamesChanged(QtProperty *, const QStringList &)),
  1107. this, SLOT(slotEnumNamesChanged(QtProperty *, const QStringList &)));
  1108. connect(fontPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty *, bool)),
  1109. this, SLOT(slotValueChanged(QtProperty *, bool)));
  1110. connect(fontPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  1111. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  1112. connect(fontPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  1113. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  1114. // CursorPropertyManager
  1115. QtCursorPropertyManager *cursorPropertyManager = new QtCursorPropertyManager(this);
  1116. d_ptr->m_typeToPropertyManager[QVariant::Cursor] = cursorPropertyManager;
  1117. d_ptr->m_typeToValueType[QVariant::Cursor] = QVariant::Cursor;
  1118. connect(cursorPropertyManager, SIGNAL(valueChanged(QtProperty *, const QCursor &)),
  1119. this, SLOT(slotValueChanged(QtProperty *, const QCursor &)));
  1120. // FlagPropertyManager
  1121. int flagId = flagTypeId();
  1122. QtFlagPropertyManager *flagPropertyManager = new QtFlagPropertyManager(this);
  1123. d_ptr->m_typeToPropertyManager[flagId] = flagPropertyManager;
  1124. d_ptr->m_typeToValueType[flagId] = QVariant::Int;
  1125. d_ptr->m_typeToAttributeToAttributeType[flagId][d_ptr->m_flagNamesAttribute] =
  1126. QVariant::StringList;
  1127. connect(flagPropertyManager, SIGNAL(valueChanged(QtProperty *, int)),
  1128. this, SLOT(slotValueChanged(QtProperty *, int)));
  1129. connect(flagPropertyManager, SIGNAL(flagNamesChanged(QtProperty *, const QStringList &)),
  1130. this, SLOT(slotFlagNamesChanged(QtProperty *, const QStringList &)));
  1131. connect(flagPropertyManager->subBoolPropertyManager(), SIGNAL(valueChanged(QtProperty *, bool)),
  1132. this, SLOT(slotValueChanged(QtProperty *, bool)));
  1133. connect(flagPropertyManager, SIGNAL(propertyInserted(QtProperty *, QtProperty *, QtProperty *)),
  1134. this, SLOT(slotPropertyInserted(QtProperty *, QtProperty *, QtProperty *)));
  1135. connect(flagPropertyManager, SIGNAL(propertyRemoved(QtProperty *, QtProperty *)),
  1136. this, SLOT(slotPropertyRemoved(QtProperty *, QtProperty *)));
  1137. // FlagPropertyManager
  1138. int groupId = groupTypeId();
  1139. QtGroupPropertyManager *groupPropertyManager = new QtGroupPropertyManager(this);
  1140. d_ptr->m_typeToPropertyManager[groupId] = groupPropertyManager;
  1141. d_ptr->m_typeToValueType[groupId] = QVariant::Invalid;
  1142. }
  1143. /*!
  1144. Destroys this manager, and all the properties it has created.
  1145. */
  1146. QtVariantPropertyManager::~QtVariantPropertyManager()
  1147. {
  1148. clear();
  1149. delete d_ptr;
  1150. }
  1151. /*!
  1152. Returns the given \a property converted into a QtVariantProperty.
  1153. If the \a property was not created by this variant manager, the
  1154. function returns 0.
  1155. \sa createProperty()
  1156. */
  1157. QtVariantProperty *QtVariantPropertyManager::variantProperty(const QtProperty *property) const
  1158. {
  1159. // 通过 QtProperty 找到对应的 QtVariantProperty
  1160. const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::const_iterator it = d_ptr->m_propertyToType.constFind(property);
  1161. if (it == d_ptr->m_propertyToType.constEnd())
  1162. return 0;
  1163. return it.value().first;
  1164. }
  1165. /*!
  1166. Returns true if the given \a propertyType is supported by this
  1167. variant manager; otherwise false.
  1168. \sa propertyType()
  1169. */
  1170. bool QtVariantPropertyManager::isPropertyTypeSupported(int propertyType) const
  1171. {
  1172. if (d_ptr->m_typeToValueType.contains(propertyType))
  1173. return true;
  1174. return false;
  1175. }
  1176. /*!
  1177. Creates and returns a variant property of the given \a propertyType
  1178. with the given \a name.
  1179. If the specified \a propertyType is not supported by this variant
  1180. manager, this function returns 0.
  1181. Do not use the inherited
  1182. QtAbstractPropertyManager::addProperty() function to create a
  1183. variant property (that function will always return 0 since it will
  1184. not be clear what type the property should have).
  1185. \sa isPropertyTypeSupported()
  1186. */
  1187. /// <summary>
  1188. /// 根据属性类型创建属性相关数据结构
  1189. /// </summary>
  1190. /// <param name="propertyType"></param>
  1191. /// <param name="name"></param>
  1192. /// <returns></returns>
  1193. QtVariantProperty *QtVariantPropertyManager::addProperty(int propertyType, const QString &name)
  1194. {
  1195. // 如果是不支持的属性则不予建立
  1196. if (!isPropertyTypeSupported(propertyType))
  1197. return 0;
  1198. bool wasCreating = d_ptr->m_creatingProperty;
  1199. d_ptr->m_creatingProperty = true;
  1200. // 保存属性Type
  1201. d_ptr->m_propertyType = propertyType;
  1202. // 首先通过基类创建并且初始化本属性
  1203. QtProperty *property = QtAbstractPropertyManager::addProperty(name);
  1204. d_ptr->m_creatingProperty = wasCreating;
  1205. d_ptr->m_propertyType = 0;
  1206. if (!property)
  1207. return 0;
  1208. // 通过 QtProperty 转换为 QtVariantProperty 并返回
  1209. return variantProperty(property);
  1210. }
  1211. /*!
  1212. Returns the given \a property's value.
  1213. If the given \a property is not managed by this manager, this
  1214. function returns an invalid variant.
  1215. \sa setValue()
  1216. */
  1217. QVariant QtVariantPropertyManager::value(const QtProperty *property) const
  1218. {
  1219. QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
  1220. if (internProp == 0)
  1221. return QVariant();
  1222. QtAbstractPropertyManager *manager = internProp->propertyManager();
  1223. if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
  1224. return intManager->value(internProp);
  1225. } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
  1226. return doubleManager->value(internProp);
  1227. } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) {
  1228. return boolManager->value(internProp);
  1229. } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
  1230. return stringManager->value(internProp);
  1231. } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
  1232. return dateManager->value(internProp);
  1233. } else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) {
  1234. return timeManager->value(internProp);
  1235. } else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) {
  1236. return dateTimeManager->value(internProp);
  1237. } else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) {
  1238. #if QT_VERSION < 0x050000
  1239. return keySequenceManager->value(internProp);
  1240. #else
  1241. return QVariant::fromValue(keySequenceManager->value(internProp));
  1242. #endif
  1243. } else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) {
  1244. return charManager->value(internProp);
  1245. } else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) {
  1246. return localeManager->value(internProp);
  1247. } else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) {
  1248. return pointManager->value(internProp);
  1249. } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
  1250. return pointFManager->value(internProp);
  1251. } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
  1252. return sizeManager->value(internProp);
  1253. } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
  1254. return sizeFManager->value(internProp);
  1255. } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
  1256. return rectManager->value(internProp);
  1257. } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
  1258. return rectFManager->value(internProp);
  1259. } else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) {
  1260. return colorManager->value(internProp);
  1261. } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
  1262. return enumManager->value(internProp);
  1263. } else if (QtSizePolicyPropertyManager *sizePolicyManager =
  1264. qobject_cast<QtSizePolicyPropertyManager *>(manager)) {
  1265. return sizePolicyManager->value(internProp);
  1266. } else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) {
  1267. return fontManager->value(internProp);
  1268. #ifndef QT_NO_CURSOR
  1269. } else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) {
  1270. return cursorManager->value(internProp);
  1271. #endif
  1272. } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
  1273. return flagManager->value(internProp);
  1274. }
  1275. return QVariant();
  1276. }
  1277. /*!
  1278. Returns the given \a property's value type.
  1279. \sa propertyType()
  1280. */
  1281. int QtVariantPropertyManager::valueType(const QtProperty *property) const
  1282. {
  1283. int propType = propertyType(property);
  1284. return valueType(propType);
  1285. }
  1286. /*!
  1287. \overload
  1288. Returns the value type associated with the given \a propertyType.
  1289. */
  1290. int QtVariantPropertyManager::valueType(int propertyType) const
  1291. {
  1292. if (d_ptr->m_typeToValueType.contains(propertyType))
  1293. return d_ptr->m_typeToValueType[propertyType];
  1294. return 0;
  1295. }
  1296. /*!
  1297. Returns the given \a property's type.
  1298. \sa valueType()
  1299. */
  1300. int QtVariantPropertyManager::propertyType(const QtProperty *property) const
  1301. {
  1302. const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::const_iterator it = d_ptr->m_propertyToType.constFind(property);
  1303. if (it == d_ptr->m_propertyToType.constEnd())
  1304. return 0;
  1305. return it.value().second;
  1306. }
  1307. /*!
  1308. Returns the given \a property's value for the specified \a
  1309. attribute
  1310. If the given \a property was not created by \e this manager, or if
  1311. the specified \a attribute does not exist, this function returns
  1312. an invalid variant.
  1313. \sa attributes(), attributeType(), setAttribute()
  1314. */
  1315. QVariant QtVariantPropertyManager::attributeValue(const QtProperty *property, const QString &attribute) const
  1316. {
  1317. int propType = propertyType(property);
  1318. if (!propType)
  1319. return QVariant();
  1320. QMap<int, QMap<QString, int> >::ConstIterator it =
  1321. d_ptr->m_typeToAttributeToAttributeType.find(propType);
  1322. if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd())
  1323. return QVariant();
  1324. QMap<QString, int> attributes = it.value();
  1325. QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute);
  1326. if (itAttr == attributes.constEnd())
  1327. return QVariant();
  1328. QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
  1329. if (internProp == 0)
  1330. return QVariant();
  1331. QtAbstractPropertyManager *manager = internProp->propertyManager();
  1332. if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
  1333. if (attribute == d_ptr->m_maximumAttribute)
  1334. return intManager->maximum(internProp);
  1335. if (attribute == d_ptr->m_minimumAttribute)
  1336. return intManager->minimum(internProp);
  1337. if (attribute == d_ptr->m_singleStepAttribute)
  1338. return intManager->singleStep(internProp);
  1339. if (attribute == d_ptr->m_readOnlyAttribute)
  1340. return intManager->isReadOnly(internProp);
  1341. return QVariant();
  1342. } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
  1343. if (attribute == d_ptr->m_maximumAttribute)
  1344. return doubleManager->maximum(internProp);
  1345. if (attribute == d_ptr->m_minimumAttribute)
  1346. return doubleManager->minimum(internProp);
  1347. if (attribute == d_ptr->m_singleStepAttribute)
  1348. return doubleManager->singleStep(internProp);
  1349. if (attribute == d_ptr->m_decimalsAttribute)
  1350. return doubleManager->decimals(internProp);
  1351. if (attribute == d_ptr->m_readOnlyAttribute)
  1352. return doubleManager->isReadOnly(internProp);
  1353. return QVariant();
  1354. } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) {
  1355. if (attribute == d_ptr->m_textVisibleAttribute)
  1356. return boolManager->textVisible(internProp);
  1357. return QVariant();
  1358. } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
  1359. if (attribute == d_ptr->m_regExpAttribute)
  1360. return stringManager->regExp(internProp);
  1361. if (attribute == d_ptr->m_echoModeAttribute)
  1362. return stringManager->echoMode(internProp);
  1363. if (attribute == d_ptr->m_readOnlyAttribute)
  1364. return stringManager->isReadOnly(internProp);
  1365. return QVariant();
  1366. } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
  1367. if (attribute == d_ptr->m_maximumAttribute)
  1368. return dateManager->maximum(internProp);
  1369. if (attribute == d_ptr->m_minimumAttribute)
  1370. return dateManager->minimum(internProp);
  1371. return QVariant();
  1372. } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
  1373. if (attribute == d_ptr->m_decimalsAttribute)
  1374. return pointFManager->decimals(internProp);
  1375. return QVariant();
  1376. } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
  1377. if (attribute == d_ptr->m_maximumAttribute)
  1378. return sizeManager->maximum(internProp);
  1379. if (attribute == d_ptr->m_minimumAttribute)
  1380. return sizeManager->minimum(internProp);
  1381. return QVariant();
  1382. } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
  1383. if (attribute == d_ptr->m_maximumAttribute)
  1384. return sizeFManager->maximum(internProp);
  1385. if (attribute == d_ptr->m_minimumAttribute)
  1386. return sizeFManager->minimum(internProp);
  1387. if (attribute == d_ptr->m_decimalsAttribute)
  1388. return sizeFManager->decimals(internProp);
  1389. return QVariant();
  1390. } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
  1391. if (attribute == d_ptr->m_constraintAttribute)
  1392. return rectManager->constraint(internProp);
  1393. return QVariant();
  1394. } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
  1395. if (attribute == d_ptr->m_constraintAttribute)
  1396. return rectFManager->constraint(internProp);
  1397. if (attribute == d_ptr->m_decimalsAttribute)
  1398. return rectFManager->decimals(internProp);
  1399. return QVariant();
  1400. } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
  1401. if (attribute == d_ptr->m_enumNamesAttribute)
  1402. return enumManager->enumNames(internProp);
  1403. if (attribute == d_ptr->m_enumIconsAttribute) {
  1404. QVariant v;
  1405. qVariantSetValue(v, enumManager->enumIcons(internProp));
  1406. return v;
  1407. }
  1408. return QVariant();
  1409. } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
  1410. if (attribute == d_ptr->m_flagNamesAttribute)
  1411. return flagManager->flagNames(internProp);
  1412. return QVariant();
  1413. }
  1414. return QVariant();
  1415. }
  1416. /*!
  1417. Returns a list of the given \a propertyType 's attributes.
  1418. \sa attributeValue(), attributeType()
  1419. */
  1420. QStringList QtVariantPropertyManager::attributes(int propertyType) const
  1421. {
  1422. QMap<int, QMap<QString, int> >::ConstIterator it =
  1423. d_ptr->m_typeToAttributeToAttributeType.find(propertyType);
  1424. if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd())
  1425. return QStringList();
  1426. return it.value().keys();
  1427. }
  1428. /*!
  1429. Returns the type of the specified \a attribute of the given \a
  1430. propertyType.
  1431. If the given \a propertyType is not supported by \e this manager,
  1432. or if the given \a propertyType does not possess the specified \a
  1433. attribute, this function returns QVariant::Invalid.
  1434. \sa attributes(), valueType()
  1435. */
  1436. int QtVariantPropertyManager::attributeType(int propertyType, const QString &attribute) const
  1437. {
  1438. QMap<int, QMap<QString, int> >::ConstIterator it =
  1439. d_ptr->m_typeToAttributeToAttributeType.find(propertyType);
  1440. if (it == d_ptr->m_typeToAttributeToAttributeType.constEnd())
  1441. return 0;
  1442. QMap<QString, int> attributes = it.value();
  1443. QMap<QString, int>::ConstIterator itAttr = attributes.find(attribute);
  1444. if (itAttr == attributes.constEnd())
  1445. return 0;
  1446. return itAttr.value();
  1447. }
  1448. /*!
  1449. \fn void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &value)
  1450. Sets the value of the given \a property to \a value.
  1451. The specified \a value must be of a type returned by valueType(),
  1452. or of type that can be converted to valueType() using the
  1453. QVariant::canConvert() function, otherwise this function does
  1454. nothing.
  1455. \sa value(), QtVariantProperty::setValue(), valueChanged()
  1456. */
  1457. // 根据属性的数据类型,调用不同的属性管理器来设置值
  1458. void QtVariantPropertyManager::setValue(QtProperty *property, const QVariant &val)
  1459. {
  1460. int propType = val.userType();
  1461. if (!propType)
  1462. return;
  1463. int valType = valueType(property);
  1464. if (propType != valType && !val.canConvert(static_cast<QVariant::Type>(valType)))
  1465. return;
  1466. QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
  1467. if (internProp == 0)
  1468. return;
  1469. QtAbstractPropertyManager *manager = internProp->propertyManager();
  1470. if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
  1471. intManager->setValue(internProp, qvariant_cast<int>(val));
  1472. return;
  1473. } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
  1474. doubleManager->setValue(internProp, qvariant_cast<double>(val));
  1475. return;
  1476. } else if (QtBoolPropertyManager *boolManager = qobject_cast<QtBoolPropertyManager *>(manager)) {
  1477. boolManager->setValue(internProp, qvariant_cast<bool>(val));
  1478. return;
  1479. } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
  1480. stringManager->setValue(internProp, qvariant_cast<QString>(val));
  1481. return;
  1482. } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
  1483. dateManager->setValue(internProp, qvariant_cast<QDate>(val));
  1484. return;
  1485. } else if (QtTimePropertyManager *timeManager = qobject_cast<QtTimePropertyManager *>(manager)) {
  1486. timeManager->setValue(internProp, qvariant_cast<QTime>(val));
  1487. return;
  1488. } else if (QtDateTimePropertyManager *dateTimeManager = qobject_cast<QtDateTimePropertyManager *>(manager)) {
  1489. dateTimeManager->setValue(internProp, qvariant_cast<QDateTime>(val));
  1490. return;
  1491. } else if (QtKeySequencePropertyManager *keySequenceManager = qobject_cast<QtKeySequencePropertyManager *>(manager)) {
  1492. keySequenceManager->setValue(internProp, qvariant_cast<QKeySequence>(val));
  1493. return;
  1494. } else if (QtCharPropertyManager *charManager = qobject_cast<QtCharPropertyManager *>(manager)) {
  1495. charManager->setValue(internProp, qvariant_cast<QChar>(val));
  1496. return;
  1497. } else if (QtLocalePropertyManager *localeManager = qobject_cast<QtLocalePropertyManager *>(manager)) {
  1498. localeManager->setValue(internProp, qvariant_cast<QLocale>(val));
  1499. return;
  1500. } else if (QtPointPropertyManager *pointManager = qobject_cast<QtPointPropertyManager *>(manager)) {
  1501. pointManager->setValue(internProp, qvariant_cast<QPoint>(val));
  1502. return;
  1503. } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
  1504. pointFManager->setValue(internProp, qvariant_cast<QPointF>(val));
  1505. return;
  1506. } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
  1507. sizeManager->setValue(internProp, qvariant_cast<QSize>(val));
  1508. return;
  1509. } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
  1510. sizeFManager->setValue(internProp, qvariant_cast<QSizeF>(val));
  1511. return;
  1512. } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
  1513. rectManager->setValue(internProp, qvariant_cast<QRect>(val));
  1514. return;
  1515. } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
  1516. rectFManager->setValue(internProp, qvariant_cast<QRectF>(val));
  1517. return;
  1518. } else if (QtColorPropertyManager *colorManager = qobject_cast<QtColorPropertyManager *>(manager)) {
  1519. colorManager->setValue(internProp, qvariant_cast<QColor>(val));
  1520. return;
  1521. } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
  1522. enumManager->setValue(internProp, qvariant_cast<int>(val));
  1523. return;
  1524. } else if (QtSizePolicyPropertyManager *sizePolicyManager =
  1525. qobject_cast<QtSizePolicyPropertyManager *>(manager)) {
  1526. sizePolicyManager->setValue(internProp, qvariant_cast<QSizePolicy>(val));
  1527. return;
  1528. } else if (QtFontPropertyManager *fontManager = qobject_cast<QtFontPropertyManager *>(manager)) {
  1529. fontManager->setValue(internProp, qvariant_cast<QFont>(val));
  1530. return;
  1531. #ifndef QT_NO_CURSOR
  1532. } else if (QtCursorPropertyManager *cursorManager = qobject_cast<QtCursorPropertyManager *>(manager)) {
  1533. cursorManager->setValue(internProp, qvariant_cast<QCursor>(val));
  1534. return;
  1535. #endif
  1536. } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
  1537. flagManager->setValue(internProp, qvariant_cast<int>(val));
  1538. return;
  1539. }
  1540. }
  1541. /*!
  1542. Sets the value of the specified \a attribute of the given \a
  1543. property, to \a value.
  1544. The new \a value's type must be of the type returned by
  1545. attributeType(), or of a type that can be converted to
  1546. attributeType() using the QVariant::canConvert() function,
  1547. otherwise this function does nothing.
  1548. \sa attributeValue(), QtVariantProperty::setAttribute(), attributeChanged()
  1549. */
  1550. void QtVariantPropertyManager::setAttribute(QtProperty *property,
  1551. const QString &attribute, const QVariant &value)
  1552. {
  1553. QVariant oldAttr = attributeValue(property, attribute);
  1554. if (!oldAttr.isValid())
  1555. return;
  1556. int attrType = value.userType();
  1557. if (!attrType)
  1558. return;
  1559. if (attrType != attributeType(propertyType(property), attribute) &&
  1560. !value.canConvert((QVariant::Type)attrType))
  1561. return;
  1562. QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
  1563. if (internProp == 0)
  1564. return;
  1565. QtAbstractPropertyManager *manager = internProp->propertyManager();
  1566. if (QtIntPropertyManager *intManager = qobject_cast<QtIntPropertyManager *>(manager)) {
  1567. if (attribute == d_ptr->m_maximumAttribute)
  1568. intManager->setMaximum(internProp, qvariant_cast<int>(value));
  1569. else if (attribute == d_ptr->m_minimumAttribute)
  1570. intManager->setMinimum(internProp, qvariant_cast<int>(value));
  1571. else if (attribute == d_ptr->m_singleStepAttribute)
  1572. intManager->setSingleStep(internProp, qvariant_cast<int>(value));
  1573. return;
  1574. } else if (QtDoublePropertyManager *doubleManager = qobject_cast<QtDoublePropertyManager *>(manager)) {
  1575. if (attribute == d_ptr->m_maximumAttribute)
  1576. doubleManager->setMaximum(internProp, qvariant_cast<double>(value));
  1577. if (attribute == d_ptr->m_minimumAttribute)
  1578. doubleManager->setMinimum(internProp, qvariant_cast<double>(value));
  1579. if (attribute == d_ptr->m_singleStepAttribute)
  1580. doubleManager->setSingleStep(internProp, qvariant_cast<double>(value));
  1581. if (attribute == d_ptr->m_decimalsAttribute)
  1582. doubleManager->setDecimals(internProp, qvariant_cast<int>(value));
  1583. return;
  1584. } else if (QtStringPropertyManager *stringManager = qobject_cast<QtStringPropertyManager *>(manager)) {
  1585. if (attribute == d_ptr->m_regExpAttribute)
  1586. stringManager->setRegExp(internProp, qvariant_cast<QRegExp>(value));
  1587. return;
  1588. } else if (QtDatePropertyManager *dateManager = qobject_cast<QtDatePropertyManager *>(manager)) {
  1589. if (attribute == d_ptr->m_maximumAttribute)
  1590. dateManager->setMaximum(internProp, qvariant_cast<QDate>(value));
  1591. if (attribute == d_ptr->m_minimumAttribute)
  1592. dateManager->setMinimum(internProp, qvariant_cast<QDate>(value));
  1593. return;
  1594. } else if (QtPointFPropertyManager *pointFManager = qobject_cast<QtPointFPropertyManager *>(manager)) {
  1595. if (attribute == d_ptr->m_decimalsAttribute)
  1596. pointFManager->setDecimals(internProp, qvariant_cast<int>(value));
  1597. return;
  1598. } else if (QtSizePropertyManager *sizeManager = qobject_cast<QtSizePropertyManager *>(manager)) {
  1599. if (attribute == d_ptr->m_maximumAttribute)
  1600. sizeManager->setMaximum(internProp, qvariant_cast<QSize>(value));
  1601. if (attribute == d_ptr->m_minimumAttribute)
  1602. sizeManager->setMinimum(internProp, qvariant_cast<QSize>(value));
  1603. return;
  1604. } else if (QtSizeFPropertyManager *sizeFManager = qobject_cast<QtSizeFPropertyManager *>(manager)) {
  1605. if (attribute == d_ptr->m_maximumAttribute)
  1606. sizeFManager->setMaximum(internProp, qvariant_cast<QSizeF>(value));
  1607. if (attribute == d_ptr->m_minimumAttribute)
  1608. sizeFManager->setMinimum(internProp, qvariant_cast<QSizeF>(value));
  1609. if (attribute == d_ptr->m_decimalsAttribute)
  1610. sizeFManager->setDecimals(internProp, qvariant_cast<int>(value));
  1611. return;
  1612. } else if (QtRectPropertyManager *rectManager = qobject_cast<QtRectPropertyManager *>(manager)) {
  1613. if (attribute == d_ptr->m_constraintAttribute)
  1614. rectManager->setConstraint(internProp, qvariant_cast<QRect>(value));
  1615. return;
  1616. } else if (QtRectFPropertyManager *rectFManager = qobject_cast<QtRectFPropertyManager *>(manager)) {
  1617. if (attribute == d_ptr->m_constraintAttribute)
  1618. rectFManager->setConstraint(internProp, qvariant_cast<QRectF>(value));
  1619. if (attribute == d_ptr->m_decimalsAttribute)
  1620. rectFManager->setDecimals(internProp, qvariant_cast<int>(value));
  1621. return;
  1622. } else if (QtEnumPropertyManager *enumManager = qobject_cast<QtEnumPropertyManager *>(manager)) {
  1623. if (attribute == d_ptr->m_enumNamesAttribute)
  1624. enumManager->setEnumNames(internProp, qvariant_cast<QStringList>(value));
  1625. if (attribute == d_ptr->m_enumIconsAttribute)
  1626. enumManager->setEnumIcons(internProp, qvariant_cast<QtIconMap>(value));
  1627. return;
  1628. } else if (QtFlagPropertyManager *flagManager = qobject_cast<QtFlagPropertyManager *>(manager)) {
  1629. if (attribute == d_ptr->m_flagNamesAttribute)
  1630. flagManager->setFlagNames(internProp, qvariant_cast<QStringList>(value));
  1631. return;
  1632. }
  1633. }
  1634. /*!
  1635. \reimp
  1636. */
  1637. bool QtVariantPropertyManager::hasValue(const QtProperty *property) const
  1638. {
  1639. if (propertyType(property) == groupTypeId())
  1640. return false;
  1641. return true;
  1642. }
  1643. /*!
  1644. \reimp
  1645. */
  1646. QString QtVariantPropertyManager::valueText(const QtProperty *property) const
  1647. {
  1648. const QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
  1649. return internProp ? !internProp->displayText().isEmpty() ? internProp->displayText() : internProp->valueText() : QString();
  1650. }
  1651. /*!
  1652. \reimp
  1653. */
  1654. QIcon QtVariantPropertyManager::valueIcon(const QtProperty *property) const
  1655. {
  1656. const QtProperty *internProp = propertyToWrappedProperty()->value(property, 0);
  1657. return internProp ? internProp->valueIcon() : QIcon();
  1658. }
  1659. /*!
  1660. \reimp
  1661. */
  1662. // 属性初始化
  1663. void QtVariantPropertyManager::initializeProperty(QtProperty *property)
  1664. {
  1665. QtVariantProperty *varProp = variantProperty(property);
  1666. if (!varProp)
  1667. return;
  1668. QMap<int, QtAbstractPropertyManager *>::ConstIterator it =
  1669. d_ptr->m_typeToPropertyManager.find(d_ptr->m_propertyType);
  1670. if (it != d_ptr->m_typeToPropertyManager.constEnd()) {
  1671. QtProperty *internProp = 0;
  1672. if (!d_ptr->m_creatingSubProperties) {
  1673. QtAbstractPropertyManager *manager = it.value();
  1674. internProp = manager->addProperty();
  1675. d_ptr->m_internalToProperty[internProp] = varProp;
  1676. }
  1677. // 添加此属性
  1678. propertyToWrappedProperty()->insert(varProp, internProp);
  1679. // 属性是否带有内部属性值
  1680. if (internProp)
  1681. {
  1682. // 遍历所有的内部属性值
  1683. QList<QtProperty *> children = internProp->subProperties();
  1684. QListIterator<QtProperty *> itChild(children);
  1685. QtVariantProperty *lastProperty = 0;
  1686. // 逐一将内部子属性值添加到列表中
  1687. while (itChild.hasNext()) {
  1688. QtVariantProperty *prop = d_ptr->createSubProperty(varProp, lastProperty, itChild.next());
  1689. lastProperty = prop ? prop : lastProperty;
  1690. }
  1691. }
  1692. }
  1693. }
  1694. /*!
  1695. \reimp
  1696. */
  1697. void QtVariantPropertyManager::uninitializeProperty(QtProperty *property)
  1698. {
  1699. const QMap<const QtProperty *, QPair<QtVariantProperty *, int> >::iterator type_it = d_ptr->m_propertyToType.find(property);
  1700. if (type_it == d_ptr->m_propertyToType.end())
  1701. return;
  1702. PropertyMap::iterator it = propertyToWrappedProperty()->find(property);
  1703. if (it != propertyToWrappedProperty()->end()) {
  1704. QtProperty *internProp = it.value();
  1705. if (internProp) {
  1706. d_ptr->m_internalToProperty.remove(internProp);
  1707. if (!d_ptr->m_destroyingSubProperties) {
  1708. delete internProp;
  1709. }
  1710. }
  1711. propertyToWrappedProperty()->erase(it);
  1712. }
  1713. d_ptr->m_propertyToType.erase(type_it);
  1714. }
  1715. /*!
  1716. \reimp
  1717. */
  1718. QtProperty *QtVariantPropertyManager::createProperty()
  1719. {
  1720. if (!d_ptr->m_creatingProperty)
  1721. return 0;
  1722. QtVariantProperty *property = new QtVariantProperty(this);
  1723. d_ptr->m_propertyToType.insert(property, qMakePair(property, d_ptr->m_propertyType));
  1724. return property;
  1725. }
  1726. /////////////////////////////
  1727. class QtVariantEditorFactoryPrivate
  1728. {
  1729. QtVariantEditorFactory *q_ptr = nullptr;
  1730. Q_DECLARE_PUBLIC(QtVariantEditorFactory)
  1731. public:
  1732. QtSpinBoxFactory *m_spinBoxFactory = nullptr;
  1733. QtDoubleSpinBoxFactory *m_doubleSpinBoxFactory = nullptr;
  1734. QtCheckBoxFactory *m_checkBoxFactory = nullptr;
  1735. QtLineEditFactory *m_lineEditFactory = nullptr;
  1736. QtDateEditFactory *m_dateEditFactory = nullptr;
  1737. QtTimeEditFactory *m_timeEditFactory = nullptr;
  1738. QtDateTimeEditFactory *m_dateTimeEditFactory = nullptr;
  1739. QtKeySequenceEditorFactory *m_keySequenceEditorFactory = nullptr;
  1740. QtCharEditorFactory *m_charEditorFactory = nullptr;
  1741. QtEnumEditorFactory *m_comboBoxFactory = nullptr;
  1742. QtCursorEditorFactory *m_cursorEditorFactory = nullptr;
  1743. QtColorEditorFactory *m_colorEditorFactory = nullptr;
  1744. QtFontEditorFactory *m_fontEditorFactory = nullptr;
  1745. QMap<QtAbstractEditorFactoryBase *, int> m_factoryToType;
  1746. QMap<int, QtAbstractEditorFactoryBase *> m_typeToFactory;
  1747. };
  1748. /*!
  1749. \class QtVariantEditorFactory
  1750. \brief The QtVariantEditorFactory class provides widgets for properties
  1751. created by QtVariantPropertyManager objects.
  1752. The variant factory provides the following widgets for the
  1753. specified property types:
  1754. \table
  1755. \header
  1756. \o Property Type
  1757. \o Widget
  1758. \row
  1759. \o \c int
  1760. \o QSpinBox
  1761. \row
  1762. \o \c double
  1763. \o QDoubleSpinBox
  1764. \row
  1765. \o \c bool
  1766. \o QCheckBox
  1767. \row
  1768. \o QString
  1769. \o QLineEdit
  1770. \row
  1771. \o QDate
  1772. \o QDateEdit
  1773. \row
  1774. \o QTime
  1775. \o QTimeEdit
  1776. \row
  1777. \o QDateTime
  1778. \o QDateTimeEdit
  1779. \row
  1780. \o QKeySequence
  1781. \o customized editor
  1782. \row
  1783. \o QChar
  1784. \o customized editor
  1785. \row
  1786. \o \c enum
  1787. \o QComboBox
  1788. \row
  1789. \o QCursor
  1790. \o QComboBox
  1791. \endtable
  1792. Note that QtVariantPropertyManager supports several additional property
  1793. types for which the QtVariantEditorFactory class does not provide
  1794. editing widgets, e.g. QPoint and QSize. To provide widgets for other
  1795. types using the variant approach, derive from the QtVariantEditorFactory
  1796. class.
  1797. \sa QtAbstractEditorFactory, QtVariantPropertyManager
  1798. */
  1799. /*!
  1800. Creates a factory with the given \a parent.
  1801. */
  1802. QtVariantEditorFactory::QtVariantEditorFactory(QObject *parent)
  1803. : QtAbstractEditorFactory<QtVariantPropertyManager>(parent)
  1804. {
  1805. d_ptr = new QtVariantEditorFactoryPrivate();
  1806. d_ptr->q_ptr = this;
  1807. d_ptr->m_spinBoxFactory = new QtSpinBoxFactory(this);
  1808. d_ptr->m_factoryToType[d_ptr->m_spinBoxFactory] = QVariant::Int;
  1809. d_ptr->m_typeToFactory[QVariant::Int] = d_ptr->m_spinBoxFactory;
  1810. d_ptr->m_doubleSpinBoxFactory = new QtDoubleSpinBoxFactory(this);
  1811. d_ptr->m_factoryToType[d_ptr->m_doubleSpinBoxFactory] = QVariant::Double;
  1812. d_ptr->m_typeToFactory[QVariant::Double] = d_ptr->m_doubleSpinBoxFactory;
  1813. d_ptr->m_checkBoxFactory = new QtCheckBoxFactory(this);
  1814. d_ptr->m_factoryToType[d_ptr->m_checkBoxFactory] = QVariant::Bool;
  1815. d_ptr->m_typeToFactory[QVariant::Bool] = d_ptr->m_checkBoxFactory;
  1816. d_ptr->m_lineEditFactory = new QtLineEditFactory(this);
  1817. d_ptr->m_factoryToType[d_ptr->m_lineEditFactory] = QVariant::String;
  1818. d_ptr->m_typeToFactory[QVariant::String] = d_ptr->m_lineEditFactory;
  1819. d_ptr->m_dateEditFactory = new QtDateEditFactory(this);
  1820. d_ptr->m_factoryToType[d_ptr->m_dateEditFactory] = QVariant::Date;
  1821. d_ptr->m_typeToFactory[QVariant::Date] = d_ptr->m_dateEditFactory;
  1822. d_ptr->m_timeEditFactory = new QtTimeEditFactory(this);
  1823. d_ptr->m_factoryToType[d_ptr->m_timeEditFactory] = QVariant::Time;
  1824. d_ptr->m_typeToFactory[QVariant::Time] = d_ptr->m_timeEditFactory;
  1825. d_ptr->m_dateTimeEditFactory = new QtDateTimeEditFactory(this);
  1826. d_ptr->m_factoryToType[d_ptr->m_dateTimeEditFactory] = QVariant::DateTime;
  1827. d_ptr->m_typeToFactory[QVariant::DateTime] = d_ptr->m_dateTimeEditFactory;
  1828. d_ptr->m_keySequenceEditorFactory = new QtKeySequenceEditorFactory(this);
  1829. d_ptr->m_factoryToType[d_ptr->m_keySequenceEditorFactory] = QVariant::KeySequence;
  1830. d_ptr->m_typeToFactory[QVariant::KeySequence] = d_ptr->m_keySequenceEditorFactory;
  1831. d_ptr->m_charEditorFactory = new QtCharEditorFactory(this);
  1832. d_ptr->m_factoryToType[d_ptr->m_charEditorFactory] = QVariant::Char;
  1833. d_ptr->m_typeToFactory[QVariant::Char] = d_ptr->m_charEditorFactory;
  1834. d_ptr->m_cursorEditorFactory = new QtCursorEditorFactory(this);
  1835. d_ptr->m_factoryToType[d_ptr->m_cursorEditorFactory] = QVariant::Cursor;
  1836. d_ptr->m_typeToFactory[QVariant::Cursor] = d_ptr->m_cursorEditorFactory;
  1837. d_ptr->m_colorEditorFactory = new QtColorEditorFactory(this);
  1838. d_ptr->m_factoryToType[d_ptr->m_colorEditorFactory] = QVariant::Color;
  1839. d_ptr->m_typeToFactory[QVariant::Color] = d_ptr->m_colorEditorFactory;
  1840. d_ptr->m_fontEditorFactory = new QtFontEditorFactory(this);
  1841. d_ptr->m_factoryToType[d_ptr->m_fontEditorFactory] = QVariant::Font;
  1842. d_ptr->m_typeToFactory[QVariant::Font] = d_ptr->m_fontEditorFactory;
  1843. d_ptr->m_comboBoxFactory = new QtEnumEditorFactory(this);
  1844. const int enumId = QtVariantPropertyManager::enumTypeId();
  1845. d_ptr->m_factoryToType[d_ptr->m_comboBoxFactory] = enumId;
  1846. d_ptr->m_typeToFactory[enumId] = d_ptr->m_comboBoxFactory;
  1847. }
  1848. /*!
  1849. Destroys this factory, and all the widgets it has created.
  1850. */
  1851. QtVariantEditorFactory::~QtVariantEditorFactory()
  1852. {
  1853. delete d_ptr;
  1854. }
  1855. /*!
  1856. \internal
  1857. Reimplemented from the QtAbstractEditorFactory class.
  1858. */
  1859. void QtVariantEditorFactory::connectPropertyManager(QtVariantPropertyManager *manager)
  1860. {
  1861. const QList<QtIntPropertyManager *> intPropertyManagers = manager->findChildren<QtIntPropertyManager *>();
  1862. for (QtIntPropertyManager *manager : intPropertyManagers)
  1863. d_ptr->m_spinBoxFactory->addPropertyManager(manager);
  1864. const QList<QtDoublePropertyManager *> doublePropertyManagers = manager->findChildren<QtDoublePropertyManager *>();
  1865. for (QtDoublePropertyManager *manager : doublePropertyManagers)
  1866. d_ptr->m_doubleSpinBoxFactory->addPropertyManager(manager);
  1867. const QList<QtBoolPropertyManager *> boolPropertyManagers = manager->findChildren<QtBoolPropertyManager *>();
  1868. for (QtBoolPropertyManager *manager : boolPropertyManagers)
  1869. d_ptr->m_checkBoxFactory->addPropertyManager(manager);
  1870. const QList<QtStringPropertyManager *> stringPropertyManagers = manager->findChildren<QtStringPropertyManager *>();
  1871. for (QtStringPropertyManager *manager : stringPropertyManagers)
  1872. d_ptr->m_lineEditFactory->addPropertyManager(manager);
  1873. const QList<QtDatePropertyManager *> datePropertyManagers = manager->findChildren<QtDatePropertyManager *>();
  1874. for (QtDatePropertyManager *manager : datePropertyManagers)
  1875. d_ptr->m_dateEditFactory->addPropertyManager(manager);
  1876. const QList<QtTimePropertyManager *> timePropertyManagers = manager->findChildren<QtTimePropertyManager *>();
  1877. for (QtTimePropertyManager *manager : timePropertyManagers)
  1878. d_ptr->m_timeEditFactory->addPropertyManager(manager);
  1879. const QList<QtDateTimePropertyManager *> dateTimePropertyManagers = manager->findChildren<QtDateTimePropertyManager *>();
  1880. for (QtDateTimePropertyManager *manager : dateTimePropertyManagers)
  1881. d_ptr->m_dateTimeEditFactory->addPropertyManager(manager);
  1882. const QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = manager->findChildren<QtKeySequencePropertyManager *>();
  1883. for (QtKeySequencePropertyManager *manager : keySequencePropertyManagers)
  1884. d_ptr->m_keySequenceEditorFactory->addPropertyManager(manager);
  1885. const QList<QtCharPropertyManager *> charPropertyManagers = manager->findChildren<QtCharPropertyManager *>();
  1886. for (QtCharPropertyManager *manager : charPropertyManagers)
  1887. d_ptr->m_charEditorFactory->addPropertyManager(manager);
  1888. const QList<QtLocalePropertyManager *> localePropertyManagers = manager->findChildren<QtLocalePropertyManager *>();
  1889. for (QtLocalePropertyManager *manager : localePropertyManagers)
  1890. d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager());
  1891. const QList<QtPointPropertyManager *> pointPropertyManagers = manager->findChildren<QtPointPropertyManager *>();
  1892. for (QtPointPropertyManager *manager : pointPropertyManagers)
  1893. d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager());
  1894. const QList<QtPointFPropertyManager *> pointFPropertyManagers = manager->findChildren<QtPointFPropertyManager *>();
  1895. for (QtPointFPropertyManager *manager : pointFPropertyManagers)
  1896. d_ptr->m_doubleSpinBoxFactory->addPropertyManager(manager->subDoublePropertyManager());
  1897. const QList<QtSizePropertyManager *> sizePropertyManagers = manager->findChildren<QtSizePropertyManager *>();
  1898. for (QtSizePropertyManager *manager : sizePropertyManagers)
  1899. d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager());
  1900. const QList<QtSizeFPropertyManager *> sizeFPropertyManagers = manager->findChildren<QtSizeFPropertyManager *>();
  1901. for (QtSizeFPropertyManager *manager : sizeFPropertyManagers)
  1902. d_ptr->m_doubleSpinBoxFactory->addPropertyManager(manager->subDoublePropertyManager());
  1903. const QList<QtRectPropertyManager *> rectPropertyManagers = manager->findChildren<QtRectPropertyManager *>();
  1904. for (QtRectPropertyManager *manager : rectPropertyManagers)
  1905. d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager());
  1906. const QList<QtRectFPropertyManager *> rectFPropertyManagers = manager->findChildren<QtRectFPropertyManager *>();
  1907. for (QtRectFPropertyManager *manager : rectFPropertyManagers)
  1908. d_ptr->m_doubleSpinBoxFactory->addPropertyManager(manager->subDoublePropertyManager());
  1909. const QList<QtColorPropertyManager *> colorPropertyManagers = manager->findChildren<QtColorPropertyManager *>();
  1910. for (QtColorPropertyManager *manager : colorPropertyManagers) {
  1911. d_ptr->m_colorEditorFactory->addPropertyManager(manager);
  1912. d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager());
  1913. }
  1914. const QList<QtEnumPropertyManager *> enumPropertyManagers = manager->findChildren<QtEnumPropertyManager *>();
  1915. for (QtEnumPropertyManager *manager : enumPropertyManagers)
  1916. d_ptr->m_comboBoxFactory->addPropertyManager(manager);
  1917. const QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = manager->findChildren<QtSizePolicyPropertyManager *>();
  1918. for (QtSizePolicyPropertyManager *manager : sizePolicyPropertyManagers) {
  1919. d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager());
  1920. d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager());
  1921. }
  1922. const QList<QtFontPropertyManager *> fontPropertyManagers = manager->findChildren<QtFontPropertyManager *>();
  1923. for (QtFontPropertyManager *manager : fontPropertyManagers) {
  1924. d_ptr->m_fontEditorFactory->addPropertyManager(manager);
  1925. d_ptr->m_spinBoxFactory->addPropertyManager(manager->subIntPropertyManager());
  1926. d_ptr->m_comboBoxFactory->addPropertyManager(manager->subEnumPropertyManager());
  1927. d_ptr->m_checkBoxFactory->addPropertyManager(manager->subBoolPropertyManager());
  1928. }
  1929. const QList<QtCursorPropertyManager *> cursorPropertyManagers = manager->findChildren<QtCursorPropertyManager *>();
  1930. for (QtCursorPropertyManager *manager : cursorPropertyManagers)
  1931. d_ptr->m_cursorEditorFactory->addPropertyManager(manager);
  1932. const QList<QtFlagPropertyManager *> flagPropertyManagers = manager->findChildren<QtFlagPropertyManager *>();
  1933. for (QtFlagPropertyManager *manager : flagPropertyManagers)
  1934. d_ptr->m_checkBoxFactory->addPropertyManager(manager->subBoolPropertyManager());
  1935. }
  1936. /*!
  1937. \internal
  1938. Reimplemented from the QtAbstractEditorFactory class.
  1939. */
  1940. QWidget *QtVariantEditorFactory::createEditor(QtVariantPropertyManager *manager, QtProperty *property,
  1941. QWidget *parent)
  1942. {
  1943. const int propType = manager->propertyType(property);
  1944. QtAbstractEditorFactoryBase *factory = d_ptr->m_typeToFactory.value(propType, 0);
  1945. if (!factory)
  1946. return 0;
  1947. return factory->createEditor(wrappedProperty(property), parent);
  1948. }
  1949. /*!
  1950. \internal
  1951. Reimplemented from the QtAbstractEditorFactory class.
  1952. */
  1953. void QtVariantEditorFactory::disconnectPropertyManager(QtVariantPropertyManager *manager)
  1954. {
  1955. const QList<QtIntPropertyManager *> intPropertyManagers = manager->findChildren<QtIntPropertyManager *>();
  1956. for (QtIntPropertyManager *manager : intPropertyManagers)
  1957. d_ptr->m_spinBoxFactory->removePropertyManager(manager);
  1958. const QList<QtDoublePropertyManager *> doublePropertyManagers = manager->findChildren<QtDoublePropertyManager *>();
  1959. for (QtDoublePropertyManager *manager : doublePropertyManagers)
  1960. d_ptr->m_doubleSpinBoxFactory->removePropertyManager(manager);
  1961. const QList<QtBoolPropertyManager *> boolPropertyManagers = manager->findChildren<QtBoolPropertyManager *>();
  1962. for (QtBoolPropertyManager *manager : boolPropertyManagers)
  1963. d_ptr->m_checkBoxFactory->removePropertyManager(manager);
  1964. const QList<QtStringPropertyManager *> stringPropertyManagers = manager->findChildren<QtStringPropertyManager *>();
  1965. for (QtStringPropertyManager *manager : stringPropertyManagers)
  1966. d_ptr->m_lineEditFactory->removePropertyManager(manager);
  1967. const QList<QtDatePropertyManager *> datePropertyManagers = manager->findChildren<QtDatePropertyManager *>();
  1968. for (QtDatePropertyManager *manager : datePropertyManagers)
  1969. d_ptr->m_dateEditFactory->removePropertyManager(manager);
  1970. const QList<QtTimePropertyManager *> timePropertyManagers = manager->findChildren<QtTimePropertyManager *>();
  1971. for (QtTimePropertyManager *manager : timePropertyManagers)
  1972. d_ptr->m_timeEditFactory->removePropertyManager(manager);
  1973. const QList<QtDateTimePropertyManager *> dateTimePropertyManagers = manager->findChildren<QtDateTimePropertyManager *>();
  1974. for (QtDateTimePropertyManager *manager : dateTimePropertyManagers)
  1975. d_ptr->m_dateTimeEditFactory->removePropertyManager(manager);
  1976. const QList<QtKeySequencePropertyManager *> keySequencePropertyManagers = manager->findChildren<QtKeySequencePropertyManager *>();
  1977. for (QtKeySequencePropertyManager *manager : keySequencePropertyManagers)
  1978. d_ptr->m_keySequenceEditorFactory->removePropertyManager(manager);
  1979. const QList<QtCharPropertyManager *> charPropertyManagers = manager->findChildren<QtCharPropertyManager *>();
  1980. for (QtCharPropertyManager *manager : charPropertyManagers)
  1981. d_ptr->m_charEditorFactory->removePropertyManager(manager);
  1982. const QList<QtLocalePropertyManager *> localePropertyManagers = manager->findChildren<QtLocalePropertyManager *>();
  1983. for (QtLocalePropertyManager *manager : localePropertyManagers)
  1984. d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager());
  1985. const QList<QtPointPropertyManager *> pointPropertyManagers = manager->findChildren<QtPointPropertyManager *>();
  1986. for (QtPointPropertyManager *manager : pointPropertyManagers)
  1987. d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager());
  1988. const QList<QtPointFPropertyManager *> pointFPropertyManagers = manager->findChildren<QtPointFPropertyManager *>();
  1989. for (QtPointFPropertyManager *manager : pointFPropertyManagers)
  1990. d_ptr->m_doubleSpinBoxFactory->removePropertyManager(manager->subDoublePropertyManager());
  1991. const QList<QtSizePropertyManager *> sizePropertyManagers = manager->findChildren<QtSizePropertyManager *>();
  1992. for (QtSizePropertyManager *manager : sizePropertyManagers)
  1993. d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager());
  1994. const QList<QtSizeFPropertyManager *> sizeFPropertyManagers = manager->findChildren<QtSizeFPropertyManager *>();
  1995. for (QtSizeFPropertyManager *manager : sizeFPropertyManagers)
  1996. d_ptr->m_doubleSpinBoxFactory->removePropertyManager(manager->subDoublePropertyManager());
  1997. const QList<QtRectPropertyManager *> rectPropertyManagers = manager->findChildren<QtRectPropertyManager *>();
  1998. for (QtRectPropertyManager *manager : rectPropertyManagers)
  1999. d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager());
  2000. const QList<QtRectFPropertyManager *> rectFPropertyManagers = manager->findChildren<QtRectFPropertyManager *>();
  2001. for (QtRectFPropertyManager *manager : rectFPropertyManagers)
  2002. d_ptr->m_doubleSpinBoxFactory->removePropertyManager(manager->subDoublePropertyManager());
  2003. const QList<QtColorPropertyManager *> colorPropertyManagers = manager->findChildren<QtColorPropertyManager *>();
  2004. for (QtColorPropertyManager *manager : colorPropertyManagers) {
  2005. d_ptr->m_colorEditorFactory->removePropertyManager(manager);
  2006. d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager());
  2007. }
  2008. const QList<QtEnumPropertyManager *> enumPropertyManagers = manager->findChildren<QtEnumPropertyManager *>();
  2009. for (QtEnumPropertyManager *manager : enumPropertyManagers)
  2010. d_ptr->m_comboBoxFactory->removePropertyManager(manager);
  2011. const QList<QtSizePolicyPropertyManager *> sizePolicyPropertyManagers = manager->findChildren<QtSizePolicyPropertyManager *>();
  2012. for (QtSizePolicyPropertyManager *manager : sizePolicyPropertyManagers) {
  2013. d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager());
  2014. d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager());
  2015. }
  2016. const QList<QtFontPropertyManager *> fontPropertyManagers = manager->findChildren<QtFontPropertyManager *>();
  2017. for (QtFontPropertyManager *manager : fontPropertyManagers) {
  2018. d_ptr->m_fontEditorFactory->removePropertyManager(manager);
  2019. d_ptr->m_spinBoxFactory->removePropertyManager(manager->subIntPropertyManager());
  2020. d_ptr->m_comboBoxFactory->removePropertyManager(manager->subEnumPropertyManager());
  2021. d_ptr->m_checkBoxFactory->removePropertyManager(manager->subBoolPropertyManager());
  2022. }
  2023. const QList<QtCursorPropertyManager *> cursorPropertyManagers = manager->findChildren<QtCursorPropertyManager *>();
  2024. for (QtCursorPropertyManager *manager : cursorPropertyManagers)
  2025. d_ptr->m_cursorEditorFactory->removePropertyManager(manager);
  2026. const QList<QtFlagPropertyManager *> flagPropertyManagers = manager->findChildren<QtFlagPropertyManager *>();
  2027. for (QtFlagPropertyManager *manager : flagPropertyManagers)
  2028. d_ptr->m_checkBoxFactory->removePropertyManager(manager->subBoolPropertyManager());
  2029. }
  2030. #if QT_VERSION >= 0x040400
  2031. QT_END_NAMESPACE
  2032. #endif
  2033. #include "moc_qtvariantproperty.cpp"