Browse Source

Merge pull request #2024 from nextcloud/use_raw_string_literals

Use raw string literals when appropriate
Michael Schuster 5 years ago
parent
commit
ccc409dbd0

+ 6 - 6
src/gui/navigationpanehelper.cpp

@@ -90,9 +90,9 @@ void NavigationPaneHelper::updateCloudStorageRegistry()
                 entriesToRemove.removeOne(folder->navigationPaneClsid());
 
                 QString clsidStr = folder->navigationPaneClsid().toString();
-                QString clsidPath = QString() % "Software\\Classes\\CLSID\\" % clsidStr;
-                QString clsidPathWow64 = QString() % "Software\\Classes\\Wow6432Node\\CLSID\\" % clsidStr;
-                QString namespacePath = QString() % "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\" % clsidStr;
+                QString clsidPath = QString() % R"(Software\Classes\CLSID\)" % clsidStr;
+                QString clsidPathWow64 = QString() % R"(Software\Classes\Wow6432Node\CLSID\)" % clsidStr;
+                QString namespacePath = QString() % R"(Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\)" % clsidStr;
 
                 QString title = folder->shortGuiRemotePathOrAppName();
                 // Write the account name in the sidebar only when using more than one account.
@@ -157,9 +157,9 @@ void NavigationPaneHelper::updateCloudStorageRegistry()
     // Then remove anything that isn't in our folder list anymore.
     foreach (auto &clsid, entriesToRemove) {
         QString clsidStr = clsid.toString();
-        QString clsidPath = QString() % "Software\\Classes\\CLSID\\" % clsidStr;
-        QString clsidPathWow64 = QString() % "Software\\Classes\\Wow6432Node\\CLSID\\" % clsidStr;
-        QString namespacePath = QString() % "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\NameSpace\\" % clsidStr;
+        QString clsidPath = QString() % R"(Software\Classes\CLSID\)" % clsidStr;
+        QString clsidPathWow64 = QString() % R"(Software\Classes\Wow6432Node\CLSID\)" % clsidStr;
+        QString namespacePath = QString() % R"(Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\)" % clsidStr;
 
         qCInfo(lcNavPane) << "Explorer Cloud storage provider: now unused, removing own CLSID" << clsidStr;
 #ifdef Q_OS_WIN

+ 1 - 1
src/gui/openfilemanager.cpp

@@ -129,7 +129,7 @@ void showInFileManager(const QString &localPath)
     } else if (Utility::isMac()) {
         QStringList scriptArgs;
         scriptArgs << QLatin1String("-e")
-                   << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"")
+                   << QString::fromLatin1(R"(tell application "Finder" to reveal POSIX file "%1")")
                           .arg(localPath);
         QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
         scriptArgs.clear();

+ 1 - 1
src/gui/socketapi.cpp

@@ -177,7 +177,7 @@ SocketApi::SocketApi(QObject *parent)
     QString socketPath;
 
     if (Utility::isWindows()) {
-        socketPath = QLatin1String("\\\\.\\pipe\\")
+        socketPath = QLatin1String(R"(\\.\pipe\)")
             + QLatin1String("ownCloud-")
             + QString::fromLocal8Bit(qgetenv("USERNAME"));
         // TODO: once the windows extension supports multiple

+ 1 - 1
src/gui/syncrunfilelog.cpp

@@ -166,7 +166,7 @@ void SyncRunFileLog::logItem(const SyncFileItem &item)
     }
     QString ts = QString::fromLatin1(item._responseTimeStamp);
     if (ts.length() > 6) {
-        QRegExp rx("(\\d\\d:\\d\\d:\\d\\d)");
+        QRegExp rx(R"((\d\d:\d\d:\d\d))");
         if (ts.contains(rx)) {
             ts = rx.cap(0);
         }

+ 1 - 1
src/gui/wizard/owncloudwizardcommon.cpp

@@ -47,7 +47,7 @@ namespace WizardCommon {
 
     QString titleTemplate()
     {
-        return QString::fromLatin1("<font color=\"%1\" size=\"5\">").arg(Theme::instance()->wizardHeaderTitleColor().name()) + QString::fromLatin1("%1</font>");
+        return QString::fromLatin1(R"(<font color="%1" size="5">)").arg(Theme::instance()->wizardHeaderTitleColor().name()) + QString::fromLatin1("%1</font>");
     }
 
     QString subTitleTemplate()

+ 1 - 1
src/libsync/abstractnetworkjob.cpp

@@ -432,7 +432,7 @@ QString networkReplyErrorString(const QNetworkReply &reply)
         return base;
     }
 
-    return AbstractNetworkJob::tr("Server replied \"%1 %2\" to \"%3 %4\"").arg(QString::number(httpStatus), httpReason, requestVerb(reply), reply.request().url().toDisplayString());
+    return AbstractNetworkJob::tr(R"(Server replied "%1 %2" to "%3 %4")").arg(QString::number(httpStatus), httpReason, requestVerb(reply), reply.request().url().toDisplayString());
 }
 
 } // namespace OCC

+ 1 - 1
src/libsync/clientsideencryptionjobs.cpp

@@ -36,7 +36,7 @@ void GetFolderEncryptStatusJob::start()
 	req.setRawHeader("OCS-APIREQUEST", "true");
     req.setHeader(QNetworkRequest::ContentTypeHeader, QByteArrayLiteral("application/xml"));
 
-	QByteArray xml = "<d:propfind xmlns:d=\"DAV:\"> <d:prop xmlns:nc=\"http://nextcloud.org/ns\"> <nc:is-encrypted/> </d:prop> </d:propfind>";
+	QByteArray xml = R"(<d:propfind xmlns:d="DAV:"> <d:prop xmlns:nc="http://nextcloud.org/ns"> <nc:is-encrypted/> </d:prop> </d:propfind>)";
 	auto *buf = new QBuffer(this);
 	buf->setData(xml);
 	buf->open(QIODevice::ReadOnly);

+ 3 - 3
src/libsync/configfile.cpp

@@ -288,14 +288,14 @@ QVariant ConfigFile::getPolicySetting(const QString &setting, const QVariant &de
 {
     if (Utility::isWindows()) {
         // check for policies first and return immediately if a value is found.
-        QSettings userPolicy(QString::fromLatin1("HKEY_CURRENT_USER\\Software\\Policies\\%1\\%2")
+        QSettings userPolicy(QString::fromLatin1(R"(HKEY_CURRENT_USER\Software\Policies\%1\%2)")
                                  .arg(APPLICATION_VENDOR, Theme::instance()->appName()),
             QSettings::NativeFormat);
         if (userPolicy.contains(setting)) {
             return userPolicy.value(setting);
         }
 
-        QSettings machinePolicy(QString::fromLatin1("HKEY_LOCAL_MACHINE\\Software\\Policies\\%1\\%2")
+        QSettings machinePolicy(QString::fromLatin1(R"(HKEY_LOCAL_MACHINE\Software\Policies\%1\%2)")
                                     .arg(APPLICATION_VENDOR, APPLICATION_NAME),
             QSettings::NativeFormat);
         if (machinePolicy.contains(setting)) {
@@ -669,7 +669,7 @@ QVariant ConfigFile::getValue(const QString &param, const QString &group,
         }
         systemSetting = systemSettings.value(param, defaultValue);
     } else { // Windows
-        QSettings systemSettings(QString::fromLatin1("HKEY_LOCAL_MACHINE\\Software\\%1\\%2")
+        QSettings systemSettings(QString::fromLatin1(R"(HKEY_LOCAL_MACHINE\Software\%1\%2)")
                                      .arg(APPLICATION_VENDOR, Theme::instance()->appName()),
             QSettings::NativeFormat);
         if (!group.isEmpty()) {

+ 1 - 1
src/libsync/networkjobs.cpp

@@ -830,7 +830,7 @@ bool JsonApiJob::finished()
         qCWarning(lcJsonApiJob) << "Nothing changed so nothing to retrieve - status code: " << httpStatusCode;
         statusCode = httpStatusCode;
     } else {
-        QRegExp rex("\"statuscode\":(\\d+),");
+        QRegExp rex(R"("statuscode":(\d+),)");
         // example: "{"ocs":{"meta":{"status":"ok","statuscode":100,"message":null},"data":{"version":{"major":8,"minor":"... (504)
         if (jsonStr.contains(rex)) {
             statusCode = rex.cap(1).toInt();

+ 1 - 1
src/libsync/syncengine.cpp

@@ -1027,7 +1027,7 @@ void SyncEngine::slotDiscoveryJobFinished(int discoveryResult)
         // files with names that contain these.
         // It's important to respect the capability also for older servers -- the
         // version check doesn't make sense for custom servers.
-        invalidFilenamePattern = "[\\\\:?*\"<>|]";
+        invalidFilenamePattern = R"([\\:?*"<>|])";
     }
     if (!invalidFilenamePattern.isEmpty()) {
         const QRegExp invalidFilenameRx(invalidFilenamePattern);

+ 1 - 1
test/testutility.cpp

@@ -120,7 +120,7 @@ private slots:
 	    qDebug() << "Version of installed Nextcloud: " << ver;
 	    QVERIFY( !ver.isEmpty());
 
-	    QRegExp rx( "Nextcloud version \\d+\\.\\d+\\.\\d+.*" );
+	    QRegExp rx( R"(Nextcloud version \d+\.\d+\.\d+.*)" );
             QVERIFY( rx.exactMatch(ver));
 	} else {
 	    QVERIFY( versionOfInstalledBinary().isEmpty());