mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:53:23 +00:00
Provide phots summary on dive list (Part 2)
Please apply this patch on top of the previous patch with the same title. 1) Provide icons with white margin to look more like photos 2) Optimise code, following Robert's suggestions. 3) Column heading for photos column is now: Photos. This takes up extra horizontal space but makes the user interface more understandable. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1fa855e1c0
commit
6aa01372fd
5 changed files with 15 additions and 16 deletions
|
@ -25,7 +25,7 @@
|
||||||
#include "core/helpers.h"
|
#include "core/helpers.h"
|
||||||
|
|
||||||
// # Date Rtg Dpth Dur Tmp Wght Suit Cyl Gas SAC OTU CNS Px Loc
|
// # Date Rtg Dpth Dur Tmp Wght Suit Cyl Gas SAC OTU CNS Px Loc
|
||||||
static int defaultWidth[] = { 70, 140, 90, 50, 50, 50, 50, 70, 50, 50, 70, 50, 50, 25, 500};
|
static int defaultWidth[] = { 70, 140, 90, 50, 50, 50, 50, 70, 50, 50, 70, 50, 50, 5, 500};
|
||||||
|
|
||||||
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), sortColumn(0),
|
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), sortColumn(0),
|
||||||
currentOrder(Qt::DescendingOrder), dontEmitDiveChangedSignal(false), selectionSaved(false)
|
currentOrder(Qt::DescendingOrder), dontEmitDiveChangedSignal(false), selectionSaved(false)
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 2.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 2.4 KiB |
|
@ -22,7 +22,6 @@ static QVariant dive_table_alignment(int column)
|
||||||
case DiveTripModel::TOTALWEIGHT:
|
case DiveTripModel::TOTALWEIGHT:
|
||||||
case DiveTripModel::SAC:
|
case DiveTripModel::SAC:
|
||||||
case DiveTripModel::OTU:
|
case DiveTripModel::OTU:
|
||||||
case DiveTripModel::PHOTOS:
|
|
||||||
case DiveTripModel::MAXCNS:
|
case DiveTripModel::MAXCNS:
|
||||||
// Right align numeric columns
|
// Right align numeric columns
|
||||||
retVal = int(Qt::AlignRight | Qt::AlignVCenter);
|
retVal = int(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
|
@ -34,6 +33,7 @@ static QVariant dive_table_alignment(int column)
|
||||||
case DiveTripModel::SUIT:
|
case DiveTripModel::SUIT:
|
||||||
case DiveTripModel::CYLINDER:
|
case DiveTripModel::CYLINDER:
|
||||||
case DiveTripModel::GAS:
|
case DiveTripModel::GAS:
|
||||||
|
case DiveTripModel::PHOTOS:
|
||||||
case DiveTripModel::LOCATION:
|
case DiveTripModel::LOCATION:
|
||||||
retVal = int(Qt::AlignLeft | Qt::AlignVCenter);
|
retVal = int(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
break;
|
break;
|
||||||
|
@ -197,13 +197,13 @@ QVariant DiveItem::data(int column, int role) const
|
||||||
retVal = QIcon(":globe-icon").pixmap(im.sz_small, im.sz_small);
|
retVal = QIcon(":globe-icon").pixmap(im.sz_small, im.sz_small);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PHOTOS: // if enabled, show photos icon: fish= photos during dive; sun=photos before/after dive
|
case PHOTOS:
|
||||||
if (dive->picture_list) // sun+fish=photos during dive as well as before/after
|
if (dive->picture_list)
|
||||||
{
|
{
|
||||||
IconMetrics im = defaultIconMetrics();
|
IconMetrics im = defaultIconMetrics();
|
||||||
retVal = QIcon(icon_names[countPhotos(dive)]).pixmap(im.sz_small, im.sz_small);
|
retVal = QIcon(icon_names[countPhotos(dive)]).pixmap(im.sz_small, im.sz_small);
|
||||||
}
|
} // If there are photos, show one of the three photo icons: fish= photos during dive;
|
||||||
break;
|
break; // sun=photos before/after dive; sun+fish=photos during dive as well as before/after
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
|
@ -323,21 +323,20 @@ QString DiveItem::displayDepthWithUnit() const
|
||||||
}
|
}
|
||||||
|
|
||||||
int DiveItem::countPhotos(dive *dive) const
|
int DiveItem::countPhotos(dive *dive) const
|
||||||
{
|
{ // Determine whether dive has pictures, and whether they were taken during or before/after dive.
|
||||||
int diveDuration = dive->duration.seconds;
|
const int bufperiod = 120; // A 2-min buffer period. Photos within 2 min of dive are assumed as
|
||||||
|
int diveDuration = dive->duration.seconds; // taken during the dive, not before/after.
|
||||||
int pic_offset, icon_index = 0;
|
int pic_offset, icon_index = 0;
|
||||||
struct picture *pic_list = dive->picture_list; // Point to 1st picture of dive
|
FOR_EACH_PICTURE (dive) { // Step through each of the pictures for this dive:
|
||||||
if (!pic_list) return 0; // This dive does not contain pictures
|
if (!picture) break; // if there are no pictures for this dive, return 0
|
||||||
do {
|
pic_offset = picture->offset.seconds;
|
||||||
pic_offset = pic_list->offset.seconds;
|
if ((pic_offset < -bufperiod) | (pic_offset > diveDuration+bufperiod)) {
|
||||||
if ((pic_offset < 0) | (pic_offset > diveDuration)) {
|
|
||||||
icon_index |= 0x02; // If picture is before/after the dive
|
icon_index |= 0x02; // If picture is before/after the dive
|
||||||
} // then set the appropriate bit ...
|
} // then set the appropriate bit ...
|
||||||
else {
|
else {
|
||||||
icon_index |= 0x01; // else set the bit for picture during the dive
|
icon_index |= 0x01; // else set the bit for picture during the dive
|
||||||
}
|
}
|
||||||
pic_list = pic_list->next; // look at next photo
|
}
|
||||||
} while (pic_list);
|
|
||||||
return icon_index; // return value: 0=no pictures; 1=pictures during dive;
|
return icon_index; // return value: 0=no pictures; 1=pictures during dive;
|
||||||
} // 2=pictures before/after; 3=pictures during as well as before/after
|
} // 2=pictures before/after; 3=pictures during as well as before/after
|
||||||
|
|
||||||
|
@ -471,7 +470,7 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int
|
||||||
ret = tr("Max CNS");
|
ret = tr("Max CNS");
|
||||||
break;
|
break;
|
||||||
case PHOTOS:
|
case PHOTOS:
|
||||||
ret = tr("█");
|
ret = tr("Photos");
|
||||||
break;
|
break;
|
||||||
case LOCATION:
|
case LOCATION:
|
||||||
ret = tr("Location");
|
ret = tr("Location");
|
||||||
|
|
Loading…
Add table
Reference in a new issue