From 99a3c009f7c8d8c5d17864cfba1e086cd0194e4f Mon Sep 17 00:00:00 2001 From: LoudSnorer Date: Sat, 11 Feb 2023 20:50:02 -0500 Subject: [PATCH] Obsoleesence QTime.start/elpased move QElapseTime.start/elapsed. also fixed sprintf. and using QdateTime(date) to get startOfDay. --- oscar/Graphs/gGraphView.h | 5 ++-- oscar/Graphs/gLineOverlay.cpp | 2 +- oscar/SleepLib/loader_plugins/cms50_loader.h | 3 ++- .../loader_plugins/cms50f37_loader.cpp | 24 +++++++++---------- .../SleepLib/loader_plugins/cms50f37_loader.h | 3 ++- .../SleepLib/loader_plugins/md300w1_loader.h | 3 ++- oscar/SleepLib/machine.cpp | 4 ++-- oscar/checkupdates.h | 3 ++- oscar/daily.cpp | 3 ++- oscar/logger.h | 3 ++- oscar/mainwindow.cpp | 5 ++-- oscar/overview.cpp | 9 ++++++- oscar/oximeterimport.cpp | 3 ++- 13 files changed, 43 insertions(+), 27 deletions(-) diff --git a/oscar/Graphs/gGraphView.h b/oscar/Graphs/gGraphView.h index e0a6f12c..49337e65 100644 --- a/oscar/Graphs/gGraphView.h +++ b/oscar/Graphs/gGraphView.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -103,7 +104,7 @@ public: QFont m_font; QString m_text; Qt::Alignment m_alignment; - QTime time; + QElapsedTimer time; protected slots: void doRedraw(); @@ -717,7 +718,7 @@ class gGraphView QPixmapCache pixmapcache; - QTime horizScrollTime, vertScrollTime; + QElapsedTimer horizScrollTime, vertScrollTime; QMenu * context_menu; QAction * pin_action; QAction * popout_action; diff --git a/oscar/Graphs/gLineOverlay.cpp b/oscar/Graphs/gLineOverlay.cpp index 9b1fa916..4b5869fd 100644 --- a/oscar/Graphs/gLineOverlay.cpp +++ b/oscar/Graphs/gLineOverlay.cpp @@ -377,7 +377,7 @@ void gLineOverlaySummary::paint(QPainter &painter, gGraph &w, const QRegion ® a = QObject::tr("Duration")+": "+w.selDurString(); } else { a = QObject::tr("Events") + ": " + QString::number(cnt) + ", " + - QObject::tr("Duration") + " " + QString().sprintf("%02i:%02i:%02i", h, m, s) + ", " + + QObject::tr("Duration") + " " + QString().asprintf("%02i:%02i:%02i", h, m, s) + ", " + m_text + ": " + QString::number(val, 'f', 2); } if (isSpan) { diff --git a/oscar/SleepLib/loader_plugins/cms50_loader.h b/oscar/SleepLib/loader_plugins/cms50_loader.h index 072f340e..fbeba9e3 100644 --- a/oscar/SleepLib/loader_plugins/cms50_loader.h +++ b/oscar/SleepLib/loader_plugins/cms50_loader.h @@ -10,6 +10,7 @@ #ifndef CMS50LOADER_H #define CMS50LOADER_H +#include #include "SleepLib/serialoximeter.h" const QString cms50_class_name = "CMS50"; @@ -73,7 +74,7 @@ protected: EventList *PULSE; EventList *SPO2; - QTime m_time; + QElapsedTimer m_time; QByteArray buffer; diff --git a/oscar/SleepLib/loader_plugins/cms50f37_loader.cpp b/oscar/SleepLib/loader_plugins/cms50f37_loader.cpp index 605d0b50..f2616c68 100644 --- a/oscar/SleepLib/loader_plugins/cms50f37_loader.cpp +++ b/oscar/SleepLib/loader_plugins/cms50f37_loader.cpp @@ -194,7 +194,7 @@ QString CMS50F37Loader::getUser() sendCommand(COMMAND_GET_USER_INFO); - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -210,7 +210,7 @@ QString CMS50F37Loader::getVendor() sendCommand(COMMAND_GET_OXIMETER_VENDOR); - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -227,7 +227,7 @@ QString CMS50F37Loader::getModel() modelsegments = 0; sendCommand(COMMAND_GET_OXIMETER_MODEL); - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -260,7 +260,7 @@ QString CMS50F37Loader::getDeviceID() sendCommand(COMMAND_GET_OXIMETER_DEVICEID); - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -275,7 +275,7 @@ int CMS50F37Loader::getUserCount() // for future use, check, then add select us userCount = -1; sendCommand(COMMAND_GET_USER_COUNT); - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -290,7 +290,7 @@ int CMS50F37Loader::getSessionCount() session_count = -1; sendCommand(COMMAND_GET_SESSION_COUNT); - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -304,7 +304,7 @@ int CMS50F37Loader::getOximeterInfo() { device_info = -1; sendCommand(COMMAND_GET_OXIMETER_INFO); - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -321,7 +321,7 @@ int CMS50F37Loader::getDuration(int session) duration = -1; sendCommand(COMMAND_GET_SESSION_DURATION, session); - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -338,7 +338,7 @@ QDateTime CMS50F37Loader::getDateTime(int session) imp_date = QDate(); imp_time = QTime(); sendCommand(COMMAND_GET_SESSION_TIME, session); - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -681,7 +681,7 @@ void CMS50F37Loader::eraseSession(int user, int session) } int z = timectr; - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -721,7 +721,7 @@ void CMS50F37Loader::setDeviceID(const QString & newid) // Supposed to return 0x04 command, so reset devid.. devid = QString(); - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); @@ -745,7 +745,7 @@ void CMS50F37Loader::syncClock() qDebug() << "cms50f37 - Couldn't write date bytes to CMS50F"; } - QTime time; + QElapsedTimer time; time.start(); do { QApplication::processEvents(); diff --git a/oscar/SleepLib/loader_plugins/cms50f37_loader.h b/oscar/SleepLib/loader_plugins/cms50f37_loader.h index bcdf532f..5ca534fd 100644 --- a/oscar/SleepLib/loader_plugins/cms50f37_loader.h +++ b/oscar/SleepLib/loader_plugins/cms50f37_loader.h @@ -10,6 +10,7 @@ #ifndef CMS50F37LOADER_H #define CMS50F37LOADER_H +#include #include "SleepLib/serialoximeter.h" const QString cms50f37_class_name = "CMS50F37"; @@ -107,7 +108,7 @@ protected: EventList *PULSE; EventList *SPO2; - QTime m_time; + QElapsedTimer m_time; QByteArray buffer; diff --git a/oscar/SleepLib/loader_plugins/md300w1_loader.h b/oscar/SleepLib/loader_plugins/md300w1_loader.h index e9c7c5be..15fab88f 100644 --- a/oscar/SleepLib/loader_plugins/md300w1_loader.h +++ b/oscar/SleepLib/loader_plugins/md300w1_loader.h @@ -10,6 +10,7 @@ #ifndef MD300W1LOADER_H #define MD300W1LOADER_H +#include #include "SleepLib/serialoximeter.h" const QString md300w1_class_name = "MD300W1"; @@ -69,7 +70,7 @@ protected: EventList *PULSE; EventList *SPO2; - QTime m_time; + QElapsedTimer m_time; QByteArray buffer; diff --git a/oscar/SleepLib/machine.cpp b/oscar/SleepLib/machine.cpp index d6658244..e18b1299 100644 --- a/oscar/SleepLib/machine.cpp +++ b/oscar/SleepLib/machine.cpp @@ -706,7 +706,7 @@ bool Machine::Load(ProgressDialog *progress) progress->setProgressValue(0); QApplication::processEvents(); - QTime time; + QElapsedTimer time; time.start(); dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); @@ -899,7 +899,7 @@ const int summaryxml_version=1; bool Machine::LoadSummary(ProgressDialog * progress) { - QTime time; + QElapsedTimer time; time.start(); QString filename = getDataPath() + summaryFileName + ".gz"; diff --git a/oscar/checkupdates.h b/oscar/checkupdates.h index aa680529..133c60f3 100644 --- a/oscar/checkupdates.h +++ b/oscar/checkupdates.h @@ -12,6 +12,7 @@ #include #include +#include #include /*! \class CheckUpdates @@ -44,7 +45,7 @@ class CheckUpdates : public QMainWindow private: QNetworkAccessManager *manager; - QTime readTimer; + QElapsedTimer readTimer; float elapsedTime; QString msg; // Message to show to user diff --git a/oscar/daily.cpp b/oscar/daily.cpp index 3fb7ca46..0184c0a7 100644 --- a/oscar/daily.cpp +++ b/oscar/daily.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -934,7 +935,7 @@ void Daily::on_ReloadDay() } inReload = true; graphView()->releaseKeyboard(); - QTime time; + QElapsedTimer time; time_t unload_time, load_time, other_time; time.start(); diff --git a/oscar/logger.h b/oscar/logger.h index 267fe3f8..a8504090 100644 --- a/oscar/logger.h +++ b/oscar/logger.h @@ -7,6 +7,7 @@ #include #include #include +#include void initializeLogger(); void shutdownLogger(); @@ -41,7 +42,7 @@ signals: void outputLog(QString); protected: volatile bool running; - QTime logtime; + QElapsedTimer logtime; bool connected; class QFile* m_logFile; class QTextStream* m_logStream; diff --git a/oscar/mainwindow.cpp b/oscar/mainwindow.cpp index 846c43bb..119c3000 100644 --- a/oscar/mainwindow.cpp +++ b/oscar/mainwindow.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -914,7 +915,7 @@ QList MainWindow::detectCPAPCards() QString lastpath = (*p_profile)[STR_PREF_LastCPAPPath].toString(); QListloaders = GetLoaders(MT_CPAP); - QTime time; + QElapsedTimer time; time.start(); // Create dialog @@ -1041,7 +1042,7 @@ QList MainWindow::selectCPAPDataCards(const QString & prompt, bool a QListloaders = GetLoaders(MT_CPAP); - QTime time; + QElapsedTimer time; time.start(); diff --git a/oscar/overview.cpp b/oscar/overview.cpp index 9a3c0868..38c5d4ec 100644 --- a/oscar/overview.cpp +++ b/oscar/overview.cpp @@ -39,8 +39,15 @@ #include "mainwindow.h" extern MainWindow *mainwin; + qint64 convertDateToTimeRtn(const QDate &date,int hours,int min,int sec) { - return QDateTime(date).addSecs(((hours*60+min)*60)+sec).toMSecsSinceEpoch(); + // date.startOfDay was introduced in 5.14. ubuntu 22.04 LTS used QT5.15 + #if QT_VERSION > QT_VERSION_CHECK(5,15,0) + return date.startOfDay().addSecs(((hours*60+min)*60)+sec).toMSecsSinceEpoch(); + #else + // this version works in QT 5.12 + return QDateTime(date).addSecs(((hours*60+min)*60)+sec).toMSecsSinceEpoch(); + #endif } qint64 convertDateToStartTime(const QDate &date) { diff --git a/oscar/oximeterimport.cpp b/oscar/oximeterimport.cpp index fb36b457..886b880c 100644 --- a/oscar/oximeterimport.cpp +++ b/oscar/oximeterimport.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "Graphs/gYAxis.h" #include "Graphs/gXAxis.h" @@ -190,7 +191,7 @@ SerialOximeter * OximeterImport::detectOximeter() ui->progressBar->setMaximum(PORTSCAN_TIMEOUT); - QTime time; + QElapsedTimer time; time.start(); oximodule = nullptr;