This commit is contained in:
Samuel Mehrbrodt 2014-05-07 13:00:34 +02:00
parent a9e620c175
commit 3d1cb3f383
2 changed files with 17 additions and 1 deletions

View File

@ -295,7 +295,7 @@ def set_case_insensitive_completer(cache, widget):
Sets a case insensitive text completer for a widget. Sets a case insensitive text completer for a widget.
:param cache: The list of items to use as suggestions. :param cache: The list of items to use as suggestions.
:param widget: A widget to set the completer (QComboBox or QTextEdit instance) :param widget: A widget to set the completer (QComboBox or QLineEdit instance)
""" """
completer = QtGui.QCompleter(cache) completer = QtGui.QCompleter(cache)
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)

View File

@ -170,3 +170,19 @@ class TestUi(TestCase):
self.assertIsInstance(action.icon(), QtGui.QIcon) self.assertIsInstance(action.icon(), QtGui.QIcon)
self.assertEqual('my tooltip', action.toolTip()) self.assertEqual('my tooltip', action.toolTip())
self.assertEqual('my statustip', action.statusTip()) self.assertEqual('my statustip', action.statusTip())
def test_set_case_insensitive_completer(self):
"""
Test setting a case insensitive completer on a widget
"""
# GIVEN: A QComboBox and a list of completion items
line_edit = QtGui.QLineEdit()
suggestions = ['one', 'Two', 'THRee', 'FOUR']
# WHEN: We call the function
set_case_insensitive_completer(suggestions, line_edit)
# THEN: The Combobox should have a completer which is case insensitive
completer = line_edit.completer()
self.assertIsInstance(completer, QtGui.QCompleter)
self.assertEqual(completer.caseSensitivity(), QtCore.Qt.CaseInsensitive)