Use QStringLiteral and QLatin1String

This commit is contained in:
Kurt Hindenburg
2015-10-15 16:25:32 -04:00
parent 51267a67ba
commit bdee35bf38
3 changed files with 46 additions and 46 deletions

View File

@@ -123,12 +123,12 @@ QString ProcessInfo::format(const QString& input) const
QString output(input);
// search for and replace known marker
output.replace("%u", userName());
output.replace("%h", localHost());
output.replace("%n", name(&ok));
output.replace(QLatin1String("%u"), userName());
output.replace(QLatin1String("%h"), localHost());
output.replace(QLatin1String("%n"), name(&ok));
QString dir = validCurrentDir();
if (output.contains("%D")) {
if (output.contains(QLatin1String("%D"))) {
QString homeDir = userHomeDir();
QString tempDir = dir;
// Change User's Home Dir w/ ~ only at the beginning
@@ -136,9 +136,9 @@ QString ProcessInfo::format(const QString& input) const
tempDir.remove(0, homeDir.length());
tempDir.prepend('~');
}
output.replace("%D", tempDir);
output.replace(QLatin1String("%D"), tempDir);
}
output.replace("%d", formatShortDir(dir));
output.replace(QLatin1String("%d"), formatShortDir(dir));
return output;
}
@@ -440,7 +440,7 @@ private:
// For user id read process status file ( /proc/<pid>/status )
// Can not use getuid() due to it does not work for 'su'
QFile statusInfo(QString("/proc/%1/status").arg(aPid));
QFile statusInfo(QStringLiteral("/proc/%1/status").arg(aPid));
if (statusInfo.open(QIODevice::ReadOnly)) {
QTextStream stream(&statusInfo);
QString statusLine;
@@ -476,7 +476,7 @@ private:
//
// FIELD FIELD (FIELD WITH SPACES) FIELD FIELD
//
QFile processInfo(QString("/proc/%1/stat").arg(aPid));
QFile processInfo(QStringLiteral("/proc/%1/stat").arg(aPid));
if (processInfo.open(QIODevice::ReadOnly)) {
QTextStream stream(&processInfo);
const QString& data = stream.readAll();
@@ -539,7 +539,7 @@ private:
// the expected format is a list of strings delimited by null characters,
// and ending in a double null character pair.
QFile argumentsFile(QString("/proc/%1/cmdline").arg(aPid));
QFile argumentsFile(QStringLiteral("/proc/%1/cmdline").arg(aPid));
if (argumentsFile.open(QIODevice::ReadOnly)) {
QTextStream stream(&argumentsFile);
const QString& data = stream.readAll();
@@ -560,7 +560,7 @@ private:
virtual bool readCurrentDir(int aPid) {
char path_buffer[MAXPATHLEN + 1];
path_buffer[MAXPATHLEN] = 0;
QByteArray procCwd = QFile::encodeName(QString("/proc/%1/cwd").arg(aPid));
QByteArray procCwd = QFile::encodeName(QStringLiteral("/proc/%1/cwd").arg(aPid));
const int length = readlink(procCwd.constData(), path_buffer, MAXPATHLEN);
if (length == -1) {
setError(UnknownError);
@@ -579,7 +579,7 @@ private:
// the expected format is a list of KEY=VALUE strings delimited by null
// characters and ending in a double null character pair.
QFile environmentFile(QString("/proc/%1/environ").arg(aPid));
QFile environmentFile(QStringLiteral("/proc/%1/environ").arg(aPid));
if (environmentFile.open(QIODevice::ReadOnly)) {
QTextStream stream(&environmentFile);
const QString& data = stream.readAll();
@@ -1024,7 +1024,7 @@ SSHProcessInfo::SSHProcessInfo(const ProcessInfo& process)
// check that this is a SSH process
const QString& name = _process.name(&ok);
if (!ok || name != "ssh") {
if (!ok || name != QLatin1String("ssh")) {
if (!ok)
qWarning() << "Could not read process info";
else
@@ -1040,9 +1040,9 @@ SSHProcessInfo::SSHProcessInfo(const ProcessInfo& process)
// these are taken from the SSH manual ( accessed via 'man ssh' )
// options which take no arguments
static const QString noArgumentOptions("1246AaCfgKkMNnqsTtVvXxYy");
static const QString noArgumentOptions(QStringLiteral("1246AaCfgKkMNnqsTtVvXxYy"));
// options which take one argument
static const QString singleArgumentOptions("bcDeFIiLlmOopRSWw");
static const QString singleArgumentOptions(QStringLiteral("bcDeFIiLlmOopRSWw"));
if (ok) {
// find the username, host and command arguments
@@ -1151,15 +1151,15 @@ QString SSHProcessInfo::format(const QString& input) const
isIpAddress = false;
// search for and replace known markers
output.replace("%u", _user);
output.replace(QLatin1String("%u"), _user);
if (isIpAddress)
output.replace("%h", _host);
output.replace(QLatin1String("%h"), _host);
else
output.replace("%h", _host.left(_host.indexOf('.')));
output.replace(QLatin1String("%h"), _host.left(_host.indexOf('.')));
output.replace("%H", _host);
output.replace("%c", _command);
output.replace(QLatin1String("%H"), _host);
output.replace(QLatin1String("%c"), _command);
return output;
}