本文整理汇总了C++中QDesignerFormEditorInterface::widgetDataBase方法的典型用法代码示例。如果您正苦于以下问题:C++ QDesignerFormEditorInterface::widgetDataBase方法的具体用法?C++ QDesignerFormEditorInterface::widgetDataBase怎么用?C++ QDesignerFormEditorInterface::widgetDataBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDesignerFormEditorInterface
的用法示例。
在下文中一共展示了QDesignerFormEditorInterface::widgetDataBase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addWidget
void WidgetBoxCategoryModel::addWidget(const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon,bool editable)
{
// build item. Filter on name + class name if it is different and not a layout.
QString filter = widget.name();
if (!filter.contains(QLatin1String("Layout")) && m_classNameRegExp.indexIn(widget.domXml()) != -1) {
const QString className = m_classNameRegExp.cap(1);
if (!filter.contains(className))
filter += className;
}
WidgetBoxCategoryEntry item(widget, filter, icon, editable);
const QDesignerWidgetDataBaseInterface *db = m_core->widgetDataBase();
const int dbIndex = db->indexOfClassName(widget.name());
if (dbIndex != -1) {
const QDesignerWidgetDataBaseItemInterface *dbItem = db->item(dbIndex);
const QString toolTip = dbItem->toolTip();
if (!toolTip.isEmpty())
item.toolTip = toolTip;
const QString whatsThis = dbItem->whatsThis();
if (!whatsThis.isEmpty())
item.whatsThis = whatsThis;
}
// insert
const int row = m_items.size();
beginInsertRows(QModelIndex(), row, row);
m_items.push_back(item);
endInsertRows();
}
示例2: createPromotionActions
PromotionTaskMenu::PromotionState PromotionTaskMenu::createPromotionActions(QDesignerFormWindowInterface *formWindow)
{
// clear out old
if (!m_promotionActions.empty()) {
qDeleteAll(m_promotionActions);
m_promotionActions.clear();
}
// No promotion of main container
if (formWindow->mainContainer() == m_widget)
return NotApplicable;
// Check for a homogenous selection
const PromotionSelectionList promotionSelection = promotionSelectionList(formWindow);
if (promotionSelection.empty())
return NoHomogenousSelection;
QDesignerFormEditorInterface *core = formWindow->core();
// if it is promoted: demote only.
if (isPromoted(formWindow->core(), m_widget)) {
const QString label = m_demoteLabel.arg( promotedExtends(core , m_widget));
QAction *demoteAction = new QAction(label, this);
connect(demoteAction, SIGNAL(triggered()), this, SLOT(slotDemoteFromCustomWidget()));
m_promotionActions.push_back(demoteAction);
return CanDemote;
}
// figure out candidates
const QString baseClassName = WidgetFactory::classNameOf(core, m_widget);
const WidgetDataBaseItemList candidates = promotionCandidates(core->widgetDataBase(), baseClassName );
if (candidates.empty()) {
// Is this thing promotable at all?
return QDesignerPromotionDialog::baseClassNames(core->promotion()).contains(baseClassName) ? CanPromote : NotApplicable;
}
// Set up a signal mapper to associate class names
if (!m_promotionMapper) {
m_promotionMapper = new QSignalMapper(this);
connect(m_promotionMapper, SIGNAL(mapped(QString)), this, SLOT(slotPromoteToCustomWidget(QString)));
}
QMenu *candidatesMenu = new QMenu();
// Create a sub menu
const WidgetDataBaseItemList::const_iterator cend = candidates.constEnd();
// Set up actions and map class names
for (WidgetDataBaseItemList::const_iterator it = candidates.constBegin(); it != cend; ++it) {
const QString customClassName = (*it)->name();
QAction *action = new QAction((*it)->name(), this);
connect(action, SIGNAL(triggered()), m_promotionMapper, SLOT(map()));
m_promotionMapper->setMapping(action, customClassName);
candidatesMenu->addAction(action);
}
// Sub menu action
QAction *subMenuAction = new QAction(m_promoteLabel, this);
subMenuAction->setMenu(candidatesMenu);
m_promotionActions.push_back(subMenuAction);
return CanPromote;
}
示例3: initialize
void QDesignerIntegrationPrivate::initialize()
{
typedef void (QDesignerIntegration::*QDesignerIntegrationUpdatePropertySlot3)(const QString &, const QVariant &, bool);
//
// integrate the `Form Editor component'
//
// Extensions
QDesignerFormEditorInterface *core = q->core();
if (QDesignerPropertyEditor *designerPropertyEditor= qobject_cast<QDesignerPropertyEditor *>(core->propertyEditor())) {
QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::propertyValueChanged,
q, static_cast<QDesignerIntegrationUpdatePropertySlot3>(&QDesignerIntegration::updateProperty));
QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::resetProperty,
q, &QDesignerIntegration::resetProperty);
QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::addDynamicProperty,
q, &QDesignerIntegration::addDynamicProperty);
QObject::connect(designerPropertyEditor, &QDesignerPropertyEditor::removeDynamicProperty,
q, &QDesignerIntegration::removeDynamicProperty);
} else {
QObject::connect(core->propertyEditor(), SIGNAL(propertyChanged(QString,QVariant)),
q, SLOT(updatePropertyPrivate(QString,QVariant))); // ### fixme: VS Integration leftover?
}
QObject::connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::formWindowAdded,
q, &QDesignerIntegrationInterface::setupFormWindow);
QObject::connect(core->formWindowManager(), &QDesignerFormWindowManagerInterface::activeFormWindowChanged,
q, &QDesignerIntegrationInterface::updateActiveFormWindow);
m_gradientManager = new QtGradientManager(q);
core->setGradientManager(m_gradientManager);
QString designerFolder = QDir::homePath();
designerFolder += QDir::separator();
designerFolder += QStringLiteral(".designer");
m_gradientsPath = designerFolder;
m_gradientsPath += QDir::separator();
m_gradientsPath += QStringLiteral("gradients.xml");
QFile f(m_gradientsPath);
if (f.open(QIODevice::ReadOnly)) {
QtGradientUtils::restoreState(m_gradientManager, QString::fromLatin1(f.readAll()));
f.close();
} else {
QFile defaultGradients(QStringLiteral(":/qt-project.org/designer/defaultgradients.xml"));
if (defaultGradients.open(QIODevice::ReadOnly)) {
QtGradientUtils::restoreState(m_gradientManager, QString::fromLatin1(defaultGradients.readAll()));
defaultGradients.close();
}
}
if (WidgetDataBase *widgetDataBase = qobject_cast<WidgetDataBase*>(core->widgetDataBase()))
widgetDataBase->grabStandardWidgetBoxIcons();
}