diff --git a/oscar/Graphs/gGraphView.cpp b/oscar/Graphs/gGraphView.cpp index 49e49b14..335c567d 100644 --- a/oscar/Graphs/gGraphView.cpp +++ b/oscar/Graphs/gGraphView.cpp @@ -3287,6 +3287,14 @@ void gGraphView::timedRedraw(int ms) timer->setSingleShot(true); timer->start(ms); } + +void gGraphView::deselect() +{ + for (auto & graph : m_graphs) { + if (graph) graph->deselect(); + } +} + void gGraphView::resetLayout() { int default_height = AppSetting->graphHeight(); @@ -3298,11 +3306,13 @@ void gGraphView::resetLayout() updateScale(); timedRedraw(0); } -void gGraphView::deselect() -{ - for (auto & graph : m_graphs) { - if (graph) graph->deselect(); - } +// Reset order of current graphs to match defaults +void gGraphView::resetGraphOrder() { + m_graphs = m_default_graphs; +} + +void gGraphView::SaveDefaultSettings() { + m_default_graphs = m_graphs; } const quint32 gvmagic = 0x41756728; diff --git a/oscar/Graphs/gGraphView.h b/oscar/Graphs/gGraphView.h index c33459e3..a1bc6f97 100644 --- a/oscar/Graphs/gGraphView.h +++ b/oscar/Graphs/gGraphView.h @@ -373,6 +373,12 @@ class gGraphView //! \brief Loads the current graph order, heights, min & max Y values from disk bool LoadSettings(QString title); + //! \brief Saves the current (initial) graph order, heights, min & Max Y values for future recovery + void SaveDefaultSettings(); + + //! \brief Reset the current graph order, heights, min & max Y values to match default values + void resetGraphOrder(); + //! \brief Returns the graph object matching the supplied name, nullptr if it does not exist. gGraph *findGraph(QString name); @@ -606,6 +612,9 @@ class gGraphView //! \brief List of all graphs contained, indexed by title QHash m_graphsbyname; + //! \brief List of initial settings of all graphs contained in this area + QList m_default_graphs; + //! \variable Vertical scroll offset (adjusted when scrollbar gets moved) int m_offsetY; //! \variable Horizontal scroll offset (unused, but can be made to work if necessary) diff --git a/oscar/daily.cpp b/oscar/daily.cpp index ee2181d8..08b399cc 100644 --- a/oscar/daily.cpp +++ b/oscar/daily.cpp @@ -200,20 +200,20 @@ Daily::Daily(QWidget *parent,gGraphView * shared) int cpapsize = sizeof(cpapcodes) / sizeof(ChannelID); - ChannelID oxicodes[] = { - OXI_Pulse, OXI_SPO2, OXI_Perf, OXI_Plethy - }; - int oxisize = sizeof(oxicodes) / sizeof(ChannelID); - - for (int i=0; i < cpapsize; ++i) { ChannelID code = cpapcodes[i]; graphlist[schema::channel[code].code()] = new gGraph(schema::channel[code].code(), GraphView, schema::channel[code].label(), channelInfo(code), default_height); } + ChannelID oximetercodes[] = { + OXI_Pulse, OXI_SPO2, OXI_Perf, OXI_Plethy + }; + + int oxisize = sizeof(oximetercodes) / sizeof(ChannelID); + //int oxigrp=p_profile->ExistsAndTrue("SyncOximetry") ? 0 : 1; // Contemplating killing this setting... for (int i=0; i < oxisize; ++i) { - ChannelID code = oxicodes[i]; + ChannelID code = oximetercodes[i]; graphlist[schema::channel[code].code()] = new gGraph(schema::channel[code].code(), GraphView, schema::channel[code].label(), channelInfo(code), default_height); } @@ -444,6 +444,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared) on_calButton_toggled(AppSetting->calendarVisible()); GraphView->resetLayout(); + GraphView->SaveDefaultSettings(); GraphView->LoadSettings("Daily"); connect(GraphView, SIGNAL(updateCurrentTime(double)), this, SLOT(on_LineCursorUpdate(double))); @@ -848,6 +849,12 @@ void Daily::ResetGraphLayout() { GraphView->resetLayout(); } +void Daily::ResetGraphOrder() +{ + GraphView->resetGraphOrder(); + ResetGraphLayout(); +} + void Daily::graphtogglebutton_toggled(bool b) { Q_UNUSED(b) diff --git a/oscar/daily.h b/oscar/daily.h index 97f662c3..90fdd8a3 100644 --- a/oscar/daily.h +++ b/oscar/daily.h @@ -60,12 +60,18 @@ public: /*! \fn ReloadGraphs() \brief Reload all graph information from disk and updates the view. */ + void ReloadGraphs(); /*! \fn ResetGraphLayout() \brief Resets all graphs in the main gGraphView back to constant heights. */ void ResetGraphLayout(); + /*! \fn ResetGraphOrder() + \brief Resets all graphs in the main gGraphView back to their initial order. + */ + void ResetGraphOrder(); + /*! \fn updateLeftSidebar() /brief Updtes left sidebar to reflect changes in pie chart visibility */ @@ -342,7 +348,7 @@ private: bool ZombieMeterMoved; bool BookmarksChanged; + }; - #endif // DAILY_H diff --git a/oscar/docs/release_notes.html b/oscar/docs/release_notes.html index 1f79c18a..8ecb565b 100644 --- a/oscar/docs/release_notes.html +++ b/oscar/docs/release_notes.html @@ -12,6 +12,7 @@ Which was written and copyright 2011-2018 © Mark Watkins

diff --git a/oscar/mainwindow.cpp b/oscar/mainwindow.cpp index f803b77c..e4888edf 100644 --- a/oscar/mainwindow.cpp +++ b/oscar/mainwindow.cpp @@ -1300,6 +1300,13 @@ void MainWindow::on_action_Reset_Graph_Layout_triggered() if (overview && (ui->tabWidget->currentWidget() == overview)) { overview->ResetGraphLayout(); } } +void MainWindow::on_action_Reset_Graph_Order_triggered() +{ + if (daily && (ui->tabWidget->currentWidget() == daily)) { daily->ResetGraphOrder(); } + + if (overview && (ui->tabWidget->currentWidget() == overview)) { overview->ResetGraphOrder(); } +} + void MainWindow::on_action_Preferences_triggered() { if (!p_profile) { diff --git a/oscar/mainwindow.h b/oscar/mainwindow.h index a5253ec4..8e18df43 100644 --- a/oscar/mainwindow.h +++ b/oscar/mainwindow.h @@ -213,6 +213,9 @@ class MainWindow : public QMainWindow //! \brief passes the ResetGraphLayout menu click to the Daily & Overview views void on_action_Reset_Graph_Layout_triggered(); + //! \brief passes the ResetGraphOrder menu click to the Daily & Overview views + void on_action_Reset_Graph_Order_triggered(); + //! \brief Opens the Preferences Dialog, and saving changes if OK is pressed void on_action_Preferences_triggered(); diff --git a/oscar/mainwindow.ui b/oscar/mainwindow.ui index 3e20f998..65e595ec 100644 --- a/oscar/mainwindow.ui +++ b/oscar/mainwindow.ui @@ -2836,6 +2836,7 @@ p, li { white-space: pre-wrap; } + @@ -3007,7 +3008,7 @@ p, li { white-space: pre-wrap; } - &Reset Graph Layout + Reset Graph &Heights Reset sizes of graphs @@ -3230,6 +3231,14 @@ p, li { white-space: pre-wrap; } Ctrl+P + + + &Reset Graphs + + + Reset order of graphs page to initial order + + diff --git a/oscar/overview.cpp b/oscar/overview.cpp index 4b58d177..ecc590ce 100644 --- a/oscar/overview.cpp +++ b/oscar/overview.cpp @@ -121,6 +121,7 @@ Overview::Overview(QWidget *parent, gGraphView *shared) : icon_off = new QIcon(":/icons/session-off.png"); GraphView->resetLayout(); + GraphView->SaveDefaultSettings(); GraphView->LoadSettings("Overview"); //no trans GraphView->setEmptyImage(QPixmap(":/icons/logo-md.png")); @@ -415,6 +416,12 @@ void Overview::ResetGraphLayout() GraphView->resetLayout(); } +void Overview::ResetGraphOrder() +{ + GraphView->resetGraphOrder(); + ResetGraphLayout(); +} + void Overview::on_rangeCombo_activated(int index) { p_profile->general->setLastOverviewRange(index); diff --git a/oscar/overview.h b/oscar/overview.h index 0789480a..7855bf3f 100644 --- a/oscar/overview.h +++ b/oscar/overview.h @@ -55,6 +55,11 @@ class Overview : public QWidget //! \brief Reset graphs to uniform heights void ResetGraphLayout(); + /*! \fn ResetGraphOrder() + \brief Resets all graphs in the main gGraphView back to their initial order. + */ + void ResetGraphOrder(); + //! \brief Calls updateGL to redraw the overview charts void RedrawGraphs();