From 85ab604c1b78bd1805e49c6d5706fc1cc6bf5bb9 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 14 Jan 2013 10:05:48 +0000 Subject: [PATCH] UseThruToday: TreeMap --- src/TreeMapWindow.cpp | 12 +++++++++--- src/TreeMapWindow.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/TreeMapWindow.cpp b/src/TreeMapWindow.cpp index 6900f8a3f..cd3a08f89 100644 --- a/src/TreeMapWindow.cpp +++ b/src/TreeMapWindow.cpp @@ -36,7 +36,7 @@ TreeMapWindow::TreeMapWindow(MainWindow *parent, bool useMetricUnits, const QDir &home) : GcWindow(parent), main(parent), home(home), - useMetricUnits(useMetricUnits), active(false), dirty(true), useCustom(false) + useMetricUnits(useMetricUnits), active(false), dirty(true), useCustom(false), useToToday(false) { setInstanceName("Treemap Window"); @@ -171,6 +171,7 @@ TreeMapWindow::useCustomRange(DateRange range) { // plot using the supplied range useCustom = true; + useToToday = false; custom = range; dateRangeChanged(custom); } @@ -178,7 +179,7 @@ TreeMapWindow::useCustomRange(DateRange range) void TreeMapWindow::useStandardRange() { - useCustom = false; + useToToday = useCustom = false; dateRangeChanged(myDateRange); } @@ -186,7 +187,8 @@ void TreeMapWindow::useThruToday() { // plot using the supplied range - useCustom = true; + useCustom = false; + useToToday = true; custom = myDateRange; if (custom.to > QDate::currentDate()) custom.to = QDate::currentDate(); dateRangeChanged(custom); @@ -214,6 +216,10 @@ TreeMapWindow::refresh() if (useCustom) { settings.from = custom.from; settings.to = custom.to; + } else if (useToToday) { + QDate today = QDate::currentDate(); + settings.from = myDateRange.from; + settings.to = myDateRange.to > today ? today : myDateRange.to; } else { settings.from = myDateRange.from; settings.to = myDateRange.to; diff --git a/src/TreeMapWindow.h b/src/TreeMapWindow.h index 7ae19ebce..4daf390d7 100644 --- a/src/TreeMapWindow.h +++ b/src/TreeMapWindow.h @@ -140,6 +140,7 @@ class TreeMapWindow : public GcWindow bool active; bool dirty; bool useCustom; + bool useToToday; DateRange custom; // custom date range supplied QList keywordDefinitions; QList fieldDefinitions;