Changed QPrinter headers, CMS50H fix, minor overview graph optimisations

This commit is contained in:
Mark Watkins 2014-09-24 11:42:14 +10:00
parent fc78ebfc16
commit b3f49f1edb
10 changed files with 162 additions and 103 deletions

View File

@ -614,7 +614,7 @@ void gSummaryChart::paint(QPainter &painter, gGraph &graph, const QRegion &regio
QColor col2(255,0,0,64);
painter.fillRect(hl_rect, QBrush(col2));
QString txt = hl_date.toString(Qt::SystemLocaleDate)+" ";
QString txt = hl_date.toString(Qt::SystemLocaleShortDate)+" ";
if (hl_day) {
// grab extra tooltip data
txt += tooltipData(hl_day, hl_idx);
@ -881,6 +881,8 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
QColor goodcolor = haveoxi ? QColor(128,255,196) : QColor(64,128,255);
QString datestr = date.toString(Qt::SystemLocaleShortDate);
for (si = day->begin(); si != day->end(); ++si) {
Session *sess = (*si);
if (!sess->enabled() || (sess->type() != m_machtype)) continue;
@ -898,7 +900,7 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
float s2 = double(slice.end - slice.start) / 3600000.0;
QColor col = (slice.status == EquipmentOn) ? goodcolor : Qt::black;
QString txt = QObject::tr("%1\nLength: %3\nStart: %2\n").arg(it.key().toString(Qt::SystemLocaleDate)).arg(st.time().toString("hh:mm:ss")).arg(s2,0,'f',2);
QString txt = QObject::tr("%1\nLength: %3\nStart: %2\n").arg(datestr).arg(st.time().toString("hh:mm:ss")).arg(s2,0,'f',2);
txt += (slice.status == EquipmentOn) ? QObject::tr("Mask On") : QObject::tr("Mask Off");
slices.append(SummaryChartSlice(&calcitems[0], s1, s2, txt, col));
@ -911,7 +913,7 @@ void gSessionTimesChart::paint(QPainter &painter, gGraph &graph, const QRegion &
float s2 = sess->hours();
QString txt = QObject::tr("%1\nLength: %3\nStart: %2").arg(it.key().toString(Qt::SystemLocaleDate)).arg(st.time().toString("hh:mm:ss")).arg(s2,0,'f',2);
QString txt = QObject::tr("%1\nLength: %3\nStart: %2").arg(datestr).arg(st.time().toString("hh:mm:ss")).arg(s2,0,'f',2);
slices.append(SummaryChartSlice(&calcitems[0], s1, s2, txt, goodcolor));
}

View File

@ -228,7 +228,7 @@ QString CMS50F37Loader::getModel()
QThread::msleep(100);
QApplication::processEvents();
if (model.startsWith("CMS50I")) {
if (model.startsWith("CMS50I") || model.startsWith("CMS50H")) {
duration_divisor = 4;
} else {
duration_divisor = 2;

View File

@ -417,13 +417,46 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
}
//void Daily::populateSessionWidget()
//{
// ui->sessionWidget->clearContents();
// ui->sessionWidget->setColumnCount(2);
// QMap<QDate, Day *>::iterator it;
// QMap<QDate, Day *>::iterator it_end = p_profile->daylist.end();
// int row = 0;
// for (it = p_profile->daylist.begin(); it != it_end; ++it) {
// const QDate & date = it.key();
// Day * day = it.value();
// QList<Session *> sessions = day->getSessions(MT_CPAP);
// int size = sessions.size();
// if (size > 0) {
// QTableWidgetItem * item = new QTableWidgetItem(date.toString(Qt::SystemLocaleShortDate));
// item->setData(Qt::UserRole, date);
// ui->sessionWidget->setItem(row, 0, item);
// SessionBar * sb = new SessionBar();
// for (int i=0; i < size; i++) {
// Session * sess = sessions[i];
// QColor col = Qt::blue;
// sb->add(sess, col);
// }
// ui->sessionWidget->setCellWidget(row, 1, sb);
// row++;
// }
// }
// ui->sessionWidget->setRowCount(row-1);
// ui->sessionWidget->setCurrentCell(row-1, 0);
// ui->sessionWidget->scrollToBottom();
//}
Daily::~Daily()
{
// disconnect(sessbar, SIGNAL(toggledSession(Session*)), this, SLOT(doToggleSession(Session*)));
// Save any last minute changes..
// delete splitter;
delete ui;
delete icon_on;
delete icon_off;
@ -721,7 +754,6 @@ void Daily::UpdateCalendarDay(QDate date)
ui->calendar->setDateTextFormat(date,nodata);
}
ui->calendar->setHorizontalHeaderFormat(QCalendarWidget::ShortDayNames);
}
void Daily::LoadDate(QDate date)
{
@ -2505,3 +2537,16 @@ void Daily::on_toggleEvents_clicked(bool checked)
updateCube();
GraphView->redraw();
}
//void Daily::on_sessionWidget_itemSelectionChanged()
//{
// int row = ui->sessionWidget->currentRow();
// QTableWidgetItem *item = ui->sessionWidget->item(row, 0);
// if (item) {
// QDate date = item->data(Qt::UserRole).toDate();
// LoadDate(date);
// qDebug() << "Clicked.. changing date to" << date;
// // ui->sessionWidget->setCurrentItem(item);
// }
//}

View File

@ -145,6 +145,9 @@ public:
QLabel * getDateDisplay();
//void populateSessionWidget();
public slots:
void on_LineCursorUpdate(double time);
void on_RangeUpdate(double minx, double maxx);
@ -276,6 +279,8 @@ private slots:
void updateGraphCombo();
//void on_sessionWidget_itemSelectionChanged();
protected:
virtual void closeEvent(QCloseEvent *);
virtual void showEvent(QShowEvent *);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1211</width>
<height>666</height>
<height>674</height>
</rect>
</property>
<property name="sizePolicy">

View File

@ -327,6 +327,9 @@ MainWindow::MainWindow(QWidget *parent) :
warnidx = 0;
wtimer.singleShot(0, this, SLOT(on_changeWarningMessage()));
loadChannels();
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(on_aboutToQuit()));
}
void MainWindow::on_changeWarningMessage()
@ -468,8 +471,16 @@ void loadChannels()
f.close();
}
void MainWindow::on_aboutToQuit()
{
Notify(QObject::tr("Don't forget to place your datacard back in your CPAP machine"), QObject::tr("SleepyHead Reminder"));
QThread::msleep(1000);
QApplication::processEvents();
}
void MainWindow::closeEvent(QCloseEvent * event)
{
saveChannels();
schema::channel.Save();
@ -644,8 +655,6 @@ void MainWindow::Startup()
ui->statStartDate->setDate(p_profile->FirstDay());
ui->statEndDate->setDate(p_profile->LastDay());
if (daily) { daily->ReloadGraphs(); }
if (overview) { overview->ReloadGraphs(); }
qprogress->hide();
@ -658,6 +667,10 @@ void MainWindow::Startup()
ui->tabWidget->setCurrentWidget(ui->welcomeTab);
if (daily) {
daily->ReloadGraphs();
// daily->populateSessionWidget();
}
}
@ -705,6 +718,8 @@ int MainWindow::importCPAP(ImportPath import, const QString &message)
delete popup;
disconnect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(on_aboutToQuit()));
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(on_aboutToQuit()));
return c;
}
@ -714,7 +729,10 @@ void MainWindow::finishCPAPImport()
GenerateStatistics();
if (overview) { overview->ReloadGraphs(); }
if (daily) { daily->ReloadGraphs(); }
if (daily) {
// daily->populateSessionWidget();
daily->ReloadGraphs();
}
}
void MainWindow::importCPAPBackups()
@ -924,7 +942,7 @@ void MainWindow::on_action_Import_Data_triggered()
if (res == QMessageBox::Cancel) {
// Give the communal progress bar back
ui->statusbar->insertWidget(2,qprogress,1);
ui->statusbar->insertWidget(1,qprogress,1);
return;
} else if (res == QMessageBox::No) {
waitmsg->setText(tr("Please wait, launching file dialog..."));
@ -992,7 +1010,7 @@ void MainWindow::on_action_Import_Data_triggered()
if (w.exec() != QDialog::Accepted) {
popup.hide();
ui->statusbar->insertWidget(2,qprogress,1);
ui->statusbar->insertWidget(1,qprogress,1);
return;
}
@ -1047,7 +1065,7 @@ void MainWindow::on_action_Import_Data_triggered()
}
// popup.hide();
// ui->statusbar->insertWidget(2, qprogress,1);
// ui->statusbar->insertWidget(1, qprogress,1);
if (newdata) {
finishCPAPImport();
@ -1515,7 +1533,7 @@ void MainWindow::on_actionCheck_for_Updates_triggered()
bool toolbox_visible = false;
void MainWindow::on_action_Screenshot_triggered()
{
getDaily()->hideSpaceHogs();
daily->hideSpaceHogs();
toolbox_visible = ui->toolBox->isVisible();
ui->toolBox->hide();
QTimer::singleShot(250, this, SLOT(DelayedScreenshot()));
@ -1560,7 +1578,7 @@ void MainWindow::DelayedScreenshot()
} else {
Notify(tr("Screenshot saved to file \"%1\"").arg(QDir::toNativeSeparators(a)));
}
getDaily()->showSpaceHogs();
daily->showSpaceHogs();
ui->toolBox->setVisible(toolbox_visible);
}
@ -1884,9 +1902,8 @@ void MainWindow::on_action_Rebuild_Oximetry_Index_triggered()
m->SaveSummary();
}
getDaily()->LoadDate(getDaily()->getDate());
//getDaily()->ReloadGraphs();
getOverview()->ReloadGraphs();
daily->LoadDate(getDaily()->getDate());
overview->ReloadGraphs();
}
void MainWindow::RestartApplication(bool force_login, bool change_datafolder)

View File

@ -325,6 +325,7 @@ class MainWindow : public QMainWindow
void on_actionExport_Journal_triggered();
void on_actionShow_Performance_Counters_toggled(bool arg1);
void on_aboutToQuit();
private:
void importCPAPBackups();

View File

@ -937,71 +937,6 @@
<property name="movable">
<bool>false</bool>
</property>
<widget class="QWidget" name="welcomeTab">
<attribute name="title">
<string>Welcome</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="warningLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: red;
color: yellow;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Warning: &lt;/span&gt;This is pre-release software, some parts of this program may not yet function as intended.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QWebView" name="welcomeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="statisticsTab">
<attribute name="title">
<string>&amp;Statistics</string>
@ -1130,6 +1065,71 @@ color: yellow;</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="welcomeTab">
<attribute name="title">
<string>Welcome</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="warningLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: red;
color: yellow;</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Warning: &lt;/span&gt;This is pre-release software, some parts of this program may not yet function as intended.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QWebView" name="welcomeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="url">
<url>
<string>about:blank</string>
</url>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="helpTab">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -1908,8 +1908,8 @@ border: 2px solid #56789a; border-radius: 30px;
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>180</width>
<height>724</height>
</rect>
</property>
<property name="palette">
@ -3056,8 +3056,8 @@ border-radius: 10px;
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>180</width>
<height>724</height>
</rect>
</property>
<property name="mouseTracking">
@ -3366,14 +3366,6 @@ border-radius: 10px;
<string>&amp;Edit Profile</string>
</property>
</action>
<action name="action_Link_Graph_Groups">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>&amp;Link Graph Groups</string>
</property>
</action>
<action name="actionExp_ort">
<property name="text">
<string>Exp&amp;ort Data</string>
@ -3404,11 +3396,6 @@ border-radius: 10px;
<string>Purge &amp;Current Selected Day</string>
</property>
</action>
<action name="actionAll_Data_for_current_CPAP_machine">
<property name="text">
<string>All data for current CPAP machine</string>
</property>
</action>
<action name="action_Sidebar_Toggle">
<property name="checkable">
<bool>true</bool>

View File

@ -7,8 +7,10 @@
* distribution for more details. */
#include <QMessageBox>
#include <QPrinter>
#include <QPrintDialog>
#include <QtPrintSupport/qprinter.h>
#include <QtPrintSupport/qprintdialog.h>
// #include <QPrinter>
//#include <QPrintDialog>
#include <QTextDocument>
#include <QProgressBar>
#include <QApplication>

View File

@ -4,7 +4,7 @@
#
#-------------------------------------------------
QT += core gui network xml
QT += core gui network xml printsupport
greaterThan(QT_MAJOR_VERSION,4) {
QT += widgets webkitwidgets