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
|
bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||||
{
|
{
|
||||||
if (justCleared || models.isEmpty())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
bool shouldShow = true;
|
bool shouldShow = true;
|
||||||
QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent);
|
QModelIndex index0 = sourceModel()->index(source_row, 0, source_parent);
|
||||||
QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE);
|
QVariant diveVariant = sourceModel()->data(index0, DiveTripModel::DIVE_ROLE);
|
||||||
struct dive *d = (struct dive *)diveVariant.value<void *>();
|
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.
|
if (!d) { // It's a trip, only show the ones that have dives to be shown.
|
||||||
bool showTrip = false;
|
bool showTrip = false;
|
||||||
for (int i = 0; i < sourceModel()->rowCount(index0); i++) {
|
for (int i = 0; i < sourceModel()->rowCount(index0); i++) {
|
||||||
|
@ -389,7 +403,7 @@ void MultiFilterSortModel::clearFilter()
|
||||||
myInvalidate();
|
myInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiFilterSortModel::startFilterDiveSite(int32_t uuid)
|
void MultiFilterSortModel::startFilterDiveSite(uint32_t uuid)
|
||||||
{
|
{
|
||||||
curr_dive_site = get_dive_site_by_uuid(uuid);
|
curr_dive_site = get_dive_site_by_uuid(uuid);
|
||||||
myInvalidate();
|
myInvalidate();
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
class MultiFilterInterface {
|
class MultiFilterInterface {
|
||||||
public:
|
public:
|
||||||
|
@ -93,7 +94,7 @@ public
|
||||||
slots:
|
slots:
|
||||||
void myInvalidate();
|
void myInvalidate();
|
||||||
void clearFilter();
|
void clearFilter();
|
||||||
void startFilterDiveSite(int32_t uuid);
|
void startFilterDiveSite(uint32_t uuid);
|
||||||
void stopFilterDiveSite();
|
void stopFilterDiveSite();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "divelistview.h"
|
#include "divelistview.h"
|
||||||
#include "qthelper.h"
|
#include "qthelper.h"
|
||||||
#include "globe.h"
|
#include "globe.h"
|
||||||
|
#include "filtermodels.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
|
@ -69,6 +70,8 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
|
||||||
|
|
||||||
ui.currentLocation->setModel(new LocationInformationModel());
|
ui.currentLocation->setModel(new LocationInformationModel());
|
||||||
connect(ui.currentLocation, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentDiveSite(int)));
|
connect(ui.currentLocation, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentDiveSite(int)));
|
||||||
|
connect(this, SIGNAL(startFilterDiveSite(uint32_t)), MultiFilterSortModel::instance(), SLOT(startFilterDiveSite(uint32_t)));
|
||||||
|
connect(this, SIGNAL(stopFilterDiveSite()), MultiFilterSortModel::instance(), SLOT(stopFilterDiveSite()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationInformationWidget::setCurrentDiveSite(int dive_nr)
|
void LocationInformationWidget::setCurrentDiveSite(int dive_nr)
|
||||||
|
@ -91,7 +94,11 @@ void LocationInformationWidget::setLocationId(uint32_t uuid)
|
||||||
if(!currentDs)
|
if(!currentDs)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (displayed_dive_site.uuid == currentDs->uuid)
|
||||||
|
return;
|
||||||
|
|
||||||
displayed_dive_site = *currentDs;
|
displayed_dive_site = *currentDs;
|
||||||
|
|
||||||
if (ui.currentLocation->currentText() != displayed_dive_site.name) {
|
if (ui.currentLocation->currentText() != displayed_dive_site.name) {
|
||||||
// this will trigger setCurrentDiveSite again, and thus,
|
// this will trigger setCurrentDiveSite again, and thus,
|
||||||
// will gethere with the correct uuid.
|
// will gethere with the correct uuid.
|
||||||
|
@ -115,6 +122,8 @@ void LocationInformationWidget::setLocationId(uint32_t uuid)
|
||||||
ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg));
|
ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg));
|
||||||
else
|
else
|
||||||
ui.diveSiteCoordinates->clear();
|
ui.diveSiteCoordinates->clear();
|
||||||
|
|
||||||
|
emit startFilterDiveSite(displayed_dive_site.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocationInformationWidget::updateGpsCoordinates()
|
void LocationInformationWidget::updateGpsCoordinates()
|
||||||
|
@ -125,6 +134,7 @@ void LocationInformationWidget::updateGpsCoordinates()
|
||||||
|
|
||||||
void LocationInformationWidget::acceptChanges()
|
void LocationInformationWidget::acceptChanges()
|
||||||
{
|
{
|
||||||
|
emit stopFilterDiveSite();
|
||||||
char *uiString;
|
char *uiString;
|
||||||
currentDs->latitude = displayed_dive_site.latitude;
|
currentDs->latitude = displayed_dive_site.latitude;
|
||||||
currentDs->longitude = displayed_dive_site.longitude;
|
currentDs->longitude = displayed_dive_site.longitude;
|
||||||
|
@ -156,6 +166,7 @@ void LocationInformationWidget::acceptChanges()
|
||||||
|
|
||||||
void LocationInformationWidget::rejectChanges()
|
void LocationInformationWidget::rejectChanges()
|
||||||
{
|
{
|
||||||
|
emit stopFilterDiveSite();
|
||||||
Q_ASSERT(currentDs != NULL);
|
Q_ASSERT(currentDs != NULL);
|
||||||
if (dive_site_is_empty(currentDs)) {
|
if (dive_site_is_empty(currentDs)) {
|
||||||
delete_dive_site(currentDs->uuid);
|
delete_dive_site(currentDs->uuid);
|
||||||
|
@ -169,6 +180,7 @@ void LocationInformationWidget::rejectChanges()
|
||||||
|
|
||||||
void LocationInformationWidget::showEvent(QShowEvent *ev)
|
void LocationInformationWidget::showEvent(QShowEvent *ev)
|
||||||
{
|
{
|
||||||
|
emit startFilterDiveSite(displayed_dive_site.uuid);
|
||||||
ui.diveSiteMessage->setCloseButtonVisible(false);
|
ui.diveSiteMessage->setCloseButtonVisible(false);
|
||||||
QGroupBox::showEvent(ev);
|
QGroupBox::showEvent(ev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ signals:
|
||||||
void informationManagementEnded();
|
void informationManagementEnded();
|
||||||
void coordinatesChanged();
|
void coordinatesChanged();
|
||||||
void startFilterDiveSite(uint32_t uuid);
|
void startFilterDiveSite(uint32_t uuid);
|
||||||
void stopFilterFiveSite();
|
void stopFilterDiveSite();
|
||||||
private:
|
private:
|
||||||
struct dive_site *currentDs;
|
struct dive_site *currentDs;
|
||||||
Ui::LocationInformation ui;
|
Ui::LocationInformation ui;
|
||||||
|
|
Loading…
Add table
Reference in a new issue