void PropertyEditor::updateBrowserValue(QtVariantProperty *property, const QVariant &value) { QVariant v = value; const int type = property->propertyType(); if (type == QtVariantPropertyManager::enumTypeId()) { const PropertySheetEnumValue e = qvariant_cast<PropertySheetEnumValue>(v); v = e.metaEnum.keys().indexOf(e.metaEnum.valueToKey(e.value)); } else if (type == DesignerPropertyManager::designerFlagTypeId()) { const PropertySheetFlagValue f = qvariant_cast<PropertySheetFlagValue>(v); v = QVariant(f.value); } else if (type == DesignerPropertyManager::designerAlignmentTypeId()) { const PropertySheetFlagValue f = qvariant_cast<PropertySheetFlagValue>(v); v = QVariant(f.value); } QDesignerPropertySheet *sheet = qobject_cast<QDesignerPropertySheet*>(m_core->extensionManager()->extension(m_object, Q_TYPEID(QDesignerPropertySheetExtension))); int index = -1; if (sheet) index = sheet->indexOf(property->propertyName()); if (sheet && m_propertyToGroup.contains(property)) { // don't do it for comments since property sheet doesn't keep them property->setEnabled(sheet->isEnabled(index)); } // Rich text string property with comment: Store/Update the font the rich text editor dialog starts out with if (type == QVariant::String && !property->subProperties().empty()) { const int fontIndex = m_propertySheet->indexOf(m_strings.m_fontProperty); if (fontIndex != -1) property->setAttribute(m_strings.m_fontAttribute, m_propertySheet->property(fontIndex)); } m_updatingBrowser = true; property->setValue(v); if (sheet && sheet->isResourceProperty(index)) property->setAttribute(QLatin1String("defaultResource"), sheet->defaultResourceProperty(index)); m_updatingBrowser = false; }
void QDesignerFormBuilder::applyProperties(QObject *o, const QList<DomProperty*> &properties) { typedef QList<DomProperty*> DomPropertyList; if (properties.empty()) return; const QDesignerPropertySheetExtension *sheet = qt_extension<QDesignerPropertySheetExtension*>(core()->extensionManager(), o); const QDesignerDynamicPropertySheetExtension *dynamicSheet = qt_extension<QDesignerDynamicPropertySheetExtension*>(core()->extensionManager(), o); const bool changingMetaObject = WidgetFactory::classNameOf(core(), o) == QStringLiteral("QAxWidget"); const QDesignerMetaObjectInterface *meta = core()->introspection()->metaObject(o); const bool dynamicPropertiesAllowed = dynamicSheet && dynamicSheet->dynamicPropertiesAllowed(); QDesignerPropertySheet *designerPropertySheet = qobject_cast<QDesignerPropertySheet *>( core()->extensionManager()->extension(o, Q_TYPEID(QDesignerPropertySheetExtension))); if (designerPropertySheet) { if (designerPropertySheet->pixmapCache()) designerPropertySheet->setPixmapCache(m_pixmapCache); if (designerPropertySheet->iconCache()) designerPropertySheet->setIconCache(m_iconCache); } const DomPropertyList::const_iterator cend = properties.constEnd(); for (DomPropertyList::const_iterator it = properties.constBegin(); it != cend; ++it) { DomProperty *p = *it; QVariant v; if (!readDomEnumerationValue(p, sheet, v)) v = toVariant(o->metaObject(), p); if (v.isNull()) continue; const QString attributeName = p->attributeName(); if (d->applyPropertyInternally(o, attributeName, v)) continue; // refuse fake properties like current tab name (weak test) if (!dynamicPropertiesAllowed) { if (changingMetaObject) // Changes after setting control of QAxWidget meta = core()->introspection()->metaObject(o); if (meta->indexOfProperty(attributeName) == -1) continue; } QObject *obj = o; QAbstractScrollArea *scroll = qobject_cast<QAbstractScrollArea *>(o); if (scroll && attributeName == QStringLiteral("cursor") && scroll->viewport()) obj = scroll->viewport(); // a real property obj->setProperty(attributeName.toUtf8(), v); } }
void FormWindowBase::reloadProperties() { pixmapCache()->clear(); iconCache()->clear(); QMapIterator<QDesignerPropertySheet *, QMap<int, bool> > itSheet(m_d->m_reloadableResources); while (itSheet.hasNext()) { QDesignerPropertySheet *sheet = itSheet.next().key(); QMapIterator<int, bool> itIndex(itSheet.value()); while (itIndex.hasNext()) { const int index = itIndex.next().key(); const QVariant newValue = sheet->property(index); if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == QLatin1String("text")) { const PropertySheetStringValue newString = qvariant_cast<PropertySheetStringValue>(newValue); // optimize a bit, reset only if the text value might contain a reference to qt resources // (however reloading of icons other than taken from resources might not work here) if (newString.value().contains(QLatin1String(":/"))) { const QVariant resetValue = QVariant::fromValue(PropertySheetStringValue()); sheet->setProperty(index, resetValue); } } sheet->setProperty(index, newValue); } if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) { const int count = tabWidget->count(); const int current = tabWidget->currentIndex(); const QString currentTabIcon = QLatin1String("currentTabIcon"); for (int i = 0; i < count; i++) { tabWidget->setCurrentIndex(i); const int index = sheet->indexOf(currentTabIcon); sheet->setProperty(index, sheet->property(index)); } tabWidget->setCurrentIndex(current); } else if (QToolBox *toolBox = qobject_cast<QToolBox *>(sheet->object())) { const int count = toolBox->count(); const int current = toolBox->currentIndex(); const QString currentItemIcon = QLatin1String("currentItemIcon"); for (int i = 0; i < count; i++) { toolBox->setCurrentIndex(i); const int index = sheet->indexOf(currentItemIcon); sheet->setProperty(index, sheet->property(index)); } toolBox->setCurrentIndex(current); } } QMapIterator<QDesignerPropertySheet *, QObject *> itSh(m_d->m_reloadablePropertySheets); while (itSh.hasNext()) { QObject *object = itSh.next().value(); reloadIconResources(iconCache(), object); } }
void FormWindowBase::reloadProperties() { pixmapCache()->clear(); iconCache()->clear(); QMapIterator<QDesignerPropertySheet *, QMap<int, bool> > itSheet(m_d->m_reloadableResources); while (itSheet.hasNext()) { QDesignerPropertySheet *sheet = itSheet.next().key(); QMapIterator<int, bool> itIndex(itSheet.value()); while (itIndex.hasNext()) { const int index = itIndex.next().key(); sheet->setProperty(index, sheet->property(index)); } if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) { const int count = tabWidget->count(); const int current = tabWidget->currentIndex(); const QString currentTabIcon = QLatin1String("currentTabIcon"); for (int i = 0; i < count; i++) { tabWidget->setCurrentIndex(i); const int index = sheet->indexOf(currentTabIcon); sheet->setProperty(index, sheet->property(index)); } tabWidget->setCurrentIndex(current); } else if (QToolBox *toolBox = qobject_cast<QToolBox *>(sheet->object())) { const int count = toolBox->count(); const int current = toolBox->currentIndex(); const QString currentItemIcon = QLatin1String("currentItemIcon"); for (int i = 0; i < count; i++) { toolBox->setCurrentIndex(i); const int index = sheet->indexOf(currentItemIcon); sheet->setProperty(index, sheet->property(index)); } toolBox->setCurrentIndex(current); } } QMapIterator<QDesignerPropertySheet *, QObject *> itSh(m_d->m_reloadablePropertySheets); while (itSh.hasNext()) { QObject *object = itSh.next().value(); reloadIconResources(iconCache(), object); } }