aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/extensionsystem/pluginview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/extensionsystem/pluginview.cpp')
-rw-r--r--src/libs/extensionsystem/pluginview.cpp65
1 files changed, 6 insertions, 59 deletions
diff --git a/src/libs/extensionsystem/pluginview.cpp b/src/libs/extensionsystem/pluginview.cpp
index 5c789413f5..88a7350e40 100644
--- a/src/libs/extensionsystem/pluginview.cpp
+++ b/src/libs/extensionsystem/pluginview.cpp
@@ -44,7 +44,9 @@
/*!
\class ExtensionSystem::PluginView
+ \inheaderfile extensionsystem/pluginview.h
\inmodule QtCreator
+
\brief The PluginView class implements a widget that shows a list of all
plugins and their state.
@@ -86,7 +88,6 @@ enum Columns { NameColumn, LoadedColumn, VersionColumn, VendorColumn, };
enum IconIndex { OkIcon, ErrorIcon, NotLoadedIcon };
static const int SortRole = Qt::UserRole + 1;
-static const int HiddenByDefaultRole = Qt::UserRole + 2;
static const QIcon &icon(IconIndex icon)
{
@@ -118,8 +119,6 @@ public:
QVariant data(int column, int role) const override
{
- if (role == HiddenByDefaultRole)
- return m_spec->isHiddenByDefault() || !m_spec->isAvailableForHostPlatform();
switch (column) {
case NameColumn:
if (role == Qt::DisplayRole)
@@ -231,8 +230,6 @@ public:
QVariant data(int column, int role) const override
{
- if (role == HiddenByDefaultRole)
- return false;
if (column == NameColumn) {
if (role == Qt::DisplayRole || role == SortRole)
return m_name;
@@ -288,40 +285,6 @@ public:
PluginView *m_view; // Not owned.
};
-class PluginFilterModel : public CategorySortFilterModel
-{
-public:
- PluginFilterModel(QObject *parent = nullptr) : CategorySortFilterModel(parent) {}
-
- void setShowHidden(bool show)
- {
- if (show == m_showHidden)
- return;
- m_showHidden = show;
- invalidateFilter();
- }
-
- bool isShowingHidden() const
- {
- return m_showHidden;
- }
-
-protected:
- bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
- {
- if (CategorySortFilterModel::filterAcceptsRow(source_row, source_parent)) {
- if (m_showHidden)
- return true;
- const QModelIndex &index = sourceModel()->index(source_row, 0, source_parent);
- return !sourceModel()->data(index, HiddenByDefaultRole).toBool();
- }
- return false;
- }
-
-private:
- bool m_showHidden = true;
-};
-
} // Internal
using namespace ExtensionSystem::Internal;
@@ -349,10 +312,9 @@ PluginView::PluginView(QWidget *parent)
m_model = new TreeModel<TreeItem, CollectionItem, PluginItem>(this);
m_model->setHeader({ tr("Name"), tr("Load"), tr("Version"), tr("Vendor") });
- m_sortModel = new PluginFilterModel(this);
+ m_sortModel = new CategorySortFilterModel(this);
m_sortModel->setSourceModel(m_model);
m_sortModel->setSortRole(SortRole);
- m_sortModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_sortModel->setFilterKeyColumn(-1/*all*/);
m_categoryView->setModel(m_sortModel);
@@ -394,27 +356,12 @@ PluginSpec *PluginView::currentPlugin() const
*/
void PluginView::setFilter(const QString &filter)
{
- m_sortModel->setFilterFixedString(filter);
- m_categoryView->expandAll();
-}
-
-/*!
- Sets the list filtering to \a showHidden.
-*/
-void PluginView::setShowHidden(bool showHidden)
-{
- m_sortModel->setShowHidden(showHidden);
+ m_sortModel->setFilterRegularExpression(
+ QRegularExpression(QRegularExpression::escape(filter),
+ QRegularExpression::CaseInsensitiveOption));
m_categoryView->expandAll();
}
-/*!
- Returns whether hidden plugins are listed.
-*/
-bool PluginView::isShowingHidden() const
-{
- return m_sortModel->isShowingHidden();
-}
-
PluginSpec *PluginView::pluginForIndex(const QModelIndex &index) const
{
const QModelIndex &sourceIndex = m_sortModel->mapToSource(index);