diff --git a/mainwindow.cpp b/mainwindow.cpp index 97a3a560..b5ac9e29 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -373,18 +373,20 @@ void MainWindow::on_action_Fullscreen_triggered() QString htmlHeader() { +// "a:link,a:visited { color: '#000020'; text-decoration: none; font-weight: bold;}" +// "a:hover { background-color: inherit; color: red; text-decoration:none; font-weight: bold; }" return QString("" "" "" +"" + "" "" "" @@ -490,6 +492,30 @@ bool RXSort(const RXChange * comp1, const RXChange * comp2) { return true; } +class MyStatsPage:public QWebPage +{ +public: + MyStatsPage(QObject *parent); + virtual ~MyStatsPage(); +protected: + //virtual void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID); + virtual void javaScriptAlert ( QWebFrame * frame, const QString & msg ); +}; +MyStatsPage::MyStatsPage(QObject *parent) +:QWebPage(parent) +{ +} +MyStatsPage::~MyStatsPage() +{ +} + +void MyStatsPage::javaScriptAlert(QWebFrame * frame, const QString & msg) +{ + Q_UNUSED(frame); + mainwin->sendStatsUrl(msg); +} + + //bool operator<(const RXChange * & comp1, const RXChange * & comp2) { //} @@ -507,6 +533,8 @@ QString formatTime(float time) seconds %= 60; return QString().sprintf("%02i:%02i",hours,minutes); //,seconds); } + + void MainWindow::on_summaryButton_clicked() { QString html=htmlHeader(); @@ -1056,7 +1084,7 @@ void MainWindow::on_summaryButton_clicked() presrel=schema::channel[CPAP_PresReliefType].option(int(rx.prelief)); presrel+=QString(" x%1").arg(rx.prelset); } else presrel="None"; - html+=QString("%3%4%5%6%7%8%9%10") + html+=QString("%3%4%5%6%7%8%9%10") .arg(rx.first.toString(Qt::ISODate)) .arg(rx.last.toString(Qt::ISODate)) .arg(rx.first.toString(Qt::SystemLocaleShortDate)) @@ -1102,13 +1130,18 @@ void MainWindow::on_summaryButton_clicked() } updateFavourites(); html+=htmlFooter(); - QWebFrame *frame=ui->summaryView->page()->currentFrame(); - frame->addToJavaScriptWindowObject("mainwin",this); - ui->summaryView->setHtml(html); + //QWebFrame *frame=ui->summaryView->page()->currentFrame(); + //frame->addToJavaScriptWindowObject("mainwin",this); + //ui->summaryView->setHtml(html); + MyStatsPage *page=new MyStatsPage(this); + page->currentFrame()->setHtml(html); + ui->summaryView->setPage(page); +// connect(ui->summaryView->page()->currentFrame(),SIGNAL(javaScriptWindowObjectCleared()) // QString file="qrc:/docs/index.html"; // QUrl url(file); // ui->webView->setUrl(url); } + void MainWindow::updateFavourites() { QDate date=PROFILE.LastDay(MT_JOURNAL); @@ -2163,7 +2196,7 @@ void MainWindow::on_actionAll_Data_for_current_CPAP_machine_triggered() void MainWindow::keyPressEvent(QKeyEvent * event) { - qDebug() << "Keypress:" << event->key(); + //qDebug() << "Keypress:" << event->key(); } void MainWindow::on_summaryButton_2_clicked() diff --git a/mainwindow.h b/mainwindow.h index 2be44386..afb22b7e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -136,6 +136,8 @@ public: \param QDate date */ void PrintReport(gGraphView *gv,QString name, QDate date=QDate::currentDate()); + + void sendStatsUrl(QString msg) { on_recordsBox_linkClicked(QUrl(msg)); } protected: virtual void keyPressEvent(QKeyEvent * event);