From e7ca9294cf7e6fb09705a3fbe0d0b0b1d727517b Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Fri, 13 Apr 2018 09:14:55 +0300 Subject: [PATCH] Refactoring. Use QChar instead of QString where possible. Point and comma. --HG-- branch : develop --- .../configpages/tapepreferencespathpage.cpp | 4 ++-- src/app/tape/tmainwindow.cpp | 20 +++++++++---------- src/app/valentina/core/vapplication.cpp | 2 +- .../configpages/preferencespathpage.cpp | 6 +++--- .../dialogs/dialogpatternproperties.cpp | 4 ++-- .../valentina/dialogs/dialogsavelayout.cpp | 4 ++-- src/app/valentina/mainwindow.cpp | 12 +++++------ src/app/valentina/mainwindowsnogui.cpp | 4 ++-- src/app/valentina/xml/vpattern.cpp | 14 ++++++------- src/libs/ifc/xml/vabstractconverter.cpp | 2 +- src/libs/ifc/xml/vdomdocument.cpp | 8 ++++---- src/libs/vmisc/projectversion.cpp | 2 +- src/libs/vmisc/vcommonsettings.cpp | 4 ++-- .../plugins/Vector3d/vvector3dproperty.cpp | 2 +- src/libs/vwidgets/vabstractmainwindow.cpp | 4 ++-- src/test/ValentinaTest/tst_readval.cpp | 4 ++-- 16 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp index e9c42d3e8..9ac1010c9 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.cpp @@ -117,7 +117,7 @@ void TapePreferencesPathPage::EditPath() QDir directory(path); if (not directory.exists()) { - usedNotExistedDir = directory.mkpath("."); + usedNotExistedDir = directory.mkpath(QChar('.')); } const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path, @@ -127,7 +127,7 @@ void TapePreferencesPathPage::EditPath() if (usedNotExistedDir) { QDir directory(path); - directory.rmpath("."); + directory.rmpath(QChar('.')); } DefaultPath(); diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index 1a07557e7..d8e1c565f 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -413,7 +413,7 @@ void TMainWindow::OpenIndividual() QDir directory(pathTo); if (not directory.exists()) { - usedNotExistedDir = directory.mkpath("."); + usedNotExistedDir = directory.mkpath(QChar('.')); } Open(pathTo, filter); @@ -421,7 +421,7 @@ void TMainWindow::OpenIndividual() if (usedNotExistedDir) { QDir directory(pathTo); - directory.rmpath("."); + directory.rmpath(QChar('.')); } } @@ -465,7 +465,7 @@ void TMainWindow::CreateFromExisting() QDir directory(pathTo); if (not directory.exists()) { - usedNotExistedDir = directory.mkpath("."); + usedNotExistedDir = directory.mkpath(QChar('.')); } const QString mPath = QFileDialog::getOpenFileName(this, tr("Select file"), pathTo, filter); @@ -485,7 +485,7 @@ void TMainWindow::CreateFromExisting() if (usedNotExistedDir) { QDir directory(pathTo); - directory.rmpath("."); + directory.rmpath(QChar('.')); } } @@ -828,13 +828,13 @@ bool TMainWindow::FileSaveAs() { filters = tr("Individual measurements") + QLatin1String(" (*.vit)"); suffix = QLatin1String("vit"); - fName += QLatin1String(".") + suffix; + fName += QChar('.') + suffix; } else { filters = tr("Multisize measurements") + QLatin1String(" (*.vst)"); suffix = QLatin1String("vst"); - fName += QLatin1String(".") + suffix; + fName += QChar('.') + suffix; } QString dir; @@ -859,7 +859,7 @@ bool TMainWindow::FileSaveAs() QDir directory(dir); if (not directory.exists()) { - usedNotExistedDir = directory.mkpath("."); + usedNotExistedDir = directory.mkpath(QChar('.')); } QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), dir + QLatin1String("/") + fName, filters); @@ -869,7 +869,7 @@ bool TMainWindow::FileSaveAs() if (usedNotExistedDir) { QDir directory(dir); - directory.rmpath("."); + directory.rmpath(QChar('.')); } }; @@ -882,7 +882,7 @@ bool TMainWindow::FileSaveAs() QFileInfo f( fileName ); if (f.suffix().isEmpty() && f.suffix() != suffix) { - fileName += QLatin1String(".") + suffix; + fileName += QChar('.') + suffix; } if (QFileInfo::exists(fileName)) @@ -986,7 +986,7 @@ void TMainWindow::ImportDataFromCSV() QFileInfo f( fileName ); if (f.suffix().isEmpty() && f.suffix() != suffix) { - fileName += QLatin1String(".") + suffix; + fileName += QChar('.') + suffix; } DialogExportToCSV dialog(this); diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index 998f5ded8..0b8fb5ffb 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -471,7 +471,7 @@ bool VApplication::CreateLogDir() const QDir logDir(LogDirPath()); if (logDir.exists() == false) { - return logDir.mkpath("."); // Create directory for log if need + return logDir.mkpath(QChar('.')); // Create directory for log if need } return true; } diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp index e7bd64380..0bbc77e9b 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.cpp @@ -142,7 +142,7 @@ void PreferencesPathPage::EditPath() QDir directory(path); if (not directory.exists()) { - usedNotExistedDir = directory.mkpath("."); + usedNotExistedDir = directory.mkpath(QChar('.')); } const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path, @@ -157,7 +157,7 @@ void PreferencesPathPage::EditPath() if (usedNotExistedDir) { QDir directory(path); - directory.rmpath("."); + directory.rmpath(QChar('.')); } DefaultPath(); return; @@ -169,7 +169,7 @@ void PreferencesPathPage::EditPath() if (usedNotExistedDir) { QDir directory(path); - directory.rmpath("."); + directory.rmpath(QChar('.')); } } diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 970fcf5c1..38018885c 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -880,8 +880,8 @@ void DialogPatternProperties::SaveImage() QByteArray byteArray; byteArray.append(doc->GetImage().toUtf8()); QByteArray ba = QByteArray::fromBase64(byteArray); - const QString extension = QLatin1String(".") + doc->GetImageExtension(); - QString filter = tr("Images") + QLatin1String(" (*") + extension + QLatin1String(")"); + const QString extension = doc->GetImageExtension().prepend(QChar('.')); + QString filter = tr("Images") + QStringLiteral(" (*") + extension + QChar(')'); QString filename = QFileDialog::getSaveFileName(this, tr("Save File"), tr("untitled"), filter, &filter #ifdef Q_OS_LINUX , QFileDialog::DontUseNativeDialog diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 25f6a3709..91185b11c 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -123,7 +123,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName QDir directory(dirPath); if (not directory.exists()) { - usedNotExistedDir = directory.mkpath("."); + usedNotExistedDir = directory.mkpath(QChar('.')); } const QString dir = QFileDialog::getExistingDirectory(this, tr("Select folder"), dirPath, @@ -141,7 +141,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName if (usedNotExistedDir) { QDir directory(dirPath); - directory.rmpath("."); + directory.rmpath(QChar('.')); } }); connect(ui->lineEditPath, &QLineEdit::textChanged, this, &DialogSaveLayout::PathChanged); diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index da9c7f3c3..2ffda6047 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1675,7 +1675,7 @@ void MainWindow::LoadIndividual() QDir directory(path); if (not directory.exists()) { - usedNotExistedDir = directory.mkpath("."); + usedNotExistedDir = directory.mkpath(QChar('.')); } const QString mPath = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter, nullptr @@ -1707,7 +1707,7 @@ void MainWindow::LoadIndividual() if (usedNotExistedDir) { QDir directory(path); - directory.rmpath("."); + directory.rmpath(QChar('.')); } } @@ -2764,7 +2764,7 @@ bool MainWindow::SaveAs() QDir directory(dir); if (not directory.exists()) { - usedNotExistedDir = directory.mkpath("."); + usedNotExistedDir = directory.mkpath(QChar('.')); } QString fileName = QFileDialog::getSaveFileName(this, tr("Save as"), @@ -2780,7 +2780,7 @@ bool MainWindow::SaveAs() if (usedNotExistedDir) { QDir directory(dir); - directory.rmpath("."); + directory.rmpath(QChar('.')); } }; @@ -4932,7 +4932,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS QDir directory(dirPath); if (not directory.exists()) { - usedNotExistedDir = directory.mkpath("."); + usedNotExistedDir = directory.mkpath(QChar('.')); } QString mPath; @@ -4948,7 +4948,7 @@ QString MainWindow::CheckPathToMeasurements(const QString &patternPath, const QS if (usedNotExistedDir) { QDir directory(dirPath); - directory.rmpath("."); + directory.rmpath(QChar('.')); } return mPath; diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index cf418a95c..c67d7219c 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -79,7 +79,7 @@ bool CreateLayoutPath(const QString &path) dir.setPath(path); if (not dir.exists(path)) { - usedNotExistedDir = dir.mkpath("."); + usedNotExistedDir = dir.mkpath(QChar('.')); } return usedNotExistedDir; } @@ -90,7 +90,7 @@ void RemoveLayoutPath(const QString &path, bool usedNotExistedDir) if (usedNotExistedDir) { QDir dir(path); - dir.rmpath("."); + dir.rmpath(QChar('.')); } } } diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index fcdd2e74a..587a63a0a 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -1338,44 +1338,44 @@ QString VPattern::GetLabelBase(quint32 index) const case 0: // de { const QString al = QStringLiteral("A,Ä,B,C,D,E,F,G,H,I,J,K,L,M,N,O,Ö,P,Q,R,S,ß,T,U,Ü,V,W,X,Y,Z"); - alphabet = al.split(","); + alphabet = al.split(QChar(',')); break; } case 2: // fr { const QString al = QStringLiteral("A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z"); - alphabet = al.split(","); + alphabet = al.split(QChar(',')); break; } case 3: // ru { const QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,И,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Э,Ю,Я"); - alphabet = al.split(","); + alphabet = al.split(QChar(',')); break; } case 4: // uk { const QString al = QStringLiteral("А,Б,В,Г,Д,Е,Ж,З,І,Ї,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Є,Ю,Я"); - alphabet = al.split(","); + alphabet = al.split(QChar(',')); break; } case 5: // hr case 7: // bs { const QString al = QStringLiteral("A,B,C,Č,Ć,D,Dž,Ð,E,F,G,H,I,J,K,L,Lj,M,N,Nj,O,P,R,S,Š,T,U,V,Z,Ž"); - alphabet = al.split(","); + alphabet = al.split(QChar(',')); break; } case 6: // sr { const QString al = QStringLiteral("А,Б,В,Г,Д,Ђ,Е,Ж,З,И,Ј,К,Л,Љ,М,Н,Њ,О,П,Р,С,Т,Ћ,У,Ф,Х,Ц,Ч,Џ,Ш"); - alphabet = al.split(","); + alphabet = al.split(QChar(',')); break; } case 1: // en default: // en { - alphabet = def.split(","); + alphabet = def.split(QChar(',')); break; } } diff --git a/src/libs/ifc/xml/vabstractconverter.cpp b/src/libs/ifc/xml/vabstractconverter.cpp index 7a2f85906..414271726 100644 --- a/src/libs/ifc/xml/vabstractconverter.cpp +++ b/src/libs/ifc/xml/vabstractconverter.cpp @@ -125,7 +125,7 @@ int VAbstractConverter::GetVersion(const QString &version) { ValidateVersion(version); - const QStringList ver = version.split("."); + const QStringList ver = version.split(QChar('.')); bool ok = false; const int major = ver.at(0).toInt(&ok); diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 01c559297..c8e4ec016 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -483,7 +483,7 @@ qreal VDomDocument::GetParametrDouble(const QDomElement &domElement, const QStri try { QString parametr = GetParametrString(domElement, name, defValue); - param = parametr.replace(",", ".").toDouble(&ok); + param = parametr.replace(QChar(','), QChar('.')).toDouble(&ok); if (ok == false) { throw VExceptionConversionError(message, name); @@ -764,7 +764,7 @@ bool VDomDocument::SaveDocument(const QString &fileName, QString &error) QString VDomDocument::Major() const { QString version = UniqueTagText(TagVersion, "0.0.0"); - QStringList v = version.split("."); + QStringList v = version.split(QChar('.')); return v.at(0); } @@ -773,7 +773,7 @@ QString VDomDocument::Major() const QString VDomDocument::Minor() const { QString version = UniqueTagText(TagVersion, "0.0.0"); - QStringList v = version.split("."); + QStringList v = version.split(QChar('.')); return v.at(1); } @@ -782,7 +782,7 @@ QString VDomDocument::Minor() const QString VDomDocument::Patch() const { QString version = UniqueTagText(TagVersion, "0.0.0"); - QStringList v = version.split("."); + QStringList v = version.split(QChar('.')); return v.at(2); } diff --git a/src/libs/vmisc/projectversion.cpp b/src/libs/vmisc/projectversion.cpp index 6d60eb340..b2d4c9d6d 100644 --- a/src/libs/vmisc/projectversion.cpp +++ b/src/libs/vmisc/projectversion.cpp @@ -71,7 +71,7 @@ QString compilerString() iccVersion = QLatin1String(__INTEL_COMPILER); } #ifdef __INTEL_COMPILER_UPDATE - return QLatin1String("Intel(R) C++ ") + iccVersion + QLatin1String(".") + QLatin1String(__INTEL_COMPILER_UPDATE) + + return QLatin1String("Intel(R) C++ ") + iccVersion + QChar('.') + QLatin1String(__INTEL_COMPILER_UPDATE) + QLatin1String(" build ") + QLatin1String(__INTEL_COMPILER_BUILD_DATE) + QLatin1String(" [") + QLatin1String(iccCompact) + QLatin1String(" compatibility]"); #else diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index e4f83e00f..bda206d1f 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -213,7 +213,7 @@ QString PrepareStandardFiles(const QString ¤tPath, const QString &standard if ((currentPath == defPath || not currentPathDir.exists()) && standardPathDir.exists()) { const QDir localdata (defPath); - if (localdata.mkpath(".")) + if (localdata.mkpath(QChar('.'))) { SymlinkCopyDirRecursive(standardPath, defPath, false); } @@ -885,7 +885,7 @@ double VCommonSettings::GetDefaultSeamAllowance() { qDebug()<< "Could not convert value"<