Wizards: Simplify error message for invalid names

This commit is contained in:
Kai Koehne
2010-03-10 10:51:15 +01:00
parent 5d1463745a
commit d0da52f548
2 changed files with 11 additions and 6 deletions

View File

@@ -92,15 +92,20 @@ bool FileNameValidatingLineEdit::validateFileName(const QString &name,
{
if (name.isEmpty()) {
if (errorMessage)
*errorMessage = tr("The name must not be empty");
*errorMessage = tr("Name is empty.");
return false;
}
// Characters
const char *notAllowedChars = allowDirectories ? notAllowedCharsSubDir : notAllowedCharsNoSubDir;
for (const char *c = notAllowedChars; *c; c++)
if (name.contains(QLatin1Char(*c))) {
if (errorMessage)
*errorMessage = tr("The name must not contain any of the characters '%1'.").arg(QLatin1String(notAllowedChars));
if (errorMessage) {
if (QChar(*c).isSpace()) {
*errorMessage = tr("Name contains white space.");
} else {
*errorMessage = tr("Invalid character '%1'.").arg(*c);
}
}
return false;
}
// Substrings
@@ -109,7 +114,7 @@ bool FileNameValidatingLineEdit::validateFileName(const QString &name,
const QLatin1String notAllowedSubString(notAllowedSubStrings[s]);
if (name.contains(notAllowedSubString)) {
if (errorMessage)
*errorMessage = tr("The name must not contain '%1'.").arg(QString(notAllowedSubString));
*errorMessage = tr("Invalid characters '%1'.").arg(QString(notAllowedSubString));
return false;
}
}
@@ -119,7 +124,7 @@ bool FileNameValidatingLineEdit::validateFileName(const QString &name,
matchesWinDevice = windowsDeviceSubDirPattern().exactMatch(name);
if (matchesWinDevice) {
if (errorMessage)
*errorMessage = tr("The name must not match that of a MS Windows device. (%1).").
*errorMessage = tr("Name matches MS Windows device. (%1).").
arg(windowsDeviceNoSubDirPattern().pattern().replace(QLatin1Char('|'), QLatin1Char(',')));
return false;
}