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>
This commit is contained in:
Jeremie Guichard 2018-04-04 08:18:29 +02:00 committed by Lubomir I. Ivanov
parent 78986589f0
commit 12dc1889c7
4 changed files with 33 additions and 1 deletions

View file

@ -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

View file

@ -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);

View file

@ -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;

View file

@ -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,