Small changes to the mean depth text

Add a tiny bit of white space to the left and display the unit as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-01-28 13:23:23 -08:00
parent 7f1373ea6d
commit eaec0bc842

View file

@ -609,19 +609,20 @@ void DiveMeanDepthItem::settingsChanged()
setVisible(prefs.show_average_depth); setVisible(prefs.show_average_depth);
} }
void DiveMeanDepthItem::createTextItem(){ void DiveMeanDepthItem::createTextItem() {
plot_data *entry = dataModel->data().entry; plot_data *entry = dataModel->data().entry;
int sec = entry[dataModel->rowCount()-1].sec; int sec = entry[dataModel->rowCount()-1].sec;
qDeleteAll(texts); qDeleteAll(texts);
texts.clear(); texts.clear();
int decimals; int decimals;
double d = get_depth_units(lastRunningSum, &decimals, NULL); const char *unitText;
double d = get_depth_units(lastRunningSum, &decimals, &unitText);
DiveTextItem *text = new DiveTextItem(this); DiveTextItem *text = new DiveTextItem(this);
text->setAlignment(Qt::AlignRight | Qt::AlignTop); text->setAlignment(Qt::AlignRight | Qt::AlignTop);
text->setBrush(getColor(TEMP_TEXT)); text->setBrush(getColor(TEMP_TEXT));
text->setPos(QPointF(hAxis->posAtValue(sec), vAxis->posAtValue(lastRunningSum))); text->setPos(QPointF(hAxis->posAtValue(sec) + 1, vAxis->posAtValue(lastRunningSum)));
text->setScale(0.8); // need to call this BEFORE setText() text->setScale(0.8); // need to call this BEFORE setText()
text->setText(QString("%1").arg(d, 0, 'f', 1)); text->setText(QString("%1%2").arg(d, 0, 'f', 1).arg(*unitText));
texts.append(text); texts.append(text);
} }