mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:43:24 +00:00
Dive list: update trip headers on filter-finish
On change of the filter, the headers of non-extended trips were not updated. Therefore, on filter-finish-event loop over all trips in DiveTripModel and signal data-changed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
bca9c8f88c
commit
2f81890f49
2 changed files with 17 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "qt-models/divetripmodel.h"
|
||||
#include "qt-models/filtermodels.h"
|
||||
#include "core/gettextfromc.h"
|
||||
#include "core/metrics.h"
|
||||
#include "core/divelist.h"
|
||||
|
@ -319,6 +320,9 @@ DiveTripModel::DiveTripModel(QObject *parent) :
|
|||
connect(&diveListNotifier, &DiveListNotifier::divesSelected, this, &DiveTripModel::divesSelected);
|
||||
connect(&diveListNotifier, &DiveListNotifier::divesDeselected, this, &DiveTripModel::divesDeselected);
|
||||
connect(&diveListNotifier, &DiveListNotifier::currentDiveChanged, this, &DiveTripModel::currentDiveChanged);
|
||||
|
||||
// Update trip headers if filter finished
|
||||
connect(MultiFilterSortModel::instance(), &MultiFilterSortModel::filterFinished, this, &DiveTripModel::filterFinished);
|
||||
}
|
||||
|
||||
int DiveTripModel::columnCount(const QModelIndex&) const
|
||||
|
@ -1095,3 +1099,15 @@ void DiveTripModel::currentDiveChanged()
|
|||
emit newCurrentDive(createIndex(diveIdx, 0, idx));
|
||||
}
|
||||
}
|
||||
|
||||
void DiveTripModel::filterFinished()
|
||||
{
|
||||
// If the filter finished, update all trip items to show the correct number of displayed dives
|
||||
// in each trip. Without doing this, only trip headers of expanded trips were updated.
|
||||
if (currentLayout == LIST)
|
||||
return; // No trips in list mode
|
||||
for (int idx = 0; idx < (int)items.size(); ++idx) {
|
||||
QModelIndex tripIndex = createIndex(idx, 0, noParent);
|
||||
dataChanged(tripIndex, tripIndex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ private slots:
|
|||
void divesSelected(dive_trip *trip, const QVector<dive *> &dives);
|
||||
void divesDeselected(dive_trip *trip, const QVector<dive *> &dives);
|
||||
void currentDiveChanged();
|
||||
void filterFinished();
|
||||
private:
|
||||
// The model has up to two levels. At the top level, we have either trips or dives
|
||||
// that do not belong to trips. Such a top-level item is represented by the "Item"
|
||||
|
|
Loading…
Add table
Reference in a new issue