// ---------------------------------------------------------- WidgetDataBase::WidgetDataBase(QDesignerFormEditorInterface *core, QObject *parent) : QDesignerWidgetDataBaseInterface(parent), m_core(core) { #define DECLARE_LAYOUT(L, C) #define DECLARE_COMPAT_WIDGET(W, C) DECLARE_WIDGET(W, C) #define DECLARE_WIDGET(W, C) append(new WidgetDataBaseItem(QString::fromUtf8(#W))); #include "widgets.table" #undef DECLARE_COMPAT_WIDGET #undef DECLARE_LAYOUT #undef DECLARE_WIDGET #undef DECLARE_WIDGET_1 append(new WidgetDataBaseItem(QString::fromUtf8("Line"))); append(new WidgetDataBaseItem(QString::fromUtf8("Spacer"))); append(new WidgetDataBaseItem(QString::fromUtf8("QSplitter"))); append(new WidgetDataBaseItem(QString::fromUtf8("QLayoutWidget"))); // QDesignerWidget is used as central widget and as container for tab widgets, etc. WidgetDataBaseItem *designerWidgetItem = new WidgetDataBaseItem(QString::fromUtf8("QDesignerWidget")); designerWidgetItem->setContainer(true); append(designerWidgetItem); append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerDialog"))); append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerMenu"))); append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerMenuBar"))); append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerDockWidget"))); append(new WidgetDataBaseItem(QString::fromUtf8("QDesignerQ3WidgetStack"))); append(new WidgetDataBaseItem(QString::fromUtf8("QAction"))); append(new WidgetDataBaseItem(QString::fromUtf8("QButtonGroup"))); // ### remove me // ### check the casts #if 0 // ### enable me after 4.1 item(indexOfClassName(QLatin1String("QToolBar")))->setContainer(true); #endif item(indexOfClassName(QLatin1String("QTabWidget")))->setContainer(true); item(indexOfClassName(QLatin1String("QGroupBox")))->setContainer(true); item(indexOfClassName(QLatin1String("QScrollArea")))->setContainer(true); item(indexOfClassName(QLatin1String("QStackedWidget")))->setContainer(true); item(indexOfClassName(QLatin1String("QToolBox")))->setContainer(true); item(indexOfClassName(QLatin1String("QFrame")))->setContainer(true); item(indexOfClassName(QLatin1String("QLayoutWidget")))->setContainer(true); item(indexOfClassName(QLatin1String("QDesignerWidget")))->setContainer(true); item(indexOfClassName(QLatin1String("QDesignerDialog")))->setContainer(true); item(indexOfClassName(QLatin1String("QSplitter")))->setContainer(true); item(indexOfClassName(QLatin1String("QMainWindow")))->setContainer(true); item(indexOfClassName(QLatin1String("QDockWidget")))->setContainer(true); item(indexOfClassName(QLatin1String("QDesignerDockWidget")))->setContainer(true); item(indexOfClassName(QLatin1String("QDesignerQ3WidgetStack")))->setContainer(true); item(indexOfClassName(QLatin1String("QMdiArea")))->setContainer(true); item(indexOfClassName(QLatin1String("QWorkspace")))->setContainer(true); item(indexOfClassName(QLatin1String("QWizard")))->setContainer(true); item(indexOfClassName(QLatin1String("QWizardPage")))->setContainer(true); item(indexOfClassName(QLatin1String("QWidget")))->setContainer(true); item(indexOfClassName(QLatin1String("QDialog")))->setContainer(true); }
static WidgetDataBaseItem *createCustomWidgetItem(const QDesignerCustomWidgetInterface *c, const QDesignerCustomWidgetData &data) { WidgetDataBaseItem *item = new WidgetDataBaseItem(c->name(), c->group()); item->setContainer(c->isContainer()); item->setCustom(true); item->setIcon(c->icon()); item->setIncludeFile(c->includeFile()); item->setToolTip(c->toolTip()); item->setWhatsThis(c->whatsThis()); item->setPluginPath(data.pluginPath()); item->setAddPageMethod(data.xmlAddPageMethod()); item->setExtends(data.xmlExtends()); return item; }
void QSimpleResource::addCustomWidgetsToWidgetDatabase(const QDesignerFormEditorInterface *core, QList<DomCustomWidget*>& custom_widget_list) { QDesignerWidgetDataBaseInterface *db = core->widgetDataBase(); for (int i=0; i < custom_widget_list.size(); ) { bool classInserted = false; DomCustomWidget *custom_widget = custom_widget_list[i]; const QString customClassName = custom_widget->elementClass(); const QString base_class = custom_widget->elementExtends(); QString includeFile; IncludeType includeType = IncludeLocal; if (const DomHeader *header = custom_widget->elementHeader()) { includeFile = header->text(); if (header->hasAttributeLocation() && header->attributeLocation() == QStringLiteral("global")) includeType = IncludeGlobal; } const bool domIsContainer = custom_widget->elementContainer(); // Append a new item if (base_class.isEmpty()) { WidgetDataBaseItem *item = new WidgetDataBaseItem(customClassName); item->setPromoted(false); item->setGroup(QCoreApplication::translate("Designer", "Custom Widgets")); item->setIncludeFile(buildIncludeFile(includeFile, includeType)); item->setContainer(domIsContainer); item->setCustom(true); addFakeMethodsToWidgetDataBase(custom_widget, item); db->append(item); custom_widget_list.removeAt(i); classInserted = true; } else { // Create a new entry cloned from base class. Note that this will ignore existing // classes, eg, plugin custom widgets. QDesignerWidgetDataBaseItemInterface *item = appendDerived(db, customClassName, QCoreApplication::translate("Designer", "Promoted Widgets"), base_class, buildIncludeFile(includeFile, includeType), true,true); // Ok, base class found. if (item) { // Hack to accommodate for old UI-files in which "container" is not set properly: // Apply "container" from DOM only if true (else, eg classes from QFrame might not accept // dropping child widgets on them as container=false). This also allows for // QWidget-derived stacked pages. if (domIsContainer) item->setContainer(domIsContainer); addFakeMethodsToWidgetDataBase(custom_widget, static_cast<WidgetDataBaseItem*>(item)); custom_widget_list.removeAt(i); classInserted = true; } } // Skip failed item. if (!classInserted) i++; } }
bool SignalSlotDialog::editPromotedClass(QDesignerFormEditorInterface *core, const QString &promotedClassName, QObject *object, QWidget *parent, FocusMode mode) { WidgetDataBase *db = qobject_cast<WidgetDataBase *>(core->widgetDataBase()); if (!db) return false; const int index = core->widgetDataBase()->indexOfClassName(promotedClassName); if (index == -1) return false; WidgetDataBaseItem* item = static_cast<WidgetDataBaseItem*>(db->item(index)); SignalSlotDialogData slotData; SignalSlotDialogData signalData; existingMethodsFromMemberSheet(core, object, slotData.m_existingMethods, signalData.m_existingMethods); slotData.m_fakeMethods = item->fakeSlots(); signalData.m_fakeMethods = item->fakeSignals(); const QStringList oldSlots = slotData.m_fakeMethods; const QStringList oldSignals = signalData.m_fakeMethods; SignalSlotDialog dlg(core->dialogGui(), parent, mode); dlg.setWindowTitle(tr("Signals/Slots of %1").arg(promotedClassName)); if (dlg.showDialog(slotData, signalData) == QDialog::Rejected) return false; if (oldSlots == slotData.m_fakeMethods && oldSignals == signalData.m_fakeMethods) return false; item->setFakeSlots(slotData.m_fakeMethods); item->setFakeSignals(signalData.m_fakeMethods); return true; }
WidgetDataBaseItem *WidgetDataBaseItem::clone(const QDesignerWidgetDataBaseItemInterface *item) { WidgetDataBaseItem *rc = new WidgetDataBaseItem(item->name(), item->group()); rc->setToolTip(item->toolTip()); rc->setWhatsThis(item->whatsThis()); rc->setIncludeFile(item->includeFile()); rc->setIcon(item->icon()); rc->setCompat(item->isCompat()); rc->setContainer(item->isContainer()); rc->setCustom(item->isCustom() ); rc->setPluginPath(item->pluginPath()); rc->setPromoted(item->isPromoted()); rc->setExtends(item->extends()); rc->setDefaultPropertyValues(item->defaultPropertyValues()); // container page method, fake slots and signals ignored here.y return rc; }