summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/filterwidget2.cpp30
-rw-r--r--desktop-widgets/filterwidget2.ui92
2 files changed, 72 insertions, 50 deletions
diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp
index ec82ba8f8..85c977b4e 100644
--- a/desktop-widgets/filterwidget2.cpp
+++ b/desktop-widgets/filterwidget2.cpp
@@ -20,7 +20,7 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent), ignoreSignal(fa
// TODO: unhide this when we discover how to search for equipment.
ui.equipment->hide();
- ui.equipmentNegate->hide();
+ ui.equipmentMode->hide();
ui.labelEquipment->hide();
ui.fromDate->setDisplayFormat(prefs.date_format);
@@ -50,6 +50,11 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent), ignoreSignal(fa
connect(ui.minVisibility, &StarWidget::valueChanged,
this, &FilterWidget2::updateFilter);
+ // We need these insane casts because Qt decided to function-overload some of their signals(!).
+ // QDoubleSpinBox::valueChanged() sends double and QString using the same signal name.
+ // QComboBox::currentIndexChanged() sends int and QString using the same signal name.
+ // Qt 5.7 provides a "convenient" helper that hides this, but only if compiling in C++14
+ // or higher. One can then write: "QOverload<double>(&QDoubleSpinBox::valueChanged)", etc.
connect(ui.maxAirTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &FilterWidget2::updateFilter);
@@ -77,19 +82,19 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent), ignoreSignal(fa
connect(ui.tags, &QLineEdit::textChanged,
this, &FilterWidget2::updateFilter);
- connect(ui.tagsNegate, &QToolButton::toggled,
+ connect(ui.tagsMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &FilterWidget2::updateFilter);
connect(ui.people, &QLineEdit::textChanged,
this, &FilterWidget2::updateFilter);
- connect(ui.peopleNegate, &QToolButton::toggled,
+ connect(ui.peopleMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &FilterWidget2::updateFilter);
connect(ui.location, &QLineEdit::textChanged,
this, &FilterWidget2::updateFilter);
- connect(ui.locationNegate, &QToolButton::toggled,
+ connect(ui.locationMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &FilterWidget2::updateFilter);
connect(ui.logged, &QCheckBox::stateChanged,
@@ -135,10 +140,11 @@ void FilterWidget2::clearFilter()
ui.fromTime->setTime(filterData.fromTime);
ui.toDate->setDate(filterData.toDate.date());
ui.toTime->setTime(filterData.toTime);
- ui.tagsNegate->setChecked(filterData.tagsNegate);
- ui.peopleNegate->setChecked(filterData.peopleNegate);
- ui.locationNegate->setChecked(filterData.locationNegate);
- ui.equipmentNegate->setChecked(filterData.equipmentNegate);
+ ui.tagsMode->setCurrentIndex(filterData.tagsNegate ? 1 : 0);
+ ui.peopleMode->setCurrentIndex(filterData.peopleNegate ? 1 : 0);
+ ui.locationMode->setCurrentIndex(filterData.locationNegate ? 1 : 0);
+ ui.equipmentMode->setCurrentIndex(filterData.equipmentNegate ? 1 : 0);
+
ignoreSignal = false;
filterDataChanged(filterData);
@@ -180,10 +186,10 @@ void FilterWidget2::updateFilter()
filterData.people = ui.people->text().split(",", QString::SkipEmptyParts);
filterData.location = ui.location->text().split(",", QString::SkipEmptyParts);
filterData.equipment = ui.equipment->text().split(",", QString::SkipEmptyParts);
- filterData.tagsNegate = ui.tagsNegate->isChecked();
- filterData.peopleNegate = ui.peopleNegate->isChecked();
- filterData.locationNegate = ui.locationNegate->isChecked();
- filterData.equipmentNegate = ui.equipmentNegate->isChecked();
+ filterData.tagsNegate = ui.tagsMode->currentIndex() == 1;
+ filterData.peopleNegate = ui.peopleMode->currentIndex() == 1;
+ filterData.locationNegate = ui.locationMode->currentIndex() == 1;
+ filterData.equipmentNegate = ui.equipmentMode->currentIndex() == 1;
filterData.logged = ui.logged->isChecked();
filterData.planned = ui.planned->isChecked();
diff --git a/desktop-widgets/filterwidget2.ui b/desktop-widgets/filterwidget2.ui
index 6167de4df..6a4345c43 100644
--- a/desktop-widgets/filterwidget2.ui
+++ b/desktop-widgets/filterwidget2.ui
@@ -291,44 +291,60 @@
</property>
</widget>
</item>
- <item row="8" column="2" colspan="2">
- <widget class="QToolButton" name="tagsNegate">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="toolTip">
- <string>Click to negate</string>
- </property>
- </widget>
- </item>
- <item row="9" column="2" colspan="2">
- <widget class="QToolButton" name="peopleNegate">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="toolTip">
- <string>Click to negate</string>
- </property>
- </widget>
- </item>
- <item row="10" column="2" colspan="2">
- <widget class="QToolButton" name="locationNegate">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="toolTip">
- <string>Click to negate</string>
- </property>
- </widget>
- </item>
- <item row="11" column="2" colspan="2">
- <widget class="QToolButton" name="equipmentNegate">
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="toolTip">
- <string>Click to negate</string>
- </property>
+ <item row="8" column="2">
+ <widget class="QComboBox" name="tagsMode">
+ <item>
+ <property name="text">
+ <string>All of</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>None of</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="9" column="2">
+ <widget class="QComboBox" name="peopleMode">
+ <item>
+ <property name="text">
+ <string>All of</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>None of</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="10" column="2">
+ <widget class="QComboBox" name="locationMode">
+ <item>
+ <property name="text">
+ <string>Matches</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Doesn't match</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="11" column="2">
+ <widget class="QComboBox" name="equipmentMode">
+ <item>
+ <property name="text">
+ <string>All of</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>None of</string>
+ </property>
+ </item>
</widget>
</item>
<item row="12" column="0">