summaryrefslogtreecommitdiff
path: root/src/statistics/ScheduledPage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/statistics/ScheduledPage.cpp')
-rw-r--r--src/statistics/ScheduledPage.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/statistics/ScheduledPage.cpp b/src/statistics/ScheduledPage.cpp
new file mode 100644
index 0000000..5e2b558
--- /dev/null
+++ b/src/statistics/ScheduledPage.cpp
@@ -0,0 +1,35 @@
+#include "ScheduledPage.h"
+#include "../dictionary/CardPack.h"
+
+ScheduledPage::ScheduledPage(const StatisticsParams* statParams):
+ TimeChartPage(statParams)
+{
+ init();
+}
+
+QList<QDateTime> ScheduledPage::getDates(const CardPack* pack) const
+{
+ QList<QDateTime> scheduled = pack->getScheduledDates();
+ adjustScheduledRecords(scheduled);
+ return scheduled;
+}
+
+void ScheduledPage::adjustScheduledRecords(QList<QDateTime>& scheduled)
+{
+ const QDate curDate = QDate::currentDate();
+ const QTime zeroTime = QTime(0, 0);
+ for(int i = 0; i < scheduled.size(); i++)
+ {
+ QDateTime& dateTime = scheduled[i];
+ if(dateTime.date() < curDate)
+ dateTime = QDateTime(curDate, zeroTime);
+ else if(laterThisDay(dateTime))
+ dateTime = QDateTime(curDate.addDays(1), zeroTime);
+ }
+}
+
+bool ScheduledPage::laterThisDay(QDateTime& dateTime)
+{
+ return dateTime.date() == QDate::currentDate() &&
+ dateTime > QDateTime::currentDateTime();
+}