diff --git a/SrcPony/at90sxx.cpp b/SrcPony/at90sxx.cpp index 08204cb..02c4c5e 100644 --- a/SrcPony/at90sxx.cpp +++ b/SrcPony/at90sxx.cpp @@ -395,8 +395,8 @@ int At90sxx::QueryType(long &type) detected_type = type; } - detected_signature.sprintf("%02X-%02X-%02X", code[0], code[1], code[2]); //snprintf(detected_signature, MAXMSG, "%02X-%02X-%02X", code[0], code[1], code[2]); + detected_signature = QString("%1-%2-%3").arg(code[0], 2, 16, QLatin1Char('0')).arg(code[1], 2, 16, QLatin1Char('0')).arg(code[2], 2, 16, QLatin1Char('0')); rv = type ? OK : DEVICE_UNKNOWN; } diff --git a/SrcPony/bitfield.cpp b/SrcPony/bitfield.cpp index 4838a36..964ec12 100644 --- a/SrcPony/bitfield.cpp +++ b/SrcPony/bitfield.cpp @@ -74,7 +74,7 @@ void BitFieldWidget::initWidget() int bitOffset = vecInfo->at(i).bit; lastBit = bitOffset; QString sDes = vecInfo->at(i).ShortDescr; - itm->setText(0, QString().sprintf("Bit %d, ", bitOffset) + sDes); + itm->setText(0, QString("Bit %1, ").arg(bitOffset) + sDes); if (vecInfo->at(i).LongDescr.length() > 0) { itm->setText(1, vecInfo->at(i).LongDescr); @@ -309,7 +309,7 @@ void BitFieldWidget::setMaskBits(const QString &cMask) // at begin of string only mskName = "^" + mskName + "\\d+"; - qDebug() << cMask << "converted to" << mskName << (bin) << localField << (Qt::dec); + qDebug() << cMask << "converted to" << mskName << (Qt::bin) << localField << (Qt::dec); // search in QTreeWidget the names for (idx = 0; idx < treeWidget->topLevelItemCount(); idx++) diff --git a/SrcPony/blockmdlg.cpp b/SrcPony/blockmdlg.cpp index 662d439..390ae1e 100644 --- a/SrcPony/blockmdlg.cpp +++ b/SrcPony/blockmdlg.cpp @@ -56,9 +56,9 @@ blockDialog::blockDialog(e2CmdWindow *bw, e2AppWinInfo *p, bool readonly, const lblTo->setText(translate(STR_MSGNUMBLOCK)); lblVal->setText(translate(STR_MSGHIGHENDBLK)); - QString str1 = QString().sprintf("%d", (int)((lock >> 4) & 0x0F)); - QString str2 = QString().sprintf("%d", (int)(lock & 0x0F)); - QString str3 = QString().sprintf("%d", (int)(fuse & 0x0F)); + QString str1 = QString("%1").arg((int)((lock >> 4) & 0x0F)); //sprintf("%d", (int)((lock >> 4) & 0x0F)); + QString str2 = QString("%1").arg((int)(lock & 0x0F)); //sprintf("%d", (int)(lock & 0x0F)); + QString str3 = QString("%1").arg((int)(fuse & 0x0F)); //sprintf("%d", (int)(fuse & 0x0F)); txiFrom->setText(str1); txiTo->setText(str2); diff --git a/SrcPony/e2awinfo.cpp b/SrcPony/e2awinfo.cpp index 108a8f0..57a2288 100644 --- a/SrcPony/e2awinfo.cpp +++ b/SrcPony/e2awinfo.cpp @@ -1346,6 +1346,8 @@ QString e2AppWinInfo::Dump(int line, int type) { long idx; long upperlimit; + char lbuf[LINEBUF_SIZE + 1]; + char tmpbuf[16 + 1]; if (!buf_ok) { @@ -1360,17 +1362,13 @@ QString e2AppWinInfo::Dump(int line, int type) { if (type == 0) { - char tmpbuf[16 + 1]; - for (int k = 0; k < hex_per_line; k++) { tmpbuf[k] = isprint(buffer[idx + k]) ? buffer[idx + k] : '.'; } - tmpbuf[hex_per_line] = 0; - linebuf.sprintf(" %06lX) %02X %02X %02X %02X %02X %02X %02X %02X - %02X %02X %02X %02X %02X %02X %02X %02X %s\n", - // snprintf(linebuf, LINEBUF_SIZE, " %06lX) %02X %02X %02X %02X %02X %02X %02X %02X - %02X %02X %02X %02X %02X %02X %02X %02X %s\n", + snprintf(lbuf, LINEBUF_SIZE, " %06lX) %02X %02X %02X %02X %02X %02X %02X %02X - %02X %02X %02X %02X %02X %02X %02X %02X %s\n", idx, buffer[idx + 0], buffer[idx + 1], @@ -1395,13 +1393,11 @@ QString e2AppWinInfo::Dump(int line, int type) } else if (type == 1) { - linebuf.sprintf(" %06lX)", idx); - // snprintf(linebuf, LINEBUF_SIZE, " %06lX)", idx); + snprintf(lbuf, LINEBUF_SIZE, " %06lX)", idx); } else if (type == 2) { - linebuf.sprintf(" %02X %02X %02X %02X %02X %02X %02X %02X - %02X %02X %02X %02X %02X %02X %02X %02X ", - // snprintf(linebuf, LINEBUF_SIZE, " %02X %02X %02X %02X %02X %02X %02X %02X - %02X %02X %02X %02X %02X %02X %02X %02X ", + snprintf(lbuf, LINEBUF_SIZE, " %02X %02X %02X %02X %02X %02X %02X %02X - %02X %02X %02X %02X %02X %02X %02X %02X ", buffer[idx + 0], buffer[idx + 1], buffer[idx + 2], @@ -1423,21 +1419,20 @@ QString e2AppWinInfo::Dump(int line, int type) } else { - char tmpbuf[16 + 1]; - for (int k = 0; k < hex_per_line; k++) { tmpbuf[k] = isprint(buffer[idx + k]) ? buffer[idx + k] : '.'; } - tmpbuf[hex_per_line] = 0; - linebuf.sprintf(" %s\n", tmpbuf); - // snprintf(linebuf, LINEBUF_SIZE, " %s\n", tmpbuf); + snprintf(lbuf, LINEBUF_SIZE, " %s\n", tmpbuf); } - // linebuf[LINEBUF_SIZE - 1] = '\0'; + lbuf[LINEBUF_SIZE] = '\0'; + return QString(lbuf); + } + else + { + return ""; } - - return linebuf; } diff --git a/SrcPony/e2cmdw.cpp b/SrcPony/e2cmdw.cpp index 0b6304e..8aaf6c5 100644 --- a/SrcPony/e2cmdw.cpp +++ b/SrcPony/e2cmdw.cpp @@ -63,7 +63,7 @@ #define STATUSBAR_FORM " Size 0 Bytes CRC 0000h " -#define STATUSBAR_PRINT " Size %5ld Bytes CRC %04Xh %c" +//#define STATUSBAR_PRINT " Size %5ld Bytes CRC %04Xh %c" class e2AppWinInfo; @@ -118,12 +118,12 @@ e2CmdWindow::e2CmdWindow(QWidget *parent) : // to check this fontSize = E2Profile::GetFontSize(); //sysFont.pointSize(); - programStyleSheet = QString().sprintf("font-size: %dpt", fontSize); + programStyleSheet = QString("font-size: %1pt").arg(fontSize); //sprintf("font-size: %dpt", fontSize); if (fontSize == -1) { fontSize = sysFont.pixelSize(); - programStyleSheet = QString().sprintf("font-size: %dpx", fontSize); + programStyleSheet = QString("font-size: %1px").arg(fontSize); //sprintf("font-size: %dpx", fontSize); } if (programStyleSheet.length() > 0) @@ -1464,20 +1464,19 @@ void e2CmdWindow::selectFontSize(QAction *mnu) // for lang menu and for fontsize menu if (sz == -1) { - programStyleSheet = QString().sprintf("font-size: %dpx", fontSize); + programStyleSheet = QString("font-size: %1px").arg(fontSize); //sprintf("font-size: %dpx", fontSize); } else { - programStyleSheet = QString().sprintf("font-size: %dpt", fontSize); + programStyleSheet = QString("font-size: %dpt").arg(fontSize); //sprintf("font-size: %dpt", fontSize); } E2Profile::SetFontSize(fontSize); - QString sSheet2 = QString("QMenu { %1; }").arg(programStyleSheet); - setStyleSheet(programStyleSheet); - // langMenu->setStyleSheet(sSheet2); + //QString sSheet2 = QString("QMenu { %1; }").arg(programStyleSheet); + //langMenu->setStyleSheet(sSheet2); setFontForWidgets(); } @@ -2912,7 +2911,7 @@ int e2CmdWindow::CmdReadCalibration(int idx) if (verbose == verboseAll) { QString str; - str = translate(STR_MSGREADCALIBOK) + QString().sprintf(": 0x%02X (%d)", rval, rval); + str = translate(STR_MSGREADCALIBOK) + QString(": 0x%1 (%2)").arg(rval, 2, 16, QLatin1Char('0')).arg(rval); //sprintf(": 0x%02X (%d)", rval, rval); QMessageBox note(QMessageBox::Information, "Calibration", str, QMessageBox::Ok); note.setStyleSheet(programStyleSheet); @@ -3190,7 +3189,7 @@ int e2CmdWindow::CmdProgram() if (verbose != verboseNo) { QString str; - str = translate(STR_MSGPROGRAMFAIL) + QString().sprintf(" (%d)", result); + str = translate(STR_MSGPROGRAMFAIL) + QString(" (%1)").arg(result); //sprintf(" (%d)", result); QMessageBox note(QMessageBox::Critical, "Program", str, QMessageBox::Close); note.setStyleSheet(programStyleSheet); @@ -4333,7 +4332,7 @@ int e2CmdWindow::CmdRunScript(bool test_mode) if (verbose != verboseNo) { QString str; - str = translate(STR_MSGPROGRAMFAIL) + QString().sprintf(" (%d)", result); + str = translate(STR_MSGPROGRAMFAIL) + QString(" (%1)").arg(result); //sprintf(" (%d)", result); QMessageBox note(QMessageBox::Critical, "Script information", str, QMessageBox::Close); note.setStyleSheet(programStyleSheet); @@ -5278,7 +5277,8 @@ void e2CmdWindow::UpdateStatusBar() if (awip) { QString buf; - buf.sprintf(STATUSBAR_PRINT, GetDevSize(), awip->GetCRC(), awip->IsBufChanged() ? '*' : ' '); + //buf.sprintf(STATUSBAR_PRINT, GetDevSize(), awip->GetCRC(), awip->IsBufChanged() ? '*' : ' '); + buf = QString(" Size %1 Bytes CRC %2h %3").arg(GetDevSize(), 5).arg(awip->GetCRC(), 4, 16, QLatin1Char('0')).arg(awip->IsBufChanged() ? '*' : ' '); lblEEPInfo->setText(buf); lblStringID->setText(awip->GetStringID()); } @@ -6481,7 +6481,7 @@ void e2CmdWindow::Print() t << QString("File: " + GetFileName()); t << QString("Device: " + awip->GetStringID()); t << QString("Note: " + awip->GetComment()); - t << QString().sprintf("Size : %ld Bytes CRC: %04X", GetDevSize(), awip->GetCRC()); + t << QString("Size : %1 Bytes CRC: %2h").arg(GetDevSize()).arg(awip->GetCRC(), 4, 16, QLatin1Char('0')); //sprintf("Size : %ld Bytes CRC: %04X", GetDevSize(), awip->GetCRC()); for (; k < no_line && curRow < 66; k++) { @@ -6501,7 +6501,7 @@ void e2CmdWindow::Print() doc.documentLayout()->setPaintDevice(&printer); - doc.setPageSize(printer.pageRect().size()); // This is necessary if you want to hide the page number + //doc.setPageSize(printer.pageRect().size()); // This is necessary if you want to hide the page number doc.setHtml(str); doc.print(&printer); } diff --git a/SrcPony/e2profil.cpp b/SrcPony/e2profil.cpp index 7d2a771..8ea7a81 100644 --- a/SrcPony/e2profil.cpp +++ b/SrcPony/e2profil.cpp @@ -211,7 +211,7 @@ QStringList E2Profile::GetLastFiles() for (int i = 0; i < 8; i++) { - QString sp = s->value(QString().sprintf("LastFile%d", i), "").toString(); + QString sp = s->value(QString("LastFile%1").arg(i), "").toString(); if (sp.length() == 0) { break; @@ -228,12 +228,12 @@ void E2Profile::SetLastFiles(const QStringList &l) foreach (QString t, l) { - s->setValue(QString().sprintf("LastFile%d", i), t); + s->setValue(QString("LastFile%1").arg(i), t); i++; } // for (; i < 8; i++) // { -// s->setValue(QString().sprintf("LastFile%d", i), ""); +// s->setValue(QString("LastFile%1").arg(i), ""); // } } @@ -243,7 +243,7 @@ QStringList E2Profile::GetLastScripts() for (int i = 0; i < 8; i++) { - QString sp = s->value(QString().sprintf("LastScript%d", i), "").toString(); + QString sp = s->value(QString("LastScript%1").arg(i), "").toString(); res << sp; } @@ -256,12 +256,12 @@ void E2Profile::SetLastScripts(const QStringList &l) foreach (QString t, l) { - s->setValue(QString().sprintf("LastScript%d", i), t); + s->setValue(QString("LastScript%1").arg(i), t); i++; } for (; i < 8; i++) { - s->setValue(QString().sprintf("LastFile%d", i), ""); + s->setValue(QString("LastFile%1").arg(i), ""); } } @@ -329,7 +329,7 @@ void E2Profile::SetI2CBaseAddr(int base_addr) { if (base_addr >= 0x00 && base_addr < 0x100) { - s->setValue("I2CBaseAddress", QString().sprintf("0x%X", base_addr)); + s->setValue("I2CBaseAddress", QString("0x%1").arg(base_addr, 0, 16)); } } @@ -532,21 +532,21 @@ void E2Profile::GetPrinterSettings(QPrinter &p) s->beginGroup("Printer"); p.setPrinterName(s->value("PrinterName").toString()); - p.setPageSize(QPrinter::PaperSize(s->value("PageSize", QPrinter::A4).toInt())); + p.setPageSize(QPageSize(QPageSize::PageSizeId(s->value("PageSize", QPageSize::A4).toInt()))); p.setCollateCopies(s->value("Copies", false).toBool()); p.setColorMode(QPrinter::ColorMode(s->value("ColorMode").toInt())); p.setCopyCount(s->value("CopyCount", 1).toInt()); p.setCreator(s->value("Creator", "").toString()); p.setDocName(s->value("DocName", "ponyprog.pdf").toString()); - p.setDoubleSidedPrinting(s->value("DoubleSide", false).toBool()); + //p.setDoubleSidedPrinting(s->value("DoubleSide", false).toBool()); p.setDuplex(QPrinter::DuplexMode(s->value("Duplex").toInt())); p.setFontEmbeddingEnabled(s->value("FontEmb", false).toBool()); p.setFullPage(s->value("FullPage", false).toBool()); - p.setOrientation(QPrinter::Orientation(s->value("Orientation", QPrinter::Portrait).toInt())); + p.setPageOrientation(QPageLayout::Orientation(s->value("Orientation", QPageLayout::Portrait).toInt())); p.setOutputFileName(s->value("OutputName", "").toString()); p.setOutputFormat(QPrinter::OutputFormat(s->value("OutputFormat", QPrinter::PdfFormat).toInt())); p.setPageOrder(QPrinter::PageOrder(s->value("PageOrder").toInt())); - p.setPaperSize(QPrinter::PaperSize(s->value("PaperSize").toInt())); + //p.setPaperSize(QPrinter::PaperSize(s->value("PaperSize").toInt())); p.setPaperSource(QPrinter::PaperSource(s->value("PaperSource").toInt())); p.setPrintProgram(s->value("PrintProg", "").toString()); p.setPrintRange(QPrinter::PrintRange(s->value("PrintRange").toInt())); @@ -557,8 +557,7 @@ void E2Profile::GetPrinterSettings(QPrinter &p) top = (s->value("TopMargin", 15).toFloat()); right = (s->value("RightMargin", 15).toFloat()); bottom = (s->value("BottomMargin", 15).toFloat()); - - p.setPageMargins(left, top, right, bottom, QPrinter::Millimeter); + p.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Unit::Millimeter); s->endGroup(); } @@ -568,33 +567,31 @@ void E2Profile::SetPrinterSettings(QPrinter &p) s->beginGroup("Printer"); s->setValue("PrinterName", p.printerName()); - s->setValue("PageSize", p.pageSize()); + s->setValue("PageSize", p.pageLayout().pageSize().id()); s->setValue("Copies", p.collateCopies()); s->setValue("ColorMode", p.colorMode()); s->setValue("CopyCount", p.copyCount()); s->setValue("Creator", p.creator()); s->setValue("DocName", p.docName()); - s->setValue("DoubleSide", p.doubleSidedPrinting()); + //s->setValue("DoubleSide", p.doubleSidedPrinting()); s->setValue("Duplex", p.duplex()); s->setValue("FontEmb", p.fontEmbeddingEnabled()); s->setValue("FullPage", p.fullPage()); - s->setValue("Orientation", p.orientation()); + s->setValue("Orientation", p.pageLayout().orientation()); s->setValue("OutputName", p.outputFileName()); s->setValue("OutputFormat", p.outputFormat()); s->setValue("PageOrder", p.pageOrder()); - s->setValue("PaperSize", p.paperSize()); + //s->setValue("PaperSize", p.paperSize()); s->setValue("PaperSource", p.paperSource()); s->setValue("PrintProg", p.printProgram()); s->setValue("PrintRange", p.printRange()); s->setValue("Resolution", p.resolution()); - qreal left, top, right, bottom; - p.getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter); - - s->setValue("LeftMargin", left); - s->setValue("TopMargin", top); - s->setValue("BottomMargin", bottom); - s->setValue("RightMargin", right); + QMarginsF qmf(p.pageLayout().margins()); + s->setValue("LeftMargin", qmf.left()); + s->setValue("TopMargin", qmf.top()); + s->setValue("BottomMargin", qmf.bottom()); + s->setValue("RightMargin", qmf.right()); s->endGroup(); } @@ -767,7 +764,7 @@ int E2Profile::GetSerialNumAddress(long &start, int &size, bool &mtype) void E2Profile::SetSerialNumAddress(unsigned long start, int size, bool mtype) { s->beginGroup("SerialNumber"); - s->setValue("Address", QString().sprintf("0x%04lX", start)); + s->setValue("Address", QString("0x%1").arg(start, 4, 16, QLatin1Char('0'))); //sprintf("0x%04lX", start) if (size >= 1) { @@ -1392,7 +1389,8 @@ void E2Profile::SetCalibrationAddress(bool enabled, unsigned long start, int siz { s->beginGroup("OscillatorCalibration"); s->setValue("Enabled", enabled); - s->setValue("StartAddress", QString().sprintf("0x%04lX", start)); + s->setValue("StartAddress", QString("0x%1").arg(start, 4, 16, QLatin1Char('0'))); //sprintf("0x%04lX", start) + if (size >= 1) { s->setValue("Size", size); @@ -1459,27 +1457,21 @@ void E2Profile::SetCOMAddress(unsigned int com1, unsigned int com2, unsigned int if (com1 > 0) { + str = QString("%1").arg(com1, 0, 16); + if (com2 > 0) { + str += QString(",%1").arg(com2, 0, 16); + if (com3 > 0) { + str += QString(",%1").arg(com3, 0, 16); + if (com4 > 0) { - str.sprintf("%X,%X,%X,%X", com1, com2, com3, com4); - } - else - { - str.sprintf("%X,%X,%X", com1, com2, com3); + str += QString(",%1").arg(com4, 0, 16); } } - else - { - str.sprintf("%X,%X", com1, com2); - } - } - else - { - str.sprintf("%X", com1); } s->setValue("LegacyPorts/COMPorts", str); @@ -1509,20 +1501,16 @@ void E2Profile::SetLPTAddress(unsigned int lpt1, unsigned int lpt2, unsigned int if (lpt1 > 0) { + str = QString("%1").arg(lpt1, 0, 16); + if (lpt2 > 0) { + str += QString(",%1").arg(lpt2, 0, 16); + if (lpt3 > 0) { - str.sprintf("%X,%X,%X", lpt1, lpt2, lpt3); + str += QString(",%1").arg(lpt3, 0, 16); } - else - { - str.sprintf("%X,%X", lpt1, lpt2); - } - } - else - { - str.sprintf("%X", lpt1); } s->setValue("LegacyPorts/LPTPorts", str); diff --git a/SrcPony/filldlg.cpp b/SrcPony/filldlg.cpp index c0b8048..8d390bc 100644 --- a/SrcPony/filldlg.cpp +++ b/SrcPony/filldlg.cpp @@ -68,13 +68,13 @@ FillDialog::FillDialog(QWidget *bw, long &cfrom, long &cto, int &cval, long max_ //TODO: should get strings from E2Profile settings, not local variables QString str; - str = QString().sprintf("0x%04lX", mFrom); + str = QString("0x%1").arg(mFrom, 4, 16, QLatin1Char('0')); //sprintf("0x%04lX", mFrom); txiFrom->setText(str); - str = QString().sprintf("0x%04lX", mTo); + str = QString("0x%1").arg(mTo, 4, 16, QLatin1Char('0')); //sprintf("0x%04lX", mTo); txiTo->setText(str); - str = QString().sprintf("0x%02X", mVal); + str = QString("0x%1").arg(mVal, 2, 16, QLatin1Char('0')); //sprintf("0x%02X", mVal); txiVal->setText(str); connect(pushOk, SIGNAL(clicked()), this, SLOT(onOk())); diff --git a/SrcPony/fusemdlg.cpp b/SrcPony/fusemdlg.cpp index 8b315de..b38a562 100644 --- a/SrcPony/fusemdlg.cpp +++ b/SrcPony/fusemdlg.cpp @@ -235,11 +235,11 @@ void fuseModalDialog::displayBitFields() QString s; if (fuseEnabled == true) { - s = QString().sprintf("Fuse: 0x%08X ", fuseBits); + s = QString("Fuse: 0x%1 ").arg(fuseBits, 8, 16, QLatin1Char('0')); //sprintf("Fuse: 0x%08X ", fuseBits); } if (lockEnabled == true) { - s += QString().sprintf("Lock: 0x%08X", lockBits); + s += QString("Lock: 0x%1").arg(lockBits, 8, 16, QLatin1Char('0')); //sprintf("Lock: 0x%08X", lockBits); } labelFuseLock->setText(s); } diff --git a/SrcPony/infomdlg.cpp b/SrcPony/infomdlg.cpp index e77b76c..90baa44 100644 --- a/SrcPony/infomdlg.cpp +++ b/SrcPony/infomdlg.cpp @@ -67,11 +67,11 @@ e24xx_infoModalDialog::e24xx_infoModalDialog(QWidget *bw, int rlv, uint16_t crc, lblVal->setText(translate(STR_MSGFLASHSIZE)); // flash size label QString str; - str = QString().sprintf("%04Xh", crc); + str = QString("%1h").arg(crc, 4, 16, QLatin1Char('0')); //sprintf("%04Xh", crc); txiTo->setText(str); txiTo->setReadOnly(true); - str = QString().sprintf("%ld Byte", size); + str = QString("%1 Byte").arg(size); //sprintf("%ld Byte", size); txiVal->setText(str); txiVal->setReadOnly(true); @@ -118,15 +118,15 @@ other_infoModalDialog::other_infoModalDialog(QWidget *bw, long fsize, long esize lblTo->setText(translate(STR_MSGEEPSIZE)); // size label lblVal->setText(translate(STR_MSGFLASHSIZE)); // flash size label - str = QString().sprintf("%04Xh", crc); + str = QString("%1h").arg(crc, 4, 16, QLatin1Char('0')); //sprintf("%04Xh", crc); txiFrom->setText(str); txiFrom->setReadOnly(true); - str = QString().sprintf("%ld Byte", fsize); + str = QString("%1 Byte").arg(fsize); //sprintf("%ld Byte", fsize); txiTo->setText(str); txiTo->setReadOnly(true); - str = QString().sprintf("%ld Byte", esize); + str = QString("%1 Byte").arg(esize); //sprintf("%ld Byte", esize); txiVal->setText(str); txiVal->setReadOnly(true); diff --git a/SrcPony/intfbuf.cpp b/SrcPony/intfbuf.cpp index a8c2226..07dea85 100644 --- a/SrcPony/intfbuf.cpp +++ b/SrcPony/intfbuf.cpp @@ -92,28 +92,26 @@ int IntelFileBuf::WriteRecord(QFile &fh, uint8_t *bptr, long curaddr, long recsi int len = recsize; QTextStream out(&fh); - out << ":"; - - //byte count - out << QString().sprintf("%02X", len & 0xFF); + //start + byte count + out << QString(":%1").arg(len & 0xFF, 2, 16, QLatin1Char('0')); //sprintf("%02X", len & 0xFF) checksum += len & 0xFF; //addr field - out << QString().sprintf("%04lX", curaddr & 0xFFFF); + out << QString("%1").arg(curaddr & 0xFFFF, 4, 16, QLatin1Char('0')); //sprintf("%04lX", curaddr & 0xFFFF); checksum += (curaddr >> 8) & 0xFF; checksum += curaddr & 0xFF; //record type - out << QString().sprintf("%02X", fmt & 0xFF); + out << QString("%1").arg(fmt & 0xFF, 2, 16, QLatin1Char('0')); //sprintf("%02X", fmt & 0xFF); checksum += fmt & 0xFF; for (j = 0; j < recsize; j++) { - out << QString().sprintf("%02X", bptr[curaddr + j]); + out << QString("%1").arg(bptr[curaddr + j], 2, 16, QLatin1Char('0')); //sprintf("%02X", bptr[curaddr + j]); checksum += bptr[curaddr + j]; } - out << QString().sprintf("%02X\n", (~checksum + 1) & 0xFF); + out << QString("%1\n").arg((~checksum + 1) & 0xFF, 2, 16, QLatin1Char('0')); //sprintf("%02X\n", (~checksum + 1) & 0xFF); } return rval; @@ -124,22 +122,20 @@ int IntelFileBuf::WriteAddressRecord(QFile &fh, long curaddr, bool linear_addres int rval = 1; QTextStream out(&fh); - out << ":"; - int checksum = 0; int len = 2; - //byte count - out << QString().sprintf("%02X", len & 0xFF); + //start + byte count + out << QString(":%1").arg(len & 0xFF, 2, 16, QLatin1Char('0')); //sprintf("%02X", len & 0xFF); checksum += len & 0xFF; //addr field - out << QString().sprintf("%04X", 0); + out << QString("0000"); //sprintf("%04X", 0); if (linear_address) { //record type - out << QString().sprintf("%02X", LIN_ADDR_RECORD & 0xFF); + out << QString("%1").arg(LIN_ADDR_RECORD & 0xFF, 2, 16, QLatin1Char('0')); //sprintf("%02X", LIN_ADDR_RECORD & 0xFF); checksum += LIN_ADDR_RECORD & 0xFF; //adjust extended linear address @@ -148,18 +144,18 @@ int IntelFileBuf::WriteAddressRecord(QFile &fh, long curaddr, bool linear_addres else { //record type - out << QString().sprintf("%02X", SEG_ADDR_RECORD & 0xFF); + out << QString("%1").arg(SEG_ADDR_RECORD & 0xFF, 2, 16, QLatin1Char('0')); //sprintf("%02X", SEG_ADDR_RECORD & 0xFF); checksum += SEG_ADDR_RECORD & 0xFF; //adjust extended segmented address curaddr >>= 4; } - out << QString().sprintf("%04lX", curaddr & 0xFFFF); + out << QString("%1").arg(curaddr & 0xFFFF, 4, 16, QLatin1Char('0')); //sprintf("%04lX", curaddr & 0xFFFF); checksum += (curaddr >> 8) & 0xFF; checksum += curaddr & 0xFF; - out << QString().sprintf("%02X\n", (~checksum + 1) & 0xFF); + out << QString("%1\n").arg((~checksum + 1) & 0xFF, 2, 16, QLatin1Char('0')); //sprintf("%02X\n", (~checksum + 1) & 0xFF); return rval; } diff --git a/SrcPony/linuxsysfsint.cpp b/SrcPony/linuxsysfsint.cpp index 2b0662f..0ecfcfc 100644 --- a/SrcPony/linuxsysfsint.cpp +++ b/SrcPony/linuxsysfsint.cpp @@ -69,7 +69,8 @@ static int gpio_open(unsigned int gpio, bool out_dir) int rval; //trying with gpio command (you need wiringPi installed) - buf.sprintf("export %u %s", gpio, out_dir ? "out" : "in"); + //buf.sprintf("export %u %s", gpio, out_dir ? "out" : "in"); + buf = QString("export %1 ").arg(gpio) + QString(out_dir ? "out" : "in"); // rval = system(buf.toLatin1().data()); rval = QProcess::execute("gpio", buf.split(" ")); @@ -97,7 +98,8 @@ static int gpio_open(unsigned int gpio, bool out_dir) if (rval == 0) { - buf.sprintf("%s/gpio%d/direction", SYSFS_GPIO_DIR, gpio); + //buf.sprintf("%s/gpio%d/direction", SYSFS_GPIO_DIR, gpio); + buf = QString(SYSFS_GPIO_DIR) + QString("/gpio%1/direction").arg(gpio); fd = open(buf.toLatin1().data(), O_WRONLY); if (fd < 0) @@ -131,7 +133,8 @@ static int gpio_open(unsigned int gpio, bool out_dir) { int fd; - buf.sprintf("%s/gpio%d/value", SYSFS_GPIO_DIR, gpio); + //buf.sprintf("%s/gpio%d/value", SYSFS_GPIO_DIR, gpio); + buf = QString(SYSFS_GPIO_DIR) + QString("/gpio%1/value").arg(gpio); fd = open(buf.toLatin1().data(), out_dir ? O_WRONLY : O_RDONLY); if (fd < 0) @@ -163,7 +166,8 @@ static int gpio_close(unsigned int gpio, int fd) } //trying with gpio command (you need wiringPi installed) - buf.sprintf("unexport %u", gpio); + //buf.sprintf("unexport %u", gpio); + buf = QString("unexport %1").arg(gpio); // rval = system(buf.toLatin1().data()); rval = QProcess::execute("gpio", buf.split(" ")); diff --git a/SrcPony/motsfbuf.cpp b/SrcPony/motsfbuf.cpp index 07f51e1..e76dfbf 100644 --- a/SrcPony/motsfbuf.cpp +++ b/SrcPony/motsfbuf.cpp @@ -142,23 +142,23 @@ int MotorolaSFileBuf::WriteRecord(QTextStream &outs, uint8_t *bptr, long curaddr int checksum = 0; //type field - outs << QString().sprintf("S%c", fmt); + outs << QString("S%1").arg(QLatin1Char(fmt)); //sprintf("S%c", fmt); //len field - outs << QString().sprintf("%02X", len & 0xFF); + outs << QString("%1").arg(len & 0xFF, 2, 16, QLatin1Char('0')); //sprintf("%02X", len & 0xFF); checksum += len & 0xFF; //addr field if (fmt == DATA_RECORD24 || fmt == END_RECORD24) { - outs << QString().sprintf("%06lX", curaddr & 0xFFFFFF); + outs << QString("%1").arg(curaddr & 0xFFFFFF, 6, 16, QLatin1Char('0')); //sprintf("%06lX", curaddr & 0xFFFFFF); checksum += (curaddr >> 16) & 0xFF; checksum += (curaddr >> 8) & 0xFF; checksum += curaddr & 0xFF; } else if (fmt == DATA_RECORD32 || fmt == END_RECORD32) { - outs << QString().sprintf("%08lX", curaddr); + outs << QString("%1").arg(curaddr, 8, 16, QLatin1Char('0')); //sprintf("%08lX", curaddr); checksum += (curaddr >> 24) & 0xFF; checksum += (curaddr >> 16) & 0xFF; checksum += (curaddr >> 8) & 0xFF; @@ -166,18 +166,18 @@ int MotorolaSFileBuf::WriteRecord(QTextStream &outs, uint8_t *bptr, long curaddr } else //all other have a 16 bit address field { - outs << QString().sprintf("%04lX", curaddr & 0xFFFF); + outs << QString("%1").arg(curaddr & 0xFFFF, 4, 16, QLatin1Char('0')); //sprintf("%04lX", curaddr & 0xFFFF); checksum += (curaddr >> 8) & 0xFF; checksum += curaddr & 0xFF; } for (j = 0; j < recsize; j++) { - outs << QString().sprintf("%02X", bptr[curaddr + j]); + outs << QString("%1").arg(bptr[curaddr + j], 2, 16, QLatin1Char('0')); //sprintf("%02X", bptr[curaddr + j]); checksum += bptr[curaddr + j]; } - outs << QString().sprintf("%02X\n", ~checksum & 0xFF); + outs << QString("%1\n").arg(~checksum & 0xFF, 2, 16, QLatin1Char('0')); //sprintf("%02X\n", ~checksum & 0xFF); } return rval; diff --git a/SrcPony/sernumdlg.cpp b/SrcPony/sernumdlg.cpp index 83b7f90..9f756a0 100644 --- a/SrcPony/sernumdlg.cpp +++ b/SrcPony/sernumdlg.cpp @@ -60,9 +60,9 @@ SerNumDialog::SerNumDialog(QWidget *bw, const QString title) : size = 4; } - txiLoc->setText(QString().sprintf("0x%04lX", loc)); - txiLen->setText(QString().sprintf("%d", size)); - txiVal->setText(QString().sprintf("%lu", val)); + txiLoc->setText(QString("0x%1").arg(loc, 4, 16, QLatin1Char('0'))); //sprintf("0x%04lX", loc)); + txiLen->setText(QString("%1").arg(size)); //sprintf("%d", size)); + txiVal->setText(QString("%1").arg(val)); //sprintf("%lu", val)); chkMemOffset->setChecked(memtype); chkAutoInc->setChecked(autoinc); @@ -204,8 +204,8 @@ OscCalibDialog::OscCalibDialog(QWidget *bw, e2AppWinInfo *aw, const QString titl loc = (loc < 0) ? 0 : loc; - txiLoc->setText(QString().sprintf("0x%04lX", loc)); - txiVal->setText(QString().sprintf("%d", val)); + txiLoc->setText(QString("0x%1").arg(loc, 4, 16, QLatin1Char('0'))); //sprintf("0x%04lX", loc)); + txiVal->setText(QString("%1").arg(val)); //sprintf("%d", val)); chkMemOffset->setChecked(memtype); chkEnabled->setChecked(enabled); @@ -272,7 +272,7 @@ void OscCalibDialog::onRead() int val = awip->ReadOscCalibration(); if (val >= 0) { - txiVal->setText(QString().sprintf("0x%02X", val)); + txiVal->setText(QString("0x%1").arg(val, 2, 16, QLatin1Char('0'))); //sprintf("0x%02X", val)); } else { diff --git a/ponyprog.pro b/ponyprog.pro index 2451bc7..f46b5df 100644 --- a/ponyprog.pro +++ b/ponyprog.pro @@ -342,6 +342,7 @@ CONFIG(debug, debug|release) { # -Wall are already on the command line (where does it come from?) # for old GCC -std=c++11 move to -std=c++0x +#QMAKE_CXXFLAGS += -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing QMAKE_CXXFLAGS += -Wno-unused-parameter unix: QMAKE_CXXFLAGS += -std=c++11