From 8734e39dc998a4d5fb83038f8b3903bebfedab5c Mon Sep 17 00:00:00 2001
From: Mark Watkins
Date: Tue, 15 Nov 2011 11:09:09 +1000
Subject: [PATCH] ExportCSV Calender highlighting, changed quick ranges to
count back from last entry
---
docs/channels.xml | 2 +-
docs/release_notes.html | 11 +++--
exportcsv.cpp | 94 +++++++++++++++++++++++++++++++++++------
exportcsv.h | 7 +++
4 files changed, 93 insertions(+), 21 deletions(-)
diff --git a/docs/channels.xml b/docs/channels.xml
index b833ca12..f215c4fb 100644
--- a/docs/channels.xml
+++ b/docs/channels.xml
@@ -44,7 +44,7 @@ One id code per item
-
+
diff --git a/docs/release_notes.html b/docs/release_notes.html
index 67f10553..6d523106 100644
--- a/docs/release_notes.html
+++ b/docs/release_notes.html
@@ -6,22 +6,21 @@
Release Notes
-This test build probably isn't as cool as the last ones, it mostly just fixes some annoying bugs.
-I would have liked to have had more to share with you this time around, but I spent the last few
-weeks functioning less than usual (fog, appendicitus, etc.. bleh).
-Still, I have managed to make a few nice improvements...
+I've been a little less functional that usual since last time (fog, headaches, appendicitus, etc.. bleh),
+however, I have still managed to cook up a few nice improvements...
What's New?
You can now Shift+Left Click on a day in an overview graph, and it will jump to that day in Daily tab.
New calendar navigation bar allows easy hiding the calendar to get more room.
(Relative) AHI is displayed above the flow rate waveform for selected area.
-A new preference option to switch some daily graphs between square plots and normal line plots.
Improved support for ResMed S9 ASV/VPAP Machines.
+Added some basic CSV export capabilities.
+A new preference option to switch some daily graphs between square plots and normal line plots.
Some graphing optimizations to improve performance.
Quite a few other little bugfixes I've forgotten about.
What's still missing/broken?
-Oximetry.. still. I know it sucks..
+Oximetry.. still mostly broken. I will eventually get around to it...
Daily report printing still needs doing.
Plenty more I'm sure of it..
diff --git a/exportcsv.cpp b/exportcsv.cpp
index 799ca5a6..fbe32b6d 100644
--- a/exportcsv.cpp
+++ b/exportcsv.cpp
@@ -1,6 +1,7 @@
#include
#include
#include
+#include
#include "SleepLib/profiles.h"
#include "SleepLib/day.h"
#include "exportcsv.h"
@@ -22,6 +23,17 @@ ExportCSV::ExportCSV(QWidget *parent) :
}
ui->startDate->setDisplayFormat(shortformat);
ui->endDate->setDisplayFormat(shortformat);
+ // Stop both calendar drop downs highlighting weekends in red
+ QTextCharFormat format = ui->startDate->calendarWidget()->weekdayTextFormat(Qt::Saturday);
+ format.setForeground(QBrush(Qt::black, Qt::SolidPattern));
+ ui->startDate->calendarWidget()->setWeekdayTextFormat(Qt::Saturday, format);
+ ui->startDate->calendarWidget()->setWeekdayTextFormat(Qt::Sunday, format);
+ ui->endDate->calendarWidget()->setWeekdayTextFormat(Qt::Saturday, format);
+ ui->endDate->calendarWidget()->setWeekdayTextFormat(Qt::Sunday, format);
+
+ // Connect the signals to update which days have CPAP data when the month is changed
+ connect(ui->startDate->calendarWidget(),SIGNAL(currentPageChanged(int,int)),SLOT(startDate_currentPageChanged(int,int)));
+ connect(ui->endDate->calendarWidget(),SIGNAL(currentPageChanged(int,int)),SLOT(endDate_currentPageChanged(int,int)));
on_quickRangeCombo_activated("Most Recent Day");
ui->rb1_details->clearFocus();
@@ -61,6 +73,8 @@ void ExportCSV::on_filenameBrowseButton_clicked()
void ExportCSV::on_quickRangeCombo_activated(const QString &arg1)
{
+ QDate first=PROFILE.FirstDay();
+ QDate last=PROFILE.LastDay();
if (arg1=="Custom") {
ui->startDate->setEnabled(true);
ui->endDate->setEnabled(true);
@@ -71,27 +85,28 @@ void ExportCSV::on_quickRangeCombo_activated(const QString &arg1)
ui->endDate->setEnabled(false);
ui->startLabel->setEnabled(false);
ui->endLabel->setEnabled(false);
+
if (arg1=="Everything") {
- ui->startDate->setDate(PROFILE.FirstDay());
- ui->endDate->setDate(PROFILE.LastDay());
+ ui->startDate->setDate(first);
+ ui->endDate->setDate(last);
} else if (arg1=="Most Recent Day") {
- ui->startDate->setDate(PROFILE.LastDay());
- ui->endDate->setDate(PROFILE.LastDay());
+ ui->startDate->setDate(last);
+ ui->endDate->setDate(last);
} else if (arg1=="Last Week") {
- ui->startDate->setDate(QDate::currentDate().addDays(-7));
- ui->endDate->setDate(QDate::currentDate());
+ ui->startDate->setDate(last.addDays(-7));
+ ui->endDate->setDate(last);
} else if (arg1=="Last Fortnight") {
- ui->startDate->setDate(QDate::currentDate().addDays(-14));
- ui->endDate->setDate(QDate::currentDate());
+ ui->startDate->setDate(last.addDays(-14));
+ ui->endDate->setDate(last);
} else if (arg1=="Last Month") {
- ui->startDate->setDate(QDate::currentDate().addMonths(-1));
- ui->endDate->setDate(QDate::currentDate());
+ ui->startDate->setDate(last.addMonths(-1));
+ ui->endDate->setDate(last);
} else if (arg1=="Last 6 Months") {
- ui->startDate->setDate(QDate::currentDate().addMonths(-6));
- ui->endDate->setDate(QDate::currentDate());
+ ui->startDate->setDate(last.addMonths(-6));
+ ui->endDate->setDate(last);
} else if (arg1=="Last Year") {
- ui->startDate->setDate(QDate::currentDate().addYears(-1));
- ui->endDate->setDate(QDate::currentDate());
+ ui->startDate->setDate(last.addYears(-1));
+ ui->endDate->setDate(last);
}
}
}
@@ -222,3 +237,54 @@ void ExportCSV::on_exportButton_clicked()
file.close();
ExportCSV::accept();
}
+
+
+void ExportCSV::UpdateCalendarDay(QDateEdit * dateedit,QDate date)
+{
+ QCalendarWidget *calendar=dateedit->calendarWidget();
+ QTextCharFormat bold;
+ QTextCharFormat cpapcol;
+ QTextCharFormat normal;
+ QTextCharFormat oxiday;
+ bold.setFontWeight(QFont::Bold);
+ cpapcol.setForeground(QBrush(Qt::blue, Qt::SolidPattern));
+ cpapcol.setFontWeight(QFont::Bold);
+ oxiday.setForeground(QBrush(Qt::red, Qt::SolidPattern));
+ oxiday.setFontWeight(QFont::Bold);
+ bool hascpap=p_profile->GetDay(date,MT_CPAP)!=NULL;
+ bool hasoxi=p_profile->GetDay(date,MT_OXIMETER)!=NULL;
+ //bool hasjournal=p_profile->GetDay(date,MT_JOURNAL)!=NULL;
+
+ if (hascpap) {
+ if (hasoxi) {
+ calendar->setDateTextFormat(date,oxiday);
+ } else {
+ calendar->setDateTextFormat(date,cpapcol);
+ }
+ } else if (p_profile->GetDay(date)) {
+ calendar->setDateTextFormat(date,bold);
+ } else {
+ calendar->setDateTextFormat(date,normal);
+ }
+ calendar->setHorizontalHeaderFormat(QCalendarWidget::ShortDayNames);
+}
+void ExportCSV::startDate_currentPageChanged(int year, int month)
+{
+ QDate d(year,month,1);
+ int dom=d.daysInMonth();
+
+ for (int i=1;i<=dom;i++) {
+ d=QDate(year,month,i);
+ UpdateCalendarDay(ui->startDate,d);
+ }
+}
+void ExportCSV::endDate_currentPageChanged(int year, int month)
+{
+ QDate d(year,month,1);
+ int dom=d.daysInMonth();
+
+ for (int i=1;i<=dom;i++) {
+ d=QDate(year,month,i);
+ UpdateCalendarDay(ui->endDate,d);
+ }
+}
diff --git a/exportcsv.h b/exportcsv.h
index a9371584..7a2beede 100644
--- a/exportcsv.h
+++ b/exportcsv.h
@@ -1,6 +1,7 @@
#ifndef EXPORTCSV_H
#define EXPORTCSV_H
+#include
#include
namespace Ui {
@@ -22,7 +23,13 @@ private slots:
void on_exportButton_clicked();
+ void startDate_currentPageChanged(int year, int month);
+ void endDate_currentPageChanged(int year, int month);
+
+
private:
+ void UpdateCalendarDay(QDateEdit * dateedit,QDate date);
+
Ui::ExportCSV *ui;
};