From b4b4a502bfe3d9470abfd50e451da56290efa4cf Mon Sep 17 00:00:00 2001 From: Kurt Hindenburg Date: Sun, 7 May 2017 14:25:35 -0400 Subject: [PATCH] More changes to QLatin1String, QLatin1Char and QStringLiteral --- src/ProfileManager.cpp | 6 +++--- src/ProfileReader.cpp | 4 ++-- src/ProfileWriter.cpp | 4 ++-- src/Pty.cpp | 12 ++++++------ src/Session.cpp | 2 +- src/SessionListModel.cpp | 4 ++-- src/SessionManager.cpp | 4 ++-- src/ShellCommand.cpp | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/ProfileManager.cpp b/src/ProfileManager.cpp index 0023814d5..36768f4d4 100644 --- a/src/ProfileManager.cpp +++ b/src/ProfileManager.cpp @@ -139,7 +139,7 @@ Profile::Ptr ProfileManager::loadProfile(const QString& shortPath) return Profile::Ptr(); if (fileInfo.suffix() != QLatin1String("profile")) - path.append(".profile"); + path.append(QLatin1String(".profile")); if (fileInfo.path().isEmpty() || fileInfo.path() == QLatin1String(".")) path.prepend(QLatin1String("konsole") + QDir::separator()); @@ -368,7 +368,7 @@ void ProfileManager::changeProfile(Profile::Ptr profile, newName = QStringLiteral("Profile ") + QString::number(nameSuffix); newTranslatedName = i18nc("The default name of a profile", "Profile #%1", nameSuffix); // TODO: remove the # above and below - too many issues - newTranslatedName.remove('#'); + newTranslatedName.remove(QLatin1Char('#')); nameSuffix++; } while (existingProfileNames.contains(newName)); @@ -376,7 +376,7 @@ void ProfileManager::changeProfile(Profile::Ptr profile, newProfile->clone(profile, true); newProfile->setProperty(Profile::UntranslatedName, newName); newProfile->setProperty(Profile::Name, newTranslatedName); - newProfile->setProperty(Profile::MenuIndex, QString("0")); + newProfile->setProperty(Profile::MenuIndex, QStringLiteral("0")); newProfile->setHidden(false); addProfile(newProfile); diff --git a/src/ProfileReader.cpp b/src/ProfileReader.cpp index 50147e294..aa9ce9954 100644 --- a/src/ProfileReader.cpp +++ b/src/ProfileReader.cpp @@ -50,7 +50,7 @@ QStringList KDE4ProfileReader::findProfiles() Q_FOREACH (const QString& dir, dirs) { const QStringList fileNames = QDir(dir).entryList(QStringList() << QStringLiteral("*.profile")); Q_FOREACH (const QString& file, fileNames) { - profiles.append(dir + '/' + file); + profiles.append(dir + QLatin1Char('/') + file); } } return profiles; @@ -68,7 +68,7 @@ void KDE4ProfileReader::readProperties(const KConfig& config, Profile::Ptr profi groupName = properties->group; } - QString name(properties->name); + QString name(QLatin1String(properties->name)); if (group.hasKey(name)) profile->setProperty(properties->property, diff --git a/src/ProfileWriter.cpp b/src/ProfileWriter.cpp index d73b85392..e66b1dde5 100644 --- a/src/ProfileWriter.cpp +++ b/src/ProfileWriter.cpp @@ -44,7 +44,7 @@ QString KDE4ProfileWriter::getPath(const Profile::Ptr profile) // the Konsole part can write/save profiles static const QString localDataLocation = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/konsole"); - return localDataLocation % "/" % profile->untranslatedName() % ".profile"; + return localDataLocation % QLatin1String("/") % profile->untranslatedName() % QLatin1String(".profile"); } void KDE4ProfileWriter::writeProperties(KConfig& config, const Profile::Ptr profile, @@ -61,7 +61,7 @@ void KDE4ProfileWriter::writeProperties(KConfig& config, } if (profile->isPropertySet(properties->property)) - group.writeEntry(QString(properties->name), + group.writeEntry(QLatin1String(properties->name), profile->property(properties->property)); } diff --git a/src/Pty.cpp b/src/Pty.cpp index c6c787af0..a95866585 100644 --- a/src/Pty.cpp +++ b/src/Pty.cpp @@ -194,8 +194,8 @@ void Pty::setInitialWorkingDirectory(const QString& dir) setWorkingDirectory(pwd); // setting PWD to "." will cause problem for bash & zsh - if (pwd != ".") - setEnv("PWD", pwd); + if (pwd != QLatin1String(".")) + setEnv(QStringLiteral("PWD"), pwd); } void Pty::addEnvironmentVariables(const QStringList& environmentVariables) @@ -204,7 +204,7 @@ void Pty::addEnvironmentVariables(const QStringList& environmentVariables) foreach(const QString& pair, environmentVariables) { // split on the first '=' character - const int separator = pair.indexOf('='); + const int separator = pair.indexOf(QLatin1Char('=')); if (separator >= 0) { QString variable = pair.left(separator); @@ -212,7 +212,7 @@ void Pty::addEnvironmentVariables(const QStringList& environmentVariables) setEnv(variable, value); - if (variable == "TERM") { + if (variable == QLatin1String("TERM")) { isTermEnvAdded = true; } } @@ -220,7 +220,7 @@ void Pty::addEnvironmentVariables(const QStringList& environmentVariables) // extra safeguard to make sure $TERM is always set if (!isTermEnvAdded) { - setEnv("TERM", "xterm-256color"); + setEnv(QStringLiteral("TERM"), QStringLiteral("xterm-256color")); } } @@ -249,7 +249,7 @@ int Pty::start(const QString& programName, // does not have a translation for // // BR:149300 - setEnv("LANGUAGE", QString(), false /* do not overwrite existing value if any */); + setEnv(QStringLiteral("LANGUAGE"), QString(), false /* do not overwrite existing value if any */); KProcess::start(); diff --git a/src/Session.cpp b/src/Session.cpp index 896a9a170..4c052ef50 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -370,7 +370,7 @@ void Session::terminalWarning(const QString& message) QString Session::shellSessionId() const { QString friendlyUuid(_uniqueIdentifier.toString()); - friendlyUuid.remove('-').remove('{').remove('}'); + friendlyUuid.remove(QLatin1Char('-')).remove(QLatin1Char('{')).remove(QLatin1Char('}')); return friendlyUuid; } diff --git a/src/SessionListModel.cpp b/src/SessionListModel.cpp index c9dbf074b..15f501508 100644 --- a/src/SessionListModel.cpp +++ b/src/SessionListModel.cpp @@ -68,10 +68,10 @@ QVariant SessionListModel::data(const QModelIndex& index, int role) const // special handling for the "%w" marker which is replaced with the // window title set by the shell - title.replace("%w", _sessions[row]->userTitle()); + title.replace(QLatin1String("%w"), _sessions[row]->userTitle()); // special handling for the "%#" marker which is replaced with the // number of the shell - title.replace("%#", QString::number(_sessions[row]->sessionId())); + title.replace(QLatin1String("%#"), QString::number(_sessions[row]->sessionId())); return title; } else if (column == 0) { return _sessions[row]->sessionId(); diff --git a/src/SessionManager.cpp b/src/SessionManager.cpp index d9c5878a2..ced2a0e03 100644 --- a/src/SessionManager.cpp +++ b/src/SessionManager.cpp @@ -176,8 +176,8 @@ void SessionManager::applyProfile(Session* session, const Profile::Ptr profile , // add environment variable containing home directory of current profile // (if specified) QStringList environment = profile->environment(); - environment << QString("PROFILEHOME=%1").arg(profile->defaultWorkingDirectory()); - environment << QString("KONSOLE_PROFILE_NAME=%1").arg(profile->name()); + environment << QStringLiteral("PROFILEHOME=%1").arg(profile->defaultWorkingDirectory()); + environment << QStringLiteral("KONSOLE_PROFILE_NAME=%1").arg(profile->name()); session->setEnvironment(environment); } diff --git a/src/ShellCommand.cpp b/src/ShellCommand.cpp index e900d174e..fd99c7ae9 100644 --- a/src/ShellCommand.cpp +++ b/src/ShellCommand.cpp @@ -48,7 +48,7 @@ QString ShellCommand::fullCommand() const if (hasSpace) quotedArgs[i] = '\"' + arg + '\"'; } - return quotedArgs.join(QChar(' ')); + return quotedArgs.join(QLatin1Char(' ')); } QString ShellCommand::command() const {