Skip to content

Commit

Permalink
Merge pull request #1630 from ales-erjavec/line-edit-restore-changed-…
Browse files Browse the repository at this point in the history
…tracking

[FIX] gui.lineEdit: Restore changed state tracking
  • Loading branch information
janezd authored Oct 6, 2016
2 parents 751f676 + 5c0986e commit 0ddff35
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions Orange/widgets/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,18 +779,31 @@ def __init__(self, parent, callback, focusInCallback=None):
self.callback = callback
self.focusInCallback = focusInCallback
self.returnPressed.connect(self.returnPressedHandler)
# did the text change between focus enter and leave
self.__changed = False
self.textEdited.connect(self.__textEdited)

def __textEdited(self):
self.__changed = True

def returnPressedHandler(self):
if hasattr(self, "cback") and self.cback:
self.cback(self.text())
if self.callback:
self.callback()
if self.__changed:
self.__changed = False
if hasattr(self, "cback") and self.cback:
self.cback(self.text())
if self.callback:
self.callback()

def setText(self, text):
self.__changed = False
super().setText(text)

def focusOutEvent(self, *e):
super().focusOutEvent(*e)
self.returnPressedHandler()

def focusInEvent(self, *e):
self.__changed = False
if self.focusInCallback:
self.focusInCallback()
return super().focusInEvent(*e)
Expand Down Expand Up @@ -839,24 +852,16 @@ def lineEdit(widget, master, value, label=None, labelWidth=None,
b = widgetBox(widget, box, orientation, addToLayout=False)
if label is not None:
widgetLabel(b, label, labelWidth)
hasHBox = _is_horizontal(orientation)
else:
b = widget
hasHBox = False

baseClass = misc.pop("baseClass", None)
if baseClass:
ledit = baseClass(b)
if b is not widget:
b.layout().addWidget(ledit)
elif focusInCallback or callback and not callbackOnType:
if not hasHBox:
outer = hBox(b, addToLayout=(b is not widget))
if b is widget:
b = outer
else:
outer = b
ledit = LineEditWFocusOut(outer, callback, focusInCallback)
ledit = LineEditWFocusOut(b, callback, focusInCallback)
else:
ledit = QtGui.QLineEdit(b)
if b is not widget:
Expand Down

0 comments on commit 0ddff35

Please sign in to comment.