From d31193de1eeee3b478c443e1c478949affb57781 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sun, 30 Oct 2011 14:43:15 +1000 Subject: [PATCH] Make Prev/Next buttons skip empty days (3 month limit) --- daily.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/daily.cpp b/daily.cpp index 1d440044..66c09fb3 100644 --- a/daily.cpp +++ b/daily.cpp @@ -856,12 +856,33 @@ void Daily::on_JournalNotesUnderline_clicked() void Daily::on_prevDayButton_clicked() { - LoadDate(previous_date.addDays(-1)); + QDate d=previous_date; + bool found=false; + for (int i=0;i<90;i++) { + d=d.addDays(-1); + if (PROFILE.GetDay(d)) { + LoadDate(d); + found=true; + break; + } + } + if (!found) LoadDate(previous_date.addDays(-1)); } void Daily::on_nextDayButton_clicked() { - LoadDate(previous_date.addDays(1)); + QDate d=previous_date; + bool found=false; + for (int i=0;i<90;i++) { + d=d.addDays(1); + if (PROFILE.GetDay(d)) { + LoadDate(d); + found=true; + break; + } + } + if (!found) LoadDate(previous_date.addDays(1)); + //LoadDate(previous_date.addDays(1)); } void Daily::on_calButton_toggled(bool checked)