diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-11-16 09:45:57 (GMT) |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2009-11-16 09:45:57 (GMT) |
commit | 01733c6c00b2fd2d5ee95b3d0837bc6c993162f3 (patch) | |
tree | b848123e743f9b7f207f7ea958e1322472b4c240 /tools/designer/src/components | |
parent | 149b13bdec3802a80e86a0de77837d7e9cbab8af (diff) | |
download | Qt-01733c6c00b2fd2d5ee95b3d0837bc6c993162f3.zip Qt-01733c6c00b2fd2d5ee95b3d0837bc6c993162f3.tar.gz Qt-01733c6c00b2fd2d5ee95b3d0837bc6c993162f3.tar.bz2 |
Designer: Filter on classname in Widget Box.
Introduce special filter string containing name plus class name
if it is different and not a layout.
Task-number: QTBUG-5492
Diffstat (limited to 'tools/designer/src/components')
-rw-r--r-- | tools/designer/src/components/widgetbox/widgetboxcategorylistview.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/tools/designer/src/components/widgetbox/widgetboxcategorylistview.cpp b/tools/designer/src/components/widgetbox/widgetboxcategorylistview.cpp index a4cd977..8155405 100644 --- a/tools/designer/src/components/widgetbox/widgetboxcategorylistview.cpp +++ b/tools/designer/src/components/widgetbox/widgetboxcategorylistview.cpp @@ -88,11 +88,15 @@ namespace qdesigner_internal { struct WidgetBoxCategoryEntry { WidgetBoxCategoryEntry(); - explicit WidgetBoxCategoryEntry(const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon, bool editable); + explicit WidgetBoxCategoryEntry(const QDesignerWidgetBoxInterface::Widget &widget, + const QString &filter, + const QIcon &icon, + bool editable); QDesignerWidgetBoxInterface::Widget widget; QString toolTip; QString whatsThis; + QString filter; QIcon icon; bool editable; }; @@ -103,8 +107,11 @@ WidgetBoxCategoryEntry::WidgetBoxCategoryEntry() : { } -WidgetBoxCategoryEntry::WidgetBoxCategoryEntry(const QDesignerWidgetBoxInterface::Widget &w, const QIcon &i, bool e) : +WidgetBoxCategoryEntry::WidgetBoxCategoryEntry(const QDesignerWidgetBoxInterface::Widget &w, + const QString &filterIn, + const QIcon &i, bool e) : widget(w), + filter(filterIn), icon(i), editable(e) { @@ -142,6 +149,7 @@ public: private: typedef QList<WidgetBoxCategoryEntry> WidgetBoxCategoryEntrys; + QRegExp m_classNameRegExp; QDesignerFormEditorInterface *m_core; WidgetBoxCategoryEntrys m_items; QListView::ViewMode m_viewMode; @@ -149,9 +157,11 @@ private: WidgetBoxCategoryModel::WidgetBoxCategoryModel(QDesignerFormEditorInterface *core, QObject *parent) : QAbstractListModel(parent), + m_classNameRegExp(QLatin1String("<widget +class *= *\"([^\"]+)\"")), m_core(core), m_viewMode(QListView::ListMode) { + Q_ASSERT(m_classNameRegExp.isValid()); } QListView::ViewMode WidgetBoxCategoryModel::viewMode() const @@ -205,8 +215,14 @@ bool WidgetBoxCategoryModel::removeCustomWidgets() void WidgetBoxCategoryModel::addWidget(const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon,bool editable) { - // build item - WidgetBoxCategoryEntry item(widget, icon, 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) { @@ -255,7 +271,7 @@ QVariant WidgetBoxCategoryModel::data(const QModelIndex &index, int role) const case Qt::WhatsThisRole: return QVariant(item.whatsThis); case FilterRole: - return item.widget.name(); + return item.filter; } return QVariant(); } |