From e2e89e1134836494b471fff22253a1a68b50407d Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Fri, 25 Nov 2011 09:03:33 +1000 Subject: [PATCH] Toying with intercepting links in Daily views html panel --- daily.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++--------- daily.h | 2 ++ 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/daily.cpp b/daily.cpp index 519ca26c..59a28b2c 100644 --- a/daily.cpp +++ b/daily.cpp @@ -226,12 +226,15 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw) ui->tabWidget->setCurrentWidget(ui->details); ui->webView->settings()->setFontSize(QWebSettings::DefaultFontSize,QApplication::font().pointSize()); + ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); + connect(ui->webView,SIGNAL(linkClicked(QUrl)),this,SLOT(on_Link_clicked(QUrl))); // TODO: Add preference to hide do this for Widget Haters.. //ui->calNavWidget->hide(); } Daily::~Daily() { + disconnect(ui->webView,SIGNAL(linkClicked(QUrl)),this,SLOT(on_Link_clicked(QUrl))); // Save any last minute changes.. if (previous_date.isValid()) Unload(previous_date); @@ -239,6 +242,33 @@ Daily::~Daily() // delete splitter; delete ui; } +void Daily::on_Link_clicked(const QUrl &url) +{ + QString code=url.toString().section("=",0,0).toLower(); + QString data=url.toString().section("=",1); + int sid=data.toInt(); + Day *day=NULL; + if (code=="cpap") { + day=PROFILE.GetDay(previous_date,MT_CPAP); + } else if (code=="oxi") { + day=PROFILE.GetDay(previous_date,MT_OXIMETER); + } else if (code=="event") { + QList list=ui->treeWidget->findItems(data,Qt::MatchContains); + if (list.size()>0) { + ui->treeWidget->setCurrentItem(list.at(0)); + ui->tabWidget->setCurrentIndex(1); + } + } else { + qDebug() << "Clicked on" << code << data; + } + if (day) { + + Session *sess=day->machine->sessionlist[sid]; + if (sess) { + GraphView->SetXBounds(sess->first(),sess->last()); + } + } +} void Daily::ReloadGraphs() { @@ -288,6 +318,9 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day) && (code!=CPAP_ClearAirway) && (code!=CPAP_CSR) && (code!=CPAP_RERA) + && (code!=CPAP_NRI) + && (code!=CPAP_LeakFlag) + && (code!=CPAP_ExP) && (code!=CPAP_FlowLimit) && (code!=CPAP_PressurePulse) && (code!=CPAP_VSnore)) continue; @@ -421,7 +454,12 @@ void Daily::Load(QDate date) } } lastcpapday=cpap; - QString html="" + QString html="" "" "" "\n"; @@ -477,6 +515,9 @@ void Daily::Load(QDate date) float rei=cpap->count(CPAP_RERA)/cpap->hours(); float vsi=cpap->count(CPAP_VSnore)/cpap->hours(); float fli=cpap->count(CPAP_FlowLimit)/cpap->hours(); + float nri=cpap->count(CPAP_NRI)/cpap->hours(); + float lki=cpap->count(CPAP_LeakFlag)/cpap->hours(); + float exp=cpap->count(CPAP_ExP)/cpap->hours(); //float p90=cpap->p90(CPAP_Pressure); //eap90=cpap->p90(CPAP_EPAP); @@ -512,21 +553,29 @@ void Daily::Load(QDate date) } else cs="2>"; html+="\n" - "\n"; + "\n"; if (cpap->machine->GetClass()=="ResMed") { - html+="\n"; + html+="\n"; } - html+="\n" - "\n" + html+="\n" + "\n" "
" "
"+tr("AHI")+""+QString().sprintf("%.2f",ahi)+"
"+tr("Hypopnea")+""+QString().sprintf("%.2f",hi)+"
"+tr("Hypopnea")+""+QString().sprintf("%.2f",hi)+"
"+tr("Apnea")+""+QString().sprintf("%.2f",uai)+"
"+tr("Unspecified Apnea")+""+QString().sprintf("%.2f",uai)+"
"+tr("Obstructive")+""+QString().sprintf("%.2f",oai)+"
"+tr("Clear Airway")+""+QString().sprintf("%.2f",cai)+"
"+tr("Obstructive")+""+QString().sprintf("%.2f",oai)+"
"+tr("Clear Airway")+""+QString().sprintf("%.2f",cai)+"
"; if (cpap->machine->GetClass()=="PRS1") { html+="" - "\n" - "\n" - "\n" - "\n" + "\n" + "\n" + "\n" + "\n" "
"+tr("RERA")+""+QString().sprintf("%.2f",rei)+"
"+tr("FlowLimit")+""+a.sprintf("%.2f",fli)+"
"+tr("Vsnore")+""+QString().sprintf("%.2f",vsi)+"
"+tr("PB/CSR")+""+QString().sprintf("%.2f",csr)+"%
"+tr("RERA")+""+QString().sprintf("%.2f",rei)+"
"+tr("FlowLimit")+""+a.sprintf("%.2f",fli)+"
"+tr("Vsnore")+""+QString().sprintf("%.2f",vsi)+"
"+tr("PB/CSR")+""+QString().sprintf("%.2f",csr)+"%
"; + } else if (cpap->machine->GetClass()=="Intellipap") { + html+="" + "\n" + "\n" + "\n" + "\n" + "
"+tr("NRI")+""+QString().sprintf("%.2f",nri)+"
"+tr("Leak Idx")+""+a.sprintf("%.2f",lki)+"
"+tr("Vibratory Snore")+""+QString().sprintf("%.2f",vsi)+"
"+tr("Exhalation Puff")+""+QString().sprintf("%.2f",exp)+"%
"; + } @@ -640,7 +689,7 @@ void Daily::Load(QDate date) ld=QDateTime::fromTime_t((*s)->last()/1000L); QHash::iterator i=(*s)->settings.find("BrokenWaveform"); if ((i!=(*s)->settings.end()) && i.value().toBool()) corrupted_waveform=true; - tmp.sprintf(("%08i"+fd.date().toString(Qt::SystemLocaleShortDate)+""+fd.toString("HH:mm ")+""+ld.toString("HH:mm")+"").toLatin1(),(*s)->session()); + tmp.sprintf(("%08i"+fd.date().toString(Qt::SystemLocaleShortDate)+""+fd.toString("HH:mm ")+""+ld.toString("HH:mm")+"").toLatin1(),(*s)->session(),(*s)->session()); html+=tmp; } } @@ -650,7 +699,7 @@ void Daily::Load(QDate date) ld=QDateTime::fromTime_t((*s)->last()/1000L); QHash::iterator i=(*s)->settings.find("BrokenWaveform"); if ((i!=(*s)->settings.end()) && i.value().toBool()) corrupted_waveform=true; - tmp.sprintf(("%08i"+fd.date().toString(Qt::SystemLocaleShortDate)+""+fd.toString("HH:mm ")+""+ld.toString("HH:mm")+"").toLatin1(),(*s)->session()); + tmp.sprintf(("%08i"+fd.date().toString(Qt::SystemLocaleShortDate)+""+fd.toString("HH:mm ")+""+ld.toString("HH:mm")+"").toLatin1(),(*s)->session(),(*s)->session()); html+=tmp; } } diff --git a/daily.h b/daily.h index 46c9a86a..36db4799 100644 --- a/daily.h +++ b/daily.h @@ -64,6 +64,8 @@ private slots: void on_calButton_toggled(bool checked); void on_todayButton_clicked(); + + void on_Link_clicked(const QUrl &url); protected: private: