From 50adde828cccff7a0eea38be106e036617f954e1 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Thu, 11 Sep 2014 22:59:52 +0200 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-ui/models.cpp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'qt-ui/models.cpp') 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; -- cgit v1.2.3-70-g09d2