summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/filterwidget2.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-01-26 14:02:09 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-01-28 07:24:10 -0800
commit11b357a4f080f43c2fc3d1c169aeb94d042d041e (patch)
tree1aac222f09ed052ffa10a64ffb6c844f00cba0c3 /desktop-widgets/filterwidget2.cpp
parentde569b03bb132b09d397747015629a6cc625e3c2 (diff)
downloadsubsurface-11b357a4f080f43c2fc3d1c169aeb94d042d041e.tar.gz
Desktop: set filter negation texts
The texts may not be perfect, but this is a start. Replace the buttons by combo-boxes. This will allow potential extension to "any of". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/filterwidget2.cpp')
-rw-r--r--desktop-widgets/filterwidget2.cpp30
1 files changed, 18 insertions, 12 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();