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);
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()

View File

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

View File

@ -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();