diff options
author | Tomaz Canabrava <tcanabrava@kde.org> | 2014-01-21 13:27:08 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-01-21 09:39:09 -0800 |
commit | 0a4e21a16813592031baf8ca90bc52418aa8965e (patch) | |
tree | 1d9d255b45de6bbe048e911fdca2fcb59d7982b2 /qt-ui/profile/diveprofileitem.cpp | |
parent | caba6500d63e6081565aebd9e872e48b049e5d03 (diff) | |
download | subsurface-0a4e21a16813592031baf8ca90bc52418aa8965e.tar.gz |
Add the depth text.
Depth text got added to the new profile.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile/diveprofileitem.cpp')
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 03ad9c18e..0715bc58b 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -103,6 +103,42 @@ void DiveProfileItem::modelDataChanged(){ pat.setColorAt(1, getColor(DEPTH_BOTTOM)); pat.setColorAt(0, getColor(DEPTH_TOP)); setBrush(QBrush(pat)); + + qDeleteAll(texts); + texts.clear(); + + int last = -1; + for (int i = 0, count = dataModel->rowCount(); i < count; i++) { + + struct plot_data *entry = static_cast<DivePlotDataModel*>(dataModel)->data()+i; + if (entry->depth < 2000) + continue; + + if ((entry == entry->max[2]) && entry->depth / 100 != last) { + plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignTop, getColor(SAMPLE_DEEP)); + last = entry->depth / 100; + } + + if ((entry == entry->min[2]) && entry->depth / 100 != last) { + plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignBottom, getColor(SAMPLE_SHALLOW)); + last = entry->depth / 100; + } + + if (entry->depth != last) + last = -1; + } +} + +void DiveProfileItem::plot_depth_sample(struct plot_data *entry,QFlags<Qt::AlignmentFlag> flags,const QColor& color) +{ + int decimals; + double d = get_depth_units(entry->depth, &decimals, NULL); + DiveTextItem *item = new DiveTextItem(this); + item->setPos(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->depth)); + item->setText(QString("%1").arg(d, 0, 'f', 1)); + item->setAlignment(flags); + item->setBrush(color); + texts.append(item); } DiveTemperatureItem::DiveTemperatureItem() |