aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divetripmodel.cpp
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 /qt-models/divetripmodel.cpp
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>
Diffstat (limited to 'qt-models/divetripmodel.cpp')
-rw-r--r--qt-models/divetripmodel.cpp27
1 files changed, 27 insertions, 0 deletions
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;