mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Filter: update filterData directly without copying
In FilterWidget2::updateFilter() a new FilterData object is generated and then copied onto the filterData member variable. Instead, modify filterData directly. This seems also more logical from a semantic point of view: Do we want to reset fields that were not set by the user? Contains trivial whitespace fix. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
cc0c4ab2f1
commit
36fa27050c
3 changed files with 21 additions and 24 deletions
|
@ -75,29 +75,26 @@ FilterWidget2::FilterWidget2(QWidget* parent)
|
|||
|
||||
void FilterWidget2::updateFilter()
|
||||
{
|
||||
FilterData data;
|
||||
filterData.validFilter = true;
|
||||
filterData.minVisibility = ui->minVisibility->currentStars();
|
||||
filterData.maxVisibility = ui->maxVisibility->currentStars();
|
||||
filterData.minRating = ui->minRating->currentStars();
|
||||
filterData.maxRating = ui->maxRating->currentStars();
|
||||
filterData.minWaterTemp = ui->minWaterTemp->value();
|
||||
filterData.maxWaterTemp = ui->maxWaterTemp->value();
|
||||
filterData.minAirTemp = ui->minAirTemp->value();
|
||||
filterData.maxWaterTemp = ui->maxWaterTemp->value();
|
||||
filterData.from = ui->from->dateTime();
|
||||
filterData.to = ui->to->dateTime();
|
||||
filterData.tags = ui->tags->text().split(",", QString::SkipEmptyParts);
|
||||
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.invertFilter = ui->invertFilter->isChecked();
|
||||
filterData.logged = ui->logged->isChecked();
|
||||
filterData.planned = ui->planned->isChecked();
|
||||
|
||||
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();
|
||||
data.logged = ui->logged->isChecked();
|
||||
data.planned = ui->planned->isChecked();
|
||||
|
||||
filterData = data;
|
||||
filterDataChanged(data);
|
||||
filterDataChanged(filterData);
|
||||
}
|
||||
|
||||
void FilterWidget2::updateLogged(int value) {
|
||||
|
|
|
@ -228,7 +228,7 @@ bool MultiFilterSortModel::lessThan(const QModelIndex &i1, const QModelIndex &i2
|
|||
return DiveTripModelBase::instance()->lessThan(i1, i2);
|
||||
}
|
||||
|
||||
void MultiFilterSortModel::filterDataChanged(const FilterData& data)
|
||||
void MultiFilterSortModel::filterDataChanged(const FilterData &data)
|
||||
{
|
||||
filterData = data;
|
||||
myInvalidate();
|
||||
|
|
|
@ -51,7 +51,7 @@ slots:
|
|||
void stopFilterDiveSite();
|
||||
void filterChanged(const QModelIndex &from, const QModelIndex &to, const QVector<int> &roles);
|
||||
void resetModel(DiveTripModelBase::Layout layout);
|
||||
void filterDataChanged(const FilterData& data);
|
||||
void filterDataChanged(const FilterData &data);
|
||||
|
||||
signals:
|
||||
void filterFinished();
|
||||
|
|
Loading…
Reference in a new issue