From c8a796c700fb954976d723c00fb4cc2dbcb2f4ae Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sun, 24 Jul 2011 17:58:20 +1000 Subject: [PATCH] App Initialization order fixups --- daily.cpp | 25 ++++++++++++------------- main.cpp | 1 - mainwindow.cpp | 47 ++++++++++++++++++++++++++--------------------- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/daily.cpp b/daily.cpp index 9f1f70d6..d8f34f7d 100644 --- a/daily.cpp +++ b/daily.cpp @@ -44,18 +44,7 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) : gSplitter->setHandleWidth(2); ui->graphSizer->addWidget(gSplitter); - AddCPAPData(flags[3]=new FlagData(CPAP_Hypopnea,4)); - AddCPAPData(flags[0]=new FlagData(CPAP_CSR,7,1,0)); - AddCPAPData(flags[1]=new FlagData(CPAP_ClearAirway,6)); - AddCPAPData(flags[2]=new FlagData(CPAP_Obstructive,5)); - AddCPAPData(flags[4]=new FlagData(CPAP_FlowLimit,3)); - AddCPAPData(flags[5]=new FlagData(CPAP_VSnore,2)); - AddCPAPData(flags[6]=new FlagData(CPAP_RERA,1)); - AddCPAPData(flags[7]=new FlagData(PRS1_PressurePulse,1)); - AddCPAPData(flags[8]=new FlagData(PRS1_Unknown0E,1)); - AddCPAPData(flags[9]=new FlagData(CPAP_Snore,1)); // Snore Index - - SF=new gGraphWindow(gSplitter,tr("Event Flags"),shared); + SF=new gGraphWindow(gSplitter,tr("Event Flags"),shared); FRW=new gGraphWindow(gSplitter,tr("Flow Rate"),SF); PRD=new gGraphWindow(gSplitter,tr("Pressure"),SF); LEAK=new gGraphWindow(gSplitter,tr("Leaks"),SF); @@ -77,6 +66,17 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) : //fmt.setDefaultFormat(fmt); offscreen_context=new QGLContext(fmt); */ + AddCPAPData(flags[3]=new FlagData(CPAP_Hypopnea,4)); + AddCPAPData(flags[0]=new FlagData(CPAP_CSR,7,1,0)); + AddCPAPData(flags[1]=new FlagData(CPAP_ClearAirway,6)); + AddCPAPData(flags[2]=new FlagData(CPAP_Obstructive,5)); + AddCPAPData(flags[4]=new FlagData(CPAP_FlowLimit,3)); + AddCPAPData(flags[5]=new FlagData(CPAP_VSnore,2)); + AddCPAPData(flags[6]=new FlagData(CPAP_RERA,1)); + AddCPAPData(flags[7]=new FlagData(PRS1_PressurePulse,1)); + AddCPAPData(flags[8]=new FlagData(PRS1_Unknown0E,1)); + AddCPAPData(flags[9]=new FlagData(CPAP_Snore,1)); // Snore Index + TAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL); TAP_EAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL); TAP_IAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL); @@ -306,7 +306,6 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) : ui->calendar->setWeekdayTextFormat(Qt::Sunday, format); ui->tabWidget->setCurrentWidget(ui->details); - ReloadGraphs(); } Daily::~Daily() diff --git a/main.cpp b/main.cpp index 68012cc1..55f77495 100644 --- a/main.cpp +++ b/main.cpp @@ -52,7 +52,6 @@ int main(int argc, char *argv[]) a.setFont(QFont("FreeSans",10)); - qInstallMsgHandler(MyOutputHandler); MainWindow w; mainwin=&w; diff --git a/mainwindow.cpp b/mainwindow.cpp index 18370a66..dbb80116 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -41,10 +41,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { - -//#ifndef Q_WS_MAC -// this->showMaximized(); -//#endif ui->setupUi(this); this->setWindowTitle(tr("SleepyHead")+QString(" v%1.%2.%3").arg(major_version).arg(minor_version).arg(revision_number)); ui->tabWidget->setCurrentIndex(0); @@ -62,14 +58,14 @@ MainWindow::MainWindow(QWidget *parent) : fmt.setRgba(true); fmt.setDefaultFormat(fmt); QGLContext smeg(fmt); */ - //new QGLContext(fmt); + + //new QGLContext(fmt); //shared_context->create(shared_context); daily=NULL; overview=NULL; oximetry=NULL; - //ui->tabWidget->setCurrentWidget(daily); qstatusbar=ui->statusbar; qprogress=new QProgressBar(this); qprogress->setMaximum(100); @@ -88,10 +84,9 @@ MainWindow::MainWindow(QWidget *parent) : ui->statusbar->addPermanentWidget(qprogress,10); Profiles::Scan(); - //loader_progress->Show(); + pref["AppName"]="SleepyHead"; + pref["VersionString"]=QString("v%1.%2.%3").arg(major_version).arg(minor_version).arg(revision_number); - //pref["Version"]=wxString(AutoVersion::_FULLVERSION_STRING,wxConvUTF8); - if (!pref.Exists("AppName")) pref["AppName"]="SleepyHead"; if (!pref.Exists("Profile")) pref["Profile"]=getUserName(); if (!pref.Exists("LinkGraphMovement")) pref["LinkGraphMovement"]=true; @@ -116,8 +111,19 @@ MainWindow::MainWindow(QWidget *parent) : if (!pref.Exists("AlwaysShowOverlayBars")) pref["AlwaysShowOverlayBars"]=true; else ui->actionOverlay_Bars->setChecked(pref["AlwaysShowOverlayBars"].toBool()); -} + daily=new Daily(ui->tabWidget); + ui->tabWidget->insertTab(1,daily,tr("Daily")); + overview=new Overview(ui->tabWidget,daily->SharedWidget()); + ui->tabWidget->insertTab(2,overview,tr("Overview")); + + oximetry=new Oximetry(ui->tabWidget,daily->SharedWidget()); + ui->tabWidget->insertTab(3,oximetry,tr("Oximetry")); + + ui->tabWidget->setCurrentWidget(ui->welcome); + +} +extern MainWindow *mainwin; MainWindow::~MainWindow() { if (daily) { @@ -133,31 +139,32 @@ MainWindow::~MainWindow() delete oximetry; } DoneGraphs(); - delete ui; Profiles::Done(); + mainwin=NULL; + delete ui; } void MainWindow::Startup() { - qDebug() << windowTitle() << "built with Qt"<< QT_VERSION_STR << "on" << __DATE__ << __TIME__; + qDebug() << pref["AppName"].toString().toAscii() << pref["VersionString"].toString().toAscii() << "built with Qt"<< QT_VERSION_STR << "on" << __DATE__ << __TIME__; qstatus->setText(tr("Loading Data")); qprogress->show(); - qstatusbar->showMessage("Your computer loads faster than JediMark's",1900); + //qstatusbar->showMessage(tr("Loading Data"),0); profile=Profiles::Get(pref["Profile"].toString()); profile->LoadMachineData(); - daily=new Daily(ui->tabWidget); - ui->tabWidget->insertTab(1,daily,tr("Daily")); + if (daily) daily->ReloadGraphs(); - overview=new Overview(ui->tabWidget,daily->SharedWidget()); - ui->tabWidget->insertTab(2,overview,tr("Overview")); + if (overview) { + overview->ReloadGraphs(); + overview->UpdateGraphs(); - oximetry=new Oximetry(ui->tabWidget,daily->SharedWidget()); - ui->tabWidget->insertTab(3,oximetry,tr("Oximetry")); + } qprogress->hide(); qstatus->setText(tr("Ready")); + //qstatusbar->clearMessage(); } @@ -183,10 +190,8 @@ void MainWindow::on_action_Import_Data_triggered() qDebug() << "Finished Importing data" << c; if (c) { profile->Save(); - //qDebug() << " profile->Save();"; if (daily) daily->ReloadGraphs(); - //qDebug() << " daily->ReloadGraphs();"; if (overview) { overview->ReloadGraphs(); overview->UpdateGraphs();