diff --git a/src/autotype/WildcardMatcher.cpp b/src/autotype/WildcardMatcher.cpp index ce6fbfe11..9031e6b1d 100644 --- a/src/autotype/WildcardMatcher.cpp +++ b/src/autotype/WildcardMatcher.cpp @@ -20,6 +20,7 @@ #include const QString WildcardMatcher::Wildcard = "*"; +const Qt::CaseSensitivity WildcardMatcher::Sensitivity = Qt::CaseInsensitive; WildcardMatcher::WildcardMatcher(QString text, QObject* parent) : QObject(parent) @@ -46,7 +47,7 @@ bool WildcardMatcher::patternContainsWildcard() bool WildcardMatcher::patternEqualsText() { - return m_text.compare(m_pattern) == 0; + return m_text.compare(m_pattern, Sensitivity) == 0; } bool WildcardMatcher::matchWithWildcards() @@ -63,7 +64,8 @@ bool WildcardMatcher::matchWithWildcards() bool WildcardMatcher::startOrEndDoesNotMatch(QStringList parts) { - return !m_text.startsWith(parts.first()) || !m_text.endsWith(parts.last()); + return !m_text.startsWith(parts.first(), Sensitivity) || + !m_text.endsWith(parts.last(), Sensitivity); } bool WildcardMatcher::partsMatch(QStringList parts) @@ -82,7 +84,7 @@ bool WildcardMatcher::partsMatch(QStringList parts) int WildcardMatcher::getMatchIndex(QString part, int startIndex) { - return m_text.indexOf(part, startIndex); + return m_text.indexOf(part, startIndex, Sensitivity); } bool WildcardMatcher::noMatchFound(int index) diff --git a/src/autotype/WildcardMatcher.h b/src/autotype/WildcardMatcher.h index fdf623822..a78536eff 100644 --- a/src/autotype/WildcardMatcher.h +++ b/src/autotype/WildcardMatcher.h @@ -34,6 +34,8 @@ public: bool match(QString pattern); private: + static const Qt::CaseSensitivity Sensitivity; + QString m_text; QString m_pattern; bool patternEqualsText(); diff --git a/tests/TestWildcardMatcher.cpp b/tests/TestWildcardMatcher.cpp index e8febe9e4..197d798c3 100644 --- a/tests/TestWildcardMatcher.cpp +++ b/tests/TestWildcardMatcher.cpp @@ -109,6 +109,13 @@ void TestWildcardMatcher::testMatchFollowingWildcards() verifyMatch(pattern); } +void TestWildcardMatcher::testCaseSensitivity() +{ + initMatcher(DefaultText.toUpper()); + QString pattern("some t**t"); + verifyMatch(pattern); +} + void TestWildcardMatcher::initMatcher(QString text) { m_matcher = new WildcardMatcher(text); diff --git a/tests/TestWildcardMatcher.h b/tests/TestWildcardMatcher.h index 2ee1c34ee..27d9a2b03 100644 --- a/tests/TestWildcardMatcher.h +++ b/tests/TestWildcardMatcher.h @@ -39,6 +39,7 @@ private Q_SLOTS: void testNoMatchWithMultipleWildcards(); void testMatchJustWildcard(); void testMatchFollowingWildcards(); + void testCaseSensitivity(); private: static const QString DefaultText;