From c173fc567db339330bffa3e51769d63c8d18a6de Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 11 Feb 2015 13:00:10 -0200 Subject: Add the ui file for the location information Just the xml file for the Ui location information. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/locationInformation.ui | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 qt-ui/locationInformation.ui (limited to 'qt-ui') diff --git a/qt-ui/locationInformation.ui b/qt-ui/locationInformation.ui new file mode 100644 index 000000000..41e8ad0bc --- /dev/null +++ b/qt-ui/locationInformation.ui @@ -0,0 +1,75 @@ + + + GroupBox + + + + 0 + 0 + 400 + 300 + + + + GroupBox + + + Dive Site + + + + + + + + + Name + + + + + + + + + + Coordinates + + + + + + + + + + Description + + + + + + + + + + Notes + + + + + + + + + + + KMessageWidget + QWidget +
kmessagewidget.h
+ 1 +
+
+ + +
-- cgit v1.2.3-70-g09d2 From 63e998b4bdeeea6d4a79533845761ef0368552de Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 11 Feb 2015 13:04:29 -0200 Subject: More meaningfull names for the ui elements. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/locationInformation.ui | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/locationInformation.ui b/qt-ui/locationInformation.ui index 41e8ad0bc..1d7afa77d 100644 --- a/qt-ui/locationInformation.ui +++ b/qt-ui/locationInformation.ui @@ -28,7 +28,7 @@ - + @@ -38,7 +38,7 @@ - + @@ -48,7 +48,7 @@ - + @@ -58,7 +58,7 @@ - + -- cgit v1.2.3-70-g09d2 From 3516ff2ab27905bc7698d5b052084b162042427f Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 11 Feb 2015 13:13:52 -0200 Subject: Create simple class to hold the location management. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/locationInformation.ui | 4 ++-- qt-ui/simplewidgets.cpp | 4 ++++ qt-ui/simplewidgets.h | 11 +++++++++++ subsurface.pro | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/locationInformation.ui b/qt-ui/locationInformation.ui index 1d7afa77d..658395b35 100644 --- a/qt-ui/locationInformation.ui +++ b/qt-ui/locationInformation.ui @@ -1,7 +1,7 @@ - GroupBox - + LocationInformation + 0 diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 5c08a3f7e..98d9bcf9f 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -646,3 +646,7 @@ void MultiFilter::closeFilter() MultiFilterSortModel::instance()->clearFilter(); hide(); } + +LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent) { + ui.setupUi(this); +} diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index 8d5b4f73c..cfa9e0423 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -6,6 +6,7 @@ class QAbstractButton; class QNetworkReply; #include +#include #include #include @@ -214,6 +215,16 @@ private: Ui::FilterWidget ui; }; +#include "ui_locationInformation.h" + +class LocationInformationWidget : public QGroupBox { +Q_OBJECT +public: + LocationInformationWidget(QWidget *parent = 0); +private: + Ui::LocationInformation ui; +}; + bool isGnome3Session(); QImage grayImage(const QImage &coloredImg); diff --git a/subsurface.pro b/subsurface.pro index d65c94f50..2469b8aa9 100644 --- a/subsurface.pro +++ b/subsurface.pro @@ -238,7 +238,8 @@ FORMS = \ qt-ui/listfilter.ui \ qt-ui/diveshareexportdialog.ui \ qt-ui/filterwidget.ui \ - qt-ui/plannerDetails.ui + qt-ui/plannerDetails.ui \ + qt-ui/locationInformation.ui # Nether usermanual or printing is supported on android right now android: FORMS -= qt-ui/printoptions.ui -- cgit v1.2.3-70-g09d2 From e3d800885f9b5814f88235f49982635f7644da8e Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 11 Feb 2015 13:19:35 -0200 Subject: Create a new state for the MainWindow: EditDiveSite Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 7 +++++++ qt-ui/mainwindow.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 257f394d6..c763f8e58 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -67,12 +67,15 @@ MainWindow::MainWindow() : QMainWindow(), PlannerSettingsWidget *plannerSettings = new PlannerSettingsWidget(); DivePlannerWidget *plannerWidget = new DivePlannerWidget(); PlannerDetails *plannerDetails = new PlannerDetails(); + LocationInformationWidget *locationInformation = new LocationInformationWidget(); registerApplicationState("Default", mainTab, profileWidget, diveListView, globeGps ); registerApplicationState("AddDive", mainTab, profileWidget, diveListView, globeGps ); registerApplicationState("EditDive", mainTab, profileWidget, diveListView, globeGps ); registerApplicationState("PlanDive", plannerWidget, profileWidget, plannerSettings, plannerDetails ); registerApplicationState("EditPlannedDive", plannerWidget, profileWidget, diveListView, globeGps ); + registerApplicationState("EditDiveSite",locationInformation, profileWidget, diveListView, globeGps ); + setApplicationState("Default"); ui.multiFilter->hide(); @@ -205,6 +208,10 @@ PlannerSettingsWidget *MainWindow::divePlannerSettingsWidget() { return qobject_cast(applicationState["PlanDive"].bottomLeft); } +LocationInformationWidget *MainWindow::locationInformationWidget() { + return qobject_cast(applicationState["EditDiveSite"].topLeft); +} + void MainWindow::setLoadedWithFiles(bool f) { filesAsArguments = f; diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 25771d650..6d4c05acc 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -68,7 +68,7 @@ public: GlobeGPS *globe(); DivePlannerWidget *divePlannerWidget(); PlannerSettingsWidget *divePlannerSettingsWidget(); - + LocationInformationWidget *locationInformationWidget(); void showError(QString message); void setTitle(enum MainWindowTitleFormat format); -- cgit v1.2.3-70-g09d2 From 7d66dcd12d42db7c9e3f18be21615204588a66e3 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 11 Feb 2015 13:32:29 -0200 Subject: Enable the location edit widget on mainwindow Clicking on the 'Manage' button now brings you to the widget to manage it. Nothing has been added on it yet. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 2 ++ qt-ui/maintab.h | 2 +- qt-ui/maintab.ui | 8 ++++---- qt-ui/mainwindow.cpp | 5 +++++ qt-ui/mainwindow.h | 1 + 5 files changed, 13 insertions(+), 5 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index e0da97a2d..385b0e2e2 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -49,6 +49,8 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.extraData->setModel(extraDataModel); closeMessage(); + connect(ui.manageDiveSite, SIGNAL(clicked()), this, SIGNAL(requestDiveSiteEdit())); + QAction *action = new QAction(tr("Apply changes"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges())); addMessageAction(action); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index a279baf7a..acbb8f14f 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -55,7 +55,7 @@ public: signals: void addDiveFinished(); void dateTimeChanged(); - + void requestDiveSiteEdit(); public slots: void addCylinder_clicked(); diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 48bad01aa..cdaab8386 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -131,7 +131,7 @@ - + manage @@ -400,7 +400,7 @@ 0 0 - 454 + 443 752 @@ -456,7 +456,7 @@ 0 0 - 454 + 443 752 @@ -773,7 +773,7 @@ 0 0 - 454 + 443 752 diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index c763f8e58..c3226c0d0 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -111,6 +111,7 @@ MainWindow::MainWindow() : QMainWindow(), connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled())); connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); + connect(mainTab, SIGNAL(requestDiveSiteEdit()), this, SLOT(enableDiveSiteEdit())); #ifdef NO_PRINTING ui.printPlan->hide(); ui.menuFile->removeAction(ui.actionPrint); @@ -212,6 +213,10 @@ LocationInformationWidget *MainWindow::locationInformationWidget() { return qobject_cast(applicationState["EditDiveSite"].topLeft); } +void MainWindow::enableDiveSiteEdit() { + setApplicationState("EditDiveSite"); +} + void MainWindow::setLoadedWithFiles(bool f) { filesAsArguments = f; diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 6d4c05acc..69ee44217 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -159,6 +159,7 @@ slots: void on_paste_triggered(); void on_actionFilterTags_triggered(); void on_actionConfigure_Dive_Computer_triggered(); + void enableDiveSiteEdit(); protected: void closeEvent(QCloseEvent *); -- cgit v1.2.3-70-g09d2 From 68691c9d6d05ba28c8e0e8c837dcd32bb2eec42c Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 11 Feb 2015 13:58:23 -0200 Subject: Accept / Cancel location edit Make it possible to cancel or accept the location edit and get back to the mainwindow default state. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 3 +-- qt-ui/mainwindow.cpp | 5 +++++ qt-ui/mainwindow.h | 1 + qt-ui/simplewidgets.cpp | 30 +++++++++++++++++++++++++++++- qt-ui/simplewidgets.h | 9 +++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 385b0e2e2..2f39c17db 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -57,12 +57,11 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), action = new QAction(tr("Discard changes"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges())); + addMessageAction(action); QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this); connect(closeKey, SIGNAL(activated()), this, SLOT(escDetected())); - addMessageAction(action); - if (qApp->style()->objectName() == "oxygen") setDocumentMode(true); else diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index c3226c0d0..51b0353be 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -112,6 +112,7 @@ MainWindow::MainWindow() : QMainWindow(), connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled())); connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); connect(mainTab, SIGNAL(requestDiveSiteEdit()), this, SLOT(enableDiveSiteEdit())); + connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState())); #ifdef NO_PRINTING ui.printPlan->hide(); ui.menuFile->removeAction(ui.actionPrint); @@ -217,6 +218,10 @@ void MainWindow::enableDiveSiteEdit() { setApplicationState("EditDiveSite"); } +void MainWindow::setDefaultState() { + setApplicationState("Default"); +} + void MainWindow::setLoadedWithFiles(bool f) { filesAsArguments = f; diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 69ee44217..300748371 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -160,6 +160,7 @@ slots: void on_actionFilterTags_triggered(); void on_actionConfigure_Dive_Computer_triggered(); void enableDiveSiteEdit(); + void setDefaultState(); protected: void closeEvent(QCloseEvent *); diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 98d9bcf9f..63ec4b4fa 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "file.h" #include "mainwindow.h" @@ -646,7 +647,34 @@ void MultiFilter::closeFilter() MultiFilterSortModel::instance()->clearFilter(); hide(); } +#include +#include -LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent) { +LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent) +{ ui.setupUi(this); + ui.diveSiteMessage->setText("You are editing the Dive Site"); + ui.diveSiteMessage->setCloseButtonVisible(false); + + QAction *action = new QAction(tr("Apply changes"), this); + connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges())); + ui.diveSiteMessage->addAction(action); + + action = new QAction(tr("Discard changes"), this); + connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges())); + ui.diveSiteMessage->addAction(action); +} + +void LocationInformationWidget::acceptChanges() +{ + emit informationManagementEnded(); +} + +void LocationInformationWidget::rejectChanges() +{ + emit informationManagementEnded(); +} + +void LocationInformationWidget::showEvent(QShowEvent *ev) { + ui.diveSiteMessage->setCloseButtonVisible(false); } diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index cfa9e0423..16ed0478c 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -221,6 +221,15 @@ class LocationInformationWidget : public QGroupBox { Q_OBJECT public: LocationInformationWidget(QWidget *parent = 0); + +public slots: + void acceptChanges(); + void rejectChanges(); + + void showEvent(QShowEvent *); +signals: + void informationManagementEnded(); + private: Ui::LocationInformation ui; }; -- cgit v1.2.3-70-g09d2 From d769c6016fb9fd484cfee90aa58eaac67f0d536a Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 11 Feb 2015 14:53:02 -0200 Subject: Copy the name and the coords when entering the EditDiveSite state Name and coords of the current dive are copied to the edit dive site screen. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 2 ++ qt-ui/simplewidgets.cpp | 10 ++++++++++ qt-ui/simplewidgets.h | 5 +++++ 3 files changed, 17 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 51b0353be..a83d0903a 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -215,6 +215,8 @@ LocationInformationWidget *MainWindow::locationInformationWidget() { } void MainWindow::enableDiveSiteEdit() { + locationInformationWidget()->setLocationName(current_dive->location); + locationInformationWidget()->setLocationCoords(printGPSCoords(current_dive->latitude.udeg, current_dive->longitude.udeg)); setApplicationState("EditDiveSite"); } diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 63ec4b4fa..c7dd47c6d 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -665,6 +665,16 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo ui.diveSiteMessage->addAction(action); } +void LocationInformationWidget::setLocationName(const QString& name) +{ + ui.diveSiteName->setText(name); +} + +void LocationInformationWidget::setLocationCoords(const QString& coords) +{ + ui.diveSiteCoordinates->setText(coords); +} + void LocationInformationWidget::acceptChanges() { emit informationManagementEnded(); diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index 16ed0478c..24af171a7 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -227,6 +227,11 @@ public slots: void rejectChanges(); void showEvent(QShowEvent *); + + /* change that to setLocationSite(QUuid diveSiteUid or something later */ + void setLocationName(const QString& name); + void setLocationCoords(const QString& coords); + signals: void informationManagementEnded(); -- cgit v1.2.3-70-g09d2 From 42afb4972ad2928f7f93dd9806234154c62f42cd Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 11 Feb 2015 10:14:45 -0800 Subject: Pass a fake dive site UUID to the callback. This is the start of the preparations to edit the dive site, passing a uuid so we can retrieve it later. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 7 ++++++- qt-ui/maintab.h | 5 +++-- qt-ui/mainwindow.cpp | 4 ++-- qt-ui/mainwindow.h | 3 ++- 4 files changed, 13 insertions(+), 6 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 2f39c17db..571d38b9d 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -49,7 +49,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.extraData->setModel(extraDataModel); closeMessage(); - connect(ui.manageDiveSite, SIGNAL(clicked()), this, SIGNAL(requestDiveSiteEdit())); + connect(ui.manageDiveSite, SIGNAL(clicked()), this, SLOT(prepareDiveSiteEdit())); QAction *action = new QAction(tr("Apply changes"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges())); @@ -213,6 +213,11 @@ MainTab::~MainTab() } } +void MainTab::prepareDiveSiteEdit() { + //TODO: GET THE CORRECT DIVESITE UUID HERE + QUuid id = QUuid::createUuid(); + emit requestDiveSiteEdit(id); +} void MainTab::toggleTriggeredColumn() { QAction *action = qobject_cast(sender()); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index acbb8f14f..c90b0fb09 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "ui_maintab.h" #include "completionmodels.h" @@ -55,7 +56,7 @@ public: signals: void addDiveFinished(); void dateTimeChanged(); - void requestDiveSiteEdit(); + void requestDiveSiteEdit(QUuid diveSiteId); public slots: void addCylinder_clicked(); @@ -93,7 +94,7 @@ slots: void photoDoubleClicked(const QString filePath); void removeSelectedPhotos(); void updateGpsCoordinates(); - + void prepareDiveSiteEdit(); private: Ui::MainTab ui; WeightModel *weightModel; diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index a83d0903a..eca4c08f8 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -111,7 +111,7 @@ MainWindow::MainWindow() : QMainWindow(), connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled())); connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); - connect(mainTab, SIGNAL(requestDiveSiteEdit()), this, SLOT(enableDiveSiteEdit())); + connect(mainTab, SIGNAL(requestDiveSiteEdit(QUuid)), this, SLOT(enableDiveSiteEdit(QUuid))); connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState())); #ifdef NO_PRINTING ui.printPlan->hide(); @@ -214,7 +214,7 @@ LocationInformationWidget *MainWindow::locationInformationWidget() { return qobject_cast(applicationState["EditDiveSite"].topLeft); } -void MainWindow::enableDiveSiteEdit() { +void MainWindow::enableDiveSiteEdit(QUuid id) { locationInformationWidget()->setLocationName(current_dive->location); locationInformationWidget()->setLocationCoords(printGPSCoords(current_dive->latitude.udeg, current_dive->longitude.udeg)); setApplicationState("EditDiveSite"); diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 300748371..ef3e8fa18 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "ui_mainwindow.h" @@ -159,7 +160,7 @@ slots: void on_paste_triggered(); void on_actionFilterTags_triggered(); void on_actionConfigure_Dive_Computer_triggered(); - void enableDiveSiteEdit(); + void enableDiveSiteEdit(QUuid id); void setDefaultState(); protected: -- cgit v1.2.3-70-g09d2 From 9edb7811ef3366cf5ee378a07adb7121fab8630a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 11 Feb 2015 10:33:36 -0800 Subject: Remove redundant function We had two functions doing exactly the same thing. Let's drop the one with the highly confusing name. Signed-off-by: Dirk Hohndel --- dive.h | 7 ------- qt-ui/subsurfacewebservices.cpp | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'qt-ui') diff --git a/dive.h b/dive.h index b350527a7..a5d0e8712 100644 --- a/dive.h +++ b/dive.h @@ -494,13 +494,6 @@ extern unsigned int dc_number; #define current_dive (get_dive(selected_dive)) #define current_dc (get_dive_dc(current_dive, dc_number)) -static inline struct dive *get_gps_location(int nr, struct dive_table *table) -{ - if (nr >= table->nr || nr < 0) - return NULL; - return table->dives[nr]; -} - static inline struct dive *get_dive(int nr) { if (nr >= dive_table.nr || nr < 0) diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 72e7e3d27..a247888a2 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -42,7 +42,7 @@ static bool merge_locations_into_dives(void) for_each_dive (i, dive) { if (!dive_has_gps_location(dive)) { - for (j = tracer; (gpsfix = get_gps_location(j, &gps_location_table)) !=NULL; j++) { + for (j = tracer; (gpsfix = get_dive_from_table(j, &gps_location_table)) !=NULL; j++) { if (dive_within_time_range (dive, gpsfix->when, SAME_GROUP)) { /* * If position is fixed during dive. This is the good one. @@ -57,7 +57,7 @@ static bool merge_locations_into_dives(void) /* * If it is not, check if there are more position fixes in SAME_GROUP range */ - if ((nextgpsfix = get_gps_location(j+1,&gps_location_table)) && + if ((nextgpsfix = get_dive_from_table(j+1,&gps_location_table)) && dive_within_time_range (dive, nextgpsfix->when, SAME_GROUP)) { /* * If distance from gpsfix to end of dive is shorter than distance between -- cgit v1.2.3-70-g09d2 From 6a812c6b6dfffca3c99f4076005de6ee9f11d614 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 12:46:21 -0800 Subject: Show location based on dive site on MainTab Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 571d38b9d..48d2a0034 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -430,9 +430,7 @@ void MainTab::updateDiveInfo(bool clear) else ui.notes->setPlainText(tmp); } - UPDATE_TEXT(displayed_dive, notes); - UPDATE_TEXT(displayed_dive, location); UPDATE_TEXT(displayed_dive, suit); UPDATE_TEXT(displayed_dive, divemaster); UPDATE_TEXT(displayed_dive, buddy); @@ -441,6 +439,9 @@ void MainTab::updateDiveInfo(bool clear) ui.DiveType->setCurrentIndex(displayed_dive.dc.divemode); if (!clear) { + struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); + if (ds) + ui.location->setText(ds->name); updateGpsCoordinates(); // Subsurface always uses "local time" as in "whatever was the local time at the location" // so all time stamps have no time zone information and are in UTC @@ -655,6 +656,7 @@ void MainTab::updateDiveInfo(bool clear) ui.rating->setCurrentStars(0); ui.coordinates->clear(); ui.visibility->setCurrentStars(0); + ui.location->clear(); } editMode = NONE; ui.cylinders->view()->hideColumn(CylindersModel::DEPTH); -- cgit v1.2.3-70-g09d2 From 9ef81d3ed38bd2e7498242095e1655d568c61f7e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 12:57:58 -0800 Subject: Show GPS coordinates based on dive site on MainTab Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 48d2a0034..363ab3c43 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -1286,8 +1286,14 @@ void MainTab::updateGpsCoordinates() if (editMode == NONE) enableEdition(); - ui.coordinates->setText(printGPSCoords(displayed_dive.latitude.udeg, displayed_dive.longitude.udeg)); - ui.coordinates->setModified(displayed_dive.latitude.udeg || displayed_dive.longitude.udeg); + struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); + if (ds && dive_site_has_gps_location(ds)) { + ui.coordinates->setText(printGPSCoords(ds->latitude.udeg, ds->longitude.udeg)); + ui.coordinates->setModified(true); + } else if (!ui.coordinates->text().isEmpty()) { + ui.coordinates->setModified(true); + ui.coordinates->clear(); + } } void MainTab::escDetected() -- cgit v1.2.3-70-g09d2 From d488c37cc11a6051f94715465264a38bf7cf4dc2 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 01:19:07 -0800 Subject: Show dive coordinates on map based on dive site Signed-off-by: Dirk Hohndel --- dive.h | 7 +++++++ qt-ui/globe.cpp | 42 ++++++++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 18 deletions(-) (limited to 'qt-ui') diff --git a/dive.h b/dive.h index c38016bb5..42cec6224 100644 --- a/dive.h +++ b/dive.h @@ -505,6 +505,13 @@ static inline struct dive *get_dive_from_table(int nr, struct dive_table *dt) return dt->dives[nr]; } +static inline struct dive_site *get_dive_site_for_dive(struct dive *dive) +{ + if (dive) + return get_dive_site_by_uuid(dive->dive_site_uuid); + return NULL; +} + static inline unsigned int number_of_computers(struct dive *dive) { unsigned int total_number = 0; diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index cda408ddc..58e7dc620 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -164,10 +164,11 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) QList selectedDiveIds; for_each_dive (idx, dive) { long lat_diff, lon_diff; - if (!dive_has_gps_location(dive)) + struct dive_site *ds = get_dive_site_for_dive(dive); + if (!dive_site_has_gps_location(ds)) continue; - lat_diff = labs(dive->latitude.udeg - lat_udeg); - lon_diff = labs(dive->longitude.udeg - lon_udeg); + lat_diff = labs(ds->latitude.udeg - lat_udeg); + lon_diff = labs(ds->longitude.udeg - lon_udeg); if (lat_diff > 180000000) lat_diff = 360000000 - lat_diff; if (lon_diff > 180000000) @@ -186,6 +187,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) void GlobeGPS::repopulateLabels() { + struct dive_site *ds; if (loadedDives) { model()->treeModel()->removeDocument(loadedDives); delete loadedDives; @@ -204,12 +206,13 @@ void GlobeGPS::repopulateLabels() // don't show that flag, it's either already shown as displayed_dive // or it's the one that we are moving right now... continue; - if (dive_has_gps_location(dive)) { - GeoDataPlacemark *place = new GeoDataPlacemark(dive->location); - place->setCoordinate(dive->longitude.udeg / 1000000.0, dive->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree); + ds = get_dive_site_for_dive(dive); + if (dive_site_has_gps_location(ds)) { + GeoDataPlacemark *place = new GeoDataPlacemark(ds->name); + place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree); // don't add dive locations twice, unless they are at least 50m apart - if (locationMap[QString(dive->location)]) { - GeoDataCoordinates existingLocation = locationMap[QString(dive->location)]->coordinate(); + if (locationMap[QString(ds->name)]) { + GeoDataCoordinates existingLocation = locationMap[QString(ds->name)]->coordinate(); GeoDataLineString segment = GeoDataLineString(); segment.append(existingLocation); GeoDataCoordinates newLocation = place->coordinate(); @@ -220,7 +223,7 @@ void GlobeGPS::repopulateLabels() if (dist < 0.05) continue; } - locationMap[QString(dive->location)] = place; + locationMap[QString(ds->name)] = place; loadedDives->append(place); } } @@ -236,23 +239,23 @@ void GlobeGPS::reload() void GlobeGPS::centerOnCurrentDive() { - struct dive *dive = current_dive; + struct dive_site *ds = get_dive_site_for_dive(current_dive); // dive has changed, if we had the 'editingDive', hide it. - if (messageWidget->isVisible() && (!dive || dive_has_gps_location(dive) || amount_selected != 1)) + if (messageWidget->isVisible() && (!ds || dive_site_has_gps_location(ds) || amount_selected != 1)) messageWidget->hide(); editingDiveLocation = false; - if (!dive) + if (!ds) return; - qreal longitude = dive->longitude.udeg / 1000000.0; - qreal latitude = dive->latitude.udeg / 1000000.0; + qreal longitude = ds->longitude.udeg / 1000000.0; + qreal latitude = ds->latitude.udeg / 1000000.0; - if ((!dive_has_gps_location(dive) || MainWindow::instance()->information()->isEditing()) && amount_selected == 1) { + if ((!dive_site_has_gps_location(ds) || MainWindow::instance()->information()->isEditing()) && amount_selected == 1) { prepareForGetDiveCoordinates(); return; } - if (!dive_has_gps_location(dive)) { + if (!dive_site_has_gps_location(ds)) { zoomOutForNoGPS(); return; } @@ -309,8 +312,10 @@ void GlobeGPS::prepareForGetDiveCoordinates() } } +// This needs to update the dive site, not just this dive void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) { + struct dive_site *ds; messageWidget->hide(); if (MainWindow::instance()->dive_list()->selectionModel()->selection().isEmpty()) @@ -324,8 +329,9 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U centerOn(lon, lat, true); // change the location of the displayed_dive and put the UI in edit mode - displayed_dive.latitude.udeg = lrint(lat * 1000000.0); - displayed_dive.longitude.udeg = lrint(lon * 1000000.0); + ds = get_dive_site_for_dive(&displayed_dive); + ds->latitude.udeg = lrint(lat * 1000000.0); + ds->longitude.udeg = lrint(lon * 1000000.0); emit(coordinatesChanged()); repopulateLabels(); editingDiveLocation = false; -- cgit v1.2.3-70-g09d2 From f8b63e1bb6e282cd0e7368bbfcf2c572a4ba507e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 01:28:41 -0800 Subject: Update completion model for dive site names This way the drop down works again. Signed-off-by: Dirk Hohndel --- qt-ui/completionmodels.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/completionmodels.cpp b/qt-ui/completionmodels.cpp index fd3cc7504..f2e70afd1 100644 --- a/qt-ui/completionmodels.cpp +++ b/qt-ui/completionmodels.cpp @@ -40,9 +40,21 @@ CREATE_CSV_UPDATE_METHOD(BuddyCompletionModel, buddy); CREATE_CSV_UPDATE_METHOD(DiveMasterCompletionModel, divemaster); -CREATE_UPDATE_METHOD(LocationCompletionModel, location); CREATE_UPDATE_METHOD(SuitCompletionModel, suit); +void LocationCompletionModel::updateModel() +{ + QStringList list; + struct dive_site *ds; + int i = 0; + for_each_dive_site(i, ds) { + if (!list.contains(ds->name)) + list.append(ds->name); + } + std::sort(list.begin(), list.end()); + setStringList(list); +} + void TagCompletionModel::updateModel() { if (g_tag_list == NULL) -- cgit v1.2.3-70-g09d2 From ccf833b45cf7cc9f0bc1ddd3220148835062593d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 01:34:00 -0800 Subject: Clear the location if we have no dive site Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 363ab3c43..d2990b194 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -442,6 +442,8 @@ void MainTab::updateDiveInfo(bool clear) struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); if (ds) ui.location->setText(ds->name); + else + ui.location->clear(); updateGpsCoordinates(); // Subsurface always uses "local time" as in "whatever was the local time at the location" // so all time stamps have no time zone information and are in UTC -- cgit v1.2.3-70-g09d2 From 5c4d2660604af8925b757025571a8dcc36da1cdc Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 02:04:20 -0800 Subject: Make editing a location work with dive sites Not sure if this is the final implementation, but at least for simple cases it works now. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index d2990b194..ab691a4b4 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -1158,25 +1158,12 @@ void MainTab::on_location_textChanged(const QString &text) // If we have GPS data for the location entered, add it. void MainTab::on_location_editingFinished() { - // if we have a location and no GPS data, look up the GPS data; - // but if the GPS data was intentionally cleared then don't - if (!currentTrip && - !same_string(displayed_dive.location, "") && - ui.coordinates->text().trimmed().isEmpty() && - !(editMode == DIVE && dive_has_gps_location(current_dive))) { - struct dive *dive; - int i = 0; - for_each_dive (i, dive) { - if (same_string(displayed_dive.location, dive->location) && - (dive->latitude.udeg || dive->longitude.udeg)) { - displayed_dive.latitude = dive->latitude; - displayed_dive.longitude = dive->longitude; - MainWindow::instance()->globe()->reload(); - updateGpsCoordinates(); - break; - } - } - } + // find the dive site or create it + const char *name = ui.location->text().toUtf8().data(); + uint32_t uuid = get_dive_site_uuid_by_name(name); + if (!uuid) + uuid = create_dive_site(name); + displayed_dive.dive_site_uuid = uuid; } void MainTab::on_suit_textChanged(const QString &text) -- cgit v1.2.3-70-g09d2 From 0e6345f65b041b5005c75b83792ca98d8ef4f766 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 02:04:20 -0800 Subject: Correctly connect the maintab to dive site management We now have a working uuid - use it. And populate the fields accordingly. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 5 ++--- qt-ui/maintab.h | 2 +- qt-ui/mainwindow.cpp | 7 +++---- qt-ui/mainwindow.h | 2 +- qt-ui/simplewidgets.cpp | 13 ++++++------- qt-ui/simplewidgets.h | 5 ++--- 6 files changed, 15 insertions(+), 19 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index ab691a4b4..b0c2009d3 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -214,10 +214,9 @@ MainTab::~MainTab() } void MainTab::prepareDiveSiteEdit() { - //TODO: GET THE CORRECT DIVESITE UUID HERE - QUuid id = QUuid::createUuid(); - emit requestDiveSiteEdit(id); + emit requestDiveSiteEdit(displayed_dive.dive_site_uuid); } + void MainTab::toggleTriggeredColumn() { QAction *action = qobject_cast(sender()); diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index c90b0fb09..505fa6f21 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -56,7 +56,7 @@ public: signals: void addDiveFinished(); void dateTimeChanged(); - void requestDiveSiteEdit(QUuid diveSiteId); + void requestDiveSiteEdit(uint32_t uuid); public slots: void addCylinder_clicked(); diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index eca4c08f8..30ab5e5df 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -111,7 +111,7 @@ MainWindow::MainWindow() : QMainWindow(), connect(DivePlannerPointsModel::instance(), SIGNAL(planCreated()), this, SLOT(planCreated())); connect(DivePlannerPointsModel::instance(), SIGNAL(planCanceled()), this, SLOT(planCanceled())); connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); - connect(mainTab, SIGNAL(requestDiveSiteEdit(QUuid)), this, SLOT(enableDiveSiteEdit(QUuid))); + connect(mainTab, SIGNAL(requestDiveSiteEdit(uint32_t)), this, SLOT(enableDiveSiteEdit(uint32_t))); connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState())); #ifdef NO_PRINTING ui.printPlan->hide(); @@ -214,9 +214,8 @@ LocationInformationWidget *MainWindow::locationInformationWidget() { return qobject_cast(applicationState["EditDiveSite"].topLeft); } -void MainWindow::enableDiveSiteEdit(QUuid id) { - locationInformationWidget()->setLocationName(current_dive->location); - locationInformationWidget()->setLocationCoords(printGPSCoords(current_dive->latitude.udeg, current_dive->longitude.udeg)); +void MainWindow::enableDiveSiteEdit(uint32_t id) { + locationInformationWidget()->setLocationId(id); setApplicationState("EditDiveSite"); } diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index ef3e8fa18..85a63123b 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -160,7 +160,7 @@ slots: void on_paste_triggered(); void on_actionFilterTags_triggered(); void on_actionConfigure_Dive_Computer_triggered(); - void enableDiveSiteEdit(QUuid id); + void enableDiveSiteEdit(uint32_t id); void setDefaultState(); protected: diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index c7dd47c6d..756251b51 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -665,14 +665,13 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo ui.diveSiteMessage->addAction(action); } -void LocationInformationWidget::setLocationName(const QString& name) +void LocationInformationWidget::setLocationId(uint32_t uuid) { - ui.diveSiteName->setText(name); -} - -void LocationInformationWidget::setLocationCoords(const QString& coords) -{ - ui.diveSiteCoordinates->setText(coords); + currentDs = get_dive_site_by_uuid(uuid); + ui.diveSiteName->setText(currentDs->name); + ui.diveSiteDescription->setText(currentDs->description); + ui.diveSiteNotes->setPlainText(currentDs->notes); + ui.diveSiteCoordinates->setText(printGPSCoords(currentDs->latitude.udeg, currentDs->longitude.udeg)); } void LocationInformationWidget::acceptChanges() diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index 24af171a7..9cedb8ad5 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -228,14 +228,13 @@ public slots: void showEvent(QShowEvent *); - /* change that to setLocationSite(QUuid diveSiteUid or something later */ - void setLocationName(const QString& name); - void setLocationCoords(const QString& coords); + void setLocationId(uint32_t uuid); signals: void informationManagementEnded(); private: + struct dive_site *currentDs; Ui::LocationInformation ui; }; -- cgit v1.2.3-70-g09d2 From 8bea7cbdc7225496de5817340a9199801a4a6c49 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 12:54:20 -0800 Subject: Show dive site name in dive list Signed-off-by: Dirk Hohndel --- qt-ui/models.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index ac2f7d899..19f0d12c0 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -1191,7 +1191,7 @@ QVariant DiveItem::data(int column, int role) const retVal = dive->maxcns; break; case LOCATION: - retVal = QString(dive->location); + retVal = QString(get_dive_location(dive)); break; } break; @@ -1232,7 +1232,7 @@ QVariant DiveItem::data(int column, int role) const retVal = dive->maxcns; break; case LOCATION: - retVal = QString(dive->location); + retVal = QString(get_dive_location(dive)); break; case GAS: const char *gas_string = get_dive_gas_string(dive); @@ -2110,7 +2110,7 @@ QVariant ProfilePrintModel::data(const QModelIndex &index, int role) const } if (row == 1) { if (col == 0) - return QString(dive->location); + return QString(get_dive_location(dive)); if (col == 3) return QString(tr("Duration: %1 min")).arg(di.displayDuration()); } -- cgit v1.2.3-70-g09d2 From 32da12664dd1055befdb7385176ff9eb8a3b9379 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 20:58:03 -0800 Subject: Switch components for cut/paste dive to dive site logic Signed-off-by: Dirk Hohndel --- dive.h | 3 +-- qt-ui/divecomponentselection.ui | 57 ++++++++++++++++++----------------------- qt-ui/maintab.cpp | 5 ++-- qt-ui/simplewidgets.cpp | 6 ++--- 4 files changed, 30 insertions(+), 41 deletions(-) (limited to 'qt-ui') diff --git a/dive.h b/dive.h index 76ea4b597..09c831e43 100644 --- a/dive.h +++ b/dive.h @@ -349,14 +349,13 @@ extern int get_cylinder_idx_by_use(struct dive *dive, enum cylinderuse cylinder_ /* when selectively copying dive information, which parts should be copied? */ struct dive_components { - unsigned int location : 1; + unsigned int divesite : 1; unsigned int notes : 1; unsigned int divemaster : 1; unsigned int buddy : 1; unsigned int suit : 1; unsigned int rating : 1; unsigned int visibility : 1; - unsigned int gps : 1; unsigned int tags : 1; unsigned int cylinders : 1; unsigned int weights : 1; diff --git a/qt-ui/divecomponentselection.ui b/qt-ui/divecomponentselection.ui index dbd0839ba..7eade039b 100644 --- a/qt-ui/divecomponentselection.ui +++ b/qt-ui/divecomponentselection.ui @@ -9,8 +9,8 @@ 0 0 - 308 - 263 + 401 + 317 @@ -41,9 +41,9 @@ - + - Location + Dive site @@ -54,34 +54,6 @@ - - - - GPS coordinates - - - - - - - Divemaster - - - - - - - Buddy - - - - - - - Rating - - - @@ -117,6 +89,27 @@ + + + + Divemaster + + + + + + + Buddy + + + + + + + Rating + + + diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index b0c2009d3..e2ccd44de 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -1314,7 +1314,6 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what) // take the data in our copyPasteDive and apply it to selected dives enableEdition(); copyPaste = true; - SHOW_SELECTIVE(location); SHOW_SELECTIVE(buddy); SHOW_SELECTIVE(divemaster); SHOW_SELECTIVE(suit); @@ -1329,8 +1328,8 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what) ui.rating->setCurrentStars(displayed_dive.rating); if (what.visibility) ui.visibility->setCurrentStars(displayed_dive.visibility); - if (what.gps) - updateGpsCoordinates(); + if (what.divesite) + ui.location->setText(get_dive_location(&displayed_dive)); if (what.tags) { char buf[1024]; taglist_get_tagstring(displayed_dive.tag_list, buf, 1024); diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 756251b51..97b39ee61 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -457,8 +457,7 @@ DiveComponentSelection::DiveComponentSelection(QWidget *parent, struct dive *tar { ui.setupUi(this); what = _what; - UI_FROM_COMPONENT(location); - UI_FROM_COMPONENT(gps); + UI_FROM_COMPONENT(divesite); UI_FROM_COMPONENT(divemaster); UI_FROM_COMPONENT(buddy); UI_FROM_COMPONENT(rating); @@ -478,8 +477,7 @@ DiveComponentSelection::DiveComponentSelection(QWidget *parent, struct dive *tar void DiveComponentSelection::buttonClicked(QAbstractButton *button) { if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) { - COMPONENT_FROM_UI(location); - COMPONENT_FROM_UI(gps); + COMPONENT_FROM_UI(divesite); COMPONENT_FROM_UI(divemaster); COMPONENT_FROM_UI(buddy); COMPONENT_FROM_UI(rating); -- cgit v1.2.3-70-g09d2 From 616cb18b2919d8131c1520975d7c5eb7e8e4aaec Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 22:20:35 -0800 Subject: Make filters work with dive sites This simply tracks the names - if we have multiple dives sites with the same name but different other data (e.g. different GPS), we could easily get this right (well, somewhat easily, it's a UI question), but for that we'd have to filter for dive site uuid instead of for dive location name. Signed-off-by: Dirk Hohndel --- qt-ui/filtermodels.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/filtermodels.cpp b/qt-ui/filtermodels.cpp index 378f46735..f44ab7cf8 100644 --- a/qt-ui/filtermodels.cpp +++ b/qt-ui/filtermodels.cpp @@ -249,7 +249,7 @@ bool LocationFilterModel::doFilter(struct dive *d, QModelIndex &index0, QAbstrac return true; } // Checked means 'Show', Unchecked means 'Hide'. - QString location(d->location); + QString location(get_dive_location(d)); // only show empty location dives if the user checked that. if (location.isEmpty()) { if (rowCount() > 0) @@ -277,7 +277,7 @@ void LocationFilterModel::repopulate() struct dive *dive; int i = 0; for_each_dive (i, dive) { - QString location(dive->location); + QString location(get_dive_location(dive)); if (!location.isEmpty() && !list.contains(location)) { list.append(location); } -- cgit v1.2.3-70-g09d2 From 4e95beabc2fd7cdd2efcceb226417f84a903861f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 22:24:12 -0800 Subject: Remove coordinates from main tab It seems to make sense to only have them on the dive site screen. For the main UI they were redundant (we have the map) and not all that useful. The only time people would want them is if they wanted to manually add GPS coordinates for a dive, but that should now be done via the dive site UI. There are a couple of FIXMEs in the code and a few code blocks that have been commented out as they will be needed in one form or another once this GPS handling is done on the dive site UI, which right now it is NOT. Signed-off-by: Dirk Hohndel --- qt-ui/globe.cpp | 7 ++- qt-ui/maintab.cpp | 38 ++++++--------- qt-ui/maintab.h | 2 - qt-ui/maintab.ui | 130 ++++++++++++++++++++++----------------------------- qt-ui/mainwindow.cpp | 5 +- qthelper.cpp | 2 + 6 files changed, 83 insertions(+), 101 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 58e7dc620..256eff175 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -347,7 +347,12 @@ void GlobeGPS::mousePressEvent(QMouseEvent *event) // there could be two scenarios that got us here; let's check if we are editing a dive if (MainWindow::instance()->information()->isEditing() && clickOnGlobe) { - MainWindow::instance()->information()->updateCoordinatesText(lat, lon); + // + // FIXME + // TODO + // + // this needs to do this on the dive site screen + // MainWindow::instance()->information()->updateCoordinatesText(lat, lon); repopulateLabels(); } else if (clickOnGlobe) { changeDiveGeoPosition(lon, lat, GeoDataCoordinates::Degree); diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index e2ccd44de..1fbb32fa8 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -72,7 +72,6 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), setEnabled(false); ui.location->installEventFilter(this); - ui.coordinates->installEventFilter(this); ui.divemaster->installEventFilter(this); ui.buddy->installEventFilter(this); ui.suit->installEventFilter(this); @@ -443,7 +442,6 @@ void MainTab::updateDiveInfo(bool clear) ui.location->setText(ds->name); else ui.location->clear(); - updateGpsCoordinates(); // Subsurface always uses "local time" as in "whatever was the local time at the location" // so all time stamps have no time zone information and are in UTC QDateTime localTime = QDateTime::fromTime_t(displayed_dive.when - gettimezoneoffset(displayed_dive.when)); @@ -454,8 +452,6 @@ void MainTab::updateDiveInfo(bool clear) setTabText(0, tr("Trip notes")); currentTrip = *MainWindow::instance()->dive_list()->selectedTrips().begin(); // only use trip relevant fields - ui.coordinates->setVisible(false); - ui.CoordinatedLabel->setVisible(false); ui.divemaster->setVisible(false); ui.DivemasterLabel->setVisible(false); ui.buddy->setVisible(false); @@ -485,8 +481,6 @@ void MainTab::updateDiveInfo(bool clear) setTabText(0, tr("Dive notes")); currentTrip = NULL; // make all the fields visible writeable - ui.coordinates->setVisible(true); - ui.CoordinatedLabel->setVisible(true); ui.divemaster->setVisible(true); ui.buddy->setVisible(true); ui.suit->setVisible(true); @@ -655,7 +649,6 @@ void MainTab::updateDiveInfo(bool clear) clearStats(); clearEquipment(); ui.rating->setCurrentStars(0); - ui.coordinates->clear(); ui.visibility->setCurrentStars(0); ui.location->clear(); } @@ -765,8 +758,6 @@ void MainTab::acceptChanges() copy_samples(&displayed_dive.dc, ¤t_dive->dc); } struct dive *cd = current_dive; - //Reset coordinates field, in case it contains garbage. - updateGpsCoordinates(); // now check if something has changed and if yes, edit the selected dives that // were identical with the master dive shown (and mark the divelist as changed) if (!same_string(displayed_dive.buddy, cd->buddy)) @@ -794,17 +785,6 @@ void MainTab::acceptChanges() time_t offset = cd->when - displayed_dive.when; MODIFY_SELECTED_DIVES(mydive->when -= offset;); } - if (displayed_dive.latitude.udeg != cd->latitude.udeg || - displayed_dive.longitude.udeg != cd->longitude.udeg) - MODIFY_SELECTED_DIVES( - if (copyPaste || - (same_string(mydive->location, cd->location) && - mydive->latitude.udeg == cd->latitude.udeg && - mydive->longitude.udeg == cd->longitude.udeg)) - gpsHasChanged(mydive, cd, ui.coordinates->text(), 0); - ); - if (!same_string(displayed_dive.location, cd->location)) - MODIFY_SELECTED_DIVES(EDIT_TEXT(location)); saveTags(); @@ -910,7 +890,6 @@ void MainTab::resetPallete() ui.buddy->setPalette(p); ui.notes->setPalette(p); ui.location->setPalette(p); - ui.coordinates->setPalette(p); ui.divemaster->setPalette(p); ui.suit->setPalette(p); ui.airtemp->setPalette(p); @@ -1148,8 +1127,17 @@ void MainTab::on_location_textChanged(const QString &text) free(displayedTrip.location); displayedTrip.location = strdup(ui.location->text().toUtf8().data()); } else { - free(displayed_dive.location); - displayed_dive.location = strdup(ui.location->text().toUtf8().data()); + // this means we switched dive sites... this requires a lot more thinking + // + // + // FIXME + // + // TODO + // + // + // + // free(displayed_dive.location); + // displayed_dive.location = strdup(ui.location->text().toUtf8().data()); } markChangedWidget(ui.location); } @@ -1195,6 +1183,7 @@ void MainTab::on_notes_textChanged() markChangedWidget(ui.notes); } +#if 0 // we'll need something like this for the dive site management void MainTab::on_coordinates_textChanged(const QString &text) { if (editMode == IGNORE || acceptingEdit == true) @@ -1211,6 +1200,7 @@ void MainTab::on_coordinates_textChanged(const QString &text) ui.coordinates->setPalette(p); // marks things red } } +#endif void MainTab::on_rating_valueChanged(int value) { @@ -1262,6 +1252,7 @@ void MainTab::editWeightWidget(const QModelIndex &index) ui.weights->edit(index); } +#if 0 // we'll need this for dive sites void MainTab::updateCoordinatesText(qreal lat, qreal lon) { int ulat = rint(lat * 1000000); @@ -1283,6 +1274,7 @@ void MainTab::updateGpsCoordinates() ui.coordinates->clear(); } } +#endif void MainTab::escDetected() { diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 505fa6f21..aebd51073 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -66,7 +66,6 @@ slots: void rejectChanges(); void on_location_textChanged(const QString &text); void on_location_editingFinished(); - void on_coordinates_textChanged(const QString &text); void on_divemaster_textChanged(); void on_buddy_textChanged(); void on_suit_textChanged(const QString &text); @@ -93,7 +92,6 @@ slots: void escDetected(void); void photoDoubleClicked(const QString filePath); void removeSelectedPhotos(); - void updateGpsCoordinates(); void prepareDiveSiteEdit(); private: Ui::MainTab ui; diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index cdaab8386..659e790ef 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -22,7 +22,9 @@ 0 - + + scrollArea + @@ -40,8 +42,8 @@ 0 0 - 443 - 758 + 441 + 753 @@ -139,40 +141,6 @@ - - - - - - - 0 - 0 - - - - Coordinates - - - - - - - Dive mode - - - - - - - false - - - - - - - - @@ -251,6 +219,7 @@ Qt::StrongFocus + tagWidget @@ -276,36 +245,50 @@ - - - Tags - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - QPlainTextEdit::NoWrap - - + + + + + + + + Tags + + + + + + + Dive mode + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + QPlainTextEdit::NoWrap + + + + @@ -400,8 +383,8 @@ 0 0 - 443 - 752 + 68 + 40 @@ -456,8 +439,8 @@ 0 0 - 443 - 752 + 441 + 363 @@ -773,8 +756,8 @@ 0 0 - 443 - 752 + 446 + 215 @@ -1036,7 +1019,6 @@ rating visibility suit - tagWidget notes diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 30ab5e5df..7776f312e 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -133,7 +133,10 @@ MainWindow::MainWindow() : QMainWindow(), #ifdef NO_MARBLE ui.menuView->removeAction(ui.actionViewGlobe); #else - connect(globe(), SIGNAL(coordinatesChanged()), information(), SLOT(updateGpsCoordinates())); + // FIXME + // TODO + // we need this on the dive sites + //connect(globe(), SIGNAL(coordinatesChanged()), information(), SLOT(updateGpsCoordinates())); #endif #ifdef NO_USERMANUAL ui.menuHelp->removeAction(ui.actionUserManual); diff --git a/qthelper.cpp b/qthelper.cpp index acb1e103a..902dc5e6d 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -165,6 +165,7 @@ bool parseGpsText(const QString &gps_text, double *latitude, double *longitude) pos == gps_text.size(); } +#if 0 // we'll need something like this for the dive site management, eventually bool gpsHasChanged(struct dive *dive, struct dive *master, const QString &gps_text, bool *parsed_out) { double latitude, longitude; @@ -193,6 +194,7 @@ bool gpsHasChanged(struct dive *dive, struct dive *master, const QString &gps_te dive->longitude.udeg = longudeg; return true; } +#endif QList getDivesInTrip(dive_trip_t *trip) { -- cgit v1.2.3-70-g09d2 From 253a137cc7fa14caa4db165ce8529a898be06406 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 22:39:54 -0800 Subject: Get location from dive site for printing Signed-off-by: Dirk Hohndel --- qt-ui/printlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index d9752d235..4be5fef73 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -462,7 +462,7 @@ void PrintLayout::addTablePrintDataRow(TablePrintModel *model, int row, struct d model->setData(model->index(row, 3), di.displayDuration(), Qt::DisplayRole); model->setData(model->index(row, 4), dive->divemaster, Qt::DisplayRole); model->setData(model->index(row, 5), dive->buddy, Qt::DisplayRole); - model->setData(model->index(row, 6), dive->location, Qt::DisplayRole); + model->setData(model->index(row, 6), get_dive_location(dive), Qt::DisplayRole); } void PrintLayout::addTablePrintHeadingRow(TablePrintModel *model, int row) const -- cgit v1.2.3-70-g09d2 From b2f0d21d43fb42918041e492cd5cb18253505960 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 12 Feb 2015 22:40:30 -0800 Subject: Get location for Facebook from dive site Signed-off-by: Dirk Hohndel --- qt-ui/socialnetworks.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/socialnetworks.cpp b/qt-ui/socialnetworks.cpp index 21ccf9354..6a81d5db7 100644 --- a/qt-ui/socialnetworks.cpp +++ b/qt-ui/socialnetworks.cpp @@ -302,7 +302,7 @@ void SocialNetworkDialog::selectionChanged() tr("min", "abbreviation for minutes"))); } if (ui->Location->isChecked()) { - fullText += tr("Dive location: %1 \n").arg(d->location); + fullText += tr("Dive location: %1 \n").arg(get_dive_location(d)); } if (ui->Buddy->isChecked()) { fullText += tr("Buddy: %1 \n").arg(d->buddy); -- cgit v1.2.3-70-g09d2 From be1b6c67c1ec0be77dfa65a1199bf8fc6d6101cf Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 07:08:08 -0800 Subject: maintab change for get_dive_site_uuid_by_name Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 1fbb32fa8..86a8965f5 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -1147,7 +1147,7 @@ void MainTab::on_location_editingFinished() { // find the dive site or create it const char *name = ui.location->text().toUtf8().data(); - uint32_t uuid = get_dive_site_uuid_by_name(name); + uint32_t uuid = get_dive_site_uuid_by_name(name, NULL); if (!uuid) uuid = create_dive_site(name); displayed_dive.dive_site_uuid = uuid; -- cgit v1.2.3-70-g09d2 From 6708e06872b395c5a0d22d4f5cf17f8ec19bdaf3 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 07:14:30 -0800 Subject: Adapt GPS coordinate download from our companion app to dive sites This is a bit awkward now. We are downloading what looks like fake dives in the v2 format. So we create a dive site for every single fix. After we merge those new dive sites into the existing dives we need to throw away all the dive sites that weren't used. Signed-off-by: Dirk Hohndel --- dive.h | 11 ---------- qt-ui/subsurfacewebservices.cpp | 47 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 16 deletions(-) (limited to 'qt-ui') diff --git a/dive.h b/dive.h index 9de3423ad..105d5d8c5 100644 --- a/dive.h +++ b/dive.h @@ -389,17 +389,6 @@ extern void dive_set_geodata_from_picture(struct dive *d, struct picture *pic); extern int explicit_first_cylinder(struct dive *dive, struct divecomputer *dc); -static inline void copy_gps_location(struct dive *from, struct dive *to) -{ - if (from && to) { - to->latitude.udeg = from->latitude.udeg; - to->longitude.udeg = from->longitude.udeg; - if (!to->location) { - to->location = strdup(from->location); - } - } -} - static inline int get_surface_pressure_in_mbar(const struct dive *dive, bool non_null) { int mbar = dive->surface_pressure.mbar; diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index a247888a2..17c15583f 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -29,7 +29,25 @@ #endif struct dive_table gps_location_table; -static bool merge_locations_into_dives(void); + +// we don't overwrite any existing GPS info in the dive +// so get the dive site and if there is none or there is one without GPS fix, add it +static void copy_gps_location(struct dive *from, struct dive *to) +{ + struct dive_site *ds = get_dive_site_for_dive(to); + if (!ds || !dive_site_has_gps_location(ds)) { + struct dive_site *gds = get_dive_site_for_dive(from); + if (!ds) { + // simply link to the one created for the fake dive + to->dive_site_uuid = gds->uuid; + } else { + ds->latitude = gds->latitude; + ds->longitude = gds->longitude; + if (same_string(ds->name, "")) + ds->name = copy_string(gds->name); + } + } +} #define SAME_GROUP 6 * 3600 // six hours //TODO: C Code. static functions are not good if we plan to have a test for them. @@ -49,7 +67,7 @@ static bool merge_locations_into_dives(void) * Asign and mark position, and end gps_location loop */ if ((dive->when <= gpsfix->when && gpsfix->when <= dive->when + dive->duration.seconds)) { - copy_gps_location(gpsfix,dive); + copy_gps_location(gpsfix, dive); changed++; tracer = j; break; @@ -65,7 +83,7 @@ static bool merge_locations_into_dives(void) * If not, simply fail and nextgpsfix will be evaluated in next iteration. */ if ((dive->when + dive->duration.seconds - gpsfix->when) < (nextgpsfix->when - gpsfix->when)) { - copy_gps_location(gpsfix,dive); + copy_gps_location(gpsfix, dive); tracer = j; break; } @@ -73,7 +91,7 @@ static bool merge_locations_into_dives(void) * If no more positions in range, the actual is the one. Asign, mark and end loop. */ } else { - copy_gps_location(gpsfix,dive); + copy_gps_location(gpsfix, dive); changed++; tracer = j; break; @@ -329,10 +347,19 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); switch (ui.buttonBox->buttonRole(button)) { case QDialogButtonBox::ApplyRole: { + int i; + struct dive *d; + struct dive_site *ds; clear_table(&gps_location_table); QByteArray url = tr("Webservice").toLocal8Bit(); parse_xml_buffer(url.data(), downloadedData.data(), downloadedData.length(), &gps_location_table, NULL); - + // make sure we mark all the dive sites that were created + for (i = 0; i < gps_location_table.nr; i++) { + d = get_dive_from_table(i, &gps_location_table); + ds = get_dive_site_by_uuid(d->dive_site_uuid); + if (ds) + ds->notes = strdup("SubsurfaceWebservice"); + } /* now merge the data in the gps_location table into the dive_table */ if (merge_locations_into_dives()) { mark_divelist_changed(true); @@ -361,6 +388,16 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button) hide(); close(); resetState(); + /* and now clean up and remove all the extra dive sites that were created */ + QSet usedUuids; + for_each_dive(i, d) { + if (d->dive_site_uuid) + usedUuids.insert(d->dive_site_uuid); + } + for_each_dive_site(i, ds) { + if (!usedUuids.contains(ds->uuid) && same_string(ds->notes, "SubsurfaceWebservice")) + delete_dive_site(ds->uuid); + } } break; case QDialogButtonBox::RejectRole: if (reply != NULL && reply->isOpen()) { -- cgit v1.2.3-70-g09d2 From 32ad046f5681ad02e3f9842075447e880145267d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 12:38:56 -0800 Subject: Allow editing of dive sites And hook things up when double clicking the globe. The user experience isn't consistent with what we do on the main tab (i.e., no coloring of fields that are changed), but it seems to work. Signed-off-by: Dirk Hohndel --- dive.c | 1 + dive.h | 1 + qt-ui/globe.cpp | 10 ++++++---- qt-ui/mainwindow.cpp | 9 ++++----- qt-ui/simplewidgets.cpp | 35 +++++++++++++++++++++++++++++++---- qt-ui/simplewidgets.h | 1 + 6 files changed, 44 insertions(+), 13 deletions(-) (limited to 'qt-ui') diff --git a/dive.c b/dive.c index 3b682ee5f..758368615 100644 --- a/dive.c +++ b/dive.c @@ -13,6 +13,7 @@ * it's used in the UI, but it seems to make the most sense to have it * here */ struct dive displayed_dive; +struct dive_site displayed_dive_site; struct tag_entry *g_tag_list = NULL; diff --git a/dive.h b/dive.h index 533a193b6..8247a5f50 100644 --- a/dive.h +++ b/dive.h @@ -474,6 +474,7 @@ struct dive_table { extern struct dive_table dive_table; extern struct dive displayed_dive; +extern struct dive_site displayed_dive_site; extern int selected_dive; extern unsigned int dc_number; #define current_dive (get_dive(selected_dive)) diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 256eff175..91bb4e858 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -206,7 +206,10 @@ void GlobeGPS::repopulateLabels() // don't show that flag, it's either already shown as displayed_dive // or it's the one that we are moving right now... continue; - ds = get_dive_site_for_dive(dive); + if (idx == -1) + ds = &displayed_dive_site; + else + ds = get_dive_site_for_dive(dive); if (dive_site_has_gps_location(ds)) { GeoDataPlacemark *place = new GeoDataPlacemark(ds->name); place->setCoordinate(ds->longitude.udeg / 1000000.0, ds->latitude.udeg / 1000000.0, 0, GeoDataCoordinates::Degree); @@ -329,9 +332,8 @@ void GlobeGPS::changeDiveGeoPosition(qreal lon, qreal lat, GeoDataCoordinates::U centerOn(lon, lat, true); // change the location of the displayed_dive and put the UI in edit mode - ds = get_dive_site_for_dive(&displayed_dive); - ds->latitude.udeg = lrint(lat * 1000000.0); - ds->longitude.udeg = lrint(lon * 1000000.0); + displayed_dive_site.latitude.udeg = lrint(lat * 1000000.0); + displayed_dive_site.longitude.udeg = lrint(lon * 1000000.0); emit(coordinatesChanged()); repopulateLabels(); editingDiveLocation = false; diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 7776f312e..6a67befa1 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -113,6 +113,8 @@ MainWindow::MainWindow() : QMainWindow(), connect(plannerDetails->printPlan(), SIGNAL(pressed()), divePlannerWidget(), SLOT(printDecoPlan())); connect(mainTab, SIGNAL(requestDiveSiteEdit(uint32_t)), this, SLOT(enableDiveSiteEdit(uint32_t))); connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState())); + connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(refreshDisplay())); + #ifdef NO_PRINTING ui.printPlan->hide(); ui.menuFile->removeAction(ui.actionPrint); @@ -133,10 +135,7 @@ MainWindow::MainWindow() : QMainWindow(), #ifdef NO_MARBLE ui.menuView->removeAction(ui.actionViewGlobe); #else - // FIXME - // TODO - // we need this on the dive sites - //connect(globe(), SIGNAL(coordinatesChanged()), information(), SLOT(updateGpsCoordinates())); + connect(globe(), SIGNAL(coordinatesChanged()), locationInformation, SLOT(updateGpsCoordinates())); #endif #ifdef NO_USERMANUAL ui.menuHelp->removeAction(ui.actionUserManual); @@ -218,7 +217,6 @@ LocationInformationWidget *MainWindow::locationInformationWidget() { } void MainWindow::enableDiveSiteEdit(uint32_t id) { - locationInformationWidget()->setLocationId(id); setApplicationState("EditDiveSite"); } @@ -276,6 +274,7 @@ void MainWindow::current_dive_changed(int divenr) } graphics()->plotDive(); information()->updateDiveInfo(); + locationInformationWidget()->setLocationId(displayed_dive.dive_site_uuid); } void MainWindow::on_actionNew_triggered() diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 97b39ee61..00f749780 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -666,19 +666,46 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo void LocationInformationWidget::setLocationId(uint32_t uuid) { currentDs = get_dive_site_by_uuid(uuid); - ui.diveSiteName->setText(currentDs->name); - ui.diveSiteDescription->setText(currentDs->description); - ui.diveSiteNotes->setPlainText(currentDs->notes); - ui.diveSiteCoordinates->setText(printGPSCoords(currentDs->latitude.udeg, currentDs->longitude.udeg)); + displayed_dive_site = *currentDs; + ui.diveSiteName->setText(displayed_dive_site.name); + ui.diveSiteDescription->setText(displayed_dive_site.description); + ui.diveSiteNotes->setPlainText(displayed_dive_site.notes); + ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg)); +} + +void LocationInformationWidget::updateGpsCoordinates() +{ + ui.diveSiteCoordinates->setText(printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg)); + MainWindow::instance()->setApplicationState("EditDiveSite"); } void LocationInformationWidget::acceptChanges() { + char *uiString; + currentDs->latitude = displayed_dive_site.latitude; + currentDs->longitude = displayed_dive_site.longitude; + uiString = ui.diveSiteName->text().toUtf8().data(); + if (!same_string(uiString, currentDs->name)) { + free(currentDs->name); + currentDs->name = copy_string(uiString); + } + uiString = ui.diveSiteDescription->text().toUtf8().data(); + if (!same_string(uiString, currentDs->description)) { + free(currentDs->description); + currentDs->description = copy_string(uiString); + } + uiString = ui.diveSiteNotes->document()->toPlainText().toUtf8().data(); + if (!same_string(uiString, currentDs->notes)) { + free(currentDs->notes); + currentDs->notes = copy_string(uiString); + } + mark_divelist_changed(true); emit informationManagementEnded(); } void LocationInformationWidget::rejectChanges() { + setLocationId(currentDs->uuid); emit informationManagementEnded(); } diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index 9cedb8ad5..d0cb60508 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -229,6 +229,7 @@ public slots: void showEvent(QShowEvent *); void setLocationId(uint32_t uuid); + void updateGpsCoordinates(void); signals: void informationManagementEnded(); -- cgit v1.2.3-70-g09d2 From 2607fea2de9f3158c7f292c4195746b9becee615 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 12:32:11 -0800 Subject: Fix compile time warning No idea why designer sometimes adds these zorder items. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.ui | 2 -- 1 file changed, 2 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 659e790ef..5267863ff 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -23,7 +23,6 @@ - scrollArea @@ -219,7 +218,6 @@ Qt::StrongFocus - tagWidget -- cgit v1.2.3-70-g09d2 From b60b4ef69d1ae81ace1d4f8ccccdd13aeee01f5a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 22:08:08 -0800 Subject: Fix crash when adding a dive If a dive has no dive_site_uuid we would dereference a NULL pointer and crash. Oops. Signed-off-by: Dirk Hohndel --- qt-ui/simplewidgets.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 00f749780..4f050063c 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -666,7 +666,10 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo void LocationInformationWidget::setLocationId(uint32_t uuid) { currentDs = get_dive_site_by_uuid(uuid); - displayed_dive_site = *currentDs; + if (currentDs) + displayed_dive_site = *currentDs; + else + memset(&displayed_dive, 0, sizeof(displayed_dive)); ui.diveSiteName->setText(displayed_dive_site.name); ui.diveSiteDescription->setText(displayed_dive_site.description); ui.diveSiteNotes->setPlainText(displayed_dive_site.notes); -- cgit v1.2.3-70-g09d2 From e32459d3139e5f9815550fe3ebbc6bfff96d5d97 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 22:42:57 -0800 Subject: When adding / planning a dive, reset the dive site manage screen Otherwise old data is still shown if the user clicks manage. Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 6a67befa1..0991a98e1 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -552,6 +552,7 @@ void MainWindow::setupForAddAndPlan(const char *model) // setup the dive cylinders DivePlannerPointsModel::instance()->clear(); DivePlannerPointsModel::instance()->setupCylinders(); + locationInformationWidget()->setLocationId(0); } void MainWindow::on_actionReplanDive_triggered() -- cgit v1.2.3-70-g09d2 From cd77e2e700da92fe0292320d5d4a82361104adfe Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 22:44:05 -0800 Subject: Make sure there is a dive site if you try to edit it If the user clicks on manage (or double clicks on the globe) and the displayed_dive doesn't actually have a dive site associated with it (e.g. because we are adding a dive or because it was imported or downloaded without dive site information, then we need to make sure that there is an empty dive site that we can make changes to. Signed-off-by: Dirk Hohndel --- qt-ui/simplewidgets.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 4f050063c..f32ce9b19 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -666,10 +666,16 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo void LocationInformationWidget::setLocationId(uint32_t uuid) { currentDs = get_dive_site_by_uuid(uuid); - if (currentDs) - displayed_dive_site = *currentDs; - else - memset(&displayed_dive, 0, sizeof(displayed_dive)); + + if (!currentDs) { + currentDs = get_dive_site_by_uuid(create_dive_site("")); + displayed_dive.dive_site_uuid = currentDs->uuid; + ui.diveSiteName->clear(); + ui.diveSiteDescription->clear(); + ui.diveSiteNotes->clear(); + ui.diveSiteCoordinates->clear(); + } + displayed_dive_site = *currentDs; ui.diveSiteName->setText(displayed_dive_site.name); ui.diveSiteDescription->setText(displayed_dive_site.description); ui.diveSiteNotes->setPlainText(displayed_dive_site.notes); @@ -708,6 +714,7 @@ void LocationInformationWidget::acceptChanges() void LocationInformationWidget::rejectChanges() { + Q_ASSERT(currentDs != NULL); setLocationId(currentDs->uuid); emit informationManagementEnded(); } -- cgit v1.2.3-70-g09d2 From 3ea2e15bd2f20e0f84bf02a468c3273a347ac554 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 23:08:33 -0800 Subject: Don't add empty dive sites It makes no sense to keep them around, it makes no sense to have dives refer to them. Signed-off-by: Dirk Hohndel --- qt-ui/simplewidgets.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index f32ce9b19..27050f6e2 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -708,6 +708,13 @@ void LocationInformationWidget::acceptChanges() free(currentDs->notes); currentDs->notes = copy_string(uiString); } + if (dive_site_is_empty(currentDs)) { + delete_dive_site(currentDs->uuid); + displayed_dive.dive_site_uuid = 0; + setLocationId(0); + } else { + setLocationId(currentDs->uuid); + } mark_divelist_changed(true); emit informationManagementEnded(); } @@ -715,7 +722,13 @@ void LocationInformationWidget::acceptChanges() void LocationInformationWidget::rejectChanges() { Q_ASSERT(currentDs != NULL); - setLocationId(currentDs->uuid); + if (dive_site_is_empty(currentDs)) { + delete_dive_site(currentDs->uuid); + displayed_dive.dive_site_uuid = 0; + setLocationId(0); + } else { + setLocationId(currentDs->uuid); + } emit informationManagementEnded(); } -- cgit v1.2.3-70-g09d2 From ca72ab574904bc7fe8083bb692f58d4647e2ff61 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 23:11:36 -0800 Subject: When closing a dive, delete all the dive sites Signed-off-by: Dirk Hohndel --- qt-ui/mainwindow.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 0991a98e1..1f4c2d7de 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -354,6 +354,8 @@ void MainWindow::closeCurrentFile() clear_git_id(); while (dive_table.nr) delete_single_dive(0); + while (dive_site_table.nr) + delete_dive_site(get_dive_site(0)->uuid); free((void *)existing_filename); existing_filename = NULL; -- cgit v1.2.3-70-g09d2 From f81e2c111d9c563a78e62c3bae64bec07c052ec0 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 13 Feb 2015 23:49:05 -0800 Subject: When updating the dive site name, show this on the maintab If we accept a change on the dive site management screen, it needs to be reflected on the Dive notes tab right away. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 5 +++++ qt-ui/maintab.h | 2 ++ qt-ui/mainwindow.cpp | 1 + 3 files changed, 8 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 86a8965f5..b78280d7a 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -395,6 +395,11 @@ bool MainTab::isEditing() return editMode != NONE; } +void MainTab::showLocation() +{ + ui.location->setText(get_dive_location(&displayed_dive)); +} + void MainTab::updateDiveInfo(bool clear) { // don't execute this while adding / planning a dive diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index aebd51073..8869b068e 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -93,6 +93,8 @@ slots: void photoDoubleClicked(const QString filePath); void removeSelectedPhotos(); void prepareDiveSiteEdit(); + void showLocation(); + private: Ui::MainTab ui; WeightModel *weightModel; diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 1f4c2d7de..56f885409 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -114,6 +114,7 @@ MainWindow::MainWindow() : QMainWindow(), connect(mainTab, SIGNAL(requestDiveSiteEdit(uint32_t)), this, SLOT(enableDiveSiteEdit(uint32_t))); connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(setDefaultState())); connect(locationInformation, SIGNAL(informationManagementEnded()), this, SLOT(refreshDisplay())); + connect(locationInformation, SIGNAL(informationManagementEnded()), information(), SLOT(showLocation())); #ifdef NO_PRINTING ui.printPlan->hide(); -- cgit v1.2.3-70-g09d2