Filter: implement any-of mode

Add an additional mode to the tags, people and location filters: any_of.
Replace the original invert-bool by an enum.
Move the common code into a distinct function.

Reported-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-02-19 16:31:21 +01:00 committed by Dirk Hohndel
parent ce669adc53
commit e550a788f0
4 changed files with 66 additions and 31 deletions

View file

@ -140,10 +140,10 @@ void FilterWidget2::clearFilter()
ui.fromTime->setTime(filterData.fromTime);
ui.toDate->setDate(filterData.toDate.date());
ui.toTime->setTime(filterData.toTime);
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);
ui.tagsMode->setCurrentIndex((int)filterData.tagsMode);
ui.peopleMode->setCurrentIndex((int)filterData.peopleMode);
ui.locationMode->setCurrentIndex((int)filterData.locationMode);
ui.equipmentMode->setCurrentIndex((int)filterData.equipmentMode);
ignoreSignal = false;
@ -186,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.tagsMode->currentIndex() == 1;
filterData.peopleNegate = ui.peopleMode->currentIndex() == 1;
filterData.locationNegate = ui.locationMode->currentIndex() == 1;
filterData.equipmentNegate = ui.equipmentMode->currentIndex() == 1;
filterData.tagsMode = (FilterData::Mode)ui.tagsMode->currentIndex();
filterData.peopleMode = (FilterData::Mode)ui.peopleMode->currentIndex();
filterData.locationMode = (FilterData::Mode)ui.locationMode->currentIndex();
filterData.equipmentMode = (FilterData::Mode)ui.equipmentMode->currentIndex();
filterData.logged = ui.logged->isChecked();
filterData.planned = ui.planned->isChecked();