I couldn't test, I assume my proxy failed.
From 8a9f30c638305e6c31d9a10b198100bba044bd0f Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 7 Oct 2015 19:33:09 -0300
Subject: [PATCH 2/4] Added the Labels for Taxonomy in dive site widget

nothing to see here - just added the widgets on the .ui files

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/locationInformation.ui | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/qt-ui/locationInformation.ui b/qt-ui/locationInformation.ui
index 9d1021e..63d9b55 100644
--- a/qt-ui/locationInformation.ui
+++ b/qt-ui/locationInformation.ui
@@ -30,14 +30,14 @@
      </property>
     </widget>
    </item>
-   <item row="3" column="0">
+   <item row="4" column="0">
     <widget class="QLabel" name="label_3">
      <property name="text">
       <string>Description</string>
      </property>
     </widget>
    </item>
-   <item row="4" column="0">
+   <item row="6" column="0">
     <widget class="QLabel" name="label_4">
      <property name="text">
       <string>Notes</string>
@@ -54,14 +54,14 @@
      </property>
     </widget>
    </item>
-   <item row="3" column="1" colspan="2">
-    <widget class="QLineEdit" name="diveSiteDescription"/>
+   <item row="6" column="1" rowspan="2" colspan="2">
+    <widget class="QPlainTextEdit" name="diveSiteNotes"/>
    </item>
    <item row="1" column="1" colspan="2">
     <widget class="QLineEdit" name="diveSiteName"/>
    </item>
-   <item row="4" column="1" rowspan="2" colspan="2">
-    <widget class="QPlainTextEdit" name="diveSiteNotes"/>
+   <item row="4" column="1" colspan="2">
+    <widget class="QLineEdit" name="diveSiteDescription"/>
    </item>
    <item row="2" column="2">
     <widget class="QToolButton" name="geoCodeButton">
@@ -75,7 +75,7 @@
     </widget>
    </item>
    <item row="0" column="0" colspan="3">
-    <widget class="KMessageWidget" name="diveSiteMessage" native="true">
+    <widget class="KMessageWidget" name="diveSiteMessage">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
        <horstretch>0</horstretch>
@@ -84,7 +84,7 @@
      </property>
     </widget>
    </item>
-   <item row="6" column="0" colspan="3">
+   <item row="8" column="0" colspan="3">
     <widget class="QGroupBox" name="diveSiteGroupBox">
      <property name="title">
       <string>Dive sites on same coordinates</string>
@@ -109,7 +109,7 @@
      </layout>
     </widget>
    </item>
-   <item row="5" column="0">
+   <item row="7" column="0">
     <spacer name="verticalSpacer">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
@@ -122,12 +122,26 @@
      </property>
     </spacer>
    </item>
+   <item row="3" column="0">
+    <widget class="QLabel" name="label_5">
+     <property name="text">
+      <string>Tags</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="1" colspan="2">
+    <widget class="QLabel" name="locationTags">
+     <property name="text">
+      <string/>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <customwidgets>
   <customwidget>
    <class>KMessageWidget</class>
-   <extends>QWidget</extends>
+   <extends>QFrame</extends>
    <header>kmessagewidget.h</header>
    <container>1</container>
   </customwidget>
-- 
2.6.1

From ee25fdec525c85b0bac3c888da66ea2cfad0d166 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 7 Oct 2015 19:34:02 -0300
Subject: [PATCH 3/4] Moved the algorithm to divesite.cpp file

This shouldn't be on the maintab.cpp, this file is already
too convoluted.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 CMakeLists.txt    |  1 +
 divesite.cpp      | 29 +++++++++++++++++++++++++++++
 divesite.h        |  3 +++
 qt-ui/maintab.cpp | 23 +----------------------
 4 files changed, 34 insertions(+), 22 deletions(-)
 create mode 100644 divesite.cpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b3c7912..287d1a8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -317,6 +317,7 @@ set(SUBSURFACE_CORE_LIB_SRCS
 	device.c
 	dive.c
 	divesite.c
+	divesite.cpp # some new stuff that is not c code but belongs to divesite.
 	divelist.c
 	equipment.c
 	file.c
diff --git a/divesite.cpp b/divesite.cpp
new file mode 100644
index 0000000..04808ff
--- /dev/null
+++ b/divesite.cpp
@@ -0,0 +1,29 @@
+#include "divesite.h"
+#include "pref.h"
+
+QString constructLocationTags(struct dive_site *ds)
+{
+	QString locationTag;
+	if (!ds->taxonomy.nr)
+		return locationTag;
+
+	locationTag = "<small><small>(tags: ";
+	QString connector;
+	for (int i = 0; i < 3; i++) {
+		if (prefs.geocoding.category[i] == TC_NONE)
+			continue;
+		for (int j = 0; j < TC_NR_CATEGORIES; j++) {
+			if (ds->taxonomy.category[j].category == prefs.geocoding.category[i]) {
+				QString tag = ds->taxonomy.category[j].value;
+				if (!tag.isEmpty()) {
+					locationTag += connector + tag;
+					connector = " / ";
+				}
+				break;
+			}
+		}
+	}
+
+	locationTag += ")</small></small>";
+	return locationTag;
+}
diff --git a/divesite.h b/divesite.h
index d898707..517b422 100644
--- a/divesite.h
+++ b/divesite.h
@@ -6,6 +6,7 @@
 #include <stdlib.h>
 
 #ifdef __cplusplus
+#include <QString>
 extern "C" {
 #else
 #include <stdbool.h>
@@ -72,6 +73,8 @@ void merge_dive_sites(uint32_t ref, uint32_t *uuids, int count);
 
 #ifdef __cplusplus
 }
+QString constructLocationTags(struct dive_site *ds);
+
 #endif
 
 #endif // DIVESITE_H
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index d448327..90d905b 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -487,29 +487,8 @@ void MainTab::updateDiveInfo(bool clear)
 		}
 
 		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++) {
-					if (prefs.geocoding.category[i] == TC_NONE)
-						continue;
-					for (int j = 0; j < TC_NR_CATEGORIES; j++) {
-						if (ds->taxonomy.category[j].category == prefs.geocoding.category[i]) {
-							QString tag = ds->taxonomy.category[j].value;
-							if (!tag.isEmpty()) {
-								locationTag += connector + tag;
-								connector = " / ";
-							}
-							break;
-						}
-					}
-				}
-				locationTag += ")</small></small>";
-			}
 			ui.location->setCurrentDiveSiteUuid(ds->uuid);
-			ui.locationTags->setText(locationTag);
+			ui.locationTags->setText(constructLocationTags(ds));
 		} else {
 			ui.location->clear();
 			clear_dive_site(&displayed_dive_site);
-- 
2.6.1

From 0f247f2b9273feab852e7bdbbd20e55149c5b52c Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 7 Oct 2015 20:00:22 -0300
Subject: [PATCH 4/4] Update UI from dive site widget when retrieving taxonomy

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 divesite.cpp                  | 6 ++++--
 divesite.h                    | 2 +-
 qt-ui/locationinformation.cpp | 3 +++
 qt-ui/maintab.cpp             | 2 +-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/divesite.cpp b/divesite.cpp
index 04808ff..39c0ff2 100644
--- a/divesite.cpp
+++ b/divesite.cpp
@@ -1,10 +1,12 @@
 #include "divesite.h"
 #include "pref.h"
 
-QString constructLocationTags(struct dive_site *ds)
+QString constructLocationTags(uint32_t ds_uuid)
 {
 	QString locationTag;
-	if (!ds->taxonomy.nr)
+	struct dive_site *ds = get_dive_site_by_uuid(ds_uuid);
+
+	if (!ds || ds->taxonomy.nr)
 		return locationTag;
 
 	locationTag = "<small><small>(tags: ";
diff --git a/divesite.h b/divesite.h
index 517b422..f18b2e8 100644
--- a/divesite.h
+++ b/divesite.h
@@ -73,7 +73,7 @@ void merge_dive_sites(uint32_t ref, uint32_t *uuids, int count);
 
 #ifdef __cplusplus
 }
-QString constructLocationTags(struct dive_site *ds);
+QString constructLocationTags(uint32_t ds_uuid);
 
 #endif
 
diff --git a/qt-ui/locationinformation.cpp b/qt-ui/locationinformation.cpp
index 5807266..a99740c 100644
--- a/qt-ui/locationinformation.cpp
+++ b/qt-ui/locationinformation.cpp
@@ -109,6 +109,9 @@ void LocationInformationWidget::updateLabels()
 	} else {
 		ui.diveSiteCoordinates->clear();
 	}
+
+	ui.locationTags->setText(constructLocationTags(displayed_dive_site.uuid));
+
 	emit startFilterDiveSite(displayed_dive_site.uuid);
 	emit startEditDiveSite(displayed_dive_site.uuid);
 }
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 90d905b..49af156 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -488,7 +488,7 @@ void MainTab::updateDiveInfo(bool clear)
 
 		if (ds) {
 			ui.location->setCurrentDiveSiteUuid(ds->uuid);
-			ui.locationTags->setText(constructLocationTags(ds));
+			ui.locationTags->setText(constructLocationTags(ds->uuid));
 		} else {
 			ui.location->clear();
 			clear_dive_site(&displayed_dive_site);
-- 
2.6.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to