I lied. it doesn't properly cancels or saves the dive yet. but a huge improvement. :)
From cb0de3db172da3eebb7f57aaf4459c48239d1711 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 26 May 2014 17:43:52 -0300 Subject: [PATCH 1/3] Activate the Planner
On the cleanup dirk forgot to set the plan tipe to PLAN instead of ADD Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 63abd1d..8a452b3 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -391,7 +391,7 @@ void MainWindow::on_actionDivePlanner_triggered() dive_list()->rememberSelection(); dive_list()->unselectDives(); - DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::ADD); + DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN); DivePlannerPointsModel::instance()->clear(); CylindersModel::instance()->clear(); int i; -- 1.9.3
From 3533b2b9d528de2013eec71ad52ee9c1a7356b1d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 26 May 2014 17:51:46 -0300 Subject: [PATCH 2/3] Do not set maxTime when the handler is moving. Fixes massive cpu hog. Signed-off-by: Tomaz Canabrava <[email protected]> --- 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 28a0740..f622996 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<dive *> 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 3c3d86d..fbfd194 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<Qt::Key, QAction *> actionsForKeys; + bool shouldCalculateMaxTime; + int maxtime; }; #endif // PROFILEWIDGET2_H -- 1.9.3
From c3298a96d9494b6fe71187f1054867b8a87be08f Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Mon, 26 May 2014 18:01:38 -0300 Subject: [PATCH 3/3] speed up the Grid: don't repaint when uneeded. added a flag to only recalculate the axis when needed. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/divecartesianaxis.cpp | 11 +++++++++-- qt-ui/profile/divecartesianaxis.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/qt-ui/profile/divecartesianaxis.cpp b/qt-ui/profile/divecartesianaxis.cpp index 353f988..25b8a55 100644 --- a/qt-ui/profile/divecartesianaxis.cpp +++ b/qt-ui/profile/divecartesianaxis.cpp @@ -34,6 +34,7 @@ double DiveCartesianAxis::tickSize() const void DiveCartesianAxis::setFontLabelScale(qreal scale) { labelScale = scale; + changed = true; } void DiveCartesianAxis::setMaximum(double maximum) @@ -41,6 +42,7 @@ void DiveCartesianAxis::setMaximum(double maximum) if (IS_FP_SAME(max, maximum)) return; max = maximum; + changed = true; emit maxChanged(); } @@ -49,6 +51,7 @@ void DiveCartesianAxis::setMinimum(double minimum) if (IS_FP_SAME(min, minimum)) return; min = minimum; + changed = true; } void DiveCartesianAxis::setTextColor(const QColor &color) @@ -67,7 +70,8 @@ DiveCartesianAxis::DiveCartesianAxis() : QObject(), textVisibility(true), lineVisibility(true), labelScale(1.0), - line_size(1) + line_size(1), + changed(true) { setPen(gridPen()); } @@ -79,11 +83,13 @@ DiveCartesianAxis::~DiveCartesianAxis() void DiveCartesianAxis::setLineSize(qreal lineSize) { line_size = lineSize; + changed = true; } void DiveCartesianAxis::setOrientation(Orientation o) { orientation = o; + changed = true; } QColor DiveCartesianAxis::colorForValue(double value) @@ -126,7 +132,7 @@ void emptyList(QList<T *> &list, double steps) void DiveCartesianAxis::updateTicks(color_indice_t color) { - if (!scene()) + if (!scene() || !changed) return; QLineF m = line(); // unused so far: @@ -241,6 +247,7 @@ void DiveCartesianAxis::updateTicks(color_indice_t color) item->setVisible(textVisibility); Q_FOREACH (DiveLineItem *item, lines) item->setVisible(lineVisibility); + changed = false; } void DiveCartesianAxis::animateChangeLine(const QLineF &newLine) diff --git a/qt-ui/profile/divecartesianaxis.h b/qt-ui/profile/divecartesianaxis.h index 34089e6..e7fa68c 100644 --- a/qt-ui/profile/divecartesianaxis.h +++ b/qt-ui/profile/divecartesianaxis.h @@ -69,6 +69,7 @@ protected: bool lineVisibility; double labelScale; qreal line_size; + bool changed; }; class DepthAxis : public DiveCartesianAxis { -- 1.9.3
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
