diff options
author | Willem Ferguson <willemferguson@zoology.up.ac.za> | 2016-11-21 11:26:58 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-11-24 09:58:46 +0900 |
commit | 6aa01372fddfa82533bceceb3275a73172644f77 (patch) | |
tree | f9a8c06bca43b0fcaf690dc73c51cda367eaa970 /qt-models/divetripmodel.cpp | |
parent | 1fa855e1c091175afcdb0cc4a3395d3aecb96d1c (diff) | |
download | subsurface-6aa01372fddfa82533bceceb3275a73172644f77.tar.gz |
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>
Diffstat (limited to 'qt-models/divetripmodel.cpp')
-rw-r--r-- | qt-models/divetripmodel.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index c7a7e9001..060fea721 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -22,7 +22,6 @@ static QVariant dive_table_alignment(int column) case DiveTripModel::TOTALWEIGHT: case DiveTripModel::SAC: case DiveTripModel::OTU: - case DiveTripModel::PHOTOS: case DiveTripModel::MAXCNS: // Right align numeric columns retVal = int(Qt::AlignRight | Qt::AlignVCenter); @@ -34,6 +33,7 @@ static QVariant dive_table_alignment(int column) case DiveTripModel::SUIT: case DiveTripModel::CYLINDER: case DiveTripModel::GAS: + case DiveTripModel::PHOTOS: case DiveTripModel::LOCATION: retVal = int(Qt::AlignLeft | Qt::AlignVCenter); break; @@ -197,13 +197,13 @@ QVariant DiveItem::data(int column, int role) const retVal = QIcon(":globe-icon").pixmap(im.sz_small, im.sz_small); } break; - case PHOTOS: // if enabled, show photos icon: fish= photos during dive; sun=photos before/after dive - if (dive->picture_list) // sun+fish=photos during dive as well as before/after + case PHOTOS: + if (dive->picture_list) { IconMetrics im = defaultIconMetrics(); retVal = QIcon(icon_names[countPhotos(dive)]).pixmap(im.sz_small, im.sz_small); - } - break; + } // If there are photos, show one of the three photo icons: fish= photos during dive; + break; // sun=photos before/after dive; sun+fish=photos during dive as well as before/after } break; case Qt::ToolTipRole: @@ -323,21 +323,20 @@ QString DiveItem::displayDepthWithUnit() const } int DiveItem::countPhotos(dive *dive) const -{ - int diveDuration = dive->duration.seconds; +{ // Determine whether dive has pictures, and whether they were taken during or before/after dive. + 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; - struct picture *pic_list = dive->picture_list; // Point to 1st picture of dive - if (!pic_list) return 0; // This dive does not contain pictures - do { - pic_offset = pic_list->offset.seconds; - if ((pic_offset < 0) | (pic_offset > diveDuration)) { + FOR_EACH_PICTURE (dive) { // Step through each of the pictures for this dive: + if (!picture) break; // if there are no pictures for this dive, return 0 + pic_offset = picture->offset.seconds; + if ((pic_offset < -bufperiod) | (pic_offset > diveDuration+bufperiod)) { icon_index |= 0x02; // If picture is before/after the dive } // then set the appropriate bit ... else { 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; } // 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"); break; case PHOTOS: - ret = tr("█"); + ret = tr("Photos"); break; case LOCATION: ret = tr("Location"); |