mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Filter out the dives that are not at dive_site.
Untested code to filter out dives that are not at the active dive_site. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
ee7e511372
commit
ffffccee93
4 changed files with 33 additions and 6 deletions
|
@ -298,14 +298,28 @@ MultiFilterSortModel::MultiFilterSortModel(QObject *parent) : QSortFilterProxyMo
|
|||
|
||||
bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
{
|
||||
if (justCleared || models.isEmpty())
|
||||
return true;
|
||||
|
||||
bool shouldShow = true;
|
||||
QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent);
|
||||
QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE);
|
||||
struct dive *d = (struct dive *)diveVariant.value<void *>();
|
||||
|
||||
if (curr_dive_site) {
|
||||
if (!d) { // It's a trip, only show the ones that have dives to be shown.
|
||||
bool showTrip = false;
|
||||
for (int i = 0; i < sourceModel()->rowCount(index0); i++) {
|
||||
QModelIndex child = sourceModel()->index(i, 0, index0);
|
||||
d = (struct dive *) sourceModel()->data(child, DiveTripModel::DIVE_ROLE).value<void*>();
|
||||
if ( d->dive_site_uuid == curr_dive_site->uuid )
|
||||
showTrip = true; // do not shortcircuit the loop or the counts will be wrong
|
||||
}
|
||||
return showTrip;
|
||||
}
|
||||
return d->dive_site_uuid == curr_dive_site->uuid;
|
||||
}
|
||||
|
||||
if (justCleared || models.isEmpty())
|
||||
return true;
|
||||
|
||||
if (!d) { // It's a trip, only show the ones that have dives to be shown.
|
||||
bool showTrip = false;
|
||||
for (int i = 0; i < sourceModel()->rowCount(index0); i++) {
|
||||
|
@ -389,7 +403,7 @@ void MultiFilterSortModel::clearFilter()
|
|||
myInvalidate();
|
||||
}
|
||||
|
||||
void MultiFilterSortModel::startFilterDiveSite(int32_t uuid)
|
||||
void MultiFilterSortModel::startFilterDiveSite(uint32_t uuid)
|
||||
{
|
||||
curr_dive_site = get_dive_site_by_uuid(uuid);
|
||||
myInvalidate();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue