mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: use C++ string functions to format plot data
This may appear a bit ominous, as it doesn't generate a string, but a vector of strings (one for each line). However, that is in preparation for the QtQuickification of the profile, where the text-items take such a list. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
422f693f5b
commit
ae299d5e66
4 changed files with 149 additions and 158 deletions
|
@ -222,8 +222,6 @@ void ToolTipItem::setTimeAxis(DiveCartesianAxis *axis)
|
|||
|
||||
void ToolTipItem::refresh(const dive *d, const QPointF &pos, bool inPlanner)
|
||||
{
|
||||
struct membufferpp mb;
|
||||
|
||||
if(refreshTime.elapsed() < 40)
|
||||
return;
|
||||
refreshTime.start();
|
||||
|
@ -233,7 +231,7 @@ void ToolTipItem::refresh(const dive *d, const QPointF &pos, bool inPlanner)
|
|||
lastTime = time;
|
||||
clear();
|
||||
|
||||
int idx = get_plot_details_new(d, &pInfo, time, &mb);
|
||||
auto [idx, lines] = get_plot_details_new(d, &pInfo, time);
|
||||
|
||||
tissues.fill();
|
||||
painter.setPen(QColor(0, 0, 0, 0));
|
||||
|
@ -253,7 +251,13 @@ void ToolTipItem::refresh(const dive *d, const QPointF &pos, bool inPlanner)
|
|||
painter.setPen(QColor(0, 0, 0, 127));
|
||||
for (int i = 0; i < 16; i++)
|
||||
painter.drawLine(i, 60, i, 60 - entry->percentages[i] / 2);
|
||||
entryToolTip.second->setPlainText(QString::fromUtf8(mb.buffer, mb.len));
|
||||
QString text;
|
||||
for (const std::string &s: lines) {
|
||||
if (!text.isEmpty())
|
||||
text += '\n';
|
||||
text += QString::fromStdString(s);
|
||||
}
|
||||
entryToolTip.second->setPlainText(text);
|
||||
}
|
||||
entryToolTip.first->setPixmap(tissues);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue