diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-07-11 21:59:21 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-11 21:59:21 -0700 |
commit | e1ae7ebab2d39cb726d4afcff71b5586a0d6fc65 (patch) | |
tree | f7ca8e54700d1efb0a546332b8c5b35ba4cf4c45 | |
parent | 236ff5c89da90e840acc0becf8efae41fc5b6282 (diff) | |
download | subsurface-e1ae7ebab2d39cb726d4afcff71b5586a0d6fc65.tar.gz |
Printing: print depth unit in table
When adding the method that includes the depth unit to the DiveItem class
I realized that this was yet another implementation of our depth unit
conversion. We should just call the existing helper instead.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/models.cpp | 17 | ||||
-rw-r--r-- | qt-ui/models.h | 1 | ||||
-rw-r--r-- | qt-ui/printlayout.cpp | 2 |
3 files changed, 9 insertions, 11 deletions
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 03c95b070..ca6f6375f 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -1189,17 +1189,14 @@ QString DiveItem::displayDate() const QString DiveItem::displayDepth() const { - QString fract, str; - const int scale = 1000; struct dive *dive = get_dive_by_uniq_id(diveId); - if (get_units()->length == units::METERS) { - fract = QString::number((unsigned)(dive->maxdepth.mm % scale) / 100); - str = QString("%1.%2").arg((unsigned)(dive->maxdepth.mm / scale)).arg(fract, 1, QChar('0')); - } - if (get_units()->length == units::FEET) { - str = QString::number(mm_to_feet(dive->maxdepth.mm), 'f', 0); - } - return str; + return get_depth_string(dive->maxdepth); +} + +QString DiveItem::displayDepthWithUnit() const +{ + struct dive *dive = get_dive_by_uniq_id(diveId); + return get_depth_string(dive->maxdepth, true); } QString DiveItem::displayDuration() const diff --git a/qt-ui/models.h b/qt-ui/models.h index 0eca7c1b4..aa314f119 100644 --- a/qt-ui/models.h +++ b/qt-ui/models.h @@ -206,6 +206,7 @@ struct DiveItem : public TreeItem { QString displayDate() const; QString displayDuration() const; QString displayDepth() const; + QString displayDepthWithUnit() const; QString displayTemperature() const; QString displayWeight() const; QString displaySac() const; diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index 735e410ab..6640d43f4 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -422,7 +422,7 @@ void PrintLayout::addTablePrintDataRow(TablePrintModel *model, int row, struct d model->insertRow(); model->setData(model->index(row, 0), QString::number(dive->number), Qt::DisplayRole); model->setData(model->index(row, 1), di.displayDate(), Qt::DisplayRole); - model->setData(model->index(row, 2), di.displayDepth(), Qt::DisplayRole); + model->setData(model->index(row, 2), di.displayDepthWithUnit(), Qt::DisplayRole); model->setData(model->index(row, 3), di.displayDuration(), Qt::DisplayRole); model->setData(model->index(row, 4), dive->divemaster, Qt::DisplayRole); model->setData(model->index(row, 5), dive->buddy, Qt::DisplayRole); |