From 3515ad71c159804e37552550add8e89cf3031b33 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 30 Oct 2014 07:40:22 -0700 Subject: Divelist: remove units from header, add tooltip This should help with the issues we are having with alignment / visibility of the relevant information in the divelist. Most people will never switch the units (or maybe switch them once, the first time they use Subsurface). So having the units shown in the table header quickly becomes redundant - yet having the units in there causes all kinds of layout issues. This patch adds a tooltip to both the header and the main data area of the divelist. The tooltip shows the column name plus unit and the column header no longer shows the units. Signed-off-by: Dirk Hohndel --- qt-ui/models.cpp | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) (limited to 'qt-ui/models.cpp') diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index f548d3730..1e41dc173 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -1209,6 +1209,54 @@ QVariant DiveItem::data(int column, int role) const break; } break; + case Qt::ToolTipRole: + switch (column) { + case NR: + retVal = tr("#"); + break; + case DATE: + retVal = tr("Date"); + break; + case RATING: + retVal = tr("Rating"); + break; + case DEPTH: + retVal = tr("Depth(%1)").arg((get_units()->length == units::METERS) ? tr("m") : tr("ft")); + break; + case DURATION: + retVal = tr("Duration"); + break; + case TEMPERATURE: + retVal = tr("Temp(%1%2)").arg(UTF8_DEGREE).arg((get_units()->temperature == units::CELSIUS) ? "C" : "F"); + break; + case TOTALWEIGHT: + retVal = tr("Weight(%1)").arg((get_units()->weight == units::KG) ? tr("kg") : tr("lbs")); + break; + case SUIT: + retVal = tr("Suit"); + break; + case CYLINDER: + retVal = tr("Cyl"); + break; + case GAS: + retVal = tr("Gas"); + break; + case SAC: + const char *unit; + get_volume_units(0, NULL, &unit); + retVal = tr("SAC(%1)").arg(QString(unit).append(tr("/min"))); + break; + case OTU: + retVal = tr("OTU"); + break; + case MAXCNS: + retVal = tr("Max CNS"); + break; + case LOCATION: + retVal = tr("Location"); + break; + } + break; } if (role == DiveTripModel::STAR_ROLE) { @@ -1359,6 +1407,52 @@ QVariant DiveTripModel::headerData(int section, Qt::Orientation orientation, int ret = defaultModelFont(); break; case Qt::DisplayRole: + switch (section) { + case NR: + ret = tr("#"); + break; + case DATE: + ret = tr("Date"); + break; + case RATING: + ret = tr("Rating"); + break; + case DEPTH: + ret = tr("Depth"); + break; + case DURATION: + ret = tr("Duration"); + break; + case TEMPERATURE: + ret = tr("Temp"); + break; + case TOTALWEIGHT: + ret = tr("Weight"); + break; + case SUIT: + ret = tr("Suit"); + break; + case CYLINDER: + ret = tr("Cyl"); + break; + case GAS: + ret = tr("Gas"); + break; + case SAC: + ret = tr("SAC"); + break; + case OTU: + ret = tr("OTU"); + break; + case MAXCNS: + ret = tr("Max CNS"); + break; + case LOCATION: + ret = tr("Location"); + break; + } + break; + case Qt::ToolTipRole: switch (section) { case NR: ret = tr("#"); -- cgit v1.2.3-70-g09d2