diff options
-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; |