App Initialization order fixups

This commit is contained in:
Mark Watkins 2011-07-24 17:58:20 +10:00
parent 454ab9cce2
commit c8a796c700
3 changed files with 38 additions and 35 deletions

View File

@ -44,18 +44,7 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) :
gSplitter->setHandleWidth(2); gSplitter->setHandleWidth(2);
ui->graphSizer->addWidget(gSplitter); ui->graphSizer->addWidget(gSplitter);
AddCPAPData(flags[3]=new FlagData(CPAP_Hypopnea,4)); SF=new gGraphWindow(gSplitter,tr("Event Flags"),shared);
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);
FRW=new gGraphWindow(gSplitter,tr("Flow Rate"),SF); FRW=new gGraphWindow(gSplitter,tr("Flow Rate"),SF);
PRD=new gGraphWindow(gSplitter,tr("Pressure"),SF); PRD=new gGraphWindow(gSplitter,tr("Pressure"),SF);
LEAK=new gGraphWindow(gSplitter,tr("Leaks"),SF); LEAK=new gGraphWindow(gSplitter,tr("Leaks"),SF);
@ -77,6 +66,17 @@ Daily::Daily(QWidget *parent,QGLWidget * shared) :
//fmt.setDefaultFormat(fmt); //fmt.setDefaultFormat(fmt);
offscreen_context=new QGLContext(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=new gGraphWindow(NULL,"",(QGLWidget* )NULL);
TAP_EAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL); TAP_EAP=new gGraphWindow(NULL,"",(QGLWidget* )NULL);
TAP_IAP=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->calendar->setWeekdayTextFormat(Qt::Sunday, format);
ui->tabWidget->setCurrentWidget(ui->details); ui->tabWidget->setCurrentWidget(ui->details);
ReloadGraphs();
} }
Daily::~Daily() Daily::~Daily()

View File

@ -52,7 +52,6 @@ int main(int argc, char *argv[])
a.setFont(QFont("FreeSans",10)); a.setFont(QFont("FreeSans",10));
qInstallMsgHandler(MyOutputHandler); qInstallMsgHandler(MyOutputHandler);
MainWindow w; MainWindow w;
mainwin=&w; mainwin=&w;

View File

@ -41,10 +41,6 @@ MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::MainWindow) ui(new Ui::MainWindow)
{ {
//#ifndef Q_WS_MAC
// this->showMaximized();
//#endif
ui->setupUi(this); ui->setupUi(this);
this->setWindowTitle(tr("SleepyHead")+QString(" v%1.%2.%3").arg(major_version).arg(minor_version).arg(revision_number)); this->setWindowTitle(tr("SleepyHead")+QString(" v%1.%2.%3").arg(major_version).arg(minor_version).arg(revision_number));
ui->tabWidget->setCurrentIndex(0); ui->tabWidget->setCurrentIndex(0);
@ -62,14 +58,14 @@ MainWindow::MainWindow(QWidget *parent) :
fmt.setRgba(true); fmt.setRgba(true);
fmt.setDefaultFormat(fmt); fmt.setDefaultFormat(fmt);
QGLContext smeg(fmt); */ QGLContext smeg(fmt); */
//new QGLContext(fmt);
//new QGLContext(fmt);
//shared_context->create(shared_context); //shared_context->create(shared_context);
daily=NULL; daily=NULL;
overview=NULL; overview=NULL;
oximetry=NULL; oximetry=NULL;
//ui->tabWidget->setCurrentWidget(daily);
qstatusbar=ui->statusbar; qstatusbar=ui->statusbar;
qprogress=new QProgressBar(this); qprogress=new QProgressBar(this);
qprogress->setMaximum(100); qprogress->setMaximum(100);
@ -88,10 +84,9 @@ MainWindow::MainWindow(QWidget *parent) :
ui->statusbar->addPermanentWidget(qprogress,10); ui->statusbar->addPermanentWidget(qprogress,10);
Profiles::Scan(); 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("Profile")) pref["Profile"]=getUserName();
if (!pref.Exists("LinkGraphMovement")) pref["LinkGraphMovement"]=true; if (!pref.Exists("LinkGraphMovement")) pref["LinkGraphMovement"]=true;
@ -116,8 +111,19 @@ MainWindow::MainWindow(QWidget *parent) :
if (!pref.Exists("AlwaysShowOverlayBars")) pref["AlwaysShowOverlayBars"]=true; if (!pref.Exists("AlwaysShowOverlayBars")) pref["AlwaysShowOverlayBars"]=true;
else ui->actionOverlay_Bars->setChecked(pref["AlwaysShowOverlayBars"].toBool()); 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() MainWindow::~MainWindow()
{ {
if (daily) { if (daily) {
@ -133,31 +139,32 @@ MainWindow::~MainWindow()
delete oximetry; delete oximetry;
} }
DoneGraphs(); DoneGraphs();
delete ui;
Profiles::Done(); Profiles::Done();
mainwin=NULL;
delete ui;
} }
void MainWindow::Startup() 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")); qstatus->setText(tr("Loading Data"));
qprogress->show(); 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=Profiles::Get(pref["Profile"].toString());
profile->LoadMachineData(); profile->LoadMachineData();
daily=new Daily(ui->tabWidget); if (daily) daily->ReloadGraphs();
ui->tabWidget->insertTab(1,daily,tr("Daily"));
overview=new Overview(ui->tabWidget,daily->SharedWidget()); if (overview) {
ui->tabWidget->insertTab(2,overview,tr("Overview")); overview->ReloadGraphs();
overview->UpdateGraphs();
oximetry=new Oximetry(ui->tabWidget,daily->SharedWidget()); }
ui->tabWidget->insertTab(3,oximetry,tr("Oximetry"));
qprogress->hide(); qprogress->hide();
qstatus->setText(tr("Ready")); qstatus->setText(tr("Ready"));
//qstatusbar->clearMessage();
} }
@ -183,10 +190,8 @@ void MainWindow::on_action_Import_Data_triggered()
qDebug() << "Finished Importing data" << c; qDebug() << "Finished Importing data" << c;
if (c) { if (c) {
profile->Save(); profile->Save();
//qDebug() << " profile->Save();";
if (daily) daily->ReloadGraphs(); if (daily) daily->ReloadGraphs();
//qDebug() << " daily->ReloadGraphs();";
if (overview) { if (overview) {
overview->ReloadGraphs(); overview->ReloadGraphs();
overview->UpdateGraphs(); overview->UpdateGraphs();