Changeset View
Changeset View
Standalone View
Standalone View
src/ShellCommand.cpp
Show All 36 Lines | 34 | { | |||
---|---|---|---|---|---|
37 | if (!_arguments.isEmpty()) { | 37 | if (!_arguments.isEmpty()) { | ||
38 | _arguments[0] = aCommand; | 38 | _arguments[0] = aCommand; | ||
39 | } | 39 | } | ||
40 | } | 40 | } | ||
41 | 41 | | |||
42 | QString ShellCommand::fullCommand() const | 42 | QString ShellCommand::fullCommand() const | ||
43 | { | 43 | { | ||
44 | QStringList quotedArgs(_arguments); | 44 | QStringList quotedArgs(_arguments); | ||
45 | for (int i = 0; i < quotedArgs.count(); i++) { | 45 | for (auto& arg : quotedArgs) { | ||
46 | QString arg = quotedArgs.at(i); | | |||
47 | bool hasSpace = false; | 46 | bool hasSpace = false; | ||
48 | for (int j = 0; j < arg.count(); j++) { | 47 | | ||
49 | if (arg[j].isSpace()) { | 48 | for (const auto &letter : arg) { | ||
49 | if (letter.isSpace()) { | ||||
50 | hasSpace = true; | 50 | hasSpace = true; | ||
51 | break; | ||||
51 | } | 52 | } | ||
52 | } | 53 | } | ||
54 | | ||||
53 | if (hasSpace) { | 55 | if (hasSpace) { | ||
54 | quotedArgs[i] = QLatin1Char('\"') + arg + QLatin1Char('\"'); | 56 | arg = QLatin1Char('\"') + arg + QLatin1Char('\"'); | ||
55 | } | 57 | } | ||
56 | } | 58 | } | ||
57 | return quotedArgs.join(QLatin1Char(' ')); | 59 | return quotedArgs.join(QLatin1Char(' ')); | ||
58 | } | 60 | } | ||
59 | 61 | | |||
60 | QString ShellCommand::command() const | 62 | QString ShellCommand::command() const | ||
61 | { | 63 | { | ||
62 | if (!_arguments.isEmpty()) { | 64 | if (!_arguments.isEmpty()) { | ||
63 | return _arguments[0]; | 65 | return _arguments[0]; | ||
64 | } else { | 66 | } else { | ||
65 | return QString(); | 67 | return QString(); | ||
66 | } | 68 | } | ||
67 | } | 69 | } | ||
68 | 70 | | |||
69 | QStringList ShellCommand::arguments() const | 71 | QStringList ShellCommand::arguments() const | ||
70 | { | 72 | { | ||
71 | return _arguments; | 73 | return _arguments; | ||
72 | } | 74 | } | ||
73 | 75 | | |||
74 | QStringList ShellCommand::expand(const QStringList &items) | 76 | QStringList ShellCommand::expand(const QStringList &items) | ||
75 | { | 77 | { | ||
76 | QStringList result; | 78 | QStringList result; | ||
77 | result.reserve(items.size()); | 79 | result.reserve(items.size()); | ||
78 | 80 | | |||
79 | foreach (const QString &item, items) { | 81 | for (const auto &item : items) { | ||
80 | result << expand(item); | 82 | result << expand(item); | ||
81 | } | 83 | } | ||
82 | 84 | | |||
83 | return result; | 85 | return result; | ||
84 | } | 86 | } | ||
85 | 87 | | |||
86 | QString ShellCommand::expand(const QString &text) | 88 | QString ShellCommand::expand(const QString &text) | ||
87 | { | 89 | { | ||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |