From 30c118203e1ada97fe5b5487df753004e6f01349 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 10 Jun 2020 07:56:14 +0200 Subject: [PATCH] Core: Remove "Show all" option in plugin dialog Turned out it was easy to overlook and didn't reduce the list of visible plugins to a degree that makes a difference. Change-Id: Ib261066b215b66ffb683a87b8592570d895917ac Reviewed-by: Eike Ziller --- src/libs/extensionsystem/pluginview.cpp | 58 +------------------------ src/libs/extensionsystem/pluginview.h | 10 ++--- src/plugins/coreplugin/plugindialog.cpp | 8 ---- 3 files changed, 6 insertions(+), 70 deletions(-) diff --git a/src/libs/extensionsystem/pluginview.cpp b/src/libs/extensionsystem/pluginview.cpp index c9f95ce5f35..bf40d8d7f84 100644 --- a/src/libs/extensionsystem/pluginview.cpp +++ b/src/libs/extensionsystem/pluginview.cpp @@ -88,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) { @@ -120,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) @@ -233,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; @@ -290,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; @@ -351,7 +312,7 @@ PluginView::PluginView(QWidget *parent) m_model = new TreeModel(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); @@ -400,23 +361,6 @@ void PluginView::setFilter(const QString &filter) m_categoryView->expandAll(); } -/*! - Sets the list filtering to \a showHidden. -*/ -void PluginView::setShowHidden(bool showHidden) -{ - m_sortModel->setShowHidden(showHidden); - 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); diff --git a/src/libs/extensionsystem/pluginview.h b/src/libs/extensionsystem/pluginview.h index f0df3bb8b16..8e6450954e1 100644 --- a/src/libs/extensionsystem/pluginview.h +++ b/src/libs/extensionsystem/pluginview.h @@ -31,7 +31,10 @@ #include -namespace Utils { class TreeView; } +namespace Utils { +class CategorySortFilterModel; +class TreeView; +} // Utils namespace ExtensionSystem { @@ -39,7 +42,6 @@ class PluginSpec; namespace Internal { class CollectionItem; -class PluginFilterModel; class PluginItem; } // Internal @@ -53,8 +55,6 @@ public: PluginSpec *currentPlugin() const; void setFilter(const QString &filter); - void setShowHidden(bool showHidden); - bool isShowingHidden() const; signals: void currentPluginChanged(ExtensionSystem::PluginSpec *spec); @@ -68,7 +68,7 @@ private: Utils::TreeView *m_categoryView; Utils::TreeModel *m_model; - Internal::PluginFilterModel *m_sortModel; + Utils::CategorySortFilterModel *m_sortModel; friend class Internal::CollectionItem; friend class Internal::PluginItem; diff --git a/src/plugins/coreplugin/plugindialog.cpp b/src/plugins/coreplugin/plugindialog.cpp index d86930cd654..86f509aeb07 100644 --- a/src/plugins/coreplugin/plugindialog.cpp +++ b/src/plugins/coreplugin/plugindialog.cpp @@ -69,14 +69,6 @@ PluginDialog::PluginDialog(QWidget *parent) connect(filterEdit, &Utils::FancyLineEdit::filterChanged, m_view, &ExtensionSystem::PluginView::setFilter); filterLayout->addWidget(filterEdit); - m_view->setShowHidden(false); - auto showHidden = new QCheckBox(tr("Show all")); - showHidden->setToolTip(tr("Show all installed plugins, including base plugins " - "and plugins that are not available on this platform.")); - showHidden->setChecked(m_view->isShowingHidden()); - connect(showHidden, &QCheckBox::stateChanged, - m_view, &ExtensionSystem::PluginView::setShowHidden); - filterLayout->addWidget(showHidden); vl->addWidget(m_view);