From addec6b69fe9022a79d83945b865a0b518f556e8 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Mon, 26 May 2014 17:51:46 -0300 Subject: Do not set maxTime when the handler is moving. Fixes massive cpu hog. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/profile/profilewidget2.cpp | 22 ++++++++++++++++++++-- qt-ui/profile/profilewidget2.h | 5 ++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 28a07404f..f62299648 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -87,7 +87,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), heartBeatItem(new DiveHeartrateItem()), rulerItem(new RulerItem2()), isGrayscale(false), - printMode(false) + printMode(false), + shouldCalculateMaxTime(true) { memset(&plotInfo, 0, sizeof(plotInfo)); @@ -421,7 +422,8 @@ void ProfileWidget2::plotDives(QList dives) */ struct plot_info pInfo = calculate_max_limits_new(d, currentdc); create_plot_info_new(d, currentdc, &pInfo); - int maxtime = get_maxtime(&pInfo); + if(shouldCalculateMaxTime) + maxtime = get_maxtime(&pInfo); int maxdepth = get_maxdepth(&pInfo); dataModel->setDive(d, pInfo); @@ -546,6 +548,22 @@ void ProfileWidget2::resizeEvent(QResizeEvent *event) fixBackgroundPos(); } +void ProfileWidget2::mousePressEvent(QMouseEvent *event) +{ + QGraphicsView::mousePressEvent(event); + if(currentState == PLAN) + shouldCalculateMaxTime = false; +} + +void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event) +{ + QGraphicsView::mouseReleaseEvent(event); + if(currentState == PLAN){ + shouldCalculateMaxTime = true; + replot(); + } +} + void ProfileWidget2::fixBackgroundPos() { if (currentState != EMPTY) diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index 3c3d86d01..fbfd1947f 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -108,7 +108,8 @@ protected: virtual void mouseMoveEvent(QMouseEvent *event); virtual void contextMenuEvent(QContextMenuEvent *event); virtual void mouseDoubleClickEvent(QMouseEvent *event); - + virtual void mousePressEvent(QMouseEvent *event); + virtual void mouseReleaseEvent(QMouseEvent *event); private: /*methods*/ void fixBackgroundPos(); void scrollViewTo(const QPoint &pos); @@ -160,6 +161,8 @@ private: int fixHandlerIndex(DiveHandler *activeHandler); friend class DiveHandler; QHash actionsForKeys; + bool shouldCalculateMaxTime; + int maxtime; }; #endif // PROFILEWIDGET2_H -- cgit v1.2.3-70-g09d2