Populate a few useful Records in the new sidebar, plus make the links work

This commit is contained in:
Mark Watkins 2011-12-25 23:27:47 +10:00
parent 1146aa3692
commit b140fe6b4b
7 changed files with 215 additions and 50 deletions

View File

@ -1120,7 +1120,8 @@ void Daily::Unload(QDate date)
} }
} }
if (journal->IsChanged()) { if (journal->IsChanged()) {
mainwin->getOverview()->ReloadGraphs();
mainwin->getOverview()->ResetGraphs();
} }
Machine *jm=PROFILE.GetMachine(MT_JOURNAL); Machine *jm=PROFILE.GetMachine(MT_JOURNAL);
if (jm) jm->SaveSession(journal); if (jm) jm->SaveSession(journal);

View File

@ -140,7 +140,12 @@ MainWindow::MainWindow(QWidget *parent) :
systray=NULL; systray=NULL;
systraymenu=NULL; systraymenu=NULL;
} }
ui->toolBox->setCurrentIndex(0);
daily->graphView()->redraw(); daily->graphView()->redraw();
ui->recordsBox->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
//connect(ui->recordsBox,SIGNAL(linkClicked(QUrl)),this,SLOT(Link_clicked(QUrl)));
} }
extern MainWindow *mainwin; extern MainWindow *mainwin;
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -712,6 +717,8 @@ void MainWindow::on_summaryButton_clicked()
html+="</table>"; html+="</table>";
html+="</div>"; html+="</div>";
QDate bestAHIdate, worstAHIdate;
EventDataType bestAHI=999.0, worstAHI=0;
if (cpapdays>0) { if (cpapdays>0) {
QDate first,last=lastcpap; QDate first,last=lastcpap;
CPAPMode mode,cmode=MODE_UNKNOWN; CPAPMode mode,cmode=MODE_UNKNOWN;
@ -723,8 +730,21 @@ void MainWindow::on_summaryButton_clicked()
QVector<RXChange> rxchange; QVector<RXChange> rxchange;
do { do {
day=PROFILE.GetDay(date,MT_CPAP); day=PROFILE.GetDay(date,MT_CPAP);
lastchanged=false; lastchanged=false;
if (day) { if (day) {
EventDataType ahi=day->count(CPAP_Obstructive)+day->count(CPAP_Hypopnea)+day->count(CPAP_Apnea)+day->count(CPAP_ClearAirway);
if (PROFILE.general->calculateRDI()) ahi+=day->count(CPAP_RERA);
ahi/=day->hours();
if (ahi > worstAHI) {
worstAHI=ahi;
worstAHIdate=date;
}
if (ahi < bestAHI) {
bestAHI=ahi;
bestAHIdate=date;
}
mode=(CPAPMode)round(day->settings_wavg(CPAP_Mode)); mode=(CPAPMode)round(day->settings_wavg(CPAP_Mode));
min=day->settings_min(CPAP_PressureMin); min=day->settings_min(CPAP_PressureMin);
if (mode==MODE_CPAP) { if (mode==MODE_CPAP) {
@ -797,7 +817,92 @@ void MainWindow::on_summaryButton_clicked()
RXsort=RX_ahi; RXsort=RX_ahi;
qSort(tmpRX.begin(),tmpRX.end(),RXSort); qSort(tmpRX.begin(),tmpRX.end(),RXSort);
tmpRX[0]->highlight=4; // worst tmpRX[0]->highlight=4; // worst
tmpRX[tmpRX.size()-1]->highlight=1; //best int ls=tmpRX.size()-1;
tmpRX[ls]->highlight=1; //best
QString recbox="<html><head><style type='text/css'>"
"p,a,td,body { font-family: '"+QApplication::font().family()+"'; }"
"p,a,td,body { font-size: "+QString::number(QApplication::font().pointSize() + 2)+"px; }"
"a:link,a:visited { color: inherit; text-decoration: none; }" //font-weight: normal;
"a:hover { background-color: inherit; color: white; text-decoration:none; font-weight: bold; }"
"</style></head><body>";
recbox+="<table width=100% cellpadding=2 cellspacing=0>";
recbox+=QString("<tr><td><b><a href='daily=%1'>%2</b></td><td><b>%3</b></td></tr>").arg(bestAHIdate.toString(Qt::ISODate)).arg("Best&nbsp;AHI").arg(bestAHI,0,'f',2);
recbox+=QString("<tr><td colspan=2>%1</td></tr>").arg(bestAHIdate.toString(Qt::SystemLocaleShortDate));
recbox+=QString("<tr><td colspan=2>&nbsp;</td></tr>");
recbox+=QString("<tr><td><b><a href='daily=%1'>%2</a></b></td><td><b>%3</b></td></tr>").arg(worstAHIdate.toString(Qt::ISODate)).arg("Worst&nbsp;AHI").arg(worstAHI,0,'f',2);
recbox+=QString("<tr><td colspan=2>%1</td></tr>").arg(worstAHIdate.toString(Qt::SystemLocaleShortDate));
recbox+=QString("<tr><td colspan=2>&nbsp;</td></tr>");
QString minstr,maxstr,modestr;
{
CPAPMode mode=(CPAPMode)(int)PROFILE.calcSettingsMax(CPAP_Mode,MT_CPAP,tmpRX[ls]->first,tmpRX[ls]->first);
if (mode<MODE_APAP) { // is CPAP?
minstr="Pressure";
maxstr="";
modestr=tr("CPAP");
} else if (mode<MODE_BIPAP) { // is AUTO?
minstr="Min";
maxstr="Max";
modestr=tr("APAP");
} else { // BIPAP or greater
minstr="EPAP";
maxstr="IPAP";
modestr=tr("Bi-Level/ASV");
}
recbox+=QString("<tr><td colspan=2><b><a href='overview=%1,%2'>%3</a></b></td></tr>")
.arg(tmpRX[ls]->first.toString(Qt::ISODate))
.arg(tmpRX[ls]->last.toString(Qt::ISODate))
.arg(tr("Best RX Setting"));
recbox+=QString("<tr><td colspan=2>%1: %2</td></tr>").arg(tr("AHI")).arg(tmpRX[ls]->ahi,0,'f',2);
recbox+=QString("<tr><td colspan=2>%1: %2</td></tr>").arg(tr("Mode")).arg(modestr);
recbox+=QString("<tr><td colspan=2>%1: %2").arg(minstr).arg(tmpRX[ls]->min,0,'f',1);
if (!maxstr.isEmpty()) recbox+=QString(" %1: %2").arg(maxstr).arg(tmpRX[ls]->max,0,'f',1);
recbox+="</td></tr>";
recbox+=QString("<tr><td colspan=2>%1: %2</td></tr>").arg(tr("Start")).arg(tmpRX[ls]->first.toString(Qt::SystemLocaleShortDate));
recbox+=QString("<tr><td colspan=2>%1: %2</td></tr>").arg(tr("End")).arg(tmpRX[ls]->last.toString(Qt::SystemLocaleShortDate));
recbox+=QString("<tr><td colspan=2>&nbsp;</td></tr>");
mode=(CPAPMode)(int)PROFILE.calcSettingsMax(CPAP_Mode,MT_CPAP,tmpRX[0]->first,tmpRX[0]->first);
if (mode<MODE_APAP) { // is CPAP?
minstr="Pressure";
maxstr="";
modestr=tr("CPAP");
} else if (mode<MODE_BIPAP) { // is AUTO?
minstr="Min";
maxstr="Max";
modestr=tr("APAP");
} else { // BIPAP or greater
minstr="EPAP";
maxstr="IPAP";
modestr=tr("Bi-Level/ASV");
}
recbox+=QString("<tr><td colspan=2><b><a href='overview=%1,%2'>%3</a></b></td></tr>")
.arg(tmpRX[0]->first.toString(Qt::ISODate))
.arg(tmpRX[0]->last.toString(Qt::ISODate))
.arg(tr("Worst RX Setting"));
recbox+=QString("<tr><td colspan=2>%1: %2</td></tr>").arg(tr("AHI")).arg(tmpRX[0]->ahi,0,'f',2);
recbox+=QString("<tr><td colspan=2>%1: %2</td></tr>").arg(tr("Mode")).arg(modestr);
recbox+=QString("<tr><td colspan=2>%1: %2").arg(minstr).arg(tmpRX[0]->min,0,'f',1);
if (!maxstr.isEmpty()) recbox+=QString(" %1: %2").arg(maxstr).arg(tmpRX[0]->max,0,'f',1);
recbox+="</td></tr>";
recbox+=QString("<tr><td colspan=2>%1: %2</td></tr>").arg(tr("Start")).arg(tmpRX[0]->first.toString(Qt::SystemLocaleShortDate));
recbox+=QString("<tr><td colspan=2>%1: %2</td></tr>").arg(tr("End")).arg(tmpRX[0]->last.toString(Qt::SystemLocaleShortDate));
}
recbox+=QString("</table>");
recbox+="</body></html>";
ui->recordsBox->setHtml(recbox);
// ui->recordsBox->append("<a href='overview'><b>Best RX Setting</b></a>");
// ui->recordsBox->append("Start: "+tmpRX[ls]->first.toString(Qt::SystemLocaleShortDate)+"<br/>End: "+tmpRX[ls]->last.toString(Qt::SystemLocaleShortDate)+"\n\n");
// ui->recordsBox->append("<a href='overview'><b>Worst RX Setting</b></a>");
// ui->recordsBox->append("Start: "+tmpRX[0]->first.toString(Qt::SystemLocaleShortDate)+"<br/>End: "+tmpRX[0]->last.toString(Qt::SystemLocaleShortDate)+"\n\n");
//show the second best and worst.. //show the second best and worst..
//if (tmpRX.size()>4) { //if (tmpRX.size()>4) {
@ -1841,3 +1946,24 @@ void MainWindow::on_action_Sidebar_Toggle_toggled(bool visible)
{ {
ui->toolBox->setVisible(visible); ui->toolBox->setVisible(visible);
} }
void MainWindow::on_recordsBox_linkClicked(const QUrl &linkurl)
{
QString link=linkurl.toString().section("=",0,0).toLower();
QString datestr=linkurl.toString().section("=",1).toLower();
qDebug() << linkurl.toString() << link << datestr;
if (link=="daily") {
QDate date=QDate::fromString(datestr,Qt::ISODate);
daily->LoadDate(date);
ui->tabWidget->setCurrentWidget(daily);
} else if (link=="overview") {
QString date1=datestr.section(",",0,0);
QString date2=datestr.section(",",1);
QDate d1=QDate::fromString(date1,Qt::ISODate);
QDate d2=QDate::fromString(date2,Qt::ISODate);
overview->setRange(d1,d2);
ui->tabWidget->setCurrentWidget(overview);
}
}

View File

@ -248,6 +248,8 @@ private slots:
void on_action_Sidebar_Toggle_toggled(bool arg1); void on_action_Sidebar_Toggle_toggled(bool arg1);
void on_recordsBox_linkClicked(const QUrl &arg1);
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;

View File

@ -271,13 +271,13 @@
<widget class="QToolBox" name="toolBox"> <widget class="QToolBox" name="toolBox">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>140</width> <width>160</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>140</width> <width>160</width>
<height>16777215</height> <height>16777215</height>
</size> </size>
</property> </property>
@ -385,7 +385,7 @@
<number>1</number> <number>1</number>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>2</number>
</property> </property>
<property name="tabSpacing"> <property name="tabSpacing">
<number>0</number> <number>0</number>
@ -395,7 +395,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>123</width> <width>143</width>
<height>513</height> <height>513</height>
</rect> </rect>
</property> </property>
@ -691,7 +691,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>138</width> <width>158</width>
<height>319</height> <height>319</height>
</rect> </rect>
</property> </property>
@ -713,7 +713,7 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QListWidget" name="listWidget"> <widget class="QListWidget" name="favouritesList">
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
@ -774,28 +774,48 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QTextEdit" name="textEdit"> <widget class="QWebView" name="recordsBox">
<property name="tabChangesFocus"> <property name="palette">
<bool>true</bool> <palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>170</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>31</green>
<blue>237</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property> </property>
<property name="readOnly"> <property name="url">
<bool>true</bool> <url>
</property> <string>about:blank</string>
<property name="html"> </url>
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Highest AHI&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;foo&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;somedate&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Lowest AHI&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;foo&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;somedate&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Most PB/CSR&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;foo&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;somedate&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;etc..&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -283,13 +283,25 @@ gGraph * Overview::createGraph(QString name,QString units, YTickerType yttype)
void Overview::ReloadGraphs() void Overview::ReloadGraphs()
{ {
ui->dateStart->setDate(p_profile->FirstDay());
ui->dateEnd->setDate(p_profile->LastDay());
GraphView->setDay(NULL); GraphView->setDay(NULL);
on_rangeCombo_activated(ui->rangeCombo->currentIndex()); on_rangeCombo_activated(ui->rangeCombo->currentIndex());
} }
void Overview::ResetGraphs()
{
QDate start=ui->dateStart->date();
QDate end=ui->dateEnd->date();
//ui->dateStart->setDate(p_profile->FirstDay());
//ui->dateEnd->setDate(p_profile->LastDay());
GraphView->setDay(NULL);
if (start.isValid() && end.isValid()) {
setRange(start,end);
}
//on_rangeCombo_activated(ui->rangeCombo->currentIndex());
}
void Overview::RedrawGraphs() void Overview::RedrawGraphs()
{ {
GraphView->redraw(); GraphView->redraw();
@ -369,10 +381,10 @@ void Overview::on_toolButton_clicked()
GraphView->SetXBounds(d1,d2); GraphView->SetXBounds(d1,d2);
} }
void Overview::on_printButton_clicked() //void Overview::on_printButton_clicked()
{ //{
mainwin->PrintReport(GraphView,STR_TR_Overview); // Must be translated the same as PrintReport checks. // mainwin->PrintReport(GraphView,STR_TR_Overview); // Must be translated the same as PrintReport checks.
} //}
void Overview::ResetGraphLayout() void Overview::ResetGraphLayout()
{ {
@ -416,7 +428,6 @@ void Overview::on_rangeCombo_activated(int index)
{ {
QDate end=PROFILE.LastDay(); QDate end=PROFILE.LastDay();
QDate start; QDate start;
ui->dateEnd->setDate(end);
if (index==0) { if (index==0) {
start=end.addDays(-6); start=end.addDays(-6);
} else if (index==1) { } else if (index==1) {
@ -433,6 +444,15 @@ void Overview::on_rangeCombo_activated(int index)
start=end.addYears(-1).addDays(1); start=end.addYears(-1).addDays(1);
} }
if (start<PROFILE.FirstDay()) start=PROFILE.FirstDay(); if (start<PROFILE.FirstDay()) start=PROFILE.FirstDay();
setRange(start,end);
}
void Overview::setRange(QDate start, QDate end)
{
ui->dateEnd->blockSignals(true);
ui->dateStart->blockSignals(true);
ui->dateStart->setDate(start); ui->dateStart->setDate(start);
ui->dateEnd->setDate(end);
ui->dateEnd->blockSignals(false);
ui->dateStart->blockSignals(false);
this->on_toolButton_clicked(); this->on_toolButton_clicked();
} }

View File

@ -41,12 +41,18 @@ public:
//! \brief Recalculates Overview chart info //! \brief Recalculates Overview chart info
void ReloadGraphs(); void ReloadGraphs();
//! \brief Recalculates Overview chart info, but keeps the date set
void ResetGraphs();
//! \brief Reset graphs to uniform heights //! \brief Reset graphs to uniform heights
void ResetGraphLayout(); void ResetGraphLayout();
//! \brief Calls updateGL to redraw the overview charts //! \brief Calls updateGL to redraw the overview charts
void RedrawGraphs(); void RedrawGraphs();
//! \brief Sets the currently selected date range of the overview display
void setRange(QDate start, QDate end);
/*! \brief Create an overview graph, adding it to the overview gGraphView object /*! \brief Create an overview graph, adding it to the overview gGraphView object
\param QString name The title of the graph \param QString name The title of the graph
\param QString units The units of measurements to show in the popup */ \param QString units The units of measurements to show in the popup */
@ -59,8 +65,8 @@ public:
QVector<SummaryChart *> OverviewCharts; QVector<SummaryChart *> OverviewCharts;
public slots: public slots:
//! \brief Print button down the bottom, does the same as File->Print // ! \brief Print button down the bottom, does the same as File->Print
void on_printButton_clicked(); //void on_printButton_clicked();
private slots: private slots:
/* void on_drStart_dateChanged(const QDate &date); /* void on_drStart_dateChanged(const QDate &date);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>668</width> <width>611</width>
<height>393</height> <height>392</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -167,16 +167,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="printButton">
<property name="toolTip">
<string>Send a Report to your Printer</string>
</property>
<property name="text">
<string>&amp;Print Overview</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>