~emihalac/mnemosyne-proj/mnemosyne-proj

« back to all changes in this revision

Viewing changes to mnemosyne/mnemosyne/pyqt_ui/completion_combo_box.py

  • Committer: Emilian Mihalache
  • Date: 2017-04-07 05:09:15 UTC
  • Revision ID: emihalac@gmail.com-20170407050915-4j5e1d5evt3vzmlm
Fix tag autocompletion when selection is done with mouse

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# completion_combo_box.py: Emilian Mihalache <emihalac@gmail.com>
3
3
#
4
4
 
5
 
from PyQt5 import QtCore, QtWidgets
 
5
from PyQt5 import QtCore, QtGui, QtWidgets
6
6
from mnemosyne.pyqt_ui.tag_line_edit import TagLineEdit
7
7
 
8
8
 
10
10
 
11
11
    def __init__(self, parent=None):
12
12
        super(CompletionComboBox, self).__init__(parent)
13
 
        tag_line_edit = TagLineEdit(self)
14
 
 
15
 
        # This performs QComboBox-internal setup of QCompleter object
16
 
        # on the QLineEdit object...
17
 
        self.setLineEdit(tag_line_edit)
18
 
 
19
 
        # ... which we have to wait for before doing our own
20
 
        # operations on that same QCompleter.
21
 
        tag_line_edit.setupCompleter()
 
 
b'\\ No newline at end of file'
 
13
 
 
14
        tag_line_edit_ = TagLineEdit(self)
 
15
        self.setLineEdit(tag_line_edit_)
 
16
 
 
17
        # Disable builtin autocompletion.
 
18
        # We'll be replacing it with an autocompletion mechanism
 
19
        #  that can work with elements after the first one.
 
20
        #
 
21
        # This _needs_ to be called _after_ setLineEdit(),
 
22
        #  because setLineEdit() will create&store a new QCompleter,
 
23
        #  which we're deleting here.
 
24
        self.setCompleter(None)
 
25
 
 
26
    def refresh_completion_model(self):
 
27
        self.lineEdit().refresh_completion_model(self.model())