diff --git a/sleepyhead/Graphs/gGraphView.cpp b/sleepyhead/Graphs/gGraphView.cpp index 2a328a60..e4102272 100644 --- a/sleepyhead/Graphs/gGraphView.cpp +++ b/sleepyhead/Graphs/gGraphView.cpp @@ -355,8 +355,11 @@ gGraphView::gGraphView(QWidget *parent, gGraphView *shared) pin_icon = QPixmap(":/icons/pushpin.png"); context_menu->addSeparator(); - context_menu->addAction(tr("100% zoom level"), this, SLOT(resetZoom())); - context_menu->addAction(tr("Reset Graph Layout"), this, SLOT(resetLayout())); + QAction * action = context_menu->addAction(tr("100% zoom level"), this, SLOT(resetZoom())); + action->setToolTip(tr("Restore X-axis zoom too 100% to view entire days data.")); + + action = context_menu->addAction(tr("Reset Graph Layout"), this, SLOT(resetLayout())); + action->setToolTip(tr("Resets all graphs to a uniform height and default order.")); context_menu->addSeparator(); limits_menu = context_menu->addMenu(tr("Y-Axis")); @@ -1689,6 +1692,7 @@ protected: MinMaxWidget::MinMaxWidget(gGraph * graph, QWidget *parent) :QWidget(parent), graph(graph) { + step = 1; createLayout(); } @@ -1704,12 +1708,27 @@ void MinMaxWidget::onMaxChanged(double d) } void MinMaxWidget::onResetClicked() { + int tmp = graph->zoomY(); + graph->setZoomY(0); EventDataType miny = graph->MinY(), maxy = graph->MaxY(); graph->roundY(miny, maxy); setMin(graph->rec_miny = miny); setMax(graph->rec_maxy = maxy); + + float r = maxy-miny; + if (r > 400) { + step = 50; + } else if (r > 100) { + step = 10; + } else if (r > 50) { + step = 5; + } else { + step = 1; + } + + graph->setZoomY(tmp); } void MinMaxWidget::onComboChanged(int idx) @@ -1739,11 +1758,15 @@ void MinMaxWidget::createLayout() combobox->addItem(tr("Auto-Fit"), 0); combobox->addItem(tr("Defaults"), 1); combobox->addItem(tr("Override"), 2); + combobox->setToolTip(tr("The Y-Axis scaling mode, 'Auto-Fit' for automatic scaling, 'Defaults' for settings according to manufacturer, and 'Override' to choose your own.")); connect(combobox, SIGNAL(activated(int)), this, SLOT(onComboChanged(int))); minbox = new QDoubleSpinBox(this); maxbox = new QDoubleSpinBox(this); + minbox->setToolTip(tr("The Minimum Y-Axis value.. Note this can be a negative number if you wish.")); + maxbox->setToolTip(tr("The Maximum Y-Axis value.. Must be greater than Minimum to work.")); + int idx = graph->zoomY(); combobox->setCurrentIndex(idx); @@ -1759,6 +1782,21 @@ void MinMaxWidget::createLayout() maxbox->setMaximum(9999.99); setMin(graph->rec_miny); setMax(graph->rec_maxy); + + float r = graph->rec_maxy - graph->rec_miny; + if (r > 400) { + step = 50; + } else if (r > 100) { + step = 10; + } else if (r > 50) { + step = 5; + } else { + step = 1; + } + + minbox->setSingleStep(step); + maxbox->setSingleStep(step); + connect(minbox, SIGNAL(valueChanged(double)), this, SLOT(onMinChanged(double))); connect(maxbox, SIGNAL(valueChanged(double)), this, SLOT(onMaxChanged(double))); @@ -1784,6 +1822,7 @@ void MinMaxWidget::createLayout() reset = new QToolButton(this); reset->setIcon(QIcon(":/icons/refresh.png")); + reset->setToolTip(tr("This button resets the Min and Max to match the Auto-Fit")); reset->setEnabled(idx == 2); layout->addWidget(reset,1,3); diff --git a/sleepyhead/Graphs/gGraphView.h b/sleepyhead/Graphs/gGraphView.h index 3aee6b6e..60b847dc 100644 --- a/sleepyhead/Graphs/gGraphView.h +++ b/sleepyhead/Graphs/gGraphView.h @@ -68,6 +68,7 @@ protected: // QCheckBox *checkbox; QDoubleSpinBox *minbox; QDoubleSpinBox *maxbox; + double step; QToolButton * reset; }; diff --git a/sleepyhead/Graphs/gLineChart.cpp b/sleepyhead/Graphs/gLineChart.cpp index cc7aa677..622d5e8b 100644 --- a/sleepyhead/Graphs/gLineChart.cpp +++ b/sleepyhead/Graphs/gLineChart.cpp @@ -1079,12 +1079,13 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) double first, last; double time = 0; - // Calculate the session time. + // Calculate the CPAP session time. for (QList::iterator s = m_day->begin(); s != m_day->end(); s++) { - if (!(*s)->enabled()) { continue; } + Session * sess = *s; + if (!sess->enabled() || (sess->machine()->type() != MT_CPAP)) continue; - first = (*s)->first(); - last = (*s)->last(); + first = sess->first(); + last = sess->last(); if (last < w.min_x) { continue; } if (first > w.max_x) { continue; } diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index 318ffcd8..211527ed 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -1979,7 +1979,7 @@ void Daily::on_LineCursorUpdate(double time) { if (time > 1) { QDateTime dt = QDateTime::fromMSecsSinceEpoch(time); - QString txt = dt.toString("MMM dd HH:mm:ss:zzz"); + QString txt = dt.toString("MMM dd HH:mm:ss.zzz"); dateDisplay->setText(txt); } else dateDisplay->setText(QString(GraphView->emptyText())); }