summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2015-01-28 17:24:00 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-01-28 13:35:43 -0800
commit7f1373ea6d074c4cfbf514bc4ea6e48bf3237bcb (patch)
tree55e77c33788c47ccb8b347d5ae29f24ac39d4ae7
parent343b82708eeb3187aa15e207bab26cbdb414f1e3 (diff)
downloadsubsurface-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>
-rw-r--r--qt-ui/profile/diveprofileitem.cpp20
-rw-r--r--qt-ui/profile/diveprofileitem.h2
2 files changed, 21 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.
diff --git a/qt-ui/profile/diveprofileitem.h b/qt-ui/profile/diveprofileitem.h
index fcbf4cd97..81e5bf4c8 100644
--- a/qt-ui/profile/diveprofileitem.h
+++ b/qt-ui/profile/diveprofileitem.h
@@ -94,6 +94,8 @@ public:
virtual void settingsChanged();
private:
+ void createTextItem();
+ double lastRunningSum;
QString visibilityKey;
};