summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/filterlist.cpp30
-rw-r--r--src/filterlist.h3
-rw-r--r--src/mainwindow.ui6
3 files changed, 26 insertions, 13 deletions
diff --git a/src/filterlist.cpp b/src/filterlist.cpp
index 36cdacd0..66a9aed0 100644
--- a/src/filterlist.cpp
+++ b/src/filterlist.cpp
@@ -78,7 +78,7 @@ FilterList::FilterList(Ui::MainWindow* ui, CategoryFactory& factory)
connect(
ui->filtersClear, &QPushButton::clicked,
- [&]{ clearSelection(); });
+ [&]{ clear(); });
connect(
ui->filtersAnd, &QCheckBox::toggled,
@@ -241,20 +241,23 @@ void FilterList::onSelection()
});
}
- ui->filtersClear->setEnabled(!criteria.empty());
-
emit criteriaChanged(criteria);
}
void FilterList::onContextMenu(const QPoint &pos)
{
QMenu menu;
- menu.addAction(tr("Deselect filters"), [&]{ clearSelection(); });
- menu.addAction(tr("Set inverted"), [&]{ toggleInverted(true); });
- menu.addAction(tr("Unset inverted"), [&]{ toggleInverted(false); });
+
+ QAction* set = menu.addAction(tr("Set inverted"), [&]{ toggleInverted(true); });
+ QAction* unset = menu.addAction(tr("Unset inverted"), [&]{ toggleInverted(false); });
menu.addSeparator();
menu.addAction(tr("Edit Categories..."), [&]{ editCategories(); });
+ if (ui->filters->selectedItems().empty()) {
+ set->setEnabled(false);
+ unset->setEnabled(false);
+ }
+
menu.exec(ui->filters->viewport()->mapToGlobal(pos));
}
@@ -267,6 +270,21 @@ void FilterList::editCategories()
}
}
+void FilterList::clear()
+{
+ const auto count = ui->filters->topLevelItemCount();
+ for (int i=0; i<count; ++i) {
+ auto* ci = dynamic_cast<CriteriaItem*>(ui->filters->topLevelItem(i));
+ if (!ci) {
+ continue;
+ }
+
+ ci->setInverted(false);
+ }
+
+ clearSelection();
+}
+
void FilterList::toggleInverted(bool b)
{
bool changed = false;
diff --git a/src/filterlist.h b/src/filterlist.h
index 1fd0942a..e98f81a9 100644
--- a/src/filterlist.h
+++ b/src/filterlist.h
@@ -32,8 +32,9 @@ private:
void onSelection();
void onCriteriaChanged();
- void editCategories();
+ void clear();
void toggleInverted(bool b);
+ void editCategories();
QTreeWidgetItem* addCriteriaItem(
QTreeWidgetItem *root, const QString &name, int categoryID,
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 6c35d239..5206d797 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -114,9 +114,6 @@
</item>
<item>
<widget class="QPushButton" name="filtersClear">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Maximum">
<horstretch>0</horstretch>
@@ -132,9 +129,6 @@
<property name="text">
<string>Clear</string>
</property>
- <property name="flat">
- <bool>true</bool>
- </property>
</widget>
</item>
<item>