Skip to content

Commit

Permalink
gui/applets: hack completer model to block noxious dataChanged signal.
Browse files Browse the repository at this point in the history
…Closes #464
sbourdeauducq committed Aug 7, 2016

Verified

This commit was signed with the committer’s verified signature.
makenowjust Hiroya Fujinami
1 parent 84f4725 commit 8a243d3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion artiq/gui/applets.py
Original file line number Diff line number Diff line change
@@ -275,7 +275,21 @@ def createEditor(self, parent, option, index):
QtWidgets.QCompleter.CaseSensitivelySortedModel)
completer.setCompletionRole(QtCore.Qt.DisplayRole)
if hasattr(self, "model"):
completer.setModel(self.model)
# "TODO: Optimize updates in the source model"
# - Qt (qcompleter.cpp), never ceasing to disappoint.
# HACK:
# In the meantime, block dataChanged signals from the model.
# dataChanged never changes the content of the QCompleter in our
# case, but causes unnecessary flickering and trashing of the user
# selection when datasets are modified due to Qt's naive handler.
# Doing this is of course convoluted due to Qt's arrogance
# about private fields and not letting users knows what
# slots are connected to signals, but thanks to the complicated
# model system there is a short dirty hack in this particular case.
nodatachanged_model = QtCore.QIdentityProxyModel()
nodatachanged_model.setSourceModel(self.model)
completer.setModel(nodatachanged_model)
nodatachanged_model.dataChanged.disconnect()
return _AutoCompleteEdit(parent, completer)

def set_model(self, model):

0 comments on commit 8a243d3

Please sign in to comment.