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>
This commit is contained in:
Berthold Stoeger 2019-01-26 14:02:09 -08:00 committed by Dirk Hohndel
parent de569b03bb
commit 11b357a4f0
2 changed files with 66 additions and 44 deletions

View file

@ -20,7 +20,7 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent), ignoreSignal(fa
// TODO: unhide this when we discover how to search for equipment. // TODO: unhide this when we discover how to search for equipment.
ui.equipment->hide(); ui.equipment->hide();
ui.equipmentNegate->hide(); ui.equipmentMode->hide();
ui.labelEquipment->hide(); ui.labelEquipment->hide();
ui.fromDate->setDisplayFormat(prefs.date_format); ui.fromDate->setDisplayFormat(prefs.date_format);
@ -50,6 +50,11 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent), ignoreSignal(fa
connect(ui.minVisibility, &StarWidget::valueChanged, connect(ui.minVisibility, &StarWidget::valueChanged,
this, &FilterWidget2::updateFilter); 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), connect(ui.maxAirTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &FilterWidget2::updateFilter); this, &FilterWidget2::updateFilter);
@ -77,19 +82,19 @@ FilterWidget2::FilterWidget2(QWidget* parent) : QWidget(parent), ignoreSignal(fa
connect(ui.tags, &QLineEdit::textChanged, connect(ui.tags, &QLineEdit::textChanged,
this, &FilterWidget2::updateFilter); this, &FilterWidget2::updateFilter);
connect(ui.tagsNegate, &QToolButton::toggled, connect(ui.tagsMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &FilterWidget2::updateFilter); this, &FilterWidget2::updateFilter);
connect(ui.people, &QLineEdit::textChanged, connect(ui.people, &QLineEdit::textChanged,
this, &FilterWidget2::updateFilter); this, &FilterWidget2::updateFilter);
connect(ui.peopleNegate, &QToolButton::toggled, connect(ui.peopleMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &FilterWidget2::updateFilter); this, &FilterWidget2::updateFilter);
connect(ui.location, &QLineEdit::textChanged, connect(ui.location, &QLineEdit::textChanged,
this, &FilterWidget2::updateFilter); this, &FilterWidget2::updateFilter);
connect(ui.locationNegate, &QToolButton::toggled, connect(ui.locationMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &FilterWidget2::updateFilter); this, &FilterWidget2::updateFilter);
connect(ui.logged, &QCheckBox::stateChanged, connect(ui.logged, &QCheckBox::stateChanged,
@ -135,10 +140,11 @@ void FilterWidget2::clearFilter()
ui.fromTime->setTime(filterData.fromTime); ui.fromTime->setTime(filterData.fromTime);
ui.toDate->setDate(filterData.toDate.date()); ui.toDate->setDate(filterData.toDate.date());
ui.toTime->setTime(filterData.toTime); ui.toTime->setTime(filterData.toTime);
ui.tagsNegate->setChecked(filterData.tagsNegate); ui.tagsMode->setCurrentIndex(filterData.tagsNegate ? 1 : 0);
ui.peopleNegate->setChecked(filterData.peopleNegate); ui.peopleMode->setCurrentIndex(filterData.peopleNegate ? 1 : 0);
ui.locationNegate->setChecked(filterData.locationNegate); ui.locationMode->setCurrentIndex(filterData.locationNegate ? 1 : 0);
ui.equipmentNegate->setChecked(filterData.equipmentNegate); ui.equipmentMode->setCurrentIndex(filterData.equipmentNegate ? 1 : 0);
ignoreSignal = false; ignoreSignal = false;
filterDataChanged(filterData); filterDataChanged(filterData);
@ -180,10 +186,10 @@ void FilterWidget2::updateFilter()
filterData.people = ui.people->text().split(",", QString::SkipEmptyParts); filterData.people = ui.people->text().split(",", QString::SkipEmptyParts);
filterData.location = ui.location->text().split(",", QString::SkipEmptyParts); filterData.location = ui.location->text().split(",", QString::SkipEmptyParts);
filterData.equipment = ui.equipment->text().split(",", QString::SkipEmptyParts); filterData.equipment = ui.equipment->text().split(",", QString::SkipEmptyParts);
filterData.tagsNegate = ui.tagsNegate->isChecked(); filterData.tagsNegate = ui.tagsMode->currentIndex() == 1;
filterData.peopleNegate = ui.peopleNegate->isChecked(); filterData.peopleNegate = ui.peopleMode->currentIndex() == 1;
filterData.locationNegate = ui.locationNegate->isChecked(); filterData.locationNegate = ui.locationMode->currentIndex() == 1;
filterData.equipmentNegate = ui.equipmentNegate->isChecked(); filterData.equipmentNegate = ui.equipmentMode->currentIndex() == 1;
filterData.logged = ui.logged->isChecked(); filterData.logged = ui.logged->isChecked();
filterData.planned = ui.planned->isChecked(); filterData.planned = ui.planned->isChecked();

View file

@ -291,44 +291,60 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="2" colspan="2"> <item row="8" column="2">
<widget class="QToolButton" name="tagsNegate"> <widget class="QComboBox" name="tagsMode">
<property name="checkable"> <item>
<bool>true</bool> <property name="text">
</property> <string>All of</string>
<property name="toolTip"> </property>
<string>Click to negate</string> </item>
</property> <item>
<property name="text">
<string>None of</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="9" column="2" colspan="2"> <item row="9" column="2">
<widget class="QToolButton" name="peopleNegate"> <widget class="QComboBox" name="peopleMode">
<property name="checkable"> <item>
<bool>true</bool> <property name="text">
</property> <string>All of</string>
<property name="toolTip"> </property>
<string>Click to negate</string> </item>
</property> <item>
<property name="text">
<string>None of</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="10" column="2" colspan="2"> <item row="10" column="2">
<widget class="QToolButton" name="locationNegate"> <widget class="QComboBox" name="locationMode">
<property name="checkable"> <item>
<bool>true</bool> <property name="text">
</property> <string>Matches</string>
<property name="toolTip"> </property>
<string>Click to negate</string> </item>
</property> <item>
<property name="text">
<string>Doesn't match</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="11" column="2" colspan="2"> <item row="11" column="2">
<widget class="QToolButton" name="equipmentNegate"> <widget class="QComboBox" name="equipmentMode">
<property name="checkable"> <item>
<bool>true</bool> <property name="text">
</property> <string>All of</string>
<property name="toolTip"> </property>
<string>Click to negate</string> </item>
</property> <item>
<property name="text">
<string>None of</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="12" column="0"> <item row="12" column="0">