From a0f87f72f46e3c586394867a890241fdf0b10da9 Mon Sep 17 00:00:00 2001 From: LoudSnorer Date: Thu, 9 Feb 2023 19:09:19 -0500 Subject: [PATCH] change sprinf to asprintf for QT obsolence --- oscar/Graphs/gGraph.cpp | 2 +- oscar/Graphs/gLineChart.cpp | 2 +- oscar/Graphs/gOverviewGraph.cpp | 13 ++++++++----- oscar/Graphs/gTTIAChart.cpp | 2 +- oscar/Graphs/gYAxis.cpp | 4 ++-- .../SleepLib/loader_plugins/cms50f37_loader.cpp | 16 ++++++++-------- oscar/SleepLib/loader_plugins/md300w1_loader.cpp | 2 +- oscar/SleepLib/loader_plugins/mseries_loader.cpp | 2 +- .../SleepLib/loader_plugins/weinmann_loader.cpp | 6 +++--- oscar/SleepLib/machine.h | 2 +- oscar/SleepLib/session.cpp | 10 +++++----- oscar/daily.cpp | 4 ++-- oscar/dailySearchTab.cpp | 2 +- oscar/exportcsv.cpp | 5 +++-- oscar/oximeterimport.cpp | 10 +++++----- oscar/statistics.cpp | 2 +- 16 files changed, 44 insertions(+), 40 deletions(-) diff --git a/oscar/Graphs/gGraph.cpp b/oscar/Graphs/gGraph.cpp index 057621e5..18db1518 100644 --- a/oscar/Graphs/gGraph.cpp +++ b/oscar/Graphs/gGraph.cpp @@ -864,7 +864,7 @@ void gGraph::mouseMoveEvent(QMouseEvent *event) m_selDurString = tr("%1 days").arg(floor(d)); } else { - m_selDurString.sprintf("%02i:%02i:%02i:%03i", h, m, s, ms); + m_selDurString.asprintf("%02i:%02i:%02i:%03i", h, m, s, ms); } ToolTipAlignment align = x >= x2 ? TT_AlignLeft : TT_AlignRight; diff --git a/oscar/Graphs/gLineChart.cpp b/oscar/Graphs/gLineChart.cpp index 4755cd33..ecc90047 100644 --- a/oscar/Graphs/gLineChart.cpp +++ b/oscar/Graphs/gLineChart.cpp @@ -425,7 +425,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion ®ion) //#define DEBUG_AUTOSCALER #ifdef DEBUG_AUTOSCALER - QString a = QString().sprintf("%.2f - %.2f",miny, maxy); + QString a = QString().asprintf("%.2f - %.2f",miny, maxy); w.renderText(a,width/2,top-5); #endif diff --git a/oscar/Graphs/gOverviewGraph.cpp b/oscar/Graphs/gOverviewGraph.cpp index 310b3643..85bbf314 100644 --- a/oscar/Graphs/gOverviewGraph.cpp +++ b/oscar/Graphs/gOverviewGraph.cpp @@ -7,6 +7,9 @@ * License. See the file COPYING in the main directory of the source code * for more details. */ +#define TEST_MACROS_ENABLEDoff +#include "test_macros.h" + #include #include #include @@ -954,7 +957,7 @@ jumpnext: if (type == ST_HOURS) { int h = f; int m = int(f * 60) % 60; - val.sprintf("%02i:%02i", h, m); + val.asprintf("%02i:%02i", h, m); ishours = true; } else { val = QString::number(f, 'f', 2); @@ -1045,9 +1048,9 @@ QString formatTime(EventDataType v, bool show_seconds = false, bool duration = f } if (show_seconds) { - return QString().sprintf("%i:%02i:%02i%s", h, m, s, pm); + return QString().asprintf("%i:%02i:%02i%s", h, m, s, pm); } else { - return QString().sprintf("%i:%02i%s", h, m, pm); + return QString().asprintf("%i:%02i%s", h, m, pm); } } @@ -1117,7 +1120,7 @@ bool gOverviewGraph::mouseMoveEvent(QMouseEvent *event, gGraph *graph) int h = t / 3600; int m = (t / 60) % 60; //int s=t % 60; - val.sprintf("%02i:%02i", h, m); + val.asprintf("%02i:%02i", h, m); } else { val = QString::number(d.value()[0], 'f', 2); } @@ -1144,7 +1147,7 @@ bool gOverviewGraph::mouseMoveEvent(QMouseEvent *event, gGraph *graph) int h = t / 3600; int m = (t / 60) % 60; //int s=t % 60; - val.sprintf("%02i:%02i", h, m); + val.asprintf("%02i:%02i", h, m); } else { val = QString::number(d.value()[0], 'f', 2); } diff --git a/oscar/Graphs/gTTIAChart.cpp b/oscar/Graphs/gTTIAChart.cpp index 8bd6ec15..bb9ca91e 100644 --- a/oscar/Graphs/gTTIAChart.cpp +++ b/oscar/Graphs/gTTIAChart.cpp @@ -83,7 +83,7 @@ void gTTIAChart::populate(Day *day, int idx) int h = ttia / 3600; int m = int(ttia) / 60 % 60; int s = int(ttia) % 60; - slices.append(SummaryChartSlice(&calcitems[0], ttia / 60.0, ttia / 60.0, QObject::tr("\nTTIA: %1").arg(QString().sprintf("%02i:%02i:%02i",h,m,s)), QColor(255,147,150))); + slices.append(SummaryChartSlice(&calcitems[0], ttia / 60.0, ttia / 60.0, QObject::tr("\nTTIA: %1").arg( QString().asprintf("%02i:%02i:%02i",h,m,s)) , QColor(255,147,150))); } QString gTTIAChart::tooltipData(Day *, int idx) diff --git a/oscar/Graphs/gYAxis.cpp b/oscar/Graphs/gYAxis.cpp index b84e7310..d7e3603c 100644 --- a/oscar/Graphs/gYAxis.cpp +++ b/oscar/Graphs/gYAxis.cpp @@ -343,9 +343,9 @@ const QString gYAxisTime::Format(EventDataType v, int dp) pm[0] = 0; } - if (dp > 2) { return QString().sprintf("%02i:%02i:%02i%s", h, m, s, pm); } + if (dp > 2) { return QString().asprintf("%02i:%02i:%02i%s", h, m, s, pm) ; } - return QString().sprintf("%i:%02i%s", h, m, pm); + return QString().asprintf("%i:%02i%s", h, m, pm) ; } const QString gYAxisWeight::Format(EventDataType v, int dp) diff --git a/oscar/SleepLib/loader_plugins/cms50f37_loader.cpp b/oscar/SleepLib/loader_plugins/cms50f37_loader.cpp index 12bf6ea2..605d0b50 100644 --- a/oscar/SleepLib/loader_plugins/cms50f37_loader.cpp +++ b/oscar/SleepLib/loader_plugins/cms50f37_loader.cpp @@ -448,9 +448,9 @@ void CMS50F37Loader::processBytes(QByteArray bytes) // COMMAND_GET_SESSION_TIME --- the date part case 0x07: // 7,80,80,80,94,8e,88,92 - year = QString().sprintf("%02i%02i",buffer.at(idx+4), buffer.at(idx+5)).toInt(); - month = QString().sprintf("%02i", buffer.at(idx+6)).toInt(); - day = QString().sprintf("%02i", buffer.at(idx+7)).toInt(); + year = QString().asprintf("%02i%02i",buffer.at(idx+4), buffer.at(idx+5)).toInt(); + month = QString().asprintf("%02i", buffer.at(idx+6)).toInt(); + day = QString().asprintf("%02i", buffer.at(idx+7)).toInt(); if ( year == 0 ) { imp_date = QDate::currentDate(); @@ -503,7 +503,7 @@ void CMS50F37Loader::processBytes(QByteArray bytes) // COMMAND_GET_SESSION_TIME case 0x12: // 12,80,80,80,82,a6,92,80 - tmpstr = QString().sprintf("%02i:%02i:%02i",buffer.at(idx+4), buffer.at(idx+5), buffer.at(idx+6)); + tmpstr = QString().asprintf("%02i:%02i:%02i",buffer.at(idx+4), buffer.at(idx+5), buffer.at(idx+6)); imp_time = QTime::fromString(tmpstr, "HH:mm:ss"); qDebug() << "cms50f37 - pB: tmpStr:" << tmpstr << " impTime: " << imp_time; @@ -640,7 +640,7 @@ void CMS50F37Loader::sendCommand(quint8 c) QString out; for (int i=0;i < 9;i++) - out += QString().sprintf("%02X ",cmd[i]); + out += QString().asprintf("%02X ",cmd[i]); qDebug() << "cms50f37 - Write:" << out; if (serial.write((char *)cmd, 9) == -1) { @@ -656,7 +656,7 @@ void CMS50F37Loader::sendCommand(quint8 c, quint8 c2) QString out; for (int i=0; i < 9; ++i) - out += QString().sprintf("%02X ",cmd[i]); + out += QString().asprintf("%02X ",cmd[i]); qDebug() << "cms50f37 - Write:" << out; if (serial.write((char *)cmd, 9) == -1) { @@ -673,7 +673,7 @@ void CMS50F37Loader::eraseSession(int user, int session) QString out; for (int i=0; i < 9; ++i) - out += QString().sprintf("%02X ",cmd[i]); + out += QString().asprintf("%02X ",cmd[i]); qDebug() << "cms50f37 - Erase Session: Write:" << out; if (serial.write((char *)cmd, 9) == -1) { @@ -711,7 +711,7 @@ void CMS50F37Loader::setDeviceID(const QString & newid) QString out; for (int i=0; i < 9; ++i) - out += QString().sprintf("%02X ",cmd[i]); + out += QString().asprintf("%02X ",cmd[i]); qDebug() << "cms50f37 - setDeviceID: Write:" << out; if (serial.write((char *)cmd, 9) == -1) { diff --git a/oscar/SleepLib/loader_plugins/md300w1_loader.cpp b/oscar/SleepLib/loader_plugins/md300w1_loader.cpp index fa13f311..faa04d18 100644 --- a/oscar/SleepLib/loader_plugins/md300w1_loader.cpp +++ b/oscar/SleepLib/loader_plugins/md300w1_loader.cpp @@ -194,7 +194,7 @@ bool MD300W1Loader::readDATFile(const QString & path) int gap; for (int pos = 0; pos < n; ++pos) { int i = 3 + (pos * 11); - QString datestr = QString().sprintf("%02d/%02d/%02d %02d:%02d:%02d", + QString datestr = QString().asprintf("%02d/%02d/%02d %02d:%02d:%02d", (unsigned char)data.at(i+4),(unsigned char)data.at(i+5),(unsigned char)data.at(i+3), (unsigned char)data.at(i+6),(unsigned char)data.at(i+7),(unsigned char)data.at(i+8)); // Ensure date is correct first to ensure DST is handled correctly diff --git a/oscar/SleepLib/loader_plugins/mseries_loader.cpp b/oscar/SleepLib/loader_plugins/mseries_loader.cpp index 162d3a3f..37dcc145 100644 --- a/oscar/SleepLib/loader_plugins/mseries_loader.cpp +++ b/oscar/SleepLib/loader_plugins/mseries_loader.cpp @@ -389,7 +389,7 @@ int MSeriesLoader::Open(const QString & path) QString a; for (int i = 0; i < 0x13; i++) { - a += QString().sprintf("%02X ", cb[i]); + a += QString().asprintf("%02X ", cb[i]); } a += " " + date.toString() + " " + time.toString(); diff --git a/oscar/SleepLib/loader_plugins/weinmann_loader.cpp b/oscar/SleepLib/loader_plugins/weinmann_loader.cpp index 7892a750..29a8f3a7 100644 --- a/oscar/SleepLib/loader_plugins/weinmann_loader.cpp +++ b/oscar/SleepLib/loader_plugins/weinmann_loader.cpp @@ -152,7 +152,7 @@ int WeinmannLoader::Open(const QString & dirpath) unsigned char *p = weekco; for (int c=0; c < wccount; ++c) { - int year = QString().sprintf("%02i%02i", p[0], p[1]).toInt(); + int year = QString().asprintf("%02i%02i", p[0], p[1]).toInt(); int month = p[2]; int day = p[3]; int hour = p[5]; @@ -206,7 +206,7 @@ int WeinmannLoader::Open(const QString & dirpath) //int c = index[DayComplianceCount]; for (int i=0; i < 5; i++) { - int year = QString().sprintf("%02i%02i", p[0], p[1]).toInt(); + int year = QString().asprintf("%02i%02i", p[0], p[1]).toInt(); int month = p[2]; int day = p[3]; int hour = p[5]; @@ -250,7 +250,7 @@ int WeinmannLoader::Open(const QString & dirpath) sess->really_set_last(qint64(ts+dur) * 1000L); sessions[ts] = sess; -// qDebug() << date << ts << dur << QString().sprintf("%02i:%02i:%02i", dur / 3600, dur/60 % 60, dur % 60); +// qDebug() << date << ts << dur << QString().asprintf("%02i:%02i:%02i", dur / 3600, dur/60 % 60, dur % 60); p += 0xd6; } diff --git a/oscar/SleepLib/machine.h b/oscar/SleepLib/machine.h index 0a7f4f8d..209916d5 100644 --- a/oscar/SleepLib/machine.h +++ b/oscar/SleepLib/machine.h @@ -159,7 +159,7 @@ class Machine //! \brief Returns the machineID as a lower case hexadecimal string - QString hexid() { return QString().sprintf("%08lx", m_id); } + QString hexid() { return QString().asprintf("%08lx", m_id); } //! \brief Unused, increments the most recent sessionID diff --git a/oscar/SleepLib/session.cpp b/oscar/SleepLib/session.cpp index d6ffa5e2..e7d4a90f 100644 --- a/oscar/SleepLib/session.cpp +++ b/oscar/SleepLib/session.cpp @@ -101,7 +101,7 @@ void Session::setEnabled(bool b) QString Session::eventFile() const { - return s_machine->getEventsPath()+QString().sprintf("%08lx.001", s_session); + return s_machine->getEventsPath()+QString().asprintf("%08lx.001", s_session); } //const int max_pack_size=128; @@ -136,7 +136,7 @@ bool Session::Destroy() { QDir dir; QString base; - base.sprintf("%08lx", s_session); + base.asprintf("%08lx", s_session); QString summaryfile = s_machine->getSummariesPath() + base + ".000"; QString eventfile = s_machine->getEventsPath() + base + ".001"; @@ -311,7 +311,7 @@ bool Session::StoreSummary() return false; } - QString filename = s_machine->getSummariesPath() + QString().sprintf("%08lx.000", s_session); + QString filename = s_machine->getSummariesPath() + QString().asprintf("%08lx.000", s_session) ; QFile file(filename); if (!file.open(QIODevice::WriteOnly)) { @@ -388,7 +388,7 @@ bool Session::LoadSummary() // static int sumcnt = 0; if (s_summary_loaded) return true; - QString filename = s_machine->getSummariesPath() + QString().sprintf("%08lx.000", s_session); + QString filename = s_machine->getSummariesPath() + QString().asprintf("%08lx.000", s_session); if (filename.isEmpty()) { qDebug() << "Empty summary filename"; @@ -669,7 +669,7 @@ bool Session::StoreEvents() QString path = s_machine->getEventsPath(); QDir dir; dir.mkpath(path); - QString filename = path+QString().sprintf("%08lx.001", s_session); + QString filename = path+ QString().asprintf("%08lx.001", s_session) ; QFile file(filename); if (!file.open(QIODevice::WriteOnly)) { diff --git a/oscar/daily.cpp b/oscar/daily.cpp index 44d7b204..3fb7ca46 100644 --- a/oscar/daily.cpp +++ b/oscar/daily.cpp @@ -1445,7 +1445,7 @@ QString Daily::getStatisticsInfo(Day * day) int s = ttia % 60; if (ttia > 0) { html+=""+tr("Total time in apnea") + - QString("%1").arg(QString().sprintf("%02i:%02i:%02i",h,m,s)); + QString("%1").arg(QString().asprintf("%02i:%02i:%02i",h,m,s)); } } @@ -1517,7 +1517,7 @@ QString Daily::getSleepTime(Day * day) .arg(date.date().toString(Qt::SystemLocaleShortDate)) .arg(date.toString("HH:mm:ss")) .arg(date2.toString("HH:mm:ss")) - .arg(QString().sprintf("%02i:%02i:%02i",h,m,s)); + .arg(QString().asprintf("%02i:%02i:%02i",h,m,s)); html+="\n"; // html+="
"; diff --git a/oscar/dailySearchTab.cpp b/oscar/dailySearchTab.cpp index 262d90d3..923024da 100644 --- a/oscar/dailySearchTab.cpp +++ b/oscar/dailySearchTab.cpp @@ -45,7 +45,7 @@ DailySearchTab::DailySearchTab(Daily* daily , QWidget* searchTabWidget , QTabWi { icon_on = new QIcon(":/icons/session-on.png"); icon_off = new QIcon(":/icons/session-off.png"); - + #if 0 // method of find the daily tabWidgets works for english. diff --git a/oscar/exportcsv.cpp b/oscar/exportcsv.cpp index 1e35df83..c292d5d7 100644 --- a/oscar/exportcsv.cpp +++ b/oscar/exportcsv.cpp @@ -257,7 +257,8 @@ void ExportCSV::on_exportButton_clicked() int h = time / 3600; int m = int(time / 60) % 60; int s = int(time) % 60; - data += sep + QString().sprintf("%02i:%02i:%02i", h, m, s); + data += sep + QString().asprintf("%02i:%02i:%02i", h, m, s); + float ahi = day->calcAHI(); data += sep + QString::number(ahi, 'f', 3); @@ -301,7 +302,7 @@ void ExportCSV::on_exportButton_clicked() int h = time / 3600; int m = int(time / 60) % 60; int s = int(time) % 60; - data += sep + QString().sprintf("%02i:%02i:%02i", h, m, s); + data += sep + QString().asprintf("%02i:%02i:%02i", h, m, s); float ahi = sess->count(AllAhiChannels); //sess->count(CPAP_AllApnea) + sess->count(CPAP_Obstructive) + sess->count(CPAP_Hypopnea) diff --git a/oscar/oximeterimport.cpp b/oscar/oximeterimport.cpp index 726574a7..fb36b457 100644 --- a/oscar/oximeterimport.cpp +++ b/oscar/oximeterimport.cpp @@ -296,7 +296,7 @@ void OximeterImport::on_directImportButton_clicked() // item->setData(Qt::UserRole+2, duration); item->setFlags(item->flags() & ~Qt::ItemIsEditable); - item = new QTableWidgetItem(QString(). sprintf("%02i:%02i:%02i", h,m,s)); + item = new QTableWidgetItem( QString().asprintf("%02i:%02i:%02i", h,m,s)); ui->tableOxiSessions->setItem(i, 1, item); item->setFlags(item->flags() & ~Qt::ItemIsEditable); @@ -740,17 +740,17 @@ void OximeterImport::updateLiveDisplay() pulse = (*(oximodule->oxirec))[size].pulse; spo2 = (*(oximodule->oxirec))[size].spo2; if (pulse > 0) { - ui->pulseDisplay->display(QString().sprintf("%3i", pulse)); + ui->pulseDisplay->display(QString().asprintf("%3i", pulse)); } else { ui->pulseDisplay->display("---"); } if (spo2 > 0) { - ui->spo2Display->display(QString().sprintf("%2i", spo2)); + ui->spo2Display->display(QString().asprintf("%2i", spo2)); } else { ui->spo2Display->display("--"); } - ui->lcdDuration->display(QString().sprintf("%02i:%02i:%02i",hours, minutes, seconds)); + ui->lcdDuration->display(QString().asprintf("%02i:%02i:%02i",hours, minutes, seconds)); } } @@ -1089,7 +1089,7 @@ void OximeterImport::chooseSession() int m = (duration / 60) % 60; int s = duration % 60; - item = new QTableWidgetItem(QString(). sprintf("%02i:%02i:%02i", h,m,s)); + item = new QTableWidgetItem( QString().asprintf("%02i:%02i:%02i", h,m,s)); ui->tableOxiSessions->setItem(row, 1, item); item->setFlags(item->flags() & ~Qt::ItemIsEditable); diff --git a/oscar/statistics.cpp b/oscar/statistics.cpp index c17f90ea..7c5daa81 100644 --- a/oscar/statistics.cpp +++ b/oscar/statistics.cpp @@ -48,7 +48,7 @@ QString formatTime(float time) int seconds = time * 3600.0; int minutes = (seconds / 60) % 60; //seconds %= 60; - return QString().sprintf("%02i:%02i", hours, minutes); //,seconds); + return QString().asprintf("%02i:%02i", hours, minutes); //,seconds); }