Disable linecursor during printing, move date indicators down bottom in overview

This commit is contained in:
Mark Watkins 2014-08-29 01:45:46 +10:00
parent 48df9c2f46
commit f0097e38ae
7 changed files with 68 additions and 7 deletions

View File

@ -329,7 +329,9 @@ void gGraph::paint(QPainter &painter, const QRegion &region)
QString t = name().section(";", -1); QString t = name().section(";", -1);
painter.drawText(m_rect, Qt::AlignHCenter | Qt::AlignTop, QObject::tr("Snapshot %1").arg(t)); QRect rec = m_rect;
rec.moveTop(rec.top() + 4);
painter.drawText(rec, Qt::AlignHCenter | Qt::AlignTop, QObject::tr("Snapshot %1").arg(t));
} }

View File

@ -1371,6 +1371,18 @@ QString gGraphView::getRangeString()
qint64 diff = m_maxx - m_minx; qint64 diff = m_maxx - m_minx;
if (diff > 86400000) { if (diff > 86400000) {
int days = ceil(double(m_maxx-m_minx) / 86400000.0);
qint64 minx = floor(double(m_minx)/86400000.0);
minx *= 86400000L;
qint64 maxx = minx + 86400000L * qint64(days)-1;
QDateTime st = QDateTime::fromMSecsSinceEpoch(minx);
QDateTime et = QDateTime::fromMSecsSinceEpoch(maxx);
QString txt = st.toString("d MMM") + " - " + et.addDays(-1).toString("d MMM yyyy");
return txt;
} else if (diff > 60000) { } else if (diff > 60000) {
fmt = "HH:mm:ss"; fmt = "HH:mm:ss";
} else { } else {

View File

@ -527,13 +527,13 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
QDateTime dt=QDateTime::fromMSecsSinceEpoch(time,Qt::UTC); // QDateTime dt=QDateTime::fromMSecsSinceEpoch(time,Qt::UTC);
QString text = dt.date().toString(Qt::SystemLocaleLongDate); // QString text = dt.date().toString(Qt::SystemLocaleLongDate);
int wid, h; // int wid, h;
GetTextExtent(text, wid, h); // GetTextExtent(text, wid, h);
w.renderText(text, left + width/2 - wid/2, top-h+5); // w.renderText(text, left + width/2 - wid/2, top-h+5);
} }

View File

@ -102,6 +102,18 @@ Overview::Overview(QWidget *parent, gGraphView *shared) :
layout->addWidget(scrollbar, 0); layout->addWidget(scrollbar, 0);
layout->layout(); layout->layout();
dateLabel = new MyLabel(this);
dateLabel->setAlignment(Qt::AlignVCenter);
dateLabel->setText("[Date Widget]");
QFont font = dateLabel->font();
font.setPointSizeF(font.pointSizeF()*1.3F);
dateLabel->setFont(font);
QPalette palette = dateLabel->palette();
palette.setColor(QPalette::Base, Qt::blue);
dateLabel->setPalette(palette);
ui->dateLayout->addWidget(dateLabel,1);
// TODO: Automate graph creation process // TODO: Automate graph creation process
ChannelID ahicode = p_profile->general->calculateRDI() ? CPAP_RDI : CPAP_AHI; ChannelID ahicode = p_profile->general->calculateRDI() ? CPAP_RDI : CPAP_AHI;
@ -316,6 +328,10 @@ Overview::Overview(QWidget *parent, gGraphView *shared) :
GraphView->setEmptyImage(QPixmap(":/docs/sheep.png")); GraphView->setEmptyImage(QPixmap(":/docs/sheep.png"));
connect(GraphView, SIGNAL(updateCurrentTime(double)), this, SLOT(on_LineCursorUpdate(double)));
connect(GraphView, SIGNAL(updateRange(double,double)), this, SLOT(on_RangeUpdate(double,double)));
} }
Overview::~Overview() Overview::~Overview()
{ {
@ -362,6 +378,24 @@ gGraph *Overview::createGraph(QString code, QString name, QString units, YTicker
return g; return g;
} }
void Overview::on_LineCursorUpdate(double time)
{
if (time > 1) {
QDateTime dt = QDateTime::fromMSecsSinceEpoch(time);
QString txt = dt.toString("dd MMM yyyy");
dateLabel->setText(txt);
} else dateLabel->setText(QString(GraphView->emptyText()));
}
void Overview::on_RangeUpdate(double minx, double maxx)
{
if (minx > 1) {
dateLabel->setText(GraphView->getRangeString());
} else {
dateLabel->setText(QString(GraphView->emptyText()));
}
}
void Overview::ReloadGraphs() void Overview::ReloadGraphs()
{ {
GraphView->setDay(nullptr); GraphView->setDay(nullptr);

View File

@ -109,6 +109,9 @@ class Overview : public QWidget
void on_toggleVisibility_clicked(bool checked); void on_toggleVisibility_clicked(bool checked);
void on_LineCursorUpdate(double time);
void on_RangeUpdate(double minx, double maxx);
private: private:
Ui::Overview *ui; Ui::Overview *ui;
gGraphView *GraphView; gGraphView *GraphView;
@ -117,6 +120,7 @@ class Overview : public QWidget
gGraphView *m_shared; gGraphView *m_shared;
QIcon *icon_on; QIcon *icon_on;
QIcon *icon_off; QIcon *icon_off;
MyLabel *dateLabel;
//! \brief Updates the calendar highlighting for the calendar object for this date. //! \brief Updates the calendar highlighting for the calendar object for this date.
void UpdateCalendarDay(QDateEdit *calendar, QDate date); void UpdateCalendarDay(QDateEdit *calendar, QDate date);

View File

@ -205,14 +205,20 @@ QToolButton:pressed {
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>260</width> <width>4</width>
<height>20</height> <height>20</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<layout class="QHBoxLayout" name="dateLayout"/>
</item>
<item> <item>
<widget class="QToolButton" name="toggleVisibility"> <widget class="QToolButton" name="toggleVisibility">
<property name="toolTip"> <property name="toolTip">

View File

@ -423,6 +423,8 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
} }
qint64 st = savest, et = saveet; qint64 st = savest, et = saveet;
bool lineCursorMode = p_profile->appearance->lineCursorMode();
p_profile->appearance->setLineCursorMode(false);
if (name == STR_TR_Daily) { if (name == STR_TR_Daily) {
if (!print_bookmarks) { if (!print_bookmarks) {
@ -655,5 +657,6 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
painter.end(); painter.end();
delete printer; delete printer;
mainwin->Notify(QObject::tr("SleepyHead has finished sending the job to the printer.")); mainwin->Notify(QObject::tr("SleepyHead has finished sending the job to the printer."));
p_profile->appearance->setLineCursorMode(lineCursorMode);
} }