change sprinf to asprintf for QT obsolence

This commit is contained in:
LoudSnorer 2023-02-09 19:09:19 -05:00
parent f60edcc637
commit a0f87f72f4
16 changed files with 44 additions and 40 deletions

View File

@ -864,7 +864,7 @@ void gGraph::mouseMoveEvent(QMouseEvent *event)
m_selDurString = tr("%1 days").arg(floor(d)); m_selDurString = tr("%1 days").arg(floor(d));
} else { } 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; ToolTipAlignment align = x >= x2 ? TT_AlignLeft : TT_AlignRight;

View File

@ -425,7 +425,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
//#define DEBUG_AUTOSCALER //#define DEBUG_AUTOSCALER
#ifdef 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); w.renderText(a,width/2,top-5);
#endif #endif

View File

@ -7,6 +7,9 @@
* License. See the file COPYING in the main directory of the source code * License. See the file COPYING in the main directory of the source code
* for more details. */ * for more details. */
#define TEST_MACROS_ENABLEDoff
#include "test_macros.h"
#include <math.h> #include <math.h>
#include <QLabel> #include <QLabel>
#include <QDateTime> #include <QDateTime>
@ -954,7 +957,7 @@ jumpnext:
if (type == ST_HOURS) { if (type == ST_HOURS) {
int h = f; int h = f;
int m = int(f * 60) % 60; int m = int(f * 60) % 60;
val.sprintf("%02i:%02i", h, m); val.asprintf("%02i:%02i", h, m);
ishours = true; ishours = true;
} else { } else {
val = QString::number(f, 'f', 2); val = QString::number(f, 'f', 2);
@ -1045,9 +1048,9 @@ QString formatTime(EventDataType v, bool show_seconds = false, bool duration = f
} }
if (show_seconds) { 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 { } 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 h = t / 3600;
int m = (t / 60) % 60; int m = (t / 60) % 60;
//int s=t % 60; //int s=t % 60;
val.sprintf("%02i:%02i", h, m); val.asprintf("%02i:%02i", h, m);
} else { } else {
val = QString::number(d.value()[0], 'f', 2); val = QString::number(d.value()[0], 'f', 2);
} }
@ -1144,7 +1147,7 @@ bool gOverviewGraph::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
int h = t / 3600; int h = t / 3600;
int m = (t / 60) % 60; int m = (t / 60) % 60;
//int s=t % 60; //int s=t % 60;
val.sprintf("%02i:%02i", h, m); val.asprintf("%02i:%02i", h, m);
} else { } else {
val = QString::number(d.value()[0], 'f', 2); val = QString::number(d.value()[0], 'f', 2);
} }

View File

@ -83,7 +83,7 @@ void gTTIAChart::populate(Day *day, int idx)
int h = ttia / 3600; int h = ttia / 3600;
int m = int(ttia) / 60 % 60; int m = int(ttia) / 60 % 60;
int s = int(ttia) % 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) QString gTTIAChart::tooltipData(Day *, int idx)

View File

@ -343,9 +343,9 @@ const QString gYAxisTime::Format(EventDataType v, int dp)
pm[0] = 0; 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) const QString gYAxisWeight::Format(EventDataType v, int dp)

View File

@ -448,9 +448,9 @@ void CMS50F37Loader::processBytes(QByteArray bytes)
// COMMAND_GET_SESSION_TIME --- the date part // COMMAND_GET_SESSION_TIME --- the date part
case 0x07: // 7,80,80,80,94,8e,88,92 case 0x07: // 7,80,80,80,94,8e,88,92
year = QString().sprintf("%02i%02i",buffer.at(idx+4), buffer.at(idx+5)).toInt(); year = QString().asprintf("%02i%02i",buffer.at(idx+4), buffer.at(idx+5)).toInt();
month = QString().sprintf("%02i", buffer.at(idx+6)).toInt(); month = QString().asprintf("%02i", buffer.at(idx+6)).toInt();
day = QString().sprintf("%02i", buffer.at(idx+7)).toInt(); day = QString().asprintf("%02i", buffer.at(idx+7)).toInt();
if ( year == 0 ) { if ( year == 0 ) {
imp_date = QDate::currentDate(); imp_date = QDate::currentDate();
@ -503,7 +503,7 @@ void CMS50F37Loader::processBytes(QByteArray bytes)
// COMMAND_GET_SESSION_TIME // COMMAND_GET_SESSION_TIME
case 0x12: // 12,80,80,80,82,a6,92,80 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"); imp_time = QTime::fromString(tmpstr, "HH:mm:ss");
qDebug() << "cms50f37 - pB: tmpStr:" << tmpstr << " impTime: " << imp_time; qDebug() << "cms50f37 - pB: tmpStr:" << tmpstr << " impTime: " << imp_time;
@ -640,7 +640,7 @@ void CMS50F37Loader::sendCommand(quint8 c)
QString out; QString out;
for (int i=0;i < 9;i++) for (int i=0;i < 9;i++)
out += QString().sprintf("%02X ",cmd[i]); out += QString().asprintf("%02X ",cmd[i]);
qDebug() << "cms50f37 - Write:" << out; qDebug() << "cms50f37 - Write:" << out;
if (serial.write((char *)cmd, 9) == -1) { if (serial.write((char *)cmd, 9) == -1) {
@ -656,7 +656,7 @@ void CMS50F37Loader::sendCommand(quint8 c, quint8 c2)
QString out; QString out;
for (int i=0; i < 9; ++i) for (int i=0; i < 9; ++i)
out += QString().sprintf("%02X ",cmd[i]); out += QString().asprintf("%02X ",cmd[i]);
qDebug() << "cms50f37 - Write:" << out; qDebug() << "cms50f37 - Write:" << out;
if (serial.write((char *)cmd, 9) == -1) { if (serial.write((char *)cmd, 9) == -1) {
@ -673,7 +673,7 @@ void CMS50F37Loader::eraseSession(int user, int session)
QString out; QString out;
for (int i=0; i < 9; ++i) 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; qDebug() << "cms50f37 - Erase Session: Write:" << out;
if (serial.write((char *)cmd, 9) == -1) { if (serial.write((char *)cmd, 9) == -1) {
@ -711,7 +711,7 @@ void CMS50F37Loader::setDeviceID(const QString & newid)
QString out; QString out;
for (int i=0; i < 9; ++i) for (int i=0; i < 9; ++i)
out += QString().sprintf("%02X ",cmd[i]); out += QString().asprintf("%02X ",cmd[i]);
qDebug() << "cms50f37 - setDeviceID: Write:" << out; qDebug() << "cms50f37 - setDeviceID: Write:" << out;
if (serial.write((char *)cmd, 9) == -1) { if (serial.write((char *)cmd, 9) == -1) {

View File

@ -194,7 +194,7 @@ bool MD300W1Loader::readDATFile(const QString & path)
int gap; int gap;
for (int pos = 0; pos < n; ++pos) { for (int pos = 0; pos < n; ++pos) {
int i = 3 + (pos * 11); 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+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)); (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 // Ensure date is correct first to ensure DST is handled correctly

View File

@ -389,7 +389,7 @@ int MSeriesLoader::Open(const QString & path)
QString a; QString a;
for (int i = 0; i < 0x13; i++) { for (int i = 0; i < 0x13; i++) {
a += QString().sprintf("%02X ", cb[i]); a += QString().asprintf("%02X ", cb[i]);
} }
a += " " + date.toString() + " " + time.toString(); a += " " + date.toString() + " " + time.toString();

View File

@ -152,7 +152,7 @@ int WeinmannLoader::Open(const QString & dirpath)
unsigned char *p = weekco; unsigned char *p = weekco;
for (int c=0; c < wccount; ++c) { 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 month = p[2];
int day = p[3]; int day = p[3];
int hour = p[5]; int hour = p[5];
@ -206,7 +206,7 @@ int WeinmannLoader::Open(const QString & dirpath)
//int c = index[DayComplianceCount]; //int c = index[DayComplianceCount];
for (int i=0; i < 5; i++) { 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 month = p[2];
int day = p[3]; int day = p[3];
int hour = p[5]; int hour = p[5];
@ -250,7 +250,7 @@ int WeinmannLoader::Open(const QString & dirpath)
sess->really_set_last(qint64(ts+dur) * 1000L); sess->really_set_last(qint64(ts+dur) * 1000L);
sessions[ts] = sess; 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; p += 0xd6;
} }

View File

@ -159,7 +159,7 @@ class Machine
//! \brief Returns the machineID as a lower case hexadecimal string //! \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 //! \brief Unused, increments the most recent sessionID

View File

@ -101,7 +101,7 @@ void Session::setEnabled(bool b)
QString Session::eventFile() const 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; //const int max_pack_size=128;
@ -136,7 +136,7 @@ bool Session::Destroy()
{ {
QDir dir; QDir dir;
QString base; QString base;
base.sprintf("%08lx", s_session); base.asprintf("%08lx", s_session);
QString summaryfile = s_machine->getSummariesPath() + base + ".000"; QString summaryfile = s_machine->getSummariesPath() + base + ".000";
QString eventfile = s_machine->getEventsPath() + base + ".001"; QString eventfile = s_machine->getEventsPath() + base + ".001";
@ -311,7 +311,7 @@ bool Session::StoreSummary()
return false; 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); QFile file(filename);
if (!file.open(QIODevice::WriteOnly)) { if (!file.open(QIODevice::WriteOnly)) {
@ -388,7 +388,7 @@ bool Session::LoadSummary()
// static int sumcnt = 0; // static int sumcnt = 0;
if (s_summary_loaded) return true; 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()) { if (filename.isEmpty()) {
qDebug() << "Empty summary filename"; qDebug() << "Empty summary filename";
@ -669,7 +669,7 @@ bool Session::StoreEvents()
QString path = s_machine->getEventsPath(); QString path = s_machine->getEventsPath();
QDir dir; QDir dir;
dir.mkpath(path); dir.mkpath(path);
QString filename = path+QString().sprintf("%08lx.001", s_session); QString filename = path+ QString().asprintf("%08lx.001", s_session) ;
QFile file(filename); QFile file(filename);
if (!file.open(QIODevice::WriteOnly)) { if (!file.open(QIODevice::WriteOnly)) {

View File

@ -1445,7 +1445,7 @@ QString Daily::getStatisticsInfo(Day * day)
int s = ttia % 60; int s = ttia % 60;
if (ttia > 0) { if (ttia > 0) {
html+="<tr><td colspan=3 align='left' bgcolor='white'><b>"+tr("Total time in apnea") + html+="<tr><td colspan=3 align='left' bgcolor='white'><b>"+tr("Total time in apnea") +
QString("</b></td><td colspan=2 bgcolor='white'>%1</td></tr>").arg(QString().sprintf("%02i:%02i:%02i",h,m,s)); QString("</b></td><td colspan=2 bgcolor='white'>%1</td></tr>").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.date().toString(Qt::SystemLocaleShortDate))
.arg(date.toString("HH:mm:ss")) .arg(date.toString("HH:mm:ss"))
.arg(date2.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+="</table>\n"; html+="</table>\n";
// html+="<hr/>"; // html+="<hr/>";

View File

@ -257,7 +257,8 @@ void ExportCSV::on_exportButton_clicked()
int h = time / 3600; int h = time / 3600;
int m = int(time / 60) % 60; int m = int(time / 60) % 60;
int s = int(time) % 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(); float ahi = day->calcAHI();
data += sep + QString::number(ahi, 'f', 3); data += sep + QString::number(ahi, 'f', 3);
@ -301,7 +302,7 @@ void ExportCSV::on_exportButton_clicked()
int h = time / 3600; int h = time / 3600;
int m = int(time / 60) % 60; int m = int(time / 60) % 60;
int s = int(time) % 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); float ahi = sess->count(AllAhiChannels);
//sess->count(CPAP_AllApnea) + sess->count(CPAP_Obstructive) + sess->count(CPAP_Hypopnea) //sess->count(CPAP_AllApnea) + sess->count(CPAP_Obstructive) + sess->count(CPAP_Hypopnea)

View File

@ -296,7 +296,7 @@ void OximeterImport::on_directImportButton_clicked()
// item->setData(Qt::UserRole+2, duration); // item->setData(Qt::UserRole+2, duration);
item->setFlags(item->flags() & ~Qt::ItemIsEditable); 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); ui->tableOxiSessions->setItem(i, 1, item);
item->setFlags(item->flags() & ~Qt::ItemIsEditable); item->setFlags(item->flags() & ~Qt::ItemIsEditable);
@ -740,17 +740,17 @@ void OximeterImport::updateLiveDisplay()
pulse = (*(oximodule->oxirec))[size].pulse; pulse = (*(oximodule->oxirec))[size].pulse;
spo2 = (*(oximodule->oxirec))[size].spo2; spo2 = (*(oximodule->oxirec))[size].spo2;
if (pulse > 0) { if (pulse > 0) {
ui->pulseDisplay->display(QString().sprintf("%3i", pulse)); ui->pulseDisplay->display(QString().asprintf("%3i", pulse));
} else { } else {
ui->pulseDisplay->display("---"); ui->pulseDisplay->display("---");
} }
if (spo2 > 0) { if (spo2 > 0) {
ui->spo2Display->display(QString().sprintf("%2i", spo2)); ui->spo2Display->display(QString().asprintf("%2i", spo2));
} else { } else {
ui->spo2Display->display("--"); 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 m = (duration / 60) % 60;
int s = duration % 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); ui->tableOxiSessions->setItem(row, 1, item);
item->setFlags(item->flags() & ~Qt::ItemIsEditable); item->setFlags(item->flags() & ~Qt::ItemIsEditable);

View File

@ -48,7 +48,7 @@ QString formatTime(float time)
int seconds = time * 3600.0; int seconds = time * 3600.0;
int minutes = (seconds / 60) % 60; int minutes = (seconds / 60) % 60;
//seconds %= 60; //seconds %= 60;
return QString().sprintf("%02i:%02i", hours, minutes); //,seconds); return QString().asprintf("%02i:%02i", hours, minutes); //,seconds);
} }