diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2015-01-28 17:24:00 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-28 13:35:43 -0800 |
commit | 7f1373ea6d074c4cfbf514bc4ea6e48bf3237bcb (patch) | |
tree | 55e77c33788c47ccb8b347d5ae29f24ac39d4ae7 /qt-ui/profile/diveprofileitem.cpp | |
parent | 343b82708eeb3187aa15e207bab26cbdb414f1e3 (diff) | |
download | subsurface-7f1373ea6d074c4cfbf514bc4ea6e48bf3237bcb.tar.gz |
Implement the mean depth text
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/diveprofileitem.cpp')
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index ad4c5c25e..5b8663a17 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -588,8 +588,9 @@ void DiveMeanDepthItem::modelDataChanged(const QModelIndex &topLeft, const QMode QPointF point(hAxis->posAtValue(entry->sec), vAxis->posAtValue(meandepthvalue)); poly.append(point); } - + lastRunningSum = meandepthvalue; setPolygon(poly); + createTextItem(); } @@ -607,6 +608,23 @@ void DiveMeanDepthItem::settingsChanged() { setVisible(prefs.show_average_depth); } + +void DiveMeanDepthItem::createTextItem(){ + plot_data *entry = dataModel->data().entry; + int sec = entry[dataModel->rowCount()-1].sec; + qDeleteAll(texts); + texts.clear(); + int decimals; + double d = get_depth_units(lastRunningSum, &decimals, NULL); + DiveTextItem *text = new DiveTextItem(this); + text->setAlignment(Qt::AlignRight | Qt::AlignTop); + text->setBrush(getColor(TEMP_TEXT)); + text->setPos(QPointF(hAxis->posAtValue(sec), vAxis->posAtValue(lastRunningSum))); + text->setScale(0.8); // need to call this BEFORE setText() + text->setText(QString("%1").arg(d, 0, 'f', 1)); + texts.append(text); +} + void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { // We don't have enougth data to calculate things, quit. |