MCPcopy Create free account
hub / github.com/deskflow/deskflow / cleanComputerName

Method cleanComputerName

src/lib/common/Settings.cpp:134–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134QString 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
157int Settings::logLevelToInt(const QString &level)
158{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected