Use qUtf8Printable.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-10-01 18:34:03 +03:00
parent 9069337a7a
commit 06a54ba40c
10 changed files with 55 additions and 53 deletions

View File

@ -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())));
}
}
}

View File

@ -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));
}
}
}

View File

@ -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<int>(type));

View File

@ -432,7 +432,7 @@ void VDomDocument::CollectId(const QDomElement &node, QVector<quint32> &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)
{

View File

@ -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
}
}

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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();

View File

@ -27,6 +27,7 @@
*************************************************************************/
#include "abstracttest.h"
#include "../vmisc/logging.h"
#include <QtTest>
@ -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;
}

View File

@ -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 <QtTest>
@ -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;