| 132 | } |
| 133 | |
| 134 | QString Settings::cleanComputerName(const QString &name) |
| 135 | { |
| 136 | static const auto hyphen = QStringLiteral("-"); |
| 137 | static const auto space = QStringLiteral(" "); |
| 138 | static const auto underscore = QStringLiteral("_"); |
| 139 | static const auto period = QStringLiteral("."); |
| 140 | static const auto nothing = QStringLiteral(""); |
| 141 | static const auto nameRegex = QRegularExpression(QStringLiteral("[^\\w\\-\\.]")); |
| 142 | |
| 143 | QString cleanName = name.simplified(); |
| 144 | cleanName.replace(space, underscore); |
| 145 | cleanName.replace(nameRegex, nothing); |
| 146 | while (cleanName.startsWith(hyphen) || cleanName.startsWith(underscore) || cleanName.startsWith(period)) |
| 147 | cleanName.removeFirst(); |
| 148 | while (cleanName.endsWith(hyphen) || cleanName.endsWith(underscore) || cleanName.endsWith(period)) |
| 149 | cleanName.removeLast(); |
| 150 | if (cleanName.length() > 255) { |
| 151 | cleanName.truncate(255); |
| 152 | cleanName = cleanComputerName(cleanName); |
| 153 | } |
| 154 | return cleanName; |
| 155 | } |
| 156 | |
| 157 | int Settings::logLevelToInt(const QString &level) |
| 158 | { |
nothing calls this directly
no outgoing calls
no test coverage detected