mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Merge branch 'taxonomy'
This commit is contained in:
commit
f554c2d16c
20 changed files with 1358 additions and 65 deletions
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ slots:
|
|||
void disableGeoLookupEdition();
|
||||
void setCurrentLocationIndex();
|
||||
void showDiveSiteSimpleEdit();
|
||||
void reverseGeocode();
|
||||
private:
|
||||
Ui::MainTab ui;
|
||||
WeightModel *weightModel;
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
@ -206,6 +219,17 @@
|
|||
</property>
|
||||
</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>
|
||||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue