Fix custom date range muddle when groupby weeks

.. the start date would progressively change as you selected a
date range in the sidebar. This is because the code to set the date
range to the start of a week looked at the wrong date variable when
using a custom date range.

Fixes #500.
This commit is contained in:
Mark Liversedge
2013-03-08 15:24:03 +00:00
parent f4949df9ea
commit a4cd35002a

View File

@@ -243,6 +243,8 @@ LTMWindow::metricSelected()
void
LTMWindow::dateRangeChanged(DateRange range)
{
if (useCustom || useToToday) range = custom;
if (!amVisible() && !dirty) return;
// we already plotted that date range
@@ -283,8 +285,8 @@ LTMWindow::filterChanged()
settings.measures = &measures;
// if we want weeks and start is not a monday go back to the monday
int dow = myDateRange.from.dayOfWeek();
if (settings.groupBy == LTM_WEEK && dow >1 && myDateRange.from != QDate())
int dow = settings.start.date().dayOfWeek();
if (settings.groupBy == LTM_WEEK && dow >1 && settings.start != QDateTime(QDate(), QTime(0,0)))
settings.start = settings.start.addDays(-1*(dow-1));
// we need to get data again and apply filter