From 06a54ba40c9d126853c841c7166f9a0f6aaa355d Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 1 Oct 2015 18:34:03 +0300 Subject: [PATCH] Use qUtf8Printable. --HG-- branch : develop --- src/app/valentina/core/vapplication.cpp | 18 +++++----- src/app/valentina/mainwindow.cpp | 36 +++++++++---------- src/app/valentina/xml/vpattern.cpp | 16 ++++----- src/libs/ifc/xml/vdomdocument.cpp | 2 +- .../drawTools/toolpoint/vabstractpoint.cpp | 4 +-- src/libs/vtools/undocommands/adddet.cpp | 4 +-- src/libs/vtools/undocommands/adddetnode.cpp | 4 +-- .../vtools/undocommands/adduniondetails.cpp | 4 +-- src/test/ValentinaTest/abstracttest.cpp | 9 ++--- .../ValentinaTest/tst_measurementregexp.cpp | 11 +++--- 10 files changed, 55 insertions(+), 53 deletions(-) diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index ed54c79f1..213d49164 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -250,7 +250,7 @@ void VApplication::NewValentina(const QString &fileName) qCDebug(vApp, "Open new detached process."); if (fileName.isEmpty()) { - qCDebug(vApp, "New process without arguments. program = %s", qApp->applicationFilePath().toUtf8().constData()); + qCDebug(vApp, "New process without arguments. program = %s", qUtf8Printable(qApp->applicationFilePath())); // Path can contain spaces. if (QProcess::startDetached("\""+qApp->applicationFilePath()+"\"")) { @@ -264,7 +264,7 @@ void VApplication::NewValentina(const QString &fileName) else { const QString run = QString("\"%1\" \"%2\"").arg(qApp->applicationFilePath()).arg(fileName); - qCDebug(vApp, "New process with arguments. program = %s", run.toUtf8().constData()); + qCDebug(vApp, "New process with arguments. program = %s", qUtf8Printable(run)); if (QProcess::startDetached(run)) { qCDebug(vApp, "The process was started successfully."); @@ -471,17 +471,17 @@ void VApplication::BeginLogging() { out.reset(new QTextStream(lockLog->GetProtected().get())); qInstallMessageHandler(noisyFailureMsgHandler); - qCDebug(vApp, "Log file %s was locked.", LogPath().toUtf8().constData()); + qCDebug(vApp, "Log file %s was locked.", qUtf8Printable(LogPath())); } else { qCDebug(vApp, "Error opening log file \'%s\'. All debug output redirected to console.", - LogPath().toUtf8().constData()); + qUtf8Printable(LogPath())); } } else { - qCDebug(vApp, "Failed to lock %s", LogPath().toUtf8().constData()); + qCDebug(vApp, "Failed to lock %s", qUtf8Printable(LogPath())); } } @@ -508,16 +508,16 @@ void VApplication::ClearOldLogs() const { if (tmp.GetProtected()->remove()) { - qCDebug(vApp, "Deleted %s", info.absoluteFilePath().toUtf8().constData()); + qCDebug(vApp, "Deleted %s", qUtf8Printable(info.absoluteFilePath())); } else { - qCDebug(vApp, "Could not delete %s", info.absoluteFilePath().toUtf8().constData()); + qCDebug(vApp, "Could not delete %s", qUtf8Printable(info.absoluteFilePath())); } } else { - qCDebug(vApp, "Failed to lock %s", info.absoluteFilePath().toUtf8().constData()); + qCDebug(vApp, "Failed to lock %s", qUtf8Printable(info.absoluteFilePath())); } } } @@ -730,7 +730,7 @@ void VApplication::GatherLogs() const } else { - qCDebug(vApp, "Failed to lock %s", info.absoluteFilePath().toUtf8().constData()); + qCDebug(vApp, "Failed to lock %s", qUtf8Printable(info.absoluteFilePath()))); } } } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index f25dc6a7d..d046cd2d0 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -146,11 +146,11 @@ void MainWindow::NewPP() { qCDebug(vMainWindow, "New PP."); QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1); - qCDebug(vMainWindow, "Generated PP name: %s", patternPieceName.toUtf8().constData()); + qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName)); qCDebug(vMainWindow, "PP count %d", comboBoxDraws->count()); patternPieceName = PatternPieceName(patternPieceName); - qCDebug(vMainWindow, "PP name: %s", patternPieceName.toUtf8().constData()); + qCDebug(vMainWindow, "PP name: %s", qUtf8Printable(patternPieceName)); if (patternPieceName.isEmpty()) { qCDebug(vMainWindow, "Name empty."); @@ -165,7 +165,7 @@ void MainWindow::AddPP(const QString &PPName) { if (doc->appendPP(PPName) == false) { - qCDebug(vMainWindow, "Error creating pattern piece with the name %s.", PPName.toUtf8().constData()); + qCDebug(vMainWindow, "Error creating pattern piece with the name %s.", qUtf8Printable(PPName)); return; } comboBoxDraws->blockSignals(true); @@ -1899,11 +1899,11 @@ bool MainWindow::SaveAs() if (lock->IsLocked()) { - qCDebug(vMainWindow, "Pattern file %s was locked.", fileName.toUtf8().constData()); + qCDebug(vMainWindow, "Pattern file %s was locked.", qUtf8Printable(fileName)); } else { - qCDebug(vMainWindow, "Failed to lock %s", fileName.toUtf8().constData()); + qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName)); qCDebug(vMainWindow, "Error type: %d", lock->GetLockError()); if (lock->GetLockError() == QLockFile::LockFailedError) { @@ -1972,7 +1972,7 @@ void MainWindow::Open() //Absolute path to last open file dir = QFileInfo(files.first()).absolutePath(); } - qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", dir.toUtf8().constData()); + qCDebug(vMainWindow, "Run QFileDialog::getOpenFileName: dir = %s.", qUtf8Printable(dir)); const QString filePath = QFileDialog::getOpenFileName(this, tr("Open file"), dir, filter); if (filePath.isEmpty()) { @@ -2085,7 +2085,7 @@ void MainWindow::FileClosedCorrect() { autofile.remove(); } - qCDebug(vMainWindow, "File %s closed correct.", curFile.toUtf8().constData()); + qCDebug(vMainWindow, "File %s closed correct.", qUtf8Printable(curFile)); } //--------------------------------------------------------------------------------------------------------------------- @@ -2359,7 +2359,7 @@ void MainWindow::New() { qCDebug(vMainWindow, "New PP."); QString patternPieceName = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1); - qCDebug(vMainWindow, "Generated PP name: %s", patternPieceName.toUtf8().constData()); + qCDebug(vMainWindow, "Generated PP name: %s", qUtf8Printable(patternPieceName)); qCDebug(vMainWindow, "First PP"); DialogNewPattern newPattern(pattern, patternPieceName, this); @@ -2367,7 +2367,7 @@ void MainWindow::New() { patternPieceName = newPattern.name(); qApp->setPatternUnit(newPattern.PatternUnit()); - qCDebug(vMainWindow, "PP name: %s", patternPieceName.toUtf8().constData()); + qCDebug(vMainWindow, "PP name: %s", qUtf8Printable(patternPieceName)); } else { @@ -2597,7 +2597,7 @@ void MainWindow::MinimumScrollBar() */ bool MainWindow::SavePattern(const QString &fileName, QString &error) { - qCDebug(vMainWindow, "Saving pattern file %s.", fileName.toUtf8().constData()); + qCDebug(vMainWindow, "Saving pattern file %s.", qUtf8Printable(fileName)); QFileInfo tempInfo(fileName); const QString mPath = doc->MPath(); @@ -2613,14 +2613,14 @@ bool MainWindow::SavePattern(const QString &fileName, QString &error) { setCurrentFile(fileName); helpLabel->setText(tr("File saved")); - qCDebug(vMainWindow, "File %s saved.", fileName.toUtf8().constData()); + qCDebug(vMainWindow, "File %s saved.", qUtf8Printable(fileName)); PatternWasModified(result); } } else { doc->SetPath(mPath); - qCDebug(vMainWindow, "Could not save file %s. %s.", fileName.toUtf8().constData(), error.toUtf8().constData()); + qCDebug(vMainWindow, "Could not save file %s. %s.", qUtf8Printable(fileName), qUtf8Printable(error)); } return result; } @@ -2649,7 +2649,7 @@ void MainWindow::AutoSavePattern() */ void MainWindow::setCurrentFile(const QString &fileName) { - qCDebug(vMainWindow, "Set current name to \"%s\"", fileName.toUtf8().constData()); + qCDebug(vMainWindow, "Set current name to \"%s\"", qUtf8Printable(fileName)); curFile = fileName; qApp->getUndoStack()->setClean(); @@ -3103,7 +3103,7 @@ MainWindow::~MainWindow() */ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasureFile) { - qCDebug(vMainWindow, "Loading new file %s.", fileName.toUtf8().constData()); + qCDebug(vMainWindow, "Loading new file %s.", qUtf8Printable(fileName)); //We have unsaved changes or load more then one file per time if (OpenNewValentina(fileName)) @@ -3123,11 +3123,11 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu if (lock->IsLocked()) { - qCDebug(vMainWindow, "Pattern file %s was locked.", fileName.toUtf8().constData()); + qCDebug(vMainWindow, "Pattern file %s was locked.", qUtf8Printable(fileName)); } else { - qCDebug(vMainWindow, "Failed to lock %s", fileName.toUtf8().constData()); + qCDebug(vMainWindow, "Failed to lock %s", qUtf8Printable(fileName)); qCDebug(vMainWindow, "Error type: %d", lock->GetLockError()); if (lock->GetLockError() == QLockFile::LockFailedError) { @@ -3342,8 +3342,8 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args) else { qCDebug(vMainWindow, "Could not copy %s.autosave to %s %s", - restoreFiles.at(i).toUtf8().constData(), restoreFiles.at(i).toUtf8().constData(), - error.toUtf8().constData()); + qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(restoreFiles.at(i)), + qUtf8Printable(error)); } } } diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 5bb77ab59..1be9b2962 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -172,7 +172,7 @@ void VPattern::Parse(const Document &parse) qCDebug(vXML, "Tag gradation."); break; default: - qCDebug(vXML, "Wrong tag name %s", domElement.tagName().toUtf8().constData()); + qCDebug(vXML, "Wrong tag name %s", qUtf8Printable(domElement.tagName())); break; } } @@ -197,7 +197,7 @@ void VPattern::setCurrentData() if (CountPP() > 1)//don't need upadate data if we have only one pattern piece { qCDebug(vXML, "Setting current data"); - qCDebug(vXML, "Current PP name %s", nameActivPP.toUtf8().constData()); + qCDebug(vXML, "Current PP name %s", qUtf8Printable(nameActivPP)); qCDebug(vXML, "PP count %d", CountPP()); quint32 id = 0; @@ -218,11 +218,11 @@ void VPattern::setCurrentData() if (id == NULL_ID) { qCDebug(vXML, "Could not find record for this current pattern piece %s", - nameActivPP.toUtf8().constData()); + qUtf8Printable(nameActivPP)); const VToolRecord tool = history.at(history.size()-1); id = tool.getId(); - qCDebug(vXML, "Taking record with id %u from PP %s", id, tool.getNameDraw().toUtf8().constData()); + qCDebug(vXML, "Taking record with id %u from PP %s", id, qUtf8Printable(tool.getNameDraw())); if (id == NULL_ID) { qCDebug(vXML, "Bad id for last record in history."); @@ -394,7 +394,7 @@ void VPattern::LiteParseTree(const Document &parse) // Restore name current pattern piece nameActivPP = namePP; - qCDebug(vXML, "Current pattern piece %s", nameActivPP.toUtf8().constData()); + qCDebug(vXML, "Current pattern piece %s", qUtf8Printable(nameActivPP)); setCurrentData(); emit FullUpdateFromFile(); // Recalculate scene rect @@ -2375,7 +2375,7 @@ QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedNa } ++i; } - qCDebug(vXML, "Point label: %s", name.toUtf8().constData()); + qCDebug(vXML, "Point label: %s", qUtf8Printable(name)); return name; } else if (type == LabelType::NewLabel) @@ -2383,7 +2383,7 @@ QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedNa if (drawList.isEmpty()) { const QString label = GetLabelBase(0); - qCDebug(vXML, "Point label: %s", label.toUtf8().constData()); + qCDebug(vXML, "Point label: %s", qUtf8Printable(label)); return label; } @@ -2411,7 +2411,7 @@ QString VPattern::GenerateLabel(const LabelType &type, const QString &reservedNa break; } } while (data->IsUnique(name) == false || name == reservedName); - qCDebug(vXML, "Point label: %s", name.toUtf8().constData()); + qCDebug(vXML, "Point label: %s", qUtf8Printable(name)); return name; } qCDebug(vXML, "Got unknow type %d", static_cast(type)); diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index aecf7b798..56fed5819 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -432,7 +432,7 @@ void VDomDocument::CollectId(const QDomElement &node, QVector &vector) */ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName) { - qCDebug(vXML, "Validation xml file %s.", fileName.toUtf8().constData()); + qCDebug(vXML, "Validation xml file %s.", qUtf8Printable(fileName)); QFile pattern(fileName); if (pattern.open(QIODevice::ReadOnly) == false) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.cpp index 464d4989e..c021dd126 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.cpp @@ -72,8 +72,8 @@ QString VAbstractPoint::PointName(quint32 id) const } catch (const VExceptionBadId &e) { - qCDebug(vTool, "Error! Couldn't get point name. %s %s", e.ErrorMessage().toUtf8().constData(), - e.DetailedInformation().toUtf8().constData()); + qCDebug(vTool, "Error! Couldn't get point name. %s %s", qUtf8Printable(e.ErrorMessage()), + qUtf8Printable(e.DetailedInformation())); return QString("");// Return empty string for property browser } } diff --git a/src/libs/vtools/undocommands/adddet.cpp b/src/libs/vtools/undocommands/adddet.cpp index 0e8cf666d..7ecc54b3d 100644 --- a/src/libs/vtools/undocommands/adddet.cpp +++ b/src/libs/vtools/undocommands/adddet.cpp @@ -66,7 +66,7 @@ void AddDet::undo() } else { - qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagDetails.toUtf8().constData()); + qCDebug(vUndo, "Can't find tag %s.", qUtf8Printable(VAbstractPattern::TagDetails)); return; } emit NeedFullParsing(); @@ -85,7 +85,7 @@ void AddDet::redo() } else { - qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagDetails.toUtf8().constData()); + qCDebug(vUndo, "Can't find tag %s.", qUtf8Printable(VAbstractPattern::TagDetails)); return; } RedoFullParsing(); diff --git a/src/libs/vtools/undocommands/adddetnode.cpp b/src/libs/vtools/undocommands/adddetnode.cpp index 5383d7368..443b449b8 100644 --- a/src/libs/vtools/undocommands/adddetnode.cpp +++ b/src/libs/vtools/undocommands/adddetnode.cpp @@ -65,7 +65,7 @@ void AddDetNode::undo() } else { - qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagModeling.toUtf8().constData()); + qCDebug(vUndo, "Can't find tag %s.", qUtf8Printable(VAbstractPattern::TagModeling)); return; } } @@ -82,7 +82,7 @@ void AddDetNode::redo() } else { - qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagModeling.toUtf8().constData()); + qCDebug(vUndo, "Can't find tag %s.", qUtf8Printable(VAbstractPattern::TagModeling)); return; } } diff --git a/src/libs/vtools/undocommands/adduniondetails.cpp b/src/libs/vtools/undocommands/adduniondetails.cpp index 15b42c47a..fdd4a286c 100644 --- a/src/libs/vtools/undocommands/adduniondetails.cpp +++ b/src/libs/vtools/undocommands/adduniondetails.cpp @@ -65,7 +65,7 @@ void AddUnionDetails::undo() } else { - qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagModeling.toUtf8().constData()); + qCDebug(vUndo, "Can't find tag %s.", qUtf8Printable(VAbstractPattern::TagModeling)); return; } emit NeedFullParsing(); @@ -83,7 +83,7 @@ void AddUnionDetails::redo() } else { - qCDebug(vUndo, "Can't find tag %s.", VAbstractPattern::TagModeling.toUtf8().constData()); + qCDebug(vUndo, "Can't find tag %s.", qUtf8Printable(VAbstractPattern::TagModeling)); return; } RedoFullParsing(); diff --git a/src/test/ValentinaTest/abstracttest.cpp b/src/test/ValentinaTest/abstracttest.cpp index 5f5f0221d..1183ee1f5 100644 --- a/src/test/ValentinaTest/abstracttest.cpp +++ b/src/test/ValentinaTest/abstracttest.cpp @@ -27,6 +27,7 @@ *************************************************************************/ #include "abstracttest.h" +#include "../vmisc/logging.h" #include @@ -79,7 +80,7 @@ bool AbstractTest::Run(const QString &program, const QStringList &arguments) if (not info.exists()) { const QString msg = QString("Can't find binary.\n%1").arg(parameters); - QWARN(msg.toUtf8().constData()); + QWARN(qUtf8Printable(msg)); return false; } @@ -90,7 +91,7 @@ bool AbstractTest::Run(const QString &program, const QStringList &arguments) if (not process->waitForFinished())// 30 sec { const QString msg = QString("The operation timed out or an error occurred.\n%1").arg(parameters); - QWARN(msg.toUtf8().constData()); + QWARN(qUtf8Printable(msg)); return false; } @@ -98,7 +99,7 @@ bool AbstractTest::Run(const QString &program, const QStringList &arguments) { const QString msg = QString("Program crashed.\n%1\n%2").arg(parameters) .arg(QString(process->readAllStandardError())); - QWARN(msg.toUtf8().constData()); + QWARN(qUtf8Printable(msg)); return false; } @@ -106,7 +107,7 @@ bool AbstractTest::Run(const QString &program, const QStringList &arguments) { const QString msg = QString("Failed.\n%1\n%2").arg(parameters) .arg(QString(process->readAllStandardError())); - QWARN(msg.toUtf8().constData()); + QWARN(qUtf8Printable(msg)); return false; } diff --git a/src/test/ValentinaTest/tst_measurementregexp.cpp b/src/test/ValentinaTest/tst_measurementregexp.cpp index 2af9b7013..1b6acfb55 100644 --- a/src/test/ValentinaTest/tst_measurementregexp.cpp +++ b/src/test/ValentinaTest/tst_measurementregexp.cpp @@ -29,6 +29,7 @@ #include "tst_measurementregexp.h" #include "../qmuparser/qmudef.h" #include "../vmisc/def.h" +#include "../vmisc/logging.h" #include "../vpatterndb/vtranslatemeasurements.h" #include @@ -95,7 +96,7 @@ void TST_MeasurementRegExp::TestMeasurementRegExp() const QString message = QString("Failed to check translation for system = p%1 and locale = %2") .arg(s) .arg(locales.at(l)); - QFAIL(message.toUtf8().constData()); + QFAIL(qUtf8Printable(message)); break; } case NoError: @@ -111,7 +112,7 @@ void TST_MeasurementRegExp::TestMeasurementRegExp() const QString message = QString("Can't remove translation for system = p%1 and locale = %2") .arg(s) .arg(locales.at(l)); - QWARN(message.toUtf8().constData()); + QWARN(qUtf8Printable(message)); } delete pmsTranslator; } @@ -398,7 +399,7 @@ int TST_MeasurementRegExp::LoadTranslation(const QString &checkedSystem, const Q .arg(checkedLocale) .arg(path) .arg(file); - QWARN(message.toUtf8().constData()); + QWARN(qUtf8Printable(message)); return ErrorSize; } @@ -412,7 +413,7 @@ int TST_MeasurementRegExp::LoadTranslation(const QString &checkedSystem, const Q .arg(checkedLocale) .arg(path) .arg(file); - QWARN(message.toUtf8().constData()); + QWARN(qUtf8Printable(message)); delete pmsTranslator; @@ -426,7 +427,7 @@ int TST_MeasurementRegExp::LoadTranslation(const QString &checkedSystem, const Q .arg(checkedLocale) .arg(path) .arg(file); - QWARN(message.toUtf8().constData()); + QWARN(qUtf8Printable(message)); delete pmsTranslator;