aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/filterwidget2.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2018-12-06 20:07:47 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-12-14 01:05:18 +0800
commit81bb6086c0e7f7ba6d4100a49cc9cf32556caaaf (patch)
tree478e59d052d3fddd564c7bbabbd44d8544b276ca /desktop-widgets/filterwidget2.cpp
parent89413c5f0779813dab1b63e24aa4b34aebc1e28c (diff)
downloadsubsurface-81bb6086c0e7f7ba6d4100a49cc9cf32556caaaf.tar.gz
Struct FilterData
The idea is that this struct will have all the needed data that will be passed to the filter model. Everything that happens on the filterwidget will fill out this struct, then forward it to the model, that in turn will activate the filter hiding some of the dives that matches on your divelist. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'desktop-widgets/filterwidget2.cpp')
-rw-r--r--desktop-widgets/filterwidget2.cpp36
1 files changed, 31 insertions, 5 deletions
diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp
index 9bf526a88..50cad019a 100644
--- a/desktop-widgets/filterwidget2.cpp
+++ b/desktop-widgets/filterwidget2.cpp
@@ -8,10 +8,17 @@ FilterWidget2::FilterWidget2(QWidget* parent)
, ui(new Ui::FilterWidget2())
{
ui->setupUi(this);
- ui->minRating->setCurrentStars(0);
- ui->maxRating->setCurrentStars(5);
- ui->minVisibility->setCurrentStars(0);
- ui->maxVisibility->setCurrentStars(5);
+
+ FilterData data;
+ ui->minRating->setCurrentStars(data.minRating);
+ ui->maxRating->setCurrentStars(data.maxRating);
+ ui->minVisibility->setCurrentStars(data.minVisibility);
+ ui->maxVisibility->setCurrentStars(data.maxVisibility);
+ ui->minAirTemp->setValue(data.minAirTemp);
+ ui->maxAirTemp->setValue(data.maxAirTemp);
+ ui->minWaterTemp->setValue(data.minWaterTemp);
+ ui->maxWaterTemp->setValue(data.maxWaterTemp);
+ ui->to->setDate(data.to.date());
connect(ui->maxRating, &StarWidget::valueChanged,
this, &FilterWidget2::updateFilter);
@@ -55,5 +62,24 @@ FilterWidget2::FilterWidget2(QWidget* parent)
void FilterWidget2::updateFilter()
{
-
+ FilterData data;
+
+ data.validFilter = true;
+ data.minVisibility = ui->minVisibility->currentStars();
+ data.maxVisibility = ui->maxVisibility->currentStars();
+ data.minRating = ui->minRating->currentStars();
+ data.maxRating = ui->maxRating->currentStars();
+ data.minWaterTemp = ui->minWaterTemp->value();
+ data.maxWaterTemp = ui->maxWaterTemp->value();
+ data.minAirTemp = ui->minAirTemp->value();
+ data.maxWaterTemp = ui->maxWaterTemp->value();
+ data.from = ui->from->dateTime();
+ data.to = ui->to->dateTime();
+ data.tags = ui->tags->text().split(",", QString::SkipEmptyParts);
+ data.people = ui->people->text().split(",", QString::SkipEmptyParts);
+ data.location = ui->location->text().split(",", QString::SkipEmptyParts);
+ data.equipment = ui->equipment->text().split(",", QString::SkipEmptyParts);
+ data.invertFilter = ui->invertFilter->isChecked();
+
+ emit filterDataChanged(data);
}