two that I'v managed to do today. going home, and will do more later. :)
Tomaz
From 6947d5b429a547bd6ee0fe3ad62b09ad5d3accc8 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Thu, 20 Aug 2015 21:29:24 -0300 Subject: [PATCH 1/2] Display dives from the same location on the list Some dive sites are separated in more than one real dive site (for instance, a 'blue hole' dive site that has different entry points on the gps), so instead of checking only the dive_site id, also check it's name. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-models/filtermodels.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp index 6bec97c..80ed0cf 100644 --- a/qt-models/filtermodels.cpp +++ b/qt-models/filtermodels.cpp @@ -308,17 +308,29 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s struct dive *d = (struct dive *)diveVariant.value<void *>(); if (curr_dive_site) { + struct dive_site *ds = NULL; 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 ) + ds = get_dive_site_by_uuid(d->dive_site_uuid); + if (!ds) + continue; + if ( same_string(ds->name, curr_dive_site->name) || ds->uuid == curr_dive_site->uuid) { + if (ds->uuid != curr_dive_site->uuid) { + qWarning() << "Warning, two different dive sites with same name have a different id" + << ds->uuid << "and" << 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; + ds = get_dive_site_by_uuid(d->dive_site_uuid); + if (!ds) + return false; + return ( same_string(ds->name, curr_dive_site->name) || ds->uuid == curr_dive_site->uuid); } if (justCleared || models.isEmpty()) -- 2.5.0
From 7129f1b4530febcffcb5729cbf918133d64f51c0 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Thu, 20 Aug 2015 22:24:49 -0300 Subject: [PATCH 2/2] Save Properties for each State of the mainWindow Each state can have the same widgets but with different properties - currently I'm using "enabled" : true and false for the DiveSiteEdit, it looks like a big amount of code for such a small thing but it was the cleaner way that I tougth of doing. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/mainwindow.cpp | 31 +++++++++++++++++++++++++++++++ qt-ui/mainwindow.h | 17 +++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 1a12305..dec5503 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -119,6 +119,13 @@ MainWindow::MainWindow() : QMainWindow(), QWidget *diveSitePictures = new QWidget(); // Placeholder + std::pair<QByteArray, QVariant> enabled = std::make_pair("enabled", QVariant(true)); + std::pair<QByteArray, QVariant> disabled = std::make_pair("enabled", QVariant(false)); + PropertyList enabledList; + PropertyList disabledList; + enabledList.push_back(enabled); + disabledList.push_back(disabled); + registerApplicationState("Default", mainTab, profileContainer, diveListView, globeGps ); registerApplicationState("AddDive", mainTab, profileContainer, diveListView, globeGps ); registerApplicationState("EditDive", mainTab, profileContainer, diveListView, globeGps ); @@ -126,6 +133,13 @@ MainWindow::MainWindow() : QMainWindow(), registerApplicationState("EditPlannedDive", plannerWidget, profileContainer, diveListView, globeGps ); registerApplicationState("EditDiveSite", diveSiteEdit, diveSitePictures, diveListView, globeGps); + setStateProperties("Default", enabledList, enabledList, enabledList,enabledList); + setStateProperties("AddDive", enabledList, enabledList, enabledList,enabledList); + setStateProperties("EditDive", enabledList, enabledList, enabledList,enabledList); + setStateProperties("PlanDive", enabledList, enabledList, enabledList,enabledList); + setStateProperties("EditPlannedDive", enabledList, enabledList, enabledList,enabledList); + setStateProperties("EditDiveSite", enabledList, enabledList, disabledList, enabledList); + setApplicationState("Default"); ui.multiFilter->hide(); @@ -213,6 +227,11 @@ MainWindow::~MainWindow() m_Instance = NULL; } +void MainWindow::setStateProperties(const QByteArray& state, const PropertyList& tl, const PropertyList& tr, const PropertyList& bl, const PropertyList& br) +{ + stateProperties[state] = PropertiesForQuadrant(tl, tr, bl, br); +} + void MainWindow::on_actionDiveSiteEdit_triggered() { setApplicationState("EditDiveSite"); } @@ -1726,9 +1745,21 @@ void MainWindow::setApplicationState(const QByteArray& state) { } SET_CURRENT_INDEX( topLeft ) + Q_FOREACH(const WidgetProperty& p, stateProperties[state].topLeft) { + ui.topLeft->currentWidget()->setProperty( p.first.data(), p.second); + } SET_CURRENT_INDEX( topRight ) + Q_FOREACH(const WidgetProperty& p, stateProperties[state].topRight) { + ui.topRight->currentWidget()->setProperty( p.first.data(), p.second); + } SET_CURRENT_INDEX( bottomLeft ) + Q_FOREACH(const WidgetProperty& p, stateProperties[state].bottomLeft) { + ui.bottomLeft->currentWidget()->setProperty( p.first.data(), p.second); + } SET_CURRENT_INDEX( bottomRight ) + Q_FOREACH(const WidgetProperty& p, stateProperties[state].bottomRight) { + ui.bottomRight->currentWidget()->setProperty( p.first.data(), p.second); + } #undef SET_CURRENT_INDEX } diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 4df1d12..2d2ea88 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -39,6 +39,9 @@ class PlannerSettingsWidget; class QUndoStack; class LocationInformationWidget; +typedef std::pair<QByteArray, QVariant> WidgetProperty; +typedef QVector<WidgetProperty> PropertyList; + enum MainWindowTitleFormat { MWTF_DEFAULT, MWTF_FILENAME @@ -89,6 +92,7 @@ public: void printPlan(); void checkSurvey(QSettings *s); void setApplicationState(const QByteArray& state); + void setStateProperties(const QByteArray& state, const PropertyList& tl, const PropertyList& tr, const PropertyList& bl,const PropertyList& br); bool inPlanner(); QUndoStack *undoStack; NotificationWidget *getNotificationWidget(); @@ -225,7 +229,20 @@ private: QWidget *bottomLeft; QWidget *bottomRight; }; + + struct PropertiesForQuadrant { + PropertiesForQuadrant(){} + PropertiesForQuadrant(const PropertyList& tl, const PropertyList& tr,const PropertyList& bl,const PropertyList& br) : + topLeft(tl), topRight(tr), bottomLeft(bl), bottomRight(br) {} + PropertyList topLeft; + PropertyList topRight; + PropertyList bottomLeft; + PropertyList bottomRight; + }; + QHash<QByteArray, WidgetForQuadrant> applicationState; + QHash<QByteArray, PropertiesForQuadrant> stateProperties; + QByteArray currentApplicationState; WindowTitleUpdate *wtu; }; -- 2.5.0
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
