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