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 <eike.ziller@qt.io>
This commit is contained in:
hjk
2020-06-10 07:56:14 +02:00
parent 72b35aa12b
commit 30c118203e
3 changed files with 6 additions and 70 deletions

View File

@@ -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<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);
@@ -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);

View File

@@ -31,7 +31,10 @@
#include <QWidget>
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<Utils::TreeItem, Internal::CollectionItem, Internal::PluginItem> *m_model;
Internal::PluginFilterModel *m_sortModel;
Utils::CategorySortFilterModel *m_sortModel;
friend class Internal::CollectionItem;
friend class Internal::PluginItem;

View File

@@ -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);