Skip to content

Commit

Permalink
Plugins dialog: show/hide non-selectable plugins.
Browse files Browse the repository at this point in the history
This is part of our work on issue #2285.
  • Loading branch information
agarny committed Feb 13, 2020
1 parent af3b6c4 commit 616d61b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
18 changes: 18 additions & 0 deletions src/pluginitemmodel.cpp
Expand Up @@ -121,6 +121,24 @@ QModelIndex PluginItem::modelIndex() const

//==============================================================================

bool PluginItem::isHidden() const
{
// Return whether we are hidden

return mHidden;
}

//==============================================================================

void PluginItem::setHidden(bool pHidden)
{
// Specify whether we are hidden

mHidden = pHidden;
}

//==============================================================================

bool PluginItem::hasCheckBox() const
{
// Return whether we have a check box
Expand Down
4 changes: 4 additions & 0 deletions src/pluginitemmodel.h
Expand Up @@ -57,6 +57,9 @@ class PluginItem

QModelIndex modelIndex() const;

bool isHidden() const;
void setHidden(bool pHidden);

bool hasCheckBox() const;
void setHasCheckBox(bool pHasCheckBox);

Expand All @@ -78,6 +81,7 @@ class PluginItem
PluginItem *mParent = nullptr;
QVector<PluginItem *> mChildren;

bool mHidden = false;
bool mHasCheckBox = false;
bool mCheckable = false;
Qt::CheckState mCheckState;
Expand Down
8 changes: 3 additions & 5 deletions src/pluginsdialog.cpp
Expand Up @@ -612,8 +612,7 @@ void PluginsDialog::selectablePluginsCheckBoxToggled(bool pChecked)
// Show/hide our unselectable plugins

for (auto unselectablePluginItem : mUnselectablePluginItems) {
mGui->treeView->setRowHidden(unselectablePluginItem->index(),
unselectablePluginItem->parent()->modelIndex(), pChecked);
unselectablePluginItem->setHidden(pChecked);
}

// Show/hide our categories, based on whether they contain visible plugins
Expand All @@ -624,10 +623,9 @@ void PluginsDialog::selectablePluginsCheckBoxToggled(bool pChecked)
// are visible

bool hideCategory = true;
QModelIndex categoryItemModelIndex = categoryItem->modelIndex();

for (int i = 0, iMax = categoryItem->childCount(); i < iMax; ++i) {
if (!mGui->treeView->isRowHidden(i, categoryItemModelIndex)) {
if (!categoryItem->child(i)->isHidden()) {
hideCategory = false;

break;
Expand All @@ -643,7 +641,7 @@ void PluginsDialog::selectablePluginsCheckBoxToggled(bool pChecked)
// Select the first visible category

for (int i = 0, iMax = mModel->invisibleRootItem()->childCount(); i < iMax; ++i) {
if (!mGui->treeView->isRowHidden(i, mModel->invisibleRootItem()->modelIndex())) {
if (!mModel->invisibleRootItem()->child(i)->isHidden()) {
mGui->treeView->setCurrentIndex(mModel->invisibleRootItem()->child(i)->modelIndex());

return;
Expand Down

0 comments on commit 616d61b

Please sign in to comment.