Skip to content

Commit

Permalink
Merge pull request #2591 from ales-erjavec/fixes/canvas/link-state
Browse files Browse the repository at this point in the history
[FIX] canvas: Fix link runtime state modeling
  • Loading branch information
astaric authored Sep 14, 2017
2 parents e131cbe + 09440bf commit dd60435
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 6 additions & 4 deletions Orange/canvas/canvas/items/linkitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ class LinkItem(QGraphicsObject):
#: These are pulled from SchemeLink.State for ease of binding to it's
#: state
State = SchemeLink.State
#: The link has no associated state.
NoState = SchemeLink.NoState
#: Link is empty; the source node does not have any value on output
Empty = SchemeLink.Empty
#: Link is active; the source node has a valid value on output
Expand Down Expand Up @@ -326,7 +328,7 @@ def __init__(self, *args):

self.__dynamic = False
self.__dynamicEnabled = False
self.__state = LinkItem.Empty
self.__state = LinkItem.NoState
self.hover = False

self.prepareGeometryChange()
Expand Down Expand Up @@ -707,10 +709,10 @@ def __updatePen(self):
normal = QPen(QBrush(QColor("#9CACB4")), 2.0)
hover = QPen(QBrush(QColor("#7D7D7D")), 2.1)

if self.__state & LinkItem.Active:
pen_style = Qt.SolidLine
else:
if self.__state & LinkItem.Empty:
pen_style = Qt.DashLine
else:
pen_style = Qt.SolidLine

normal.setStyle(pen_style)
hover.setStyle(pen_style)
Expand Down
12 changes: 7 additions & 5 deletions Orange/canvas/scheme/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ class State(enum.IntEnum):
"""
Flags indicating the runtime state of a link
"""
#: The link has no associated state.
NoState = 0
#: A link is empty when it has no value on it
Empty = 0
Empty = 1
#: A link is active when the source node provides a value on output
Active = 1
Active = 2
#: A link is pending when it's sink node has not yet been notified
#: of a change (note that Empty|Pending is a valid state)
Pending = 2
Pending = 4

Empty, Active, Pending = State
NoState, Empty, Active, Pending = State

def __init__(self, source_node, source_channel,
sink_node, sink_channel, enabled=True, properties=None,
Expand Down Expand Up @@ -125,7 +127,7 @@ def __init__(self, source_node, source_channel,

self.__enabled = enabled
self.__dynamic_enabled = False
self.__state = SchemeLink.Empty
self.__state = SchemeLink.NoState
self.__tool_tip = ""
self.properties = properties or {}

Expand Down

0 comments on commit dd60435

Please sign in to comment.