diff options
author | Anton Lundin <glance@acc.umu.se> | 2014-09-11 22:59:52 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-09-18 06:42:18 -0700 |
commit | 50adde828cccff7a0eea38be106e036617f954e1 (patch) | |
tree | ab8199d070f8b5e9eb12d22ce06540710bc1e4a9 | |
parent | 3e86640aaf759578f61d17942630f283a3a395a8 (diff) | |
download | subsurface-50adde828cccff7a0eea38be106e036617f954e1.tar.gz |
Switch some columns to right alignment in divelist
Some columns in the dive list makes more sense to have right aligned
than left aligned. This switches the numeric columns to right alignment
so they is more easily compared visually.
But, we keep the NR-column left-aligned because we use its left
indentation as dive-in-a-trip marker.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/models.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index a1813f5b1..1d28373e1 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -1063,6 +1063,34 @@ static int nitrox_sort_value(struct dive *dive) return he * 1000 + o2; } +static QVariant dive_table_alignment(int column) +{ + QVariant retVal; + switch (column) { + case DiveTripModel::DEPTH: + case DiveTripModel::DURATION: + case DiveTripModel::TEMPERATURE: + case DiveTripModel::TOTALWEIGHT: + case DiveTripModel::SAC: + case DiveTripModel::OTU: + case DiveTripModel::MAXCNS: + // Right align numeric columns + retVal = int(Qt::AlignRight | Qt::AlignVCenter); + break; + // NR needs to be left aligned becase its the indent marker for trips too + case DiveTripModel::NR: + case DiveTripModel::DATE: + case DiveTripModel::RATING: + case DiveTripModel::SUIT: + case DiveTripModel::CYLINDER: + case DiveTripModel::GAS: + case DiveTripModel::LOCATION: + retVal = int(Qt::AlignLeft | Qt::AlignVCenter); + break; + } + return retVal; +} + QVariant DiveItem::data(int column, int role) const { QVariant retVal; @@ -1070,7 +1098,7 @@ QVariant DiveItem::data(int column, int role) const switch (role) { case Qt::TextAlignmentRole: - retVal = int(Qt::AlignLeft | Qt::AlignVCenter); + retVal = dive_table_alignment(column); break; case DiveTripModel::SORT_ROLE: Q_ASSERT(dive != NULL); @@ -1306,6 +1334,9 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int return ret; switch (role) { + case Qt::TextAlignmentRole: + ret = dive_table_alignment(section); + break; case Qt::FontRole: ret = defaultModelFont(); break; |