diff options
-rw-r--r-- | src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp index 2f5b7f536..65a697a5e 100644 --- a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp +++ b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp @@ -200,21 +200,21 @@ bool WidgetBoxCategoryModel::removeCustomWidgets() 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. + static const QRegularExpression classNameRegExp(QStringLiteral("<widget +class *= *\"([^\"]+)\"")); + Q_ASSERT(classNameRegExp.isValid()); + const auto match = classNameRegExp.match(widget.domXml()); + const QString className = match.hasMatch() ? match.captured(1) : QString{}; + + // Filter on name + class name if it is different and not a layout. QString filter = widget.name(); - if (!filter.contains(QStringLiteral("Layout"))) { - static const QRegularExpression classNameRegExp(QStringLiteral("<widget +class *= *\"([^\"]+)\"")); - Q_ASSERT(classNameRegExp.isValid()); - const QRegularExpressionMatch match = classNameRegExp.match(widget.domXml()); - if (match.hasMatch()) { - const QString className = match.captured(1); - if (!filter.contains(className)) - filter += className; - } - } + if (!className.isEmpty() && !filter.contains(QStringLiteral("Layout")) && !filter.contains(className)) + filter += className; + WidgetBoxCategoryEntry item(widget, filter, icon, editable); const QDesignerWidgetDataBaseInterface *db = m_core->widgetDataBase(); - const int dbIndex = db->indexOfClassName(widget.name()); + int dbIndex = className.isEmpty() ? -1 : db->indexOfClassName(className); + if (dbIndex == -1) + dbIndex = db->indexOfClassName(widget.name()); if (dbIndex != -1) { const QDesignerWidgetDataBaseItemInterface *dbItem = db->item(dbIndex); const QString toolTip = dbItem->toolTip(); |