diff --git a/sleepyhead/Graphs/gSessionTimesChart.h b/sleepyhead/Graphs/gSessionTimesChart.h index 5a3142cd..5fd30e9b 100644 --- a/sleepyhead/Graphs/gSessionTimesChart.h +++ b/sleepyhead/Graphs/gSessionTimesChart.h @@ -185,6 +185,10 @@ public: gSummaryChart * sc = new gSummaryChart(m_label, m_machtype); Layer::CloneInto(sc); CloneInto(sc); + + // copy this here, because only base summary charts need it + sc->calcitems = calcitems; + return sc; } @@ -192,7 +196,6 @@ public: layer->m_empty = m_empty; layer->firstday = firstday; layer->lastday = lastday; -// layer->calcitems = calcitems; layer->expected_slices = expected_slices; layer->nousedays = nousedays; layer->totaldays = totaldays; diff --git a/sleepyhead/Graphs/gXAxis.cpp b/sleepyhead/Graphs/gXAxis.cpp index a1059c67..bc995ec2 100644 --- a/sleepyhead/Graphs/gXAxis.cpp +++ b/sleepyhead/Graphs/gXAxis.cpp @@ -151,7 +151,7 @@ void gXAxis::paint(QPainter &painter, gGraph &w, const QRegion ®ion) } else if (xx > 600000) { // Minutes fd = " j0:00"; dividx = 10; - divmax = 27; + divmax = 21; fitmode = 1; } else if (xx > 5000) { // Seconds fd = " j0:00:00"; @@ -286,9 +286,9 @@ void gXAxis::paint(QPainter &painter, gGraph &w, const QRegion ®ion) if (!m_utcfix) { j += tz_offset; } ms = j % 1000; + s = (j / 1000L) % 60L; m = (j / 60000L) % 60L; h = (j / 3600000L) % 24L; - s = (j / 1000L) % 60L; //int d=(j/86400000) % 7; if (fitmode == 0) { @@ -305,11 +305,9 @@ void gXAxis::paint(QPainter &painter, gGraph &w, const QRegion ®ion) } else if (fitmode == 1) { // minute tmpstr = QString("%1:%2").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0')); } else if (fitmode == 2) { // second - tmpstr = QString("%1:%2:%3").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0')).arg(s, 2, 10, - QChar('0')); + tmpstr = QString("%1:%2:%3").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0')).arg(s, 2, 10, QChar('0')); } else if (fitmode == 3) { // milli - tmpstr = QString("%1:%2:%3:%4").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0')).arg(s, 2, 10, - QChar('0')).arg(ms, 3, 10, QChar('0')); + tmpstr = QString("%1:%2:%3:%4").arg(h, 2, 10, QChar('0')).arg(m, 2, 10, QChar('0')).arg(s, 2, 10, QChar('0')).arg(ms, 3, 10, QChar('0')); } int tx = px - x / 2.0; diff --git a/sleepyhead/SleepLib/loader_plugins/intellipap_loader.cpp b/sleepyhead/SleepLib/loader_plugins/intellipap_loader.cpp index ca3da23b..070d501f 100644 --- a/sleepyhead/SleepLib/loader_plugins/intellipap_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/intellipap_loader.cpp @@ -28,6 +28,11 @@ Intellipap::~Intellipap() IntellipapLoader::IntellipapLoader() { + const QString INTELLIPAP_ICON = ":/icons/intellipap.png"; + QString s = newInfo().series; + m_pixmap_paths[s] = INTELLIPAP_ICON; + m_pixmaps[s] = QPixmap(INTELLIPAP_ICON); + m_buffer = nullptr; m_type = MT_CPAP; } diff --git a/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp b/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp index b4640f03..c27c0de9 100644 --- a/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp @@ -120,9 +120,13 @@ struct WaveHeaderList { PRS1Loader::PRS1Loader() { - // Todo: Register PRS1 custom channels + const QString PRS1_ICON = ":/icons/prs1.png"; - //genCRCTable(); + QString s = newInfo().series; + m_pixmap_paths[s] = PRS1_ICON; + m_pixmaps[s] = QPixmap(PRS1_ICON); + + //genCRCTable(); // find what I did with this.. m_buffer = nullptr; m_type = MT_CPAP; } diff --git a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp index 4f6ef980..723025e4 100644 --- a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp @@ -33,6 +33,10 @@ const QString STR_UnknownModel = "Resmed S9 ???"; ChannelID RMS9_EPR, RMS9_EPRLevel, RMS9_Mode; +const QString STR_ResMed_AirSense10 = "AirSense 10"; +const QString STR_ResMed_S9 = "S9"; + + // Return the model name matching the supplied model number. const QString & lookupModel(quint16 model) @@ -345,6 +349,13 @@ void ResmedLoader::ParseSTR(Machine *mach, QStringList strfiles) epr_level= EventDataType(sig->data[rec]) * sig->gain + sig->offset; } + if ((sig = str.lookupLabel("S.EPR.EPRType"))) { + epr = EventDataType(sig->data[rec]) * sig->gain + sig->offset; + epr += 1; + } + + + if ((epr >= 0) && (epr_level >= 0)) { R.epr_level = epr_level; R.epr = epr; @@ -916,6 +927,14 @@ void ResmedImport::run() ResmedLoader::ResmedLoader() { + const QString RMS9_ICON = ":/icons/rms9.png"; + const QString RM10_ICON = ":/icons/sheep.png"; + + m_pixmaps[STR_ResMed_S9] = QPixmap(RMS9_ICON); + m_pixmaps[STR_ResMed_AirSense10] = QPixmap(RM10_ICON); + m_pixmap_paths[STR_ResMed_S9] = RMS9_ICON; + m_pixmap_paths[STR_ResMed_AirSense10] = RM10_ICON; + m_type = MT_CPAP; } ResmedLoader::~ResmedLoader() @@ -1119,12 +1138,12 @@ MachineInfo ResmedLoader::PeekInfo(const QString & path) } else if (key == "PNA") { // Product Name value.replace("_"," "); - if (value.contains("S9")) { - value.replace("S9", ""); - info.series = value; - } else if (value.contains("AirSense 10")) { - value.replace("AirSense 10", ""); - info.series = "AirSense 10"; + if (value.contains(STR_ResMed_S9)) { + value.replace(STR_ResMed_S9, ""); + info.series = STR_ResMed_S9; + } else if (value.contains(STR_ResMed_AirSense10)) { + value.replace(STR_ResMed_AirSense10, ""); + info.series = STR_ResMed_AirSense10; } value.replace("(",""); value.replace(")",""); @@ -2259,7 +2278,7 @@ bool ResmedLoader::LoadEVE(Session *sess, const QString & path) // Notes: Event records have useless duration record. // sess->updateFirst(edf.startdate); - EventList *OA = nullptr, *HY = nullptr, *CA = nullptr, *UA = nullptr; + EventList *OA = nullptr, *HY = nullptr, *CA = nullptr, *UA = nullptr, *RE = nullptr; // Allow for empty sessions.. @@ -2353,6 +2372,12 @@ bool ResmedLoader::LoadEVE(Session *sess, const QString & path) if (sess->checkInside(tt)) HY->AddEvent(tt, duration + 10); // Only Hyponea's Need the extra duration??? } else if (matchSignal(CPAP_Apnea, t)) { if (sess->checkInside(tt)) UA->AddEvent(tt, duration); + } else if (matchSignal(CPAP_RERA, t)) { + // Not all machines have it, so only create it when necessary.. + if (!RE) { + if (!(RE = sess->AddEventList(CPAP_RERA, EVL_Event))) { return false; } + } + if (sess->checkInside(tt)) RE->AddEvent(tt, duration); } else if (matchSignal(CPAP_ClearAirway, t)) { // Not all machines have it, so only create it when necessary.. if (!CA) { @@ -2867,6 +2892,7 @@ void ResInitModelMap() resmed_codes[CPAP_Obstructive].push_back("Obstructive apnea"); resmed_codes[CPAP_Hypopnea].push_back("Hypopnea"); resmed_codes[CPAP_Apnea].push_back("Apnea"); + resmed_codes[CPAP_RERA].push_back("Arousal"); resmed_codes[CPAP_ClearAirway].push_back("Central apnea"); resmed_codes[CPAP_Mode].push_back("Mode"); resmed_codes[CPAP_Mode].push_back("Modus"); @@ -2882,7 +2908,7 @@ void ResInitModelMap() resmed_codes[RMS9_SetPressure].push_back("Inställt tryck"); resmed_codes[RMS9_EPR].push_back("EPR"); - resmed_codes[RMS9_EPR].push_back("S.EPR.EPRType"); + //resmed_codes[RMS9_EPR].push_back("S.EPR.EPRType"); resmed_codes[RMS9_EPR].push_back("\xE5\x91\xBC\xE6\xB0\x94\xE9\x87\x8A\xE5\x8E\x8B\x28\x45\x50"); // Chinese resmed_codes[RMS9_EPRLevel].push_back("EPR Level"); diff --git a/sleepyhead/SleepLib/machine.cpp b/sleepyhead/SleepLib/machine.cpp index e164d07c..687777af 100644 --- a/sleepyhead/SleepLib/machine.cpp +++ b/sleepyhead/SleepLib/machine.cpp @@ -333,6 +333,19 @@ bool Machine::unlinkDay(Day * d) return day.remove(day.key(d)) > 0; } +QString Machine::getPixmapPath() +{ + if (!loader()) return ""; + return loader()->getPixmapPath(info.series); +} + +QPixmap & Machine::getPixmap() +{ + static QPixmap pm; + if (!loader()) return pm; + return loader()->getPixmap(info.series); +} + bool Machine::unlinkSession(Session * sess) { MachineType mt = sess->type(); @@ -514,11 +527,9 @@ bool Machine::Load() } ProgressDialog * popup = new ProgressDialog(nullptr); - QPixmap image(getCPAPPixmap(info.loadername)); - if (!image.isNull()) { - image = image.scaled(64,64); - popup->setPixmap(image); - } + + QPixmap image = getPixmap().scaled(64,64); + popup->setPixmap(image); popup->setMessage(QObject::tr("Loading %1 data...").arg(info.brand)); popup->show(); diff --git a/sleepyhead/SleepLib/machine.h b/sleepyhead/SleepLib/machine.h index 77e6fd50..dae02682 100644 --- a/sleepyhead/SleepLib/machine.h +++ b/sleepyhead/SleepLib/machine.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -220,6 +221,10 @@ class Machine void updateChannels(Session * sess); + + QString getPixmapPath(); + QPixmap & getPixmap(); + protected: MachineInfo info; QDate firstday, lastday; diff --git a/sleepyhead/SleepLib/machine_loader.cpp b/sleepyhead/SleepLib/machine_loader.cpp index df80de8a..c6839f36 100644 --- a/sleepyhead/SleepLib/machine_loader.cpp +++ b/sleepyhead/SleepLib/machine_loader.cpp @@ -16,6 +16,9 @@ extern QProgressBar *qprogress; #include "machine_loader.h" +bool genpixmapinit = false; +QPixmap * MachineLoader::genericCPAPPixmap; + // This crap moves to Profile QList m_loaders; @@ -150,6 +153,10 @@ void DestroyLoaders() MachineLoader::MachineLoader() :QObject(nullptr) { + if (!genpixmapinit) { + genericCPAPPixmap = new QPixmap(genericPixmapPath); + genpixmapinit = true; + } m_abort = false; m_type = MT_UNKNOWN; m_status = NEUTRAL; diff --git a/sleepyhead/SleepLib/machine_loader.h b/sleepyhead/SleepLib/machine_loader.h index 29762a35..7d5199d2 100644 --- a/sleepyhead/SleepLib/machine_loader.h +++ b/sleepyhead/SleepLib/machine_loader.h @@ -11,6 +11,8 @@ #include #include +#include + #include "profiles.h" #include "machine.h" @@ -20,6 +22,7 @@ class MachineLoader; enum DeviceStatus { NEUTRAL, IMPORTING, LIVE, DETECTING }; +const QString genericPixmapPath = ":/icons/mask.png"; /*! \class MachineLoader @@ -84,6 +87,20 @@ class MachineLoader: public QObject void removeMachine(Machine * m); virtual void initChannels() {} + QPixmap & getPixmap(QString series) { + QHash::iterator it = m_pixmaps.find(series); + if (it != m_pixmaps.end()) { + return it.value(); + } + return *genericCPAPPixmap; + } + QString getPixmapPath(QString series) { + QHash::iterator it = m_pixmap_paths.find(series); + if (it != m_pixmap_paths.end()) { + return it.value(); + } + return genericPixmapPath; + } signals: void updateProgress(int cnt, int total); @@ -92,6 +109,8 @@ signals: //! \brief Contains a list of Machine records known by this loader QList m_machlist; + static QPixmap * genericCPAPPixmap; + MachineType m_type; QString m_class; Profile *m_profile; @@ -106,9 +125,11 @@ signals: void finishAddingSessions(); QMap new_sessions; + QHash m_pixmaps; + QHash m_pixmap_paths; + private: QList m_tasklist; - }; class CPAPLoader:public MachineLoader diff --git a/sleepyhead/mainwindow.cpp b/sleepyhead/mainwindow.cpp index 1d581f8e..204585b7 100644 --- a/sleepyhead/mainwindow.cpp +++ b/sleepyhead/mainwindow.cpp @@ -573,12 +573,12 @@ QString getCPAPPixmap(QString mach_class) return cpapimage; } -QIcon getCPAPIcon(QString mach_class) -{ - QString cpapimage = getCPAPPixmap(mach_class); +//QIcon getCPAPIcon(QString mach_class) +//{ +// QString cpapimage = getCPAPPixmap(mach_class); - return QIcon(cpapimage); -} +// return QIcon(cpapimage); +//} void MainWindow::PopulatePurgeMenu() { @@ -597,13 +597,13 @@ void MainWindow::PopulatePurgeMenu() QAction * action = new QAction(name.replace("&","&&"), ui->menu_Rebuild_CPAP_Data); action->setIconVisibleInMenu(true); - action->setIcon(getCPAPIcon(mach->loaderName())); + action->setIcon(mach->getPixmap()); action->setData(mach->loaderName()+":"+mach->serial()); ui->menu_Rebuild_CPAP_Data->addAction(action); action = new QAction(name.replace("&","&&"), ui->menuPurge_CPAP_Data); action->setIconVisibleInMenu(true); - action->setIcon(getCPAPIcon(mach->loaderName())); + action->setIcon(mach->getPixmap()); //getCPAPIcon(mach->loaderName())); action->setData(mach->loaderName()+":"+mach->serial()); ui->menuPurge_CPAP_Data->addAction(action); @@ -672,7 +672,9 @@ int MainWindow::importCPAP(ImportPath import, const QString &message) QHBoxLayout *hlayout = new QHBoxLayout; QLabel * imglabel = new QLabel(popup); - QPixmap image(getCPAPPixmap(import.loader->loaderName())); + + QPixmap image = import.loader->getPixmap(import.loader->PeekInfo(import.path).series); +// QPixmap image(getCPAPPixmap(import.loader->loaderName())); image = image.scaled(64,64); imglabel->setPixmap(image); @@ -914,7 +916,9 @@ void MainWindow::on_action_Import_Data_triggered() mbox.setDefaultButton(QMessageBox::Yes); mbox.setButtonText(QMessageBox::No, tr("Specify")); - QPixmap pixmap = QPixmap(getCPAPPixmap(datacards[0].loader->loaderName())).scaled(64,64); + QPixmap pixmap = datacards[0].loader->getPixmap(datacards[0].loader->PeekInfo(datacards[0].path).series); + + //QPixmap pixmap = QPixmap(getCPAPPixmap(datacards[0].loader->loaderName())).scaled(64,64); mbox.setIconPixmap(pixmap); int res = mbox.exec(); diff --git a/sleepyhead/mainwindow.h b/sleepyhead/mainwindow.h index 942cfecc..cfc9ffe2 100644 --- a/sleepyhead/mainwindow.h +++ b/sleepyhead/mainwindow.h @@ -59,7 +59,7 @@ class MainWindow; extern QStatusBar *qstatusbar; -QString getCPAPPixmap(QString mach_class); +//QString getCPAPPixmap(QString mach_class); class Daily; diff --git a/sleepyhead/welcome.cpp b/sleepyhead/welcome.cpp index e96101ce..20676991 100644 --- a/sleepyhead/welcome.cpp +++ b/sleepyhead/welcome.cpp @@ -130,9 +130,7 @@ QString GenerateWelcomeHTML() Machine * cpap = day->machine(MT_CPAP); if (cpap) { - if (cpap->loaderName() == STR_MACH_ResMed) cpapimage = "qrc:/icons/rms9.png"; - else if (cpap->loaderName() == STR_MACH_PRS1) cpapimage = "qrc:/icons/prs1.png"; - else if (cpap->loaderName() == STR_MACH_Intellipap) cpapimage = "qrc:/icons/intellipap.png"; + cpapimage = "qrc"+cpap->getPixmapPath(); } html += "

";