void QtDoubleSpinBoxFactory::slotSetValue(double value) { QObject *object = this->sender(); const QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itcend = m_editorToProperty.constEnd(); for (QMap<QDoubleSpinBox *, QtProperty *>::ConstIterator itEditor = m_editorToProperty.constBegin(); itEditor != itcend; ++itEditor) { if (itEditor.key() == object) { QtProperty *property = itEditor.value(); QtDoublePropertyManager *manager = this->propertyManager(property); if (!manager) return; manager->setValue(property, value); return; } } }
QWidget * BorderDrawersLoader::createEditor(BorderDrawerInterface * drawer, bool createCommands) { if (!drawer) return 0; QtTreePropertyBrowser * browser = new QtTreePropertyBrowser(); BorderChangeListener * listener = new BorderChangeListener(drawer, browser, createCommands); // QVariant type of property QtVariantPropertyManager * variantManager = 0; KVariantEditorFactory * variantFactory = 0; // Integer type of property QtIntPropertyManager * integerManager = 0; KSliderEditFactory * integerFactory = 0; // Double type of property QtDoublePropertyManager * doubleManager = 0; KDoubleSpinBoxFactory * doubleFactory = 0; const QMetaObject * meta = drawer->metaObject(); int propertiesCount = meta->propertyCount(); for (int i = 0; i < propertiesCount; ++i) { QMetaProperty metaProperty = meta->property(i); QString propertyName = drawer->propertyName(metaProperty); if (propertyName.isEmpty()) continue; QtProperty * property; switch (metaProperty.type()) { case QVariant::Int: { if (!integerManager || !integerFactory) { integerManager = new QtIntPropertyManager(browser); integerFactory = new KSliderEditFactory(browser); browser->setFactoryForManager(integerManager, integerFactory); } property = integerManager->addProperty(propertyName); integerManager->setValue(property, metaProperty.read(drawer).toInt()); integerManager->setMinimum(property, drawer->minimumValue(metaProperty).toInt()); integerManager->setMaximum(property, drawer->maximumValue(metaProperty).toInt()); } break; case QVariant::Double: { if (!doubleManager || !doubleFactory) { doubleManager = new QtDoublePropertyManager(browser); doubleFactory = new KDoubleSpinBoxFactory(browser); browser->setFactoryForManager(doubleManager, doubleFactory); } property = doubleManager->addProperty(propertyName); doubleManager->setValue(property, metaProperty.read(drawer).toDouble()); doubleManager->setMinimum(property, drawer->minimumValue(metaProperty).toDouble()); doubleManager->setMaximum(property, drawer->maximumValue(metaProperty).toDouble()); } break; case Enum: { } break; default: { if (!variantManager || !variantFactory) { variantManager = new QtVariantPropertyManager(browser); variantFactory = new KVariantEditorFactory(browser); browser->setFactoryForManager(variantManager, variantFactory); } property = variantManager->addProperty(metaProperty.type(), propertyName); variantManager->setValue(property, metaProperty.read(drawer)); } } browser->addProperty(property); } if (integerManager) { connect(integerFactory, SIGNAL(editingFinished()), listener, SLOT(editingFinished())); connect(integerManager, SIGNAL(propertyChanged(QtProperty*)), listener, SLOT(propertyChanged(QtProperty*))); } if (doubleManager) { connect(doubleFactory, SIGNAL(editingFinished()), listener, SLOT(editingFinished())); connect(doubleManager, SIGNAL(propertyChanged(QtProperty*)), listener, SLOT(propertyChanged(QtProperty*))); } if (variantManager) { connect(variantFactory, SIGNAL(editingFinished()), listener, SLOT(editingFinished())); connect(variantManager, SIGNAL(propertyChanged(QtProperty*)), listener, SLOT(propertyChanged(QtProperty*))); } return browser; }