Obsoleesence QTime.start/elpased move QElapseTime.start/elapsed. also fixed sprintf. and using QdateTime(date) to get startOfDay.

This commit is contained in:
LoudSnorer 2023-02-11 20:50:02 -05:00
parent a0a0e08bc7
commit 99a3c009f7
13 changed files with 43 additions and 27 deletions

View File

@ -26,6 +26,7 @@
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QToolButton> #include <QToolButton>
#include <QTimer> #include <QTimer>
#include <QElapsedTimer>
#include <QGestureEvent> #include <QGestureEvent>
#include <QPinchGesture> #include <QPinchGesture>
@ -103,7 +104,7 @@ public:
QFont m_font; QFont m_font;
QString m_text; QString m_text;
Qt::Alignment m_alignment; Qt::Alignment m_alignment;
QTime time; QElapsedTimer time;
protected slots: protected slots:
void doRedraw(); void doRedraw();
@ -717,7 +718,7 @@ class gGraphView
QPixmapCache pixmapcache; QPixmapCache pixmapcache;
QTime horizScrollTime, vertScrollTime; QElapsedTimer horizScrollTime, vertScrollTime;
QMenu * context_menu; QMenu * context_menu;
QAction * pin_action; QAction * pin_action;
QAction * popout_action; QAction * popout_action;

View File

@ -377,7 +377,7 @@ void gLineOverlaySummary::paint(QPainter &painter, gGraph &w, const QRegion &reg
a = QObject::tr("Duration")+": "+w.selDurString(); a = QObject::tr("Duration")+": "+w.selDurString();
} else { } else {
a = QObject::tr("Events") + ": " + QString::number(cnt) + ", " + 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); m_text + ": " + QString::number(val, 'f', 2);
} }
if (isSpan) { if (isSpan) {

View File

@ -10,6 +10,7 @@
#ifndef CMS50LOADER_H #ifndef CMS50LOADER_H
#define CMS50LOADER_H #define CMS50LOADER_H
#include <QElapsedTimer>
#include "SleepLib/serialoximeter.h" #include "SleepLib/serialoximeter.h"
const QString cms50_class_name = "CMS50"; const QString cms50_class_name = "CMS50";
@ -73,7 +74,7 @@ protected:
EventList *PULSE; EventList *PULSE;
EventList *SPO2; EventList *SPO2;
QTime m_time; QElapsedTimer m_time;
QByteArray buffer; QByteArray buffer;

View File

@ -194,7 +194,7 @@ QString CMS50F37Loader::getUser()
sendCommand(COMMAND_GET_USER_INFO); sendCommand(COMMAND_GET_USER_INFO);
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -210,7 +210,7 @@ QString CMS50F37Loader::getVendor()
sendCommand(COMMAND_GET_OXIMETER_VENDOR); sendCommand(COMMAND_GET_OXIMETER_VENDOR);
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -227,7 +227,7 @@ QString CMS50F37Loader::getModel()
modelsegments = 0; modelsegments = 0;
sendCommand(COMMAND_GET_OXIMETER_MODEL); sendCommand(COMMAND_GET_OXIMETER_MODEL);
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -260,7 +260,7 @@ QString CMS50F37Loader::getDeviceID()
sendCommand(COMMAND_GET_OXIMETER_DEVICEID); sendCommand(COMMAND_GET_OXIMETER_DEVICEID);
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -275,7 +275,7 @@ int CMS50F37Loader::getUserCount() // for future use, check, then add select us
userCount = -1; userCount = -1;
sendCommand(COMMAND_GET_USER_COUNT); sendCommand(COMMAND_GET_USER_COUNT);
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -290,7 +290,7 @@ int CMS50F37Loader::getSessionCount()
session_count = -1; session_count = -1;
sendCommand(COMMAND_GET_SESSION_COUNT); sendCommand(COMMAND_GET_SESSION_COUNT);
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -304,7 +304,7 @@ int CMS50F37Loader::getOximeterInfo()
{ {
device_info = -1; device_info = -1;
sendCommand(COMMAND_GET_OXIMETER_INFO); sendCommand(COMMAND_GET_OXIMETER_INFO);
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -321,7 +321,7 @@ int CMS50F37Loader::getDuration(int session)
duration = -1; duration = -1;
sendCommand(COMMAND_GET_SESSION_DURATION, session); sendCommand(COMMAND_GET_SESSION_DURATION, session);
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -338,7 +338,7 @@ QDateTime CMS50F37Loader::getDateTime(int session)
imp_date = QDate(); imp_date = QDate();
imp_time = QTime(); imp_time = QTime();
sendCommand(COMMAND_GET_SESSION_TIME, session); sendCommand(COMMAND_GET_SESSION_TIME, session);
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -681,7 +681,7 @@ void CMS50F37Loader::eraseSession(int user, int session)
} }
int z = timectr; int z = timectr;
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -721,7 +721,7 @@ void CMS50F37Loader::setDeviceID(const QString & newid)
// Supposed to return 0x04 command, so reset devid.. // Supposed to return 0x04 command, so reset devid..
devid = QString(); devid = QString();
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();
@ -745,7 +745,7 @@ void CMS50F37Loader::syncClock()
qDebug() << "cms50f37 - Couldn't write date bytes to CMS50F"; qDebug() << "cms50f37 - Couldn't write date bytes to CMS50F";
} }
QTime time; QElapsedTimer time;
time.start(); time.start();
do { do {
QApplication::processEvents(); QApplication::processEvents();

View File

@ -10,6 +10,7 @@
#ifndef CMS50F37LOADER_H #ifndef CMS50F37LOADER_H
#define CMS50F37LOADER_H #define CMS50F37LOADER_H
#include <QElapsedTimer>
#include "SleepLib/serialoximeter.h" #include "SleepLib/serialoximeter.h"
const QString cms50f37_class_name = "CMS50F37"; const QString cms50f37_class_name = "CMS50F37";
@ -107,7 +108,7 @@ protected:
EventList *PULSE; EventList *PULSE;
EventList *SPO2; EventList *SPO2;
QTime m_time; QElapsedTimer m_time;
QByteArray buffer; QByteArray buffer;

View File

@ -10,6 +10,7 @@
#ifndef MD300W1LOADER_H #ifndef MD300W1LOADER_H
#define MD300W1LOADER_H #define MD300W1LOADER_H
#include <QElapsedTimer>
#include "SleepLib/serialoximeter.h" #include "SleepLib/serialoximeter.h"
const QString md300w1_class_name = "MD300W1"; const QString md300w1_class_name = "MD300W1";
@ -69,7 +70,7 @@ protected:
EventList *PULSE; EventList *PULSE;
EventList *SPO2; EventList *SPO2;
QTime m_time; QElapsedTimer m_time;
QByteArray buffer; QByteArray buffer;

View File

@ -706,7 +706,7 @@ bool Machine::Load(ProgressDialog *progress)
progress->setProgressValue(0); progress->setProgressValue(0);
QApplication::processEvents(); QApplication::processEvents();
QTime time; QElapsedTimer time;
time.start(); time.start();
dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
@ -899,7 +899,7 @@ const int summaryxml_version=1;
bool Machine::LoadSummary(ProgressDialog * progress) bool Machine::LoadSummary(ProgressDialog * progress)
{ {
QTime time; QElapsedTimer time;
time.start(); time.start();
QString filename = getDataPath() + summaryFileName + ".gz"; QString filename = getDataPath() + summaryFileName + ".gz";

View File

@ -12,6 +12,7 @@
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QMainWindow> #include <QMainWindow>
#include <QElapsedTimer>
#include <QProgressDialog> #include <QProgressDialog>
/*! \class CheckUpdates /*! \class CheckUpdates
@ -44,7 +45,7 @@ class CheckUpdates : public QMainWindow
private: private:
QNetworkAccessManager *manager; QNetworkAccessManager *manager;
QTime readTimer; QElapsedTimer readTimer;
float elapsedTime; float elapsedTime;
QString msg; // Message to show to user QString msg; // Message to show to user

View File

@ -15,6 +15,7 @@
#include <QTextBlock> #include <QTextBlock>
#include <QColorDialog> #include <QColorDialog>
#include <QSpacerItem> #include <QSpacerItem>
#include <QElapsedTimer>
#include <QBuffer> #include <QBuffer>
#include <QPixmap> #include <QPixmap>
#include <QMessageBox> #include <QMessageBox>
@ -934,7 +935,7 @@ void Daily::on_ReloadDay()
} }
inReload = true; inReload = true;
graphView()->releaseKeyboard(); graphView()->releaseKeyboard();
QTime time; QElapsedTimer time;
time_t unload_time, load_time, other_time; time_t unload_time, load_time, other_time;
time.start(); time.start();

View File

@ -7,6 +7,7 @@
#include <QMutex> #include <QMutex>
#include <QWaitCondition> #include <QWaitCondition>
#include <QTime> #include <QTime>
#include <QElapsedTimer>
void initializeLogger(); void initializeLogger();
void shutdownLogger(); void shutdownLogger();
@ -41,7 +42,7 @@ signals:
void outputLog(QString); void outputLog(QString);
protected: protected:
volatile bool running; volatile bool running;
QTime logtime; QElapsedTimer logtime;
bool connected; bool connected;
class QFile* m_logFile; class QFile* m_logFile;
class QTextStream* m_logStream; class QTextStream* m_logStream;

View File

@ -17,6 +17,7 @@
#include <QResource> #include <QResource>
#include <QProgressBar> #include <QProgressBar>
#include <QTimer> #include <QTimer>
#include <QElapsedTimer>
#include <QSettings> #include <QSettings>
#include <QPixmap> #include <QPixmap>
#include <QDesktopWidget> #include <QDesktopWidget>
@ -914,7 +915,7 @@ QList<ImportPath> MainWindow::detectCPAPCards()
QString lastpath = (*p_profile)[STR_PREF_LastCPAPPath].toString(); QString lastpath = (*p_profile)[STR_PREF_LastCPAPPath].toString();
QList<MachineLoader *>loaders = GetLoaders(MT_CPAP); QList<MachineLoader *>loaders = GetLoaders(MT_CPAP);
QTime time; QElapsedTimer time;
time.start(); time.start();
// Create dialog // Create dialog
@ -1041,7 +1042,7 @@ QList<ImportPath> MainWindow::selectCPAPDataCards(const QString & prompt, bool a
QList<MachineLoader *>loaders = GetLoaders(MT_CPAP); QList<MachineLoader *>loaders = GetLoaders(MT_CPAP);
QTime time; QElapsedTimer time;
time.start(); time.start();

View File

@ -39,8 +39,15 @@
#include "mainwindow.h" #include "mainwindow.h"
extern MainWindow *mainwin; extern MainWindow *mainwin;
qint64 convertDateToTimeRtn(const QDate &date,int hours,int min,int sec) { 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) { qint64 convertDateToStartTime(const QDate &date) {

View File

@ -12,6 +12,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QStandardPaths> #include <QStandardPaths>
#include <QDesktopServices> #include <QDesktopServices>
#include <QElapsedTimer>
#include "Graphs/gYAxis.h" #include "Graphs/gYAxis.h"
#include "Graphs/gXAxis.h" #include "Graphs/gXAxis.h"
@ -190,7 +191,7 @@ SerialOximeter * OximeterImport::detectOximeter()
ui->progressBar->setMaximum(PORTSCAN_TIMEOUT); ui->progressBar->setMaximum(PORTSCAN_TIMEOUT);
QTime time; QElapsedTimer time;
time.start(); time.start();
oximodule = nullptr; oximodule = nullptr;