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.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'qt-ui/maintab.h') 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(); -- 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/maintab.h') 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 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/maintab.h') 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 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/maintab.h') 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 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/maintab.h') 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