From 030fa04b0cb4df459cbcc7e6d1d0bdc8f977cd72 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Thu, 20 Dec 2012 14:50:10 +0000 Subject: [PATCH] LTMPlot refresh optimisation Only refresh when dateRange actually changes within dateRangeChanged() since it is a signal used by the HomeWindow to ask a replot when a tab is selected. Should speed up navigation across diary and home view. --- src/LTMWindow.cpp | 8 +++++++- src/LTMWindow.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/LTMWindow.cpp b/src/LTMWindow.cpp index 677277681..23099ca11 100644 --- a/src/LTMWindow.cpp +++ b/src/LTMWindow.cpp @@ -40,6 +40,7 @@ LTMWindow::LTMWindow(MainWindow *parent, bool useMetricUnits, const QDir &home) { main = parent; setInstanceName("Metric Window"); + plotted = DateRange(QDate(01,01,01), QDate(01,01,01)); // the plot QVBoxLayout *mainLayout = new QVBoxLayout; @@ -157,6 +158,7 @@ void LTMWindow::refreshPlot() { if (amVisible() == true) { + plotted = myDateRange; ltmPlot->setData(&settings); dirty = false; } @@ -199,9 +201,13 @@ LTMWindow::metricSelected() void LTMWindow::dateRangeChanged(DateRange range) -{ Q_UNUSED( range ) +{ if (!amVisible() && !dirty) return; + // we already plotted that date range + if (range.from == plotted.from && + range.to == plotted.to) return; + settings.data = &results; settings.measures = &measures; diff --git a/src/LTMWindow.h b/src/LTMWindow.h index 88626b249..fe1f64d2d 100644 --- a/src/LTMWindow.h +++ b/src/LTMWindow.h @@ -143,6 +143,7 @@ class LTMWindow : public LTMPlotContainer // passed from MainWindow QDir home; bool useMetricUnits; + DateRange plotted; // qwt picker LTMToolTip *picker;