From b59efb0afbb09f079fe43cb60ca6ba91982a5cd1 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Mon, 21 Jul 2014 19:39:26 +1000 Subject: [PATCH] Show line cursor in overview --- sleepyhead/Graphs/gFlagsLine.cpp | 5 +++-- sleepyhead/Graphs/gGraph.cpp | 4 ++-- sleepyhead/Graphs/gGraphView.cpp | 11 ++++++++--- sleepyhead/Graphs/gLineChart.cpp | 5 ++--- sleepyhead/Graphs/gSummaryChart.cpp | 22 ++++++++++++++++++++++ 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/sleepyhead/Graphs/gFlagsLine.cpp b/sleepyhead/Graphs/gFlagsLine.cpp index 87bc9600..f3fcdf84 100644 --- a/sleepyhead/Graphs/gFlagsLine.cpp +++ b/sleepyhead/Graphs/gFlagsLine.cpp @@ -128,8 +128,9 @@ void gFlagsGroup::paint(QPainter &painter, gGraph &g, const QRegion ®ion) bool gFlagsGroup::mouseMoveEvent(QMouseEvent *event, gGraph *graph) { - if (graph->graphView()->metaSelect()) - graph->timedRedraw(30); + if (p_profile->appearance->lineCursorMode()) { + graph->timedRedraw(0); + } if (!p_profile->appearance->graphTooltips()) { return false; diff --git a/sleepyhead/Graphs/gGraph.cpp b/sleepyhead/Graphs/gGraph.cpp index 97038456..b258d2b8 100644 --- a/sleepyhead/Graphs/gGraph.cpp +++ b/sleepyhead/Graphs/gGraph.cpp @@ -696,8 +696,8 @@ void gGraph::mouseMoveEvent(QMouseEvent *event) int x2 = m_graphview->pointClicked().x() - m_rect.left(); - int w = m_rect.width() - (left + right); - //int h=m_lastbounds.height()-(bottom+m_marginbottom); + int w = m_rect.width() - left - right; + double xx = max_x - min_x; double xmult = xx / w; diff --git a/sleepyhead/Graphs/gGraphView.cpp b/sleepyhead/Graphs/gGraphView.cpp index 6a892bea..ac9abc73 100644 --- a/sleepyhead/Graphs/gGraphView.cpp +++ b/sleepyhead/Graphs/gGraphView.cpp @@ -1982,10 +1982,15 @@ void gGraphView::refreshTimeout() } void gGraphView::timedRedraw(int ms) { - if (!timer->isActive()) { - timer->setSingleShot(true); - timer->start(ms); + + if (timer->isActive()) { + int m = timer->remainingTime(); + if (m > ms) { + timer->stop(); + } else return; } + timer->setSingleShot(true); + timer->start(ms); } void gGraphView::resetLayout() { diff --git a/sleepyhead/Graphs/gLineChart.cpp b/sleepyhead/Graphs/gLineChart.cpp index dcb75277..3c9af1f7 100644 --- a/sleepyhead/Graphs/gLineChart.cpp +++ b/sleepyhead/Graphs/gLineChart.cpp @@ -160,8 +160,7 @@ EventDataType gLineChart::Maxy() bool gLineChart::mouseMoveEvent(QMouseEvent *event, gGraph *graph) { Q_UNUSED(event) - if (graph->graphView()->metaSelect()) - graph->timedRedraw(30); + Q_UNUSED(graph) return true; } @@ -279,7 +278,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) if ((time > minx) && (time < maxx)) { double xpos = (time - minx) * xmult; - painter.setPen(QPen(QBrush(QColor(Qt::gray)),1)); + painter.setPen(QPen(QBrush(QColor(0,255,0,255)),1)); painter.drawLine(left+xpos, top-w.marginTop()-3, left+xpos, top+height+w.bottom-1); } diff --git a/sleepyhead/Graphs/gSummaryChart.cpp b/sleepyhead/Graphs/gSummaryChart.cpp index 8fc1d545..02392abd 100644 --- a/sleepyhead/Graphs/gSummaryChart.cpp +++ b/sleepyhead/Graphs/gSummaryChart.cpp @@ -493,6 +493,28 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) lastdaygood = true; + if (p_profile->appearance->lineCursorMode()) { + qint64 time = w.currentTime(); + double xmult = double(width) / xx; + + if ((time > minx) && (time < maxx)) { + double xpos = (time - minx) * xmult; + painter.setPen(QPen(QBrush(QColor(0,255,0,255)),1)); + painter.drawLine(left+xpos, top-w.marginTop()-3, left+xpos, top+height+w.bottom-1); + } + + + + QDateTime dt=QDateTime::fromMSecsSinceEpoch(time,Qt::UTC); + + QString text = dt.date().toString(Qt::SystemLocaleLongDate); + + int wid, h; + GetTextExtent(text, wid, h); + w.renderText(text, left + width/2 - wid/2, top-h+5); + + } + for (int i = 0; i < numcodes; i++) { totalcounts[i] = 0;