diff --git a/UpdaterWindow.cpp b/UpdaterWindow.cpp index 7f5b62e1..5916c9ee 100644 --- a/UpdaterWindow.cpp +++ b/UpdaterWindow.cpp @@ -193,9 +193,7 @@ void UpdaterWindow::ParseUpdateXML(QIODevice * dev) close(); return; } - - - qDebug() << "Version" << release->version << "has updates for" << platform; + qDebug() << "Version" << release->version << "has release section" << platform; QString latestapp="", latestqt=""; updates.clear(); diff --git a/UpdaterWindow.h b/UpdaterWindow.h index 00034cb4..b4344139 100644 --- a/UpdaterWindow.h +++ b/UpdaterWindow.h @@ -15,8 +15,19 @@ namespace Ui { class UpdaterWindow; } +/*! \enum RequestMode + \brief Used in replyFinished() to differentiate the current update task. +*/ enum RequestMode { RM_None, RM_CheckUpdates, RM_GetFile }; + +/*! \class UpdaterWindow + \brief Auto Update Module for SleepyHead + + This class handles the complete Auto-Update procedure for SleepyHead, it does the network checks, + parses the update.xml from SourceForge host, checks for any new updates, and provides the UI + and mechanisms to download and replace the binaries according to what is specified in update.xml. + */ class UpdaterWindow : public QMainWindow { Q_OBJECT @@ -24,7 +35,13 @@ class UpdaterWindow : public QMainWindow public: explicit UpdaterWindow(QWidget *parent = 0); ~UpdaterWindow(); + + //! Start the void checkForUpdates(); + + /*! \fn ParseUpdateXML(QIODevice * dev) + \brief Parses the update.xml from either QFile or QNetworkReply source + */ void ParseUpdateXML(QIODevice * dev); protected slots: diff --git a/daily.cpp b/daily.cpp index 96b91546..a3a89806 100644 --- a/daily.cpp +++ b/daily.cpp @@ -35,13 +35,14 @@ #include "Graphs/gStatsLine.h" //extern QProgressBar *qprogress; +extern MainWindow * mainwin; const int min_height=150; const float ounce_convert=28.3495231; const float pound_convert=ounce_convert*16; -Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw) - :QWidget(parent),mainwin(mw), ui(new Ui::Daily) +Daily::Daily(QWidget *parent,gGraphView * shared) + :QWidget(parent), ui(new Ui::Daily) { ui->setupUi(this); @@ -524,7 +525,6 @@ void Daily::LoadDate(QDate date) void Daily::on_calendar_selectionChanged() { - if (previous_date.isValid()) Unload(previous_date); @@ -550,30 +550,6 @@ void Daily::ResetGraphLayout() //splitter->setSizes(splitter_sizes); } -void Daily::ShowHideGraphs() -{ -/* int vis=0; - for (int i=0;iisEmpty()) { - GraphAction[i]->setVisible(false); - Graphs[i]->hide(); - } else { - Graphs[i]->ResetBounds(); - GraphAction[i]->setVisible(true); - if (GraphAction[i]->isChecked()) { - Graphs[i]->show(); - vis++; - } else { - Graphs[i]->hide(); - } - } - } - GraphLayout->setMinimumHeight(vis*default_height+10); - //splitter->setMaximumHeight(vis*default_height); - splitter->layout(); - //splitter->update(); - RedrawGraphs(); */ -} void Daily::graphtogglebutton_toggled(bool b) { Q_UNUSED(b) diff --git a/daily.h b/daily.h index 526ea92d..29f1aca9 100644 --- a/daily.h +++ b/daily.h @@ -32,75 +32,220 @@ namespace Ui { class MainWindow; + +/*! \class Daily + \brief SleepyHead's Daily view which displays the calendar and all the graphs relative to a selected Day + */ class Daily : public QWidget { Q_OBJECT public: - explicit Daily(QWidget *parent, gGraphView *shared,MainWindow *mw); + /*! \fn Daily() + \brief Constructs a Daily object + \param parent * (QObject parent) + \param shared * + \param MainWindow * + + Creates all the graph objects and adds them to the main gGraphView area for this tab. + + shared is not used for daily object + Neither is MainWindow * mw, as a "mainwin" global is used instead. + */ + explicit Daily(QWidget *parent, gGraphView *shared); ~Daily(); + /*! \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 graphView() + \returns the main graphView area for the Daily View + */ gGraphView *graphView() { return GraphView; } + + /*! \fn RedrawGraphs() + \brief Calls updateGL on the main graphView area, redrawing the OpenGL area + */ void RedrawGraphs(); + + /*! \fn LoadDate() + \brief Selects a new day object, unloading the previous one, and loads the graph data for the supplied date. + \param QDate date + */ void LoadDate(QDate date); + + /*! \fn getDate() + \brief Returns the most recently loaded Date + \return QDate + */ QDate getDate() { return previous_date; } - void PrintReport(); + + /*! \fn UnitsChanged() + \brief Called by Profile editor when measurement units are changed + */ void UnitsChanged(); + + /*! \fn GetJournalSession(QDate date) + \brief Looks up if there is a journal object for a supplied date + \param QDate date + \returns Session * containing valid Journal Session object or NULL if none found. + */ Session * GetJournalSession(QDate date); + QString GetDetailsText(); + /*! \fn eventBreakdownPie() + \brief Returns a pointer to the Event Breakdown Piechart for the Report Printing module + \returns gGraph * object containing this chart + */ gGraph * eventBreakdownPie() { return GAHI; } private slots: + /*! \fn on_calendar_currentPageChanged(int year, int month); + \brief Scans through all days for this month, updating the day colors for the calendar object + \param int year + \param int month + */ void on_calendar_currentPageChanged(int year, int month); + + /*! \fn on_calendar_selectionChanged(); + \brief Called when the calendar object is clicked. Selects and loads a new date, unloading the previous one. + */ void on_calendar_selectionChanged(); + + /* Journal Notes edit buttons I don't want to document */ void on_JournalNotesItalic_clicked(); void on_JournalNotesBold_clicked(); void on_JournalNotesFontsize_activated(int index); void on_JournalNotesColour_clicked(); + void on_JournalNotesUnderline_clicked(); void on_treeWidget_itemSelectionChanged(); - void on_JournalNotesUnderline_clicked(); - void ShowHideGraphs(); + + /*! \fn on_nextDayButton_clicked(); + \brief Step backwards one day (if possible) + */ void on_prevDayButton_clicked(); + /*! \fn on_nextDayButton_clicked(); + \brief Step forward one day (if possible) + */ void on_nextDayButton_clicked(); + /*! \fn on_calButton_toggled(); + \brief Hides the calendar and put it out of the way, giving more room for the Details area. + */ void on_calButton_toggled(bool checked); + /*! \fn on_todayButton_clicked(); + \brief Select the most recent day. + */ void on_todayButton_clicked(); + /*! \fn Link_clicked(const QUrl &url); + \brief Called when a link is clicked on in the HTML Details tab + \param const QUrl & url + */ void Link_clicked(const QUrl &url); + void on_evViewSlider_valueChanged(int value); + /*! \fn on_treeWidget_itemClicked(QTreeWidgetItem *item, int column); + \brief Called when an event is selected in the Event tab.. Zooms into the graph area. + \param QTreeWidgetItem *item + \param int column + */ void on_treeWidget_itemClicked(QTreeWidgetItem *item, int column); + /*! \fn graphtogglebutton_toggled(bool) + \brief Called to hide/show a graph when on of the toggle bottoms underneath the graph area is clicked + \param bool button status + */ void graphtogglebutton_toggled(bool); + /*! \fn on_addBookmarkButton_clicked() + \brief Current selected graph Area is added to Bookmark's list for this day's journal object. + */ void on_addBookmarkButton_clicked(); + /*! \fn on_removeBookmarkButton_clicked() + \brief Currently selected bookmark is removed from this day's Bookmark list. + */ void on_removeBookmarkButton_clicked(); + /*! \fn on_bookmarkTable_itemClicked(QTableWidgetItem *item); + \brief Called when a bookmark has been selected.. Zooms in on the area + \param QTableWidgetItem *item + */ void on_bookmarkTable_itemClicked(QTableWidgetItem *item); + /*! \fn on_bookmarkTable_itemChanged(QTableWidgetItem *item); + \brief Called when bookmarks have been altered.. Saves the bookmark list to Journal object. + */ void on_bookmarkTable_itemChanged(QTableWidgetItem *item); + /*! \fn on_weightSpinBox_valueChanged(double arg1); + \brief Called when weight has changed.. Updates the BMI dislpay and journal objects. + + Also Refreshes the Overview charts + */ void on_weightSpinBox_valueChanged(double arg1); + /*! \fn on_ouncesSpinBox_valueChanged(int arg1); + \brief Called when weights ounces component has changed.. Updates the BMI dislpay and journal objects. + + Also Refreshes the Overview charts + */ void on_ouncesSpinBox_valueChanged(int arg1); + /*! \fn on_ouncesSpinBox_valueChanged(int arg1); + \brief Called when the zombie slider has been moved.. Updates the BMI dislpay and journal objects. + + Also Refreshes the Overview charts + */ void on_ZombieMeter_valueChanged(int value); protected: private: + /*! \fn CreateJournalSession() + \brief Create a new journal session for this date, if one doesn't exist. + \param QDate date + + Creates a new journal Machine record if necessary. + */ Session * CreateJournalSession(QDate date); + + /*! \fn update_Bookmarks() + \brief Saves the current bookmark list to the Journal object + */ void update_Bookmarks(); + /*! \fn Load(QDate date) + \brief Selects a new day object, loads it's content and generates the HTML for the Details tab + \param QDate date + */ void Load(QDate date); + /*! \fn Unload(QDate date) + \brief Saves any journal changes for the provided date. + \param QDate date + */ void Unload(QDate date); + /*! \fn UpdateCalendarDay(QDate date) + \brief Updates the calendar visual information, changing a dates color depending on what data is available. + \param QDate date + */ void UpdateCalendarDay(QDate date); + /*! \fn UpdateEventsTree(QDate date) + \brief Refreshes the Events tree from the supplied Day object. + \param QTreeWidget * tree + \param Day * + */ void UpdateEventsTree(QTreeWidget * tree,Day *day); gGraph *PRD,*FRW,*GAHI,*TAP,*LEAK,*SF,*TAP_EAP,*TAP_IAP,*PULSE,*SPO2, @@ -120,7 +265,6 @@ private: void UpdateCPAPGraphs(Day *day); void UpdateOXIGraphs(Day *day); - MainWindow * mainwin; Ui::Daily *ui; QDate previous_date; QMenu *show_graph_menu; diff --git a/mainwindow.cpp b/mainwindow.cpp index 5ef7adfe..72ada4e9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -71,6 +71,7 @@ MainWindow::MainWindow(QWidget *parent) : logtime.start(); ui->setupUi(this); + QString version=VersionString(); if (QString(GIT_BRANCH)!="master") version+=QString(" ")+QString(GIT_BRANCH); this->setWindowTitle(tr("SleepyHead")+QString(" v%1 (Profile: %2)").arg(version).arg(PREF["Profile"].toString())); @@ -81,6 +82,7 @@ MainWindow::MainWindow(QWidget *parent) : oximetry=NULL; prefdialog=NULL; + // Initialize Status Bar objects qstatusbar=ui->statusbar; qprogress=new QProgressBar(this); qprogress->setMaximum(100); @@ -98,6 +100,10 @@ MainWindow::MainWindow(QWidget *parent) : ui->statusbar->addPermanentWidget(qprogress,1); ui->statusbar->addPermanentWidget(qstatus2,0); + + // This next section is a mess.. + // Preferences & Profile variables really need to initialize somewhere else + if (!PROFILE.Exists("ShowDebug")) PROFILE["ShowDebug"]=false; ui->actionDebug->setChecked(PROFILE["ShowDebug"].toBool()); @@ -105,8 +111,6 @@ MainWindow::MainWindow(QWidget *parent) : ui->logText->hide(); } - // TODO: Move all this to profile creation. - // This speeds up the second part of importing craploads.. later it will speed up the first part too. if (!PROFILE.Exists("EnableMultithreading")) PROFILE["EnableMultithreading"]=QThread::idealThreadCount()>1; @@ -136,15 +140,14 @@ MainWindow::MainWindow(QWidget *parent) : // Using the dirty registry here. :( QSettings settings("Jedimark", "SleepyHead"); + + // Load previous Window geometry this->restoreGeometry(settings.value("MainWindow/geometry").toByteArray()); + // Start with the Welcome Tab ui->tabWidget->setCurrentWidget(ui->welcome); - /*netmanager = new QNetworkAccessManager(this); - connect(netmanager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); - - connect(ui->webView, SIGNAL(statusBarMessage(QString)), this, SLOT(updatestatusBarMessage(QString))); */ - + // Nifty Notification popups in System Tray (uses Growl on Mac) if (QSystemTrayIcon::isSystemTrayAvailable() && QSystemTrayIcon::supportsMessages()) { systray=new QSystemTrayIcon(QIcon(":/docs/sheep.png"),this); systray->show(); @@ -157,7 +160,7 @@ MainWindow::MainWindow(QWidget *parent) : systraymenu->addAction("Check for Updates",this,SLOT(on_actionCheck_for_Updates_triggered())); systraymenu->addSeparator(); systraymenu->addAction("Exit",this,SLOT(close())); - } else { + } else { // if not available, the messages will popup in the taskbar systray=NULL; systraymenu=NULL; } @@ -166,13 +169,13 @@ MainWindow::MainWindow(QWidget *parent) : extern MainWindow *mainwin; MainWindow::~MainWindow() { - if (systray) delete systray; if (systraymenu) delete systraymenu; + if (systray) delete systray; - //if (!isMaximized()) { + // Save current window position QSettings settings("Jedimark", "SleepyHead"); settings.setValue("MainWindow/geometry", saveGeometry()); - //} + if (daily) { daily->close(); delete daily; @@ -185,7 +188,11 @@ MainWindow::~MainWindow() oximetry->close(); delete oximetry; } + + // Trash anything allocated by the Graph objects DoneGraphs(); + + // Shutdown and Save the current User profile Profiles::Done(); mainwin=NULL; delete ui; @@ -214,7 +221,7 @@ void MainWindow::Startup() //SnapshotGraph->setMinimumSize(1024,512); SnapshotGraph->hide(); - daily=new Daily(ui->tabWidget,NULL,this); + daily=new Daily(ui->tabWidget,NULL); ui->tabWidget->insertTab(1,daily,tr("Daily")); overview=new Overview(ui->tabWidget,daily->graphView()); diff --git a/mainwindow.h b/mainwindow.h index 027575b0..4bc7238e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -30,6 +30,11 @@ extern QStatusBar *qstatusbar; class Daily; class Report; class Overview; + +/*! \class MainWindow + \brief The Main Application window for SleepyHead + */ + class MainWindow : public QMainWindow { Q_OBJECT @@ -37,86 +42,170 @@ class MainWindow : public QMainWindow public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); + + //! \brief Log message s to Application Debug log void Log(QString s); + + + //! \brief Create a new menu object in the main menubar. QMenu * CreateMenu(QString title); + + //! \brief Start the automatic update checker process void CheckForUpdates(); + + /*! \fn Notify(QString s,int ms=5000, QString title="SleepyHead v"+VersionString()); + \brief Pops up a message box near the system tray + \param QString string + \param int ms + \param title + + Title is shown in bold + string is the main message content to show + ms = millisecond delay of how long to show popup + + Mac needs Growl notification system for this to work + */ void Notify(QString s,int ms=5000, QString title="SleepyHead v"+VersionString()); + + /*! \fn gGraphView *snapshotGraph() + \brief Returns the current snapshotGraph object used by the report printing system */ gGraphView *snapshotGraph() { return SnapshotGraph; } + Daily *getDaily() { return daily; } Overview *getOverview() { return overview; } Oximetry *getOximetry() { return oximetry; } + + /*! \fn void RestartApplication(bool force_login=false); + \brief Closes down SleepyHead and restarts it + \param bool force_login + + If force_login is set, it will return to the login menu even if it's set to skip + */ void RestartApplication(bool force_login=false); + //! \brief Self explainitory, selects the Oximetry Tab void selectOximetryTab(); void JumpDaily(); + + /*! \fn void PrintReport gGraphView *gv,QString name, QDate date=QDate::currentDate()); + \brief Prepares a report using gGraphView object, and sends to a created QPrinter object + \param gGraphView *gv GraphView Object containing which graph set to print + \param QString name Report Title + \param QDate date + */ void PrintReport(gGraphView *gv,QString name, QDate date=QDate::currentDate()); + private slots: + /*! \fn void on_action_Import_Data_triggered(); + \brief Provide the file dialog for selecting import location, and start the import process + This is called when the Import button is clicked + */ void on_action_Import_Data_triggered(); + //! \brief Selects the welcome page when it's clicked on void on_actionView_Welcome_triggered(); + //! \brief Toggle Fullscreen (currently F11) void on_action_Fullscreen_triggered(); + //! \brief Loads the default page in the Welcome screens web browser void on_homeButton_clicked(); + //! \brief Go back in the welcome browsers history void on_backButton_clicked(); + //! \brief Go forward in the welcome browsers history void on_forwardButton_clicked(); + //! \brief Updates the URL bar to show changes to the URL void on_webView_urlChanged(const QUrl &arg1); + //! \brief Loads a web page when enter is pressed in the URL bar void on_urlBar_activated(const QString &arg1); + //! \brief Selects the Daily page and redraws the graphs void on_dailyButton_clicked(); + //! \brief Selects the Overview page and redraws the graphs void on_overviewButton_clicked(); + //! \brief called when webpage has finished loading in welcome browser void on_webView_loadFinished(bool arg1); + //! \brief called when webpage has starts loading in welcome browser void on_webView_loadStarted(); + //! \brief Updates the progress bar in the statusbar while a page is loading void on_webView_loadProgress(int progress); + //! \brief Display About Dialog void on_action_About_triggered(); + //! \brief Called after a timeout to initiate loading of all summary data for this profile void Startup(); + //! \brief Toggle the Debug pane on and off void on_actionDebug_toggled(bool arg1); + //! \brief passes the ResetGraphLayout menu click to the Daily & Overview views void on_action_Reset_Graph_Layout_triggered(); + //! \brief Opens the Preferences Dialog, and saving changes if OK is pressed void on_action_Preferences_triggered(); + //! \brief Opens and/or shows the Oximetry page void on_oximetryButton_clicked(); + //! \brief Creates the UpdaterWindow object that actually does the real check for updates void on_actionCheck_for_Updates_triggered(); + //! \brief Attempts to do a screenshot of the application window + //! \note This is currently broken on Macs void on_action_Screenshot_triggered(); + + //! \brief This is the actual screenshot code.. It's delayed with a QTimer to give the menu time to close. void DelayedScreenshot(); + //! \brief a slot that calls the real Oximetry tab selector void on_actionView_O_ximetry_triggered(); + + //! \brief Updates the Statusbar message with the QString message contained in Text void updatestatusBarMessage (const QString & text); + + //! \brief Passes the Daily, Overview & Oximetry object to Print Report, based on current tab void on_actionPrint_Report_triggered(); + //! \brief Opens the Profile Editor void on_action_Edit_Profile_triggered(); + //! \brief Toggled the LinkGraphGroups preference, which forces the link between Oximetry & CPAP days void on_action_Link_Graph_Groups_toggled(bool arg1); + //! \brief Selects the next view tab void on_action_CycleTabs_triggered(); + //! \brief Opens the CSV Export window void on_actionExp_ort_triggered(); + //! \brief Opens the User Guide at the wiki in the welcome browser. void on_actionOnline_Users_Guide_triggered(); + //! \brief Opens the Frequently Asked Questions at the wiki in the welcome browser. void on_action_Frequently_Asked_Questions_triggered(); + /*! \fn void on_action_Rebuild_Oximetry_Index_triggered(); + \brief This function scans over all oximetry data and reindexes and tries to fix any inconsistencies. + */ void on_action_Rebuild_Oximetry_Index_triggered(); + //! \brief Log out, by effectively forcing a restart void on_actionChange_User_triggered(); + //! \brief Destroy the CPAP data for the currently selected day, so it can be freshly imported again void on_actionPurge_Current_Day_triggered(); + //! \brief Destroy ALL the CPAP data for the currently selected machine, so it can be freshly imported again void on_actionAll_Data_for_current_CPAP_machine_triggered(); private: diff --git a/preferencesdialog.h b/preferencesdialog.h index d0b8670a..f0714c23 100644 --- a/preferencesdialog.h +++ b/preferencesdialog.h @@ -19,6 +19,10 @@ namespace Ui { class PreferencesDialog; } + +/*! \class MySortFilterProxyModel + \brief Enables the Graph tabs view to be filtered + */ class MySortFilterProxyModel:public QSortFilterProxyModel { Q_OBJECT @@ -30,12 +34,17 @@ protected: }; +//! \note MaksProfile in still a work in progress struct MaskProfile { QString name; EventDataType pflow[5][2]; }; +/*! \class PreferencesDialog + \brief SleepyHead's Main Preferences Window + This provides the Preferences form and logic to alter Preferences for SleepyHead +*/ class PreferencesDialog : public QDialog { Q_OBJECT @@ -43,8 +52,12 @@ class PreferencesDialog : public QDialog public: explicit PreferencesDialog(QWidget *parent, Profile * _profile); ~PreferencesDialog(); + + /*! \fn Save() + \brief Save the current preferences, called when Ok button is clicked on */ void Save(); void RefreshLastChecked(); + private slots: void on_eventTable_doubleClicked(const QModelIndex &index); void on_combineSlider_valueChanged(int value); diff --git a/profileselect.cpp b/profileselect.cpp index 1d70a281..cab785e6 100644 --- a/profileselect.cpp +++ b/profileselect.cpp @@ -165,6 +165,9 @@ void ProfileSelect::deleteProfile() } } } + +//! \fn ProfileSelect::QuickLogin() +//! \brief For programmatically bypassing the login window void ProfileSelect::QuickLogin() { on_listView_activated(ui->listView->currentIndex()); @@ -187,6 +190,9 @@ void ProfileSelect::on_newProfileButton_clicked() accept(); } + +//! \fn ProfileSelect::on_listView_activated(const QModelIndex &index) +//! \brief Process the selected login, requesting passwords if required. void ProfileSelect::on_listView_activated(const QModelIndex &index) { QString name=index.data().toString(); diff --git a/profileselect.h b/profileselect.h index 2ca86abf..cf7eac41 100644 --- a/profileselect.h +++ b/profileselect.h @@ -15,6 +15,9 @@ namespace Ui { class ProfileSelect; } +/*! \class ProfileSelect + \brief Simple Login Window providing a list of all profiles to select from + */ class ProfileSelect : public QDialog { Q_OBJECT diff --git a/updateparser.h b/updateparser.h index fb5f3174..6fecacfd 100644 --- a/updateparser.h +++ b/updateparser.h @@ -5,6 +5,9 @@ #include #include +/*! \struct Update + \brief Holds platform specific information about an individual updates + */ class Update { public: @@ -23,6 +26,9 @@ public: QString unzipped_path; }; +/*! \struct Release + \brief Holds information about an individual major release + */ struct Release { Release() {} @@ -46,6 +52,10 @@ struct Release Q_DECLARE_METATYPE(Update *) + +/*! \class UpdateParser + \brief SAX XML parser for update.xml + */ class UpdateParser:public QXmlDefaultHandler { public: