diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-07-02 07:03:03 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-07-02 07:03:03 -0700 |
commit | f554c2d16cb5816b6b1a97b0349488bc70b512b0 (patch) | |
tree | 60811b1d64c2f37378ed20147f829cf74849d1dd /qt-ui | |
parent | 1d59b028c91ab7943cfece4a113948c61110dfc3 (diff) | |
parent | 0a0a6f07d5dbb2c24184d22c3c2cedf89ffdc7ac (diff) | |
download | subsurface-f554c2d16cb5816b6b1a97b0349488bc70b512b0.tar.gz |
Merge branch 'taxonomy'
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/maintab.cpp | 28 | ||||
-rw-r--r-- | qt-ui/maintab.h | 1 | ||||
-rw-r--r-- | qt-ui/maintab.ui | 66 | ||||
-rw-r--r-- | qt-ui/preferences.cpp | 25 |
4 files changed, 89 insertions, 31 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 144a43094..591f665d5 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -77,6 +77,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui.location->setCompleter(completer); 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())); @@ -506,9 +507,26 @@ void MainTab::updateDiveInfo(bool clear) if (!clear) { struct dive_site *ds = get_dive_site_by_uuid(displayed_dive.dive_site_uuid); + ui.geocodeButton->setVisible(ds && dive_site_has_gps_location(ds)); if (ds) { + // construct the location tags + QString locationTag; + if (ds->taxonomy.nr) { + locationTag = "<small><small>(tags: "; + QString connector = ""; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < NR_CATEGORIES; j++) { + if (ds->taxonomy.category[j].category == prefs.geocoding.category[i]) { + locationTag += connector + QString(ds->taxonomy.category[j].value); + connector = " / "; + break; + } + } + } + locationTag += ")</small></small>"; + } 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 { @@ -546,6 +564,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); @@ -1538,3 +1557,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 c96acb28a..306aee66e 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -98,6 +98,7 @@ slots: void disableGeoLookupEdition(); void setCurrentLocationIndex(); void showDiveSiteSimpleEdit(); + void reverseGeocode(); private: Ui::MainTab ui; WeightModel *weightModel; diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 7ac703076..3318bf788 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -167,25 +167,38 @@ </item> <item> <layout class="QVBoxLayout" name="verticalLayout"> + <property name="leftMargin"> + <number>5</number> + </property> + <property name="rightMargin"> + <number>5</number> + </property> <property name="spacing"> <number>0</number> </property> <item> - <widget class="QLabel" name="LocationLabel"> - <property name="text"> - <string>Location</string> - </property> - <property name="alignment"> - <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="locationTags"> - <property name="text"> - <string/> - </property> - </widget> + <layout class="QHBoxLayout" name="LocationLayout" stretch="0,1"> + <item> + <widget class="QLabel" name="LocationLabel"> + <property name="text"> + <string>Location</string> + </property> + <property name="alignment"> + <set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="locationTags"> + <property name="text"> + <string/> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + </widget> + </item> + </layout> </item> <item> <layout class="QHBoxLayout" name="horizontalLayout_2"> @@ -207,6 +220,17 @@ </widget> </item> <item> + <widget class="QToolButton" name="geocodeButton"> + <property name="text"> + <string>...</string> + </property> + <property name="icon"> + <iconset resource="../subsurface.qrc"> + <normaloff>:/geocode</normaloff>:/geocode</iconset> + </property> + </widget> + </item> + <item> <widget class="QtWaitingSpinner" name="waitingSpinner" native="true"/> </item> </layout> @@ -539,8 +563,8 @@ <rect> <x>0</x> <y>0</y> - <width>449</width> - <height>743</height> + <width>100</width> + <height>30</height> </rect> </property> <layout class="QGridLayout" name="equipmentTabScrollAreaLayout"> @@ -634,8 +658,8 @@ <rect> <x>0</x> <y>0</y> - <width>449</width> - <height>743</height> + <width>286</width> + <height>300</height> </rect> </property> <layout class="QGridLayout" name="diveInfoScrollAreaLayout"> @@ -975,8 +999,8 @@ <rect> <x>0</x> <y>0</y> - <width>449</width> - <height>743</height> + <width>297</width> + <height>177</height> </rect> </property> <layout class="QHBoxLayout" name="horizontalLayout"> 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(); } |