diff --git a/src/customdocument.cpp b/src/customdocument.cpp index 2e1214ae..d00532a8 100644 --- a/src/customdocument.cpp +++ b/src/customdocument.cpp @@ -198,7 +198,7 @@ bool CustomDocument::openLinkAtCursorPosition() } if (isLocalFilePath && convertLocalFilepathsToURLs) { - openUrl(QStringLiteral("file://") + urlString); + openUrl(QStringLiteral("file://%1").arg(urlString)); } else { openUrl(urlString); } @@ -284,7 +284,7 @@ QMap CustomDocument::parseMarkdownUrlsFromText(const QString & while (iterator.hasNext()) { QRegularExpressionMatch match = iterator.next(); QString url = match.captured(0); - urlMap[url] = QStringLiteral("http://") + url; + urlMap[url] = QStringLiteral("http://%1").arg(url); } // match reference urls like this: [this url][1] with this later: @@ -296,8 +296,8 @@ QMap CustomDocument::parseMarkdownUrlsFromText(const QString & QString linkText = match.captured(1); QString referenceId = match.captured(2); - QRegularExpression refRegExp(QStringLiteral("\\[") + QRegularExpression::escape(referenceId) - + QStringLiteral("\\]: (.+)")); + QRegularExpression refRegExp( + QStringLiteral("\\[%1\\]: (.+)").arg(QRegularExpression::escape(referenceId))); QRegularExpressionMatch urlMatch = refRegExp.match(toPlainText()); if (urlMatch.hasMatch()) { diff --git a/src/dbmanager.cpp b/src/dbmanager.cpp index bb92ea16..d8e2d69d 100644 --- a/src/dbmanager.cpp +++ b/src/dbmanager.cpp @@ -1103,7 +1103,8 @@ void DBManager::moveNode(int nodeId, const NodeData &target) QSqlQuery query(m_db); auto node = getNode(nodeId); - QString newAbsolutePath = target.absolutePath() + PATH_SEPARATOR + QString::number(nodeId); + QString newAbsolutePath = + QStringLiteral("%1%2%3").arg(target.absolutePath(), PATH_SEPARATOR).arg(nodeId); if (target.id() == SpecialNodeID::TrashFolder) { qint64 deletionTime = QDateTime::currentMSecsSinceEpoch(); query.prepare(QStringLiteral( @@ -2415,13 +2416,15 @@ void DBManager::exportNotes(const QString &baseExportPath, const QString &extens { // Ensure the export directory exists QString rootFolderName = QStringLiteral("Notes"); - QString exportPathNew = baseExportPath + QDir::separator() + rootFolderName; + QString exportPathNew = + QStringLiteral("%1%2%3").arg(baseExportPath, QDir::separator(), rootFolderName); QDir directory; int counter = 1; while (directory.exists(exportPathNew)) { - exportPathNew = baseExportPath + QDir::separator() + rootFolderName + " " - + QString::number(counter++); + exportPathNew = QStringLiteral("%1%2%3 %4") + .arg(baseExportPath, QDir::separator(), rootFolderName) + .arg(counter++); } qDebug() << "Exporting notes to:" << exportPathNew; directory.mkpath(exportPathNew); @@ -2449,8 +2452,9 @@ void DBManager::exportNotes(const QString &baseExportPath, const QString &extens counter = 1; while (directory.exists(path)) { - path = exportPathNew + QDir::separator() + relativePath + " " - + QString::number(counter++); + path = QStringLiteral("%1%2%3 %4") + .arg(exportPathNew, QDir::separator(), relativePath) + .arg(counter++); } QDir().mkpath(path); @@ -2488,7 +2492,8 @@ void DBManager::exportNotes(const QString &baseExportPath, const QString &extens safeTitle = doc.toPlainText(); safeTitle.replace(QRegularExpression(R"([\/\\:*?"<>|])"), "_"); // Make the title filesystem-safe - QString filePath = notePath + QDir::separator() + safeTitle + extension; + QString filePath = + QStringLiteral("%1%2%3%4").arg(notePath, QDir::separator(), safeTitle, extension); if (safeTitle.isEmpty()) { safeTitle = QStringLiteral("Untitled Note"); @@ -2496,8 +2501,10 @@ void DBManager::exportNotes(const QString &baseExportPath, const QString &extens counter = 1; while (directory.exists(filePath)) { - filePath = notePath + QDir::separator() + safeTitle + " " + QString::number(counter++) - + extension; + filePath = QStringLiteral("%1%2%3 %4%5") + .arg(notePath, QDir::separator(), safeTitle) + .arg(counter++) + .arg(extension); } // qDebug() << "Exporting note:" << filePath; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index adb54b27..01da8f6d 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -180,8 +180,8 @@ void MainWindow::InitData() { QFileInfo fi(m_settingsDatabase->fileName()); QDir dir(fi.absolutePath()); - QString oldNoteDBPath(dir.path() + QStringLiteral("/Notes.ini")); - QString oldTrashDBPath(dir.path() + QStringLiteral("/Trash.ini")); + QString oldNoteDBPath = QStringLiteral("%1/Notes.ini").arg(dir.path()); + QString oldTrashDBPath = QStringLiteral("%1/Trash.ini").arg(dir.path()); bool isV0_9_0 = (QFile::exists(oldNoteDBPath) || QFile::exists(oldTrashDBPath)); if (isV0_9_0) { @@ -1657,7 +1657,7 @@ void MainWindow::setupDatabases() if (!folderCreated) qFatal("ERROR: Can't create settings folder : %s", dir.absolutePath().toStdString().c_str()); - QString defaultDBPath = dir.path() + QDir::separator() + QStringLiteral("notes.db"); + QString defaultDBPath = QStringLiteral("%1%2notes.db").arg(dir.path(), QDir::separator()); QString noteDBFilePath = m_settingsDatabase->value(QStringLiteral("noteDBFilePath"), QString()).toString(); @@ -3522,12 +3522,12 @@ void MainWindow::migrateFromV0_9_0() QFileInfo fi(m_settingsDatabase->fileName()); QDir dir(fi.absolutePath()); - QString oldNoteDBPath(dir.path() + QDir::separator() + "Notes.ini"); + QString oldNoteDBPath = QStringLiteral("%1%2Notes.ini").arg(dir.path(), QDir::separator()); if (QFile::exists(oldNoteDBPath)) { migrateNoteFromV0_9_0(oldNoteDBPath); } - QString oldTrashDBPath(dir.path() + QDir::separator() + "Trash.ini"); + QString oldTrashDBPath = QStringLiteral("%1%2Trash.ini").arg(dir.path(), QDir::separator()); if (QFile::exists(oldTrashDBPath)) { migrateTrashFromV0_9_0(oldTrashDBPath); } diff --git a/src/nodepath.cpp b/src/nodepath.cpp index f9611545..4d11bd4c 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -22,11 +22,13 @@ NodePath NodePath::parentPath() const QString NodePath::getAllNoteFolderPath() { - return PATH_SEPARATOR + QString::number(SpecialNodeID::RootFolder); + return QStringLiteral("%1%2").arg(PATH_SEPARATOR).arg(SpecialNodeID::RootFolder); } QString NodePath::getTrashFolderPath() { - return PATH_SEPARATOR + QString::number(SpecialNodeID::RootFolder) + PATH_SEPARATOR - + QString::number(SpecialNodeID::TrashFolder); + return QStringLiteral("%1%2%1%3") + .arg(PATH_SEPARATOR) + .arg(SpecialNodeID::RootFolder) + .arg(SpecialNodeID::TrashFolder); } diff --git a/src/noteeditorlogic.cpp b/src/noteeditorlogic.cpp index af2c903e..0751c674 100644 --- a/src/noteeditorlogic.cpp +++ b/src/noteeditorlogic.cpp @@ -411,7 +411,7 @@ void NoteEditorLogic::updateTaskText(int startLinePosition, int endLinePosition, } } - QString newTaskText = taskExpressionText + " " + newTextModified; + QString newTaskText = QStringLiteral("%1 %2").arg(taskExpressionText, newTextModified); if (newTaskText.size() > 0 && newTaskText[newTaskText.size() - 1] == '\n') { newTaskText.remove(newTaskText.size() - 1, 1); } @@ -422,7 +422,7 @@ void NoteEditorLogic::updateTaskText(int startLinePosition, int endLinePosition, void NoteEditorLogic::addNewTask(int startLinePosition, const QString newTaskText) { - QString newText = "\n- [ ] " + newTaskText; + QString newText = QStringLiteral("\n- [ ] %1").arg(newTaskText); QTextDocument *document = m_textEdit->document(); QTextBlock startBlock = document->findBlockByLineNumber(startLinePosition); @@ -631,9 +631,9 @@ bool NoteEditorLogic::checkForTasksInEditor() else if (!line.isEmpty() && isPreviousLineATask) { if (tasks.size() > 0) { QJsonObject newTask = tasks[tasks.size() - 1].toObject(); - QString newTaskText = newTask["text"].toString() + " \n" - + lineTrimmed; // For markdown rendering a line break needs two white - // spaces + QString newTaskText = + QStringLiteral("%1 \n%2").arg(newTask["text"].toString(), lineTrimmed); + // For markdown rendering a line break needs two white spaces newTask["text"] = newTaskText; newTask["taskEndLine"] = i; tasks[tasks.size() - 1] = newTask; diff --git a/src/notelistview.cpp b/src/notelistview.cpp index ed9e4c0f..6b72227b 100644 --- a/src/notelistview.cpp +++ b/src/notelistview.cpp @@ -741,7 +741,8 @@ void NoteListView::onCustomContextMenu(QPoint point) } for (auto id : std::as_const(tagInNote)) { auto tag = m_tagPool->getTag(id); - auto tagAction = new QAction(QStringLiteral("✓ Remove tag ") + tag.name(), this); + auto tagAction = + new QAction(QStringLiteral("✓ Remove tag %1").arg(tag.name()), this); connect(tagAction, &QAction::triggered, this, [this, id, notes] { removeNotesFromTag(notes, id); }); tagAction->setIcon(createTagIcon(tag.color())); @@ -754,7 +755,7 @@ void NoteListView::onCustomContextMenu(QPoint point) continue; } auto tag = m_tagPool->getTag(id); - auto tagAction = new QAction(QStringLiteral(" ") + tag.name(), this); + auto tagAction = new QAction(QStringLiteral(" %1").arg(tag.name()), this); connect(tagAction, &QAction::triggered, this, [this, id, notes] { addNotesToTag(notes, id); }); tagAction->setIcon(createTagIcon(tag.color()));