Fix inputMask accessor of QLineControl.

Do not append blank character if it is the default.

Task-number: QTBUG-20834
Change-Id: I17f6ac4058f295f25ff49f33c41bd9ee40b75811
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
Friedemann Kleint 2012-03-23 13:48:02 +01:00 committed by Qt by Nokia
parent 989b7f2337
commit c039ad21b5
2 changed files with 16 additions and 5 deletions

View File

@ -277,7 +277,18 @@ public:
bool hasAcceptableInput() const { return hasAcceptableInput(m_text); }
bool fixup();
QString inputMask() const { return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString(); }
QString inputMask() const
{
QString mask;
if (m_maskData) {
mask = m_inputMask;
if (m_blank != QLatin1Char(' ')) {
mask += QLatin1Char(';');
mask += m_blank;
}
}
return mask;
}
void setInputMask(const QString &mask)
{
parseInputMask(mask);

View File

@ -665,14 +665,14 @@ void tst_QLineEdit::inputMask_data()
QTest::newRow("nul 2") << QString() << QString();
// try different masks
QTest::newRow("mask 1") << QString("000.000.000.000") << QString("000.000.000.000; ");
QTest::newRow("mask 1") << QString("000.000.000.000") << QString("000.000.000.000");
QTest::newRow("mask 2") << QString("000.000.000.000;#") << QString("000.000.000.000;#");
QTest::newRow("mask 3") << QString("AAA.aa.999.###;") << QString("AAA.aa.999.###; ");
QTest::newRow("mask 4") << QString(">abcdef<GHIJK") << QString(">abcdef<GHIJK; ");
QTest::newRow("mask 3") << QString("AAA.aa.999.###;") << QString("AAA.aa.999.###");
QTest::newRow("mask 4") << QString(">abcdef<GHIJK") << QString(">abcdef<GHIJK");
// set an invalid input mask...
// the current behaviour is that this exact (faulty) string is returned.
QTest::newRow("invalid") << QString("ABCDEFGHIKLMNOP;") << QString("ABCDEFGHIKLMNOP; ");
QTest::newRow("invalid") << QString("ABCDEFGHIKLMNOP;") << QString("ABCDEFGHIKLMNOP");
// verify that we can unset the mask again
QTest::newRow("unset") << QString("") << QString();