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>
This commit is contained in:
Anton Lundin 2014-09-11 22:59:52 +02:00 committed by Dirk Hohndel
parent 3e86640aaf
commit 50adde828c

View file

@ -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;