Do not set maxTime when the handler is moving.

Fixes massive cpu hog.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-05-26 17:51:46 -03:00 committed by Dirk Hohndel
parent fe2eb1a9fc
commit addec6b69f
2 changed files with 24 additions and 3 deletions

View file

@ -87,7 +87,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
heartBeatItem(new DiveHeartrateItem()), heartBeatItem(new DiveHeartrateItem()),
rulerItem(new RulerItem2()), rulerItem(new RulerItem2()),
isGrayscale(false), isGrayscale(false),
printMode(false) printMode(false),
shouldCalculateMaxTime(true)
{ {
memset(&plotInfo, 0, sizeof(plotInfo)); memset(&plotInfo, 0, sizeof(plotInfo));
@ -421,7 +422,8 @@ void ProfileWidget2::plotDives(QList<dive *> dives)
*/ */
struct plot_info pInfo = calculate_max_limits_new(d, currentdc); struct plot_info pInfo = calculate_max_limits_new(d, currentdc);
create_plot_info_new(d, currentdc, &pInfo); create_plot_info_new(d, currentdc, &pInfo);
int maxtime = get_maxtime(&pInfo); if(shouldCalculateMaxTime)
maxtime = get_maxtime(&pInfo);
int maxdepth = get_maxdepth(&pInfo); int maxdepth = get_maxdepth(&pInfo);
dataModel->setDive(d, pInfo); dataModel->setDive(d, pInfo);
@ -546,6 +548,22 @@ void ProfileWidget2::resizeEvent(QResizeEvent *event)
fixBackgroundPos(); 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() void ProfileWidget2::fixBackgroundPos()
{ {
if (currentState != EMPTY) if (currentState != EMPTY)

View file

@ -108,7 +108,8 @@ protected:
virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event);
virtual void contextMenuEvent(QContextMenuEvent *event); virtual void contextMenuEvent(QContextMenuEvent *event);
virtual void mouseDoubleClickEvent(QMouseEvent *event); virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
private: /*methods*/ private: /*methods*/
void fixBackgroundPos(); void fixBackgroundPos();
void scrollViewTo(const QPoint &pos); void scrollViewTo(const QPoint &pos);
@ -160,6 +161,8 @@ private:
int fixHandlerIndex(DiveHandler *activeHandler); int fixHandlerIndex(DiveHandler *activeHandler);
friend class DiveHandler; friend class DiveHandler;
QHash<Qt::Key, QAction *> actionsForKeys; QHash<Qt::Key, QAction *> actionsForKeys;
bool shouldCalculateMaxTime;
int maxtime;
}; };
#endif // PROFILEWIDGET2_H #endif // PROFILEWIDGET2_H