From a413141b334e89b0c9944bc403b8774f85427509 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 1 Jul 2015 12:32:46 -0700 Subject: Geo taxonomy: adjust the preferences to the new data structures This allows us to pick which three categories of geo taxonomy will be shown in the UI. Signed-off-by: Dirk Hohndel --- qt-ui/preferences.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index c93460f9a..25638c991 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -241,9 +241,9 @@ void PreferencesDialog::setUiFromPrefs() ui.enable_geocoding->setChecked( prefs.geocoding.enable_geocoding ); ui.parse_without_gps->setChecked(prefs.geocoding.parse_dive_without_gps); ui.tag_existing_dives->setChecked(prefs.geocoding.tag_existing_dives); - ui.first_item->setCurrentText(prefs.geocoding.first_item); - ui.second_item->setCurrentText(prefs.geocoding.second_item); - ui.third_item->setCurrentText(prefs.geocoding.third_item); + ui.first_item->setCurrentIndex(prefs.geocoding.category[0]); + ui.second_item->setCurrentIndex(prefs.geocoding.category[1]); + ui.third_item->setCurrentIndex(prefs.geocoding.category[2]); } void PreferencesDialog::restorePrefs() @@ -288,6 +288,13 @@ void PreferencesDialog::rememberPrefs() else \ prefs.field = default_prefs.field +#define GET_ENUM(name, type, field) \ + v = s.value(QString(name)); \ + if (v.isValid()) \ + prefs.field = (enum type)v.toInt(); \ + else \ + prefs.field = default_prefs.field + #define GET_INT_DEF(name, field, defval) \ v = s.value(QString(name)); \ if (v.isValid()) \ @@ -455,9 +462,9 @@ void PreferencesDialog::syncSettings() s.setValue("enable_geocoding", ui.enable_geocoding->isChecked()); s.setValue("parse_dives_without_gps", ui.parse_without_gps->isChecked()); s.setValue("tag_existing_dives", ui.tag_existing_dives->isChecked()); - s.setValue("first_item", ui.first_item->currentText()); - s.setValue("second_item", ui.second_item->currentText()); - s.setValue("third_item", ui.third_item->currentText()); + s.setValue("cat0", ui.first_item->currentIndex()); + s.setValue("cat1", ui.second_item->currentIndex()); + s.setValue("cat2", ui.third_item->currentIndex()); s.endGroup(); loadSettings(); @@ -603,9 +610,9 @@ void PreferencesDialog::loadSettings() GET_BOOL("enable_geocoding", geocoding.enable_geocoding); GET_BOOL("parse_dives_without_gps", geocoding.parse_dive_without_gps); GET_BOOL("tag_existing_dives", geocoding.tag_existing_dives); - GET_TXT("first_item", geocoding.first_item); - GET_TXT("second_item", geocoding.second_item); - GET_TXT("third_item", geocoding.third_item); + GET_ENUM("cat0", taxonomy_category, geocoding.category[0]); + GET_ENUM("cat1", taxonomy_category, geocoding.category[1]); + GET_ENUM("cat2", taxonomy_category, geocoding.category[2]); s.endGroup(); } -- cgit v1.2.3-70-g09d2 From 3055f4ac2212fef67a6e191538fe615f48be7042 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 1 Jul 2015 12:33:48 -0700 Subject: Geo taxonomy: show the chosen taxonomy entries in the notes pane This isn't perfect - I'd like to have them show behind the word Location instead as what we have now creates movement in the position of the fields on the screen which I think is distracting. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index d60e22a79..b5981c977 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -496,9 +496,26 @@ void MainTab::updateDiveInfo(bool clear) if (!clear) { struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); + qDebug() << "showing dive site uuid" << ds->uuid << ds; if (ds) { + // construct the location tags + QString locationTag; + if (ds->taxonomy.nr) { + QString connector = ""; + for (int i = 0; i < 3; i++) { + qDebug() << "looking for category" << prefs.geocoding.category[i]; + for (int j = 0; j < NR_CATEGORIES; j++) { + qDebug() << "seeing category" << ds->taxonomy.category[j].category; + if (ds->taxonomy.category[j].category == prefs.geocoding.category[i]) { + locationTag += connector + QString(ds->taxonomy.category[j].value); + connector = " / "; + break; + } + } + } + } ui.location->setText(ds->name); - ui.locationTags->setText(ds->description); // TODO: This should be three tags following davide's explanation. + ui.locationTags->setText(locationTag); if (displayed_dive.dive_site_uuid) copy_dive_site(get_dive_site_by_uuid(displayed_dive.dive_site_uuid), &displayed_dive_site); } else { -- cgit v1.2.3-70-g09d2 From 80f26912b070328806436fbd3d1d4a37a56e4bb6 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 1 Jul 2015 15:38:08 -0700 Subject: Notes pane: move the location taxonomy to a better spot And display it smaller, marked as "tags". Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 2 ++ qt-ui/maintab.ui | 37 ++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index b5981c977..688927cb6 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -501,6 +501,7 @@ void MainTab::updateDiveInfo(bool clear) // construct the location tags QString locationTag; if (ds->taxonomy.nr) { + locationTag = "(tags: "; QString connector = ""; for (int i = 0; i < 3; i++) { qDebug() << "looking for category" << prefs.geocoding.category[i]; @@ -513,6 +514,7 @@ void MainTab::updateDiveInfo(bool clear) } } } + locationTag += ")"; } ui.location->setText(ds->name); ui.locationTags->setText(locationTag); diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 7ac703076..c7801666f 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -171,21 +171,28 @@ 0 - - - Location - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - - - - - - - + + + + + Location + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + + + Qt::RichText + + + + -- cgit v1.2.3-70-g09d2 From c3e38b6da34561cae0f66c151527df55f99be9b0 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 1 Jul 2015 16:07:21 -0700 Subject: Notes pane: once again fix the layout It seems nearly impossible to keep all these margins consistent. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.ui | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index c7801666f..3623cf8db 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -167,6 +167,12 @@ + + 5 + + + 5 + 0 -- cgit v1.2.3-70-g09d2 From 92722adeba68cde39d9388c629d99ed747af385e Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 1 Jul 2015 16:38:22 -0700 Subject: Notes pane: don't show taxonomy info for trip location Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 688927cb6..109c816c2 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -555,6 +555,7 @@ void MainTab::updateDiveInfo(bool clear) ui.watertemp->setVisible(false); // rename the remaining fields and fill data from selected trip ui.LocationLabel->setText(tr("Trip location")); + ui.locationTags->clear(); ui.location->setText(currentTrip->location); ui.NotesLabel->setText(tr("Trip notes")); ui.notes->setText(currentTrip->notes); -- cgit v1.2.3-70-g09d2 From baf68868f5af3f3339504bceca0ca0d6676f8eee Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 1 Jul 2015 16:38:43 -0700 Subject: Notes pane: add geo code button This still needs to be hooked up. Signed-off-by: Dirk Hohndel --- icons/geocode.svg | 1010 +++++++++++++++++++++++++++++++++++++++++++++++++++++ qt-ui/maintab.ui | 23 +- subsurface.qrc | 1 + 3 files changed, 1028 insertions(+), 6 deletions(-) create mode 100644 icons/geocode.svg (limited to 'qt-ui') diff --git a/icons/geocode.svg b/icons/geocode.svg new file mode 100644 index 000000000..517e8788f --- /dev/null +++ b/icons/geocode.svg @@ -0,0 +1,1010 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Jakub Steiner + + + + + Tuomas Kuosmanen + + + + http://jimmac.musichall.cz + + + internet + tools + applications + category + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 3623cf8db..3318bf788 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -219,6 +219,17 @@ + + + + ... + + + + :/geocode:/geocode + + + @@ -552,8 +563,8 @@ 0 0 - 449 - 743 + 100 + 30 @@ -647,8 +658,8 @@ 0 0 - 449 - 743 + 286 + 300 @@ -988,8 +999,8 @@ 0 0 - 449 - 743 + 297 + 177 diff --git a/subsurface.qrc b/subsurface.qrc index a28c86ad6..349d9d7b2 100644 --- a/subsurface.qrc +++ b/subsurface.qrc @@ -78,5 +78,6 @@ icons/process-stop.svg icons/edit-circled.svg icons/Emblem-earth.svg + icons/geocode.svg -- cgit v1.2.3-70-g09d2 From d966fd2606e4ac0054eafd5af1171fc2a5c495b4 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 1 Jul 2015 12:37:50 -0700 Subject: Trigger reverse geo lookup by pressing the button This may not be the best UI, but for now it works. Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 10 +++++++++- qt-ui/maintab.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 109c816c2..26f221883 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -59,6 +59,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), closeMessage(); connect(ui.addDiveSite, SIGNAL(clicked()), this, SLOT(showDiveSiteSimpleEdit())); + connect(ui.geocodeButton, SIGNAL(clicked()), this, SLOT(reverseGeocode())); QAction *action = new QAction(tr("Apply changes"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(acceptChanges())); @@ -496,7 +497,7 @@ void MainTab::updateDiveInfo(bool clear) if (!clear) { struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); - qDebug() << "showing dive site uuid" << ds->uuid << ds; + ui.geocodeButton->setVisible(ds && dive_site_has_gps_location(ds)); if (ds) { // construct the location tags QString locationTag; @@ -1550,3 +1551,10 @@ void MainTab::showAndTriggerEditSelective(struct dive_components what) weightModel->changed = true; } } + +void MainTab::reverseGeocode() +{ + ReverseGeoLookupThread *geoLookup = ReverseGeoLookupThread::instance(); + geoLookup->lookup(&displayed_dive_site); + MainWindow::instance()->information()->updateDiveInfo(); +} diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 844710954..eac1521cc 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -97,6 +97,7 @@ slots: void disableGeoLookupEdition(); void setCurrentLocationIndex(); void showDiveSiteSimpleEdit(); + void reverseGeocode(); private: Ui::MainTab ui; WeightModel *weightModel; -- cgit v1.2.3-70-g09d2 From 0a0a6f07d5dbb2c24184d22c3c2cedf89ffdc7ac Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 2 Jul 2015 06:59:08 -0700 Subject: Remove a few more debug messages Yes, I could go back and try to fix the earlier commits. This is easier. Signed-off-by: Dirk Hohndel --- divesitehelpers.cpp | 1 - qt-ui/maintab.cpp | 2 -- 2 files changed, 3 deletions(-) (limited to 'qt-ui') diff --git a/divesitehelpers.cpp b/divesitehelpers.cpp index 4cc40f203..d635969da 100644 --- a/divesitehelpers.cpp +++ b/divesitehelpers.cpp @@ -138,7 +138,6 @@ void ReverseGeoLookupThread::run() { if (ds->taxonomy.category == NULL) ds->taxonomy.category = alloc_taxonomy(); ds->taxonomy.category[ds->taxonomy.nr].category = OCEAN; - qDebug() << "set category of slot" << ds->taxonomy.nr << "to OCEAN(1)"; ds->taxonomy.category[ds->taxonomy.nr].origin = taxonomy::GEOCODED; ds->taxonomy.category[ds->taxonomy.nr].value = copy_string(qPrintable(oceanName["name"].toString())); ds->taxonomy.nr++; diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 26f221883..dd6ce72b0 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -505,9 +505,7 @@ void MainTab::updateDiveInfo(bool clear) locationTag = "(tags: "; QString connector = ""; for (int i = 0; i < 3; i++) { - qDebug() << "looking for category" << prefs.geocoding.category[i]; for (int j = 0; j < NR_CATEGORIES; j++) { - qDebug() << "seeing category" << ds->taxonomy.category[j].category; if (ds->taxonomy.category[j].category == prefs.geocoding.category[i]) { locationTag += connector + QString(ds->taxonomy.category[j].value); connector = " / "; -- cgit v1.2.3-70-g09d2