Allow empty string as intermediate match
QRegularExpressionValidator and QRegularExpression disagree on what a partial match means. [ChangeLog][QtGui][QRegularExpressionValidator] Allow empty string as intermediate match Change-Id: Ia6c55beb54870b1be5c88b6ef3eceebc8ca3f86b Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
parent
41db4b8cdc
commit
71ed74e72e
@ -1013,7 +1013,7 @@ QValidator::State QRegularExpressionValidator::validate(QString &input, int &pos
|
||||
const QRegularExpressionMatch m = d->usedRe.match(input, 0, QRegularExpression::PartialPreferCompleteMatch);
|
||||
if (m.hasMatch()) {
|
||||
return Acceptable;
|
||||
} else if (m.hasPartialMatch()) {
|
||||
} else if (input.isEmpty() || m.hasPartialMatch()) {
|
||||
return Intermediate;
|
||||
} else {
|
||||
pos = input.size();
|
||||
|
@ -74,6 +74,9 @@ void tst_QRegularExpressionValidator::validate_data()
|
||||
QTest::newRow("data14") << QRegularExpression("\\w\\d\\d") << QString("E5") << QValidator::Intermediate;
|
||||
QTest::newRow("data15") << QRegularExpression("\\w\\d\\d") << QString("+9") << QValidator::Invalid;
|
||||
|
||||
QTest::newRow("emptystr1") << QRegularExpression("[T][e][s][t]") << QString("") << QValidator::Intermediate;
|
||||
QTest::newRow("emptystr2") << QRegularExpression("[T][e][s][t]") << QString() << QValidator::Intermediate;
|
||||
|
||||
QTest::newRow("empty01") << QRegularExpression() << QString() << QValidator::Acceptable;
|
||||
QTest::newRow("empty02") << QRegularExpression() << QString("test") << QValidator::Acceptable;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user