summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Jeremie Guichard <djebrest@gmail.com>2018-04-04 08:18:29 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-04-04 14:10:45 +0300
commit12dc1889c704c6af9125d3ef3f0d2a1c1fe603f7 (patch)
tree8da754777ec401b96b482bde8873301ac5983761
parent78986589f0f9bd32094a8de6cdb0d192a6935ebc (diff)
downloadsubsurface-12dc1889c704c6af9125d3ef3f0d2a1c1fe603f7.tar.gz
Add "Tags" column in Desktop app's dive list view
Add DiveItem::displayTags helper method to return Tags as a QString New Tags column is by default inserted before "Photos" column by default disabled Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
-rw-r--r--CHANGELOG.md1
-rw-r--r--desktop-widgets/divelistview.cpp3
-rw-r--r--qt-models/divetripmodel.cpp27
-rw-r--r--qt-models/divetripmodel.h3
4 files changed, 33 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d375e18f7..5dc393390 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,4 @@
+- Desktop: Add Tags column in dive list view
- Desktop: revert change that inadvertantly broke applying GPS
coordinates to dives
- Map-widget: try to match the zoom level in Google Maps
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index 95e0e3fe9..0014c31f2 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -480,7 +480,8 @@ void DiveListView::reloadHeaderActions()
i == DiveTripModel::TOTALWEIGHT ||
i == DiveTripModel::SUIT ||
i == DiveTripModel::CYLINDER ||
- i == DiveTripModel::SAC);
+ i == DiveTripModel::SAC ||
+ i == DiveTripModel::TAGS);
bool shown = s.value(settingName, showHeaderFirstRun).toBool();
a->setCheckable(true);
a->setChecked(shown);
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp
index 5addeeb08..082d3212e 100644
--- a/qt-models/divetripmodel.cpp
+++ b/qt-models/divetripmodel.cpp
@@ -36,6 +36,7 @@ static QVariant dive_table_alignment(int column)
case DiveTripModel::SUIT:
case DiveTripModel::CYLINDER:
case DiveTripModel::GAS:
+ case DiveTripModel::TAGS:
case DiveTripModel::PHOTOS:
case DiveTripModel::COUNTRY:
case DiveTripModel::LOCATION:
@@ -136,6 +137,9 @@ QVariant DiveItem::data(int column, int role) const
case MAXCNS:
retVal = dive->maxcns;
break;
+ case TAGS:
+ retVal = displayTags();
+ break;
case PHOTOS:
retVal = countPhotos(dive);
break;
@@ -186,6 +190,9 @@ QVariant DiveItem::data(int column, int role) const
else
retVal = dive->maxcns;
break;
+ case TAGS:
+ retVal = displayTags();
+ break;
case PHOTOS:
break;
case COUNTRY:
@@ -265,6 +272,9 @@ QVariant DiveItem::data(int column, int role) const
case MAXCNS:
retVal = tr("Max. CNS");
break;
+ case TAGS:
+ retVal = tr("Tags");
+ break;
case PHOTOS:
retVal = tr("Photos before/during/after dive");
break;
@@ -409,6 +419,17 @@ QString DiveItem::displayWeightWithUnit() const
return weight_string(weight()) + ((get_units()->weight == units::KG) ? tr("kg") : tr("lbs"));
}
+QString DiveItem::displayTags() const
+{
+ struct dive *dive = get_dive_by_uniq_id(diveId);
+ if (!dive->tag_list)
+ return QString();
+
+ char buf[1024];
+ taglist_get_tagstring(dive->tag_list, buf, 1024);
+ return QString(buf);
+}
+
int DiveItem::weight() const
{
struct dive *dive = get_dive_by_uniq_id(diveId);
@@ -498,6 +519,9 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int
case MAXCNS:
ret = tr("Max CNS");
break;
+ case TAGS:
+ ret = tr("Tags");
+ break;
case PHOTOS:
ret = tr("Photos");
break;
@@ -552,6 +576,9 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int
case MAXCNS:
ret = tr("Max CNS");
break;
+ case TAGS:
+ ret = tr("Tags");
+ break;
case PHOTOS:
ret = tr("Photos before/during/after dive");
break;
diff --git a/qt-models/divetripmodel.h b/qt-models/divetripmodel.h
index ec9b615b0..98dc5bca3 100644
--- a/qt-models/divetripmodel.h
+++ b/qt-models/divetripmodel.h
@@ -23,6 +23,7 @@ public:
SAC,
OTU,
MAXCNS,
+ TAGS,
PHOTOS,
COUNTRY,
LOCATION,
@@ -43,6 +44,7 @@ public:
QString displayWeightWithUnit() const;
QString displaySac() const;
QString displaySacWithUnit() const;
+ QString displayTags() const;
int countPhotos(dive *dive) const;
int weight() const;
QString icon_names[4];
@@ -72,6 +74,7 @@ public:
SAC,
OTU,
MAXCNS,
+ TAGS,
PHOTOS,
COUNTRY,
LOCATION,