Ignore:
Files:
2 added
2 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/application/canvasmain.py

    r11446 r11415  
    537537                    checked=True, 
    538538                    shortcut=QKeySequence(Qt.ControlModifier | 
    539                                           (Qt.ShiftModifier | Qt.Key_D)), 
     539                                          Qt.ShiftModifier | Qt.Key_D), 
    540540                    triggered=self.set_tool_dock_expanded) 
    541541 
  • Orange/OrangeCanvas/canvas/__init__.py

    r11442 r11369  
    44====== 
    55 
    6 The :mod:`.canvas` package contains classes for visualizing the 
    7 contents of a :class:`~.scheme.Scheme`, utilizing the Qt's `Graphics View 
    8 Framework`_. 
    9  
    10 .. _`Graphics View Framework`: http://qt-project.org/doc/qt-4.8/graphicsview.html 
     6The :mod:`canvas` package contains classes for visualizing the 
     7contents of a :class:`.scheme.Scheme`, based on the Qt's Graphics view 
     8framework. 
    119 
    1210""" 
  • Orange/OrangeCanvas/canvas/items/annotationitem.py

    r11444 r11401  
    6262        return unicode(self.__placeholderText) 
    6363 
    64     placeholderText_ = Property(unicode, placeholderText, setPlaceholderText, 
    65                                 doc="Placeholder text") 
     64    placeholderText_ = Property(unicode, placeholderText, setPlaceholderText) 
    6665 
    6766    def paint(self, painter, option, widget=None): 
     
    7473                     self.textInteractionFlags() & Qt.TextEditable): 
    7574            brect = self.boundingRect() 
    76             painter.setFont(self.font()) 
    7775            metrics = painter.fontMetrics() 
    7876            text = metrics.elidedText(self.__placeholderText, Qt.ElideRight, 
  • Orange/OrangeCanvas/canvas/items/linkitem.py

    r11442 r11369  
    11""" 
    2 ========= 
    32Link Item 
    4 ========= 
    53 
    64""" 
     
    1816 
    1917class LinkCurveItem(QGraphicsPathItem): 
    20     """ 
    21     Link curve item. The main component of a :class:`LinkItem`. 
     18    """Link curve item. The main component of `LinkItem`. 
    2219    """ 
    2320    def __init__(self, parent): 
    2421        QGraphicsPathItem.__init__(self, parent) 
    25         if not isinstance(parent, LinkItem): 
    26             raise TypeError("'LinkItem' expected") 
    27  
     22        assert(isinstance(parent, LinkItem)) 
    2823        self.setAcceptedMouseButtons(Qt.NoButton) 
    2924        self.__canvasLink = parent 
     
    4439 
    4540    def linkItem(self): 
    46         """ 
    47         Return the :class:`LinkItem` instance this curve belongs to. 
     41        """Return the :class:`LinkItem` instance this curve belongs to. 
     42 
    4843        """ 
    4944        return self.__canvasLink 
     
    8883 
    8984class LinkAnchorIndicator(QGraphicsEllipseItem): 
    90     """ 
    91     A visual indicator of the link anchor point at both ends 
    92     of the :class:`LinkItem`. 
     85    """A visual indicator of the link anchor point at both ends 
     86    of the `LinkItem`. 
    9387 
    9488    """ 
     
    114108class LinkItem(QGraphicsObject): 
    115109    """ 
    116     A Link item in the canvas that connects two :class:`.NodeItem`\s in the 
    117     canvas. 
    118  
    119     The link curve connects two `Anchor` items (see :func:`setSourceItem` 
    120     and :func:`setSinkItem`). Once the anchors are set the curve 
    121     automatically adjusts its end points whenever the anchors move. 
    122  
    123     An optional source/sink text item can be displayed above the curve's 
    124     central point (:func:`setSourceName`, :func:`setSinkName`) 
    125  
     110    A Link in the canvas. 
    126111    """ 
    127112 
    128     #: Z value of the item 
    129113    Z_VALUE = 0 
     114    """Z value of the item""" 
    130115 
    131116    def __init__(self, *args): 
     
    161146    def setSourceItem(self, item, anchor=None): 
    162147        """ 
    163         Set the source `item` (:class:`.NodeItem`). Use `anchor` 
    164         (:class:`.AnchorPoint`) as the curve start point (if ``None`` a new 
    165         output anchor will be created using ``item.newOutputAnchor()``). 
     148        Set the source `item` (:class:`NodeItem`). Use `anchor` 
     149        (:class:`AnchorPoint`) as the curve start point (if ``None`` a new 
     150        output anchor will be created). 
    166151 
    167152        Setting item to ``None`` and a valid anchor is a valid operation 
     
    211196    def setSinkItem(self, item, anchor=None): 
    212197        """ 
    213         Set the sink `item` (:class:`.NodeItem`). Use `anchor` 
    214         (:class:`.AnchorPoint`) as the curve end point (if ``None`` a new 
    215         input anchor will be created using ``item.newInputAnchor()``). 
     198        Set the sink `item` (:class:`NodeItem`). Use `anchor` 
     199        (:class:`AnchorPoint`) as the curve end point (if ``None`` a new 
     200        input anchor will be created). 
    216201 
    217202        Setting item to ``None`` and a valid anchor is a valid operation 
     
    261246    def setFont(self, font): 
    262247        """ 
    263         Set the font for the channel names text item. 
     248        Set the font for the channel names text. 
    264249        """ 
    265250        if font != self.font(): 
     
    413398    def setEnabled(self, enabled): 
    414399        """ 
    415         Reimplemented from :class:`QGraphicsObject` 
    416  
    417400        Set link enabled state. When disabled the link is rendered with a 
    418401        dashed line. 
     
    442425    def setDynamic(self, dynamic): 
    443426        """ 
    444         Mark the link as dynamic (i.e. it responds to 
    445         :func:`setDynamicEnabled`). 
     427        Mark the link as dynamic (e.i. it responds to the 
     428        ``setDynamicEnabled``). 
    446429 
    447430        """ 
  • Orange/OrangeCanvas/canvas/items/nodeitem.py

    r11442 r11411  
    11""" 
    2 ========= 
    3 Node Item 
    4 ========= 
     2NodeItem 
    53 
    64""" 
     
    5452    Create and return a default palette for a node. 
    5553    """ 
    56     return create_palette(QColor(NAMED_COLORS["light-yellow"]), 
    57                           QColor(NAMED_COLORS["yellow"])) 
     54    return create_palette(QColor(NAMED_COLORS["light-orange"]), 
     55                          QColor(NAMED_COLORS["orange"])) 
    5856 
    5957 
     
    274272    """ 
    275273 
    276     #: Signal emitted when the item's scene position changes. 
     274    # Signal emitted when the item's scene position changes. 
    277275    scenePositionChanged = Signal(QPointF) 
    278276 
    279     #: Signal emitted when the item's `anchorDirection` changes. 
    280277    anchorDirectionChanged = Signal(QPointF) 
    281278 
     
    695692    """ 
    696693 
    697     #: Signal emitted when the scene position of the node has changed. 
     694    # Scene position of the node has changed. 
    698695    positionChanged = Signal() 
    699696 
    700     #: Signal emitted when the geometry of the channel anchors changes. 
     697    # Geometry of the channel anchors changed 
    701698    anchorGeometryChanged = Signal() 
    702699 
    703     #: Signal emitted when the item has been activated (by a mouse double 
    704     #: click or a keyboard) 
     700    # The item has been activated (by a mouse double click or a keyboard). 
    705701    activated = Signal() 
    706702 
    707     #: The item is under the mouse. 
     703    # The item is under the mouse. 
    708704    hovered = Signal() 
    709705 
     
    856852    def setIcon(self, icon): 
    857853        """ 
    858         Set the node item's icon (:class:`QIcon`). 
     854        Set the node item's icon. 
    859855        """ 
    860856        if isinstance(icon, QIcon): 
     
    997993    def newInputAnchor(self): 
    998994        """ 
    999         Create and return a new input :class:`AnchorPoint`. 
     995        Create and return a new input anchor point. 
    1000996        """ 
    1001997        if not (self.widget_description and self.widget_description.inputs): 
     
    10231019    def newOutputAnchor(self): 
    10241020        """ 
    1025         Create and return a new output :class:`AnchorPoint`. 
     1021        Create a new output anchor indicator. 
    10261022        """ 
    10271023        if not (self.widget_description and self.widget_description.outputs): 
     
    10491045    def inputAnchors(self): 
    10501046        """ 
    1051         Return a list of all input anchor points. 
     1047        Return a list of input anchor points. 
    10521048        """ 
    10531049        return self.inputAnchorItem.anchorPoints() 
     
    10551051    def outputAnchors(self): 
    10561052        """ 
    1057         Return a list of all output anchor points. 
     1053        Return a list of output anchor points. 
    10581054        """ 
    10591055        return self.outputAnchorItem.anchorPoints() 
  • Orange/OrangeCanvas/canvas/scene.py

    r11442 r11411  
    3636class CanvasScene(QGraphicsScene): 
    3737    """ 
    38     A Graphics Scene for displaying an :class:`~.scheme.Scheme` instance. 
     38    A Graphics Scene for displaying and editing an :class:`Scheme`. 
    3939    """ 
    4040 
    41     #: Signal emitted when a :class:`NodeItem` has been added to the scene. 
     41    #: An node item has been added to the scene. 
    4242    node_item_added = Signal(items.NodeItem) 
    4343 
    44     #: Signal emitted when a :class:`NodeItem` has been removed from the 
    45     #: scene. 
     44    #: An node item has been removed from the scene 
    4645    node_item_removed = Signal(items.LinkItem) 
    4746 
    48     #: Signal emitted when a new :class:`LinkItem` has been added to the 
    49     #: scene. 
     47    #: A new link item has been added to the scene 
    5048    link_item_added = Signal(items.LinkItem) 
    5149 
    52     #: Signal emitted when a :class:`LinkItem` has been removed. 
     50    #: Link item has been removed 
    5351    link_item_removed = Signal(items.LinkItem) 
    5452 
    55     #: Signal emitted when a :class:`Annotation` item has been added. 
     53    #: Annotation item has been added 
    5654    annotation_added = Signal(items.annotationitem.Annotation) 
    5755 
    58     #: Signal emitted when a :class:`Annotation` item has been removed. 
     56    #: Annotation item has been removed 
    5957    annotation_removed = Signal(items.annotationitem.Annotation) 
    6058 
    61     #: Signal emitted when the position of a :class:`NodeItem` has changed. 
     59    #: The position of a node has changed 
    6260    node_item_position_changed = Signal(items.NodeItem, QPointF) 
    6361 
    64     #: Signal emitted when an :class:`NodeItem` has been double clicked. 
     62    #: An node item has been double clicked 
    6563    node_item_double_clicked = Signal(items.NodeItem) 
    6664 
     
    124122 
    125123    def clear_scene(self): 
    126         """ 
    127         Clear (reset) the scene. 
    128         """ 
    129124        self.scheme = None 
    130125        self.__node_items = [] 
     
    143138 
    144139    def set_scheme(self, scheme): 
    145         """ 
    146         Set the scheme to display. Populates the scene with nodes and links 
    147         already in the scheme. Any further change to the scheme will be 
    148         reflected in the scene. 
    149  
    150         Parameters 
    151         ---------- 
    152         scheme : :class:`~.scheme.Scheme` 
     140        """Set the scheme to display and edit. Populates the scene 
     141        with nodes and links already in the scheme. 
    153142 
    154143        """ 
     
    205194 
    206195    def set_registry(self, registry): 
    207         """ 
    208         Set the widget registry. 
    209         """ 
    210         # TODO: Remove/Deprecate. Is used only to get the category/background 
    211         # color. That should be part of the SchemeNode/WidgetDescription. 
     196        """Set the widget registry. 
     197        """ 
    212198        log.info("Setting registry '%s on '%s'." % (registry, self)) 
    213199        self.registry = registry 
    214200 
    215201    def set_anchor_layout(self, layout): 
    216         """ 
    217         Set an :class:`~.layout.AnchorLayout` 
    218         """ 
    219202        if self.__anchor_layout != layout: 
    220203            if self.__anchor_layout: 
     
    225208 
    226209    def anchor_layout(self): 
    227         """ 
    228         Return the anchor layout instance. 
    229         """ 
    230210        return self.__anchor_layout 
    231211 
    232212    def set_channel_names_visible(self, visible): 
    233         """ 
    234         Set the channel names visibility. 
    235         """ 
    236213        self.__channel_names_visible = visible 
    237214        for link in self.__link_items: 
     
    239216 
    240217    def channel_names_visible(self): 
    241         """ 
    242         Return the channel names visibility state. 
    243         """ 
    244218        return self.__channel_names_visible 
    245219 
    246220    def set_node_animation_enabled(self, enabled): 
    247         """ 
    248         Set node animation enabled state. 
    249         """ 
    250221        if self.__node_animation_enabled != enabled: 
    251222            self.__node_animation_enabled = enabled 
     
    255226 
    256227    def add_node_item(self, item): 
    257         """ 
    258         Add a :class:`.NodeItem` instance to the scene. 
     228        """Add a :class:`NodeItem` instance to the scene. 
    259229        """ 
    260230        if item in self.__node_items: 
     
    291261 
    292262    def add_node(self, node): 
    293         """ 
    294         Add and return a default constructed :class:`.NodeItem` for a 
    295         :class:`SchemeNode` instance `node`. If the `node` is already in 
    296         the scene do nothing and just return its item. 
     263        """Add and return a default constructed `NodeItem` for a 
     264        `SchemeNode` instance. If the node is already in the scene 
     265        do nothing and just return its item. 
    297266 
    298267        """ 
     
    321290 
    322291    def new_node_item(self, widget_desc, category_desc=None): 
    323         """ 
    324         Construct an new :class:`.NodeItem` from a `WidgetDescription`. 
     292        """Construct an new `NodeItem` from a `WidgetDescription`. 
    325293        Optionally also set `CategoryDescription`. 
    326294 
     
    345313 
    346314    def remove_node_item(self, item): 
    347         """ 
    348         Remove `item` (:class:`.NodeItem`) from the scene. 
     315        """Remove `item` (:class:`NodeItem`) from the scene. 
    349316        """ 
    350317        self.activated_mapper.removePyMappings(item) 
     
    360327 
    361328    def remove_node(self, node): 
    362         """ 
    363         Remove the :class:`.NodeItem` instance that was previously 
    364         constructed for a :class:`SchemeNode` `node` using the `add_node` 
    365         method. 
     329        """Remove the `NodeItem` instance that was previously constructed for 
     330        a `SchemeNode` node using the `add_node` method. 
    366331 
    367332        """ 
     
    376341 
    377342    def node_items(self): 
    378         """ 
    379         Return all :class:`.NodeItem` instances in the scene. 
     343        """Return all :class:`NodeItem` instances in the scene. 
    380344        """ 
    381345        return list(self.__node_items) 
    382346 
    383347    def add_link_item(self, item): 
    384         """ 
    385         Add a link (:class:`.LinkItem`) to the scene. 
     348        """Add a link (:class:`LinkItem`)to the scene. 
    386349        """ 
    387350        if item.scene() is not self: 
     
    401364 
    402365    def add_link(self, scheme_link): 
    403         """ 
    404         Create and add a :class:`.LinkItem` instance for a 
    405         :class:`SchemeLink` instance. If the link is already in the scene 
    406         do nothing and just return its :class:`.LinkItem`. 
     366        """Create and add a `LinkItem` instance for a `SchemeLink` 
     367        instance. If the link is already in the scene do nothing 
     368        and just return its `LinkItem`. 
    407369 
    408370        """ 
     
    430392    def new_link_item(self, source_item, source_channel, 
    431393                      sink_item, sink_channel): 
    432         """ 
    433         Construct and return a new :class:`.LinkItem` 
     394        """Construct and return a new `LinkItem` 
    434395        """ 
    435396        item = items.LinkItem() 
     
    459420 
    460421    def remove_link_item(self, item): 
    461         """ 
    462         Remove a link (:class:`.LinkItem`) from the scene. 
     422        """Remove a link (:class:`LinkItem`) from the scene. 
    463423        """ 
    464424        # Invalidate the anchor layout. 
     
    483443 
    484444    def remove_link(self, scheme_link): 
    485         """ 
    486         Remove a :class:`.LinkItem` instance that was previously constructed 
    487         for a :class:`SchemeLink` instance `link` using the `add_link` method. 
     445        """ Remove a `LinkItem` instance that was previously constructed for 
     446        a `SchemeLink` node using the `add_link` method. 
    488447 
    489448        """ 
     
    493452 
    494453    def link_items(self): 
    495         """ 
    496         Return all :class:`.LinkItem`\s in the scene. 
     454        """Return all :class:`LinkItems` in the scene. 
     455 
    497456        """ 
    498457        return list(self.__link_items) 
    499458 
    500459    def add_annotation_item(self, annotation): 
    501         """ 
    502         Add an :class:`.Annotation` item to the scene. 
     460        """Add an `Annotation` item to the scene. 
     461 
    503462        """ 
    504463        self.__annotation_items.append(annotation) 
     
    508467 
    509468    def add_annotation(self, scheme_annot): 
    510         """ 
    511         Create a new item for :class:`SchemeAnnotation` and add it 
     469        """Create a new item for :class:`SchemeAnnotation` and add it 
    512470        to the scene. If the `scheme_annot` is already in the scene do 
    513471        nothing and just return its item. 
     
    546504 
    547505    def remove_annotation_item(self, annotation): 
    548         """ 
    549         Remove an :class:`.Annotation` instance from the scene. 
     506        """Remove an `Annotation` item from the scene. 
    550507 
    551508        """ 
     
    555512 
    556513    def remove_annotation(self, scheme_annotation): 
    557         """ 
    558         Remove an :class:`.Annotation` instance that was previously added 
    559         using :func:`add_anotation`. 
    560  
    561         """ 
    562514        item = self.__item_for_annotation.pop(scheme_annotation) 
    563515 
     
    574526 
    575527    def annotation_items(self): 
    576         """ 
    577         Return all :class:`.Annotation` items in the scene. 
     528        """Return all `Annotation` items in the scene. 
     529 
    578530        """ 
    579531        return self.__annotation_items 
     
    588540 
    589541    def commit_scheme_node(self, node): 
    590         """ 
    591         Commit the `node` into the scheme. 
     542        """Commit the `node` into the scheme. 
    592543        """ 
    593544        if not self.editable: 
     
    602553            self.scheme.add_node(node) 
    603554        except Exception: 
    604             log.error("An error occurred while committing node '%s'", 
     555            log.error("An unexpected error occurred while commiting node '%s'", 
    605556                      node, exc_info=True) 
    606557            # Cleanup (remove the node item) 
     
    612563 
    613564    def commit_scheme_link(self, link): 
    614         """ 
    615         Commit a scheme link. 
     565        """Commit a scheme link. 
    616566        """ 
    617567        if not self.editable: 
     
    626576 
    627577    def node_for_item(self, item): 
    628         """ 
    629         Return the `SchemeNode` for the `item`. 
     578        """Return the `SchemeNode` for the `item`. 
    630579        """ 
    631580        rev = dict([(v, k) for k, v in self.__item_for_node.items()]) 
     
    633582 
    634583    def item_for_node(self, node): 
    635         """ 
    636         Return the :class:`NodeItem` instance for a :class:`SchemeNode`. 
     584        """Return the :class:`NodeItem` instance for a :class:`SchemeNode`. 
    637585        """ 
    638586        return self.__item_for_node[node] 
    639587 
    640588    def link_for_item(self, item): 
    641         """ 
    642         Return the `SchemeLink for `item` (:class:`LinkItem`). 
     589        """Return the `SchemeLink for `item` (:class:`LinkItem`). 
    643590        """ 
    644591        rev = dict([(v, k) for k, v in self.__item_for_link.items()]) 
     
    646593 
    647594    def item_for_link(self, link): 
    648         """ 
    649         Return the :class:`LinkItem` for a :class:`SchemeLink` 
     595        """Return the :class:`LinkItem` for a :class:`SchemeLink` 
    650596        """ 
    651597        return self.__item_for_link[link] 
    652598 
    653599    def selected_node_items(self): 
    654         """ 
    655         Return the selected :class:`NodeItem`'s. 
     600        """Return the selected :class:`NodeItem`'s. 
    656601        """ 
    657602        return [item for item in self.__node_items if item.isSelected()] 
    658603 
    659604    def selected_annotation_items(self): 
    660         """ 
    661         Return the selected :class:`Annotation`'s 
     605        """Return the selected :class:`Annotation`'s 
    662606        """ 
    663607        return [item for item in self.__annotation_items if item.isSelected()] 
    664608 
    665609    def node_links(self, node_item): 
    666         """ 
    667         Return all links from the `node_item` (:class:`NodeItem`). 
     610        """Return all links from the `node_item` (:class:`NodeItem`). 
    668611        """ 
    669612        return self.node_output_links(node_item) + \ 
     
    671614 
    672615    def node_output_links(self, node_item): 
    673         """ 
    674         Return a list of all output links from `node_item`. 
     616        """Return a list of all output links from `node_item`. 
    675617        """ 
    676618        return [link for link in self.__link_items 
     
    678620 
    679621    def node_input_links(self, node_item): 
    680         """ 
    681         Return a list of all input links for `node_item`. 
     622        """Return a list of all input links for `node_item`. 
    682623        """ 
    683624        return [link for link in self.__link_items 
     
    685626 
    686627    def neighbor_nodes(self, node_item): 
    687         """ 
    688         Return a list of `node_item`'s (class:`NodeItem`) neighbor nodes. 
     628        """Return a list of `node_item`'s (class:`NodeItem`) neighbor nodes. 
    689629        """ 
    690630        neighbors = map(attrgetter("sourceItem"), 
     
    871811 
    872812def grab_svg(scene): 
    873     """ 
    874     Return a SVG rendering of the scene contents. 
    875  
    876     Parameters 
    877     ---------- 
    878     scene : :class:`CanvasScene` 
    879  
     813    """Return a SVG rendering of the scene contents. 
    880814    """ 
    881815    from PyQt4.QtSvg import QSvgGenerator 
  • Orange/OrangeCanvas/document/interactions.py

    r11450 r11401  
    11""" 
    2 ========================= 
    3 User Interaction Handlers 
    4 ========================= 
    5  
    6 User interaction handlers for a :class:`~.SchemeEditWidget`. 
    7  
    8 User interactions encapsulate the logic of user interactions with the 
    9 scheme document. 
    10  
    11 All interactions are subclasses of :class:`UserInteraction`. 
    12  
     2User interaction handlers for CanvasScene. 
    133 
    144""" 
    15  
    165import logging 
    176 
    187from PyQt4.QtGui import ( 
    19     QApplication, QGraphicsRectItem, QPen, QBrush, QColor, QFontMetrics, 
    20     QUndoCommand 
     8    QApplication, QGraphicsRectItem, QPen, QBrush, QColor, QFontMetrics 
    219) 
    2210 
     
    3321from ..gui.quickhelp import QuickHelpTipEvent 
    3422from . import commands 
    35 from .editlinksdialog import EditLinksDialog 
    3623 
    3724log = logging.getLogger(__name__) 
     
    3926 
    4027class UserInteraction(QObject): 
    41     """ 
    42     Base class for user interaction handlers. 
    43  
    44     Parameters 
    45     ---------- 
    46     document : :class:`~.SchemeEditWidget` 
    47         An scheme editor instance with which the user is interacting. 
    48     parent : :class:`QObject`, optional 
    49         A parent QObject 
    50     deleteOnEnd : bool, optional 
    51         Should the UserInteraction be deleted when it finishes (``True`` 
    52         by default). 
    53  
    54     """ 
    55     # Cancel reason flags 
    56  
    57     #: No specified reason 
    58     NoReason = 0 
    59     #: User canceled the operation (e.g. pressing ESC) 
    60     UserCancelReason = 1 
    61     #: Another interaction was set 
    62     InteractionOverrideReason = 3 
    63     #: An internal error occurred 
    64     ErrorReason = 4 
    65     #: Other (unspecified) reason 
     28    # cancel reason flags 
     29    NoReason = 0  # No specified reason 
     30    UserCancelReason = 1  # User canceled the operation (e.g. pressing ESC) 
     31    InteractionOverrideReason = 3  # Another interaction was set 
     32    ErrorReason = 4  # An internal error occurred 
    6633    OtherReason = 5 
    6734 
    68     #: Emitted when the interaction is set on the scene. 
     35    # Emitted when the interaction is set on the scene. 
    6936    started = Signal() 
    7037 
    71     #: Emitted when the interaction finishes successfully. 
     38    # Emitted when the interaction finishes successfully. 
    7239    finished = Signal() 
    7340 
    74     #: Emitted when the interaction ends (canceled or finished) 
     41    # Emitted when the interaction ends (canceled or finished) 
    7542    ended = Signal() 
    7643 
    77     #: Emitted when the interaction is canceled. 
     44    # Emitted when the interaction is canceled. 
    7845    canceled = Signal([], [int]) 
    7946 
     
    9259 
    9360    def start(self): 
    94         """ 
    95         Start the interaction. This is called by the :class:`CanvasScene` when 
     61        """Start the interaction. This is called by the scene when 
    9662        the interaction is installed. 
    9763 
    98         .. note:: Must be called from subclass implementations. 
     64        Must be called from subclass implementations. 
    9965 
    10066        """ 
     
    10268 
    10369    def end(self): 
    104         """ 
    105         Finish the interaction. Restore any leftover state in this method. 
    106  
    107         .. note:: This gets called from the default :func:`cancel` 
    108                   implementation. 
     70        """Finish the interaction. Restore any leftover state in 
     71        this method. 
     72 
     73        .. note:: This gets called from the default `cancel` implementation. 
    10974 
    11075        """ 
     
    12691 
    12792    def cancel(self, reason=OtherReason): 
    128         """ 
    129         Cancel the interaction with `reason`. 
     93        """Cancel the interaction for `reason`. 
    13094        """ 
    13195 
     
    136100 
    137101    def isFinished(self): 
    138         """ 
    139         Is the interaction finished. 
     102        """Has the interaction finished. 
    140103        """ 
    141104        return self.__finished 
    142105 
    143106    def isCanceled(self): 
    144         """ 
    145         Was the interaction canceled. 
     107        """Was the interaction canceled. 
    146108        """ 
    147109        return self.__canceled 
    148110 
    149111    def cancelReason(self): 
    150         """ 
    151         Return the reason the interaction was canceled. 
     112        """Return the reason the interaction was canceled. 
    152113        """ 
    153114        return self.__cancelReason 
    154115 
    155116    def mousePressEvent(self, event): 
    156         """ 
    157         Handle a `QGraphicsScene.mousePressEvent`. 
    158         """ 
    159117        return False 
    160118 
    161119    def mouseMoveEvent(self, event): 
    162         """ 
    163         Handle a `GraphicsScene.mouseMoveEvent`. 
    164         """ 
    165120        return False 
    166121 
    167122    def mouseReleaseEvent(self, event): 
    168         """ 
    169         Handle a `QGraphicsScene.mouseReleaseEvent`. 
    170         """ 
    171123        return False 
    172124 
    173125    def mouseDoubleClickEvent(self, event): 
    174         """ 
    175         Handle a `QGraphicsScene.mouseDoubleClickEvent`. 
    176         """ 
    177126        return False 
    178127 
    179128    def keyPressEvent(self, event): 
    180         """ 
    181         Handle a `QGraphicsScene.keyPressEvent` 
    182         """ 
    183129        if self.cancelOnEsc and event.key() == Qt.Key_Escape: 
    184130            self.cancel(self.UserCancelReason) 
     
    186132 
    187133    def keyReleaseEvent(self, event): 
    188         """ 
    189         Handle a `QGraphicsScene.keyPressEvent` 
    190         """ 
    191134        return False 
    192135 
     
    196139 
    197140 
    198 class UserCanceledError(ValueError): 
    199     pass 
    200  
    201  
    202141def reversed_arguments(func): 
    203     """ 
    204     Return a function with reversed argument order. 
     142    """Return a function with reversed argument order. 
    205143    """ 
    206144    def wrapped(*args): 
     
    210148 
    211149class NewLinkAction(UserInteraction): 
    212     """ 
    213     User drags a new link from an existing `NodeAnchorItem` to create 
     150    """User drags a new link from an existing node anchor item to create 
    214151    a connection between two existing nodes or to a new node if the release 
    215152    is over an empty area, in which case a quick menu for new node selection 
     
    228165        self.direction = None 
    229166 
    230         # An `NodeItem` currently under the mouse as a possible 
    231         # link drop target. 
    232167        self.current_target_item = None 
    233         # A temporary `LinkItem` used while dragging. 
    234168        self.tmp_link_item = None 
    235         # An temporary `AnchorPoint` inserted into `current_target_item` 
    236169        self.tmp_anchor_point = None 
    237         # An `AnchorPoint` following the mouse cursor 
    238170        self.cursor_anchor_point = None 
    239         # An QUndoCommand 
    240         self.macro = None 
    241171 
    242172    def remove_tmp_anchor(self): 
    243         """ 
    244         Remove a temporary anchor point from the current target item. 
     173        """Remove a temp anchor point from the current target item. 
    245174        """ 
    246175        if self.direction == self.FROM_SOURCE: 
     
    251180 
    252181    def create_tmp_anchor(self, item): 
    253         """ 
    254         Create a new tmp anchor at the `item` (:class:`NodeItem`). 
     182        """Create a new tmp anchor at the item (`NodeItem`). 
    255183        """ 
    256184        assert(self.tmp_anchor_point is None) 
     
    261189 
    262190    def can_connect(self, target_item): 
    263         """ 
    264         Is the connection between `self.from_item` (item where the drag 
    265         started) and `target_item` possible. 
     191        """Is the connection between `self.from_item` (item where the drag 
     192        started) and `target_item`. 
    266193 
    267194        """ 
     
    275202 
    276203    def set_link_target_anchor(self, anchor): 
    277         """ 
    278         Set the temp line target anchor. 
     204        """Set the temp line target anchor 
    279205        """ 
    280206        if self.direction == self.FROM_SOURCE: 
     
    284210 
    285211    def target_node_item_at(self, pos): 
    286         """ 
    287         Return a suitable :class:`NodeItem` at position `pos` on which 
    288         a link can be dropped. 
    289  
    290         """ 
    291         # Test for a suitable `NodeAnchorItem` or `NodeItem` at pos. 
     212        """Return a suitable NodeItem on which a link can be dropped. 
     213        """ 
     214        # Test for a suitable NodeAnchorItem or NodeItem at pos. 
    292215        if self.direction == self.FROM_SOURCE: 
    293216            anchor_type = items.SinkAnchorItem 
     
    394317            node = None 
    395318            stack = self.document.undoStack() 
    396  
    397             self.macro = QUndoCommand(self.tr("Add link")) 
     319            stack.beginMacro("Add link") 
    398320 
    399321            if item: 
    400                 # If the release was over a node item then connect them 
     322                # If the release was over a widget item 
     323                # then connect them 
    401324                node = self.scene.node_for_item(item) 
    402325            else: 
     
    411334 
    412335                if node is not None: 
    413                     commands.AddNodeCommand(self.scheme, node, 
    414                                             parent=self.macro) 
     336                    self.document.addNode(node) 
    415337 
    416338            if node is not None: 
    417                 if self.direction == self.FROM_SOURCE: 
    418                     source_node = self.scene.node_for_item(self.source_item) 
    419                     sink_node = node 
    420                 else: 
    421                     source_node = node 
    422                     sink_node = self.scene.node_for_item(self.sink_item) 
    423                 self.connect_nodes(source_node, sink_node) 
    424  
    425                 if not self.isCanceled() or not self.isFinished() and \ 
    426                         self.macro is not None: 
    427                     # Push (commit) the add link/node action on the stack. 
    428                     stack.push(self.macro) 
    429  
    430             self.end() 
    431  
     339                self.connect_existing(node) 
     340            else: 
     341                self.end() 
     342 
     343            stack.endMacro() 
    432344        else: 
    433345            self.end() 
     
    435347 
    436348    def create_new(self, event): 
    437         """ 
    438         Create and return a new node with a `QuickMenu`. 
     349        """Create and return a new node with a QuickWidgetMenu. 
    439350        """ 
    440351        pos = event.screenPos() 
     
    479390            return node 
    480391 
    481     def connect_nodes(self, source_node, sink_node): 
    482         """ 
    483         Connect `source_node` to `sink_node`. If there are more then one 
    484         equally weighted and non conflicting links possible present a 
    485         detailed dialog for link editing. 
    486  
    487         """ 
     392    def connect_existing(self, node): 
     393        """Connect anchor_item to `node`. 
     394        """ 
     395        if self.direction == self.FROM_SOURCE: 
     396            source_item = self.source_item 
     397            source_node = self.scene.node_for_item(source_item) 
     398            sink_node = node 
     399        else: 
     400            source_node = node 
     401            sink_item = self.sink_item 
     402            sink_node = self.scene.node_for_item(sink_item) 
     403 
    488404        try: 
    489405            possible = self.scheme.propose_links(source_node, sink_node) 
     
    496412 
    497413            source, sink, w = possible[0] 
    498  
    499             # just a list of signal tuples for now, will be converted 
    500             # to SchemeLinks later 
    501414            links_to_add = [(source, sink)] 
    502             links_to_remove = [] 
     415 
    503416            show_link_dialog = False 
    504417 
     
    516429                    show_link_dialog = True 
    517430 
    518             if show_link_dialog: 
    519                 existing = self.scheme.find_links(source_node=source_node, 
    520                                                   sink_node=sink_node) 
    521  
    522                 if existing: 
    523                     # edit_links will populate the view with existing links 
    524                     initial_links = None 
    525                 else: 
    526                     initial_links = [(source, sink)] 
    527  
    528                 try: 
    529                     rstatus, links_to_add, links_to_remove = self.edit_links( 
    530                         source_node, sink_node, initial_links 
     431                if show_link_dialog: 
     432                    existing = self.scheme.find_links(source_node=source_node, 
     433                                                      sink_node=sink_node) 
     434 
     435                    if existing: 
     436                        # EditLinksDialog will populate the view with 
     437                        # existing links 
     438                        initial_links = None 
     439                    else: 
     440                        initial_links = [(source, sink)] 
     441 
     442                    links_action = EditNodeLinksAction( 
     443                                    self.document, source_node, sink_node) 
     444                    try: 
     445                        links_action.edit_links(initial_links) 
     446                    except Exception: 
     447                        log.error("'EditNodeLinksAction' failed", 
     448                                  exc_info=True) 
     449                        raise 
     450                    # EditNodeLinksAction already commits the links on accepted 
     451                    links_to_add = [] 
     452 
     453            for source, sink in links_to_add: 
     454                if sink.single: 
     455                    # Remove an existing link to the sink channel if present. 
     456                    existing_link = self.scheme.find_links( 
     457                        sink_node=sink_node, sink_channel=sink 
    531458                    ) 
    532                 except Exception: 
    533                     log.error("Failed to edit the links", 
    534                               exc_info=True) 
    535                     raise 
    536                 if rstatus == EditLinksDialog.Rejected: 
    537                     raise UserCanceledError 
    538             else: 
    539                 # links_to_add now needs to be a list of actual SchemeLinks 
    540                 links_to_add = [scheme.SchemeLink( 
    541                                     source_node, source_channel, 
    542                                     sink_node, sink_channel) 
    543                                 for source_channel, sink_channel 
    544                                 in links_to_add] 
    545  
    546                 links_to_add, links_to_remove = \ 
    547                     add_links_plan(self.scheme, links_to_add) 
    548  
    549             # Remove temp items before creating any new links 
    550             self.cleanup() 
    551  
    552             for link in links_to_remove: 
    553                 commands.RemoveLinkCommand(self.scheme, link, 
    554                                            parent=self.macro) 
    555  
    556             for link in links_to_add: 
    557                 # Check if the new requested link is a duplicate of an 
    558                 # existing link 
     459 
     460                    if existing_link: 
     461                        self.document.removeLink(existing_link[0]) 
     462 
     463                # Check if the new link is a duplicate of an existing link 
    559464                duplicate = self.scheme.find_links( 
    560                     link.source_node, link.source_channel, 
    561                     link.sink_node, link.sink_channel 
     465                    source_node, source, sink_node, sink 
    562466                ) 
    563467 
    564                 if not duplicate: 
    565                     commands.AddLinkCommand(self.scheme, link, 
    566                                             parent=self.macro) 
     468                if duplicate: 
     469                    # Do nothing. 
     470                    continue 
     471 
     472                # Remove temp items before creating a new link 
     473                self.cleanup() 
     474 
     475                link = scheme.SchemeLink(source_node, source, sink_node, sink) 
     476                self.document.addLink(link) 
    567477 
    568478        except scheme.IncompatibleChannelTypeError: 
     
    575485            log.info("Cannot connect: no possible links.") 
    576486            self.cancel() 
    577         except UserCanceledError: 
    578             log.info("User canceled a new link action.") 
    579             self.cancel(UserInteraction.UserCancelReason) 
    580487        except Exception: 
    581488            log.error("An error occurred during the creation of a new link.", 
     
    583490            self.cancel() 
    584491 
    585     def edit_links(self, source_node, sink_node, initial_links=None): 
    586         """ 
    587         Show and execute the `EditLinksDialog`. 
    588         Optional `initial_links` list can provide a list of initial 
    589         `(source, sink)` channel tuples to show in the view, otherwise 
    590         the dialog is populated with existing links in the scheme (passing 
    591         an empty list will disable all initial links). 
    592  
    593         """ 
    594         status, links_to_add, links_to_remove = \ 
    595             edit_links( 
    596                 self.scheme, source_node, sink_node, initial_links, 
    597                 parent=self.document 
    598             ) 
    599  
    600         if status == EditLinksDialog.Accepted: 
    601             links_to_add = [scheme.SchemeLink( 
    602                                 source_node, source_channel, 
    603                                 sink_node, sink_channel) 
    604                             for source_channel, sink_channel in links_to_add] 
    605  
    606             links_to_remove = [self.scheme.find_links( 
    607                                    source_node, source_channel, 
    608                                    sink_node, sink_channel) 
    609                                for source_channel, sink_channel 
    610                                in links_to_remove] 
    611  
    612             links_to_remove = reduce(list.__add__, links_to_remove, []) 
    613             conflicting = filter(None, 
    614                                  [conflicting_single_link(self.scheme, link) 
    615                                   for link in links_to_add]) 
    616             for link in conflicting: 
    617                 if link not in links_to_remove: 
    618                     links_to_remove.append(link) 
    619  
    620             return status, links_to_add, links_to_remove 
    621         else: 
    622             return status, [], [] 
     492        if not self.isFinished(): 
     493            self.end() 
    623494 
    624495    def end(self): 
    625496        self.cleanup() 
    626         # Remove the help tip set in mousePressEvent 
    627         self.macro = None 
    628497        helpevent = QuickHelpTipEvent("", "") 
    629498        QCoreApplication.postEvent(self.document, helpevent) 
     
    635504 
    636505    def cleanup(self): 
    637         """ 
    638         Cleanup all temporary items in the scene that are left. 
     506        """Cleanup all temp items in the scene that are left. 
    639507        """ 
    640508        if self.tmp_link_item: 
     
    656524 
    657525 
    658 def edit_links(scheme, source_node, sink_node, initial_links=None, 
    659                parent=None): 
    660     """ 
    661     Show and execute the `EditLinksDialog`. 
    662     Optional `initial_links` list can provide a list of initial 
    663     `(source, sink)` channel tuples to show in the view, otherwise 
    664     the dialog is populated with existing links in the scheme (passing 
    665     an empty list will disable all initial links). 
    666  
    667     """ 
    668     log.info("Constructing a Link Editor dialog.") 
    669  
    670     dlg = EditLinksDialog(parent) 
    671  
    672     # all SchemeLinks between the two nodes. 
    673     links = scheme.find_links(source_node=source_node, sink_node=sink_node) 
    674     existing_links = [(link.source_channel, link.sink_channel) 
    675                       for link in links] 
    676  
    677     if initial_links is None: 
    678         initial_links = list(existing_links) 
    679  
    680     dlg.setNodes(source_node, sink_node) 
    681     dlg.setLinks(initial_links) 
    682  
    683     log.info("Executing a Link Editor Dialog.") 
    684     rval = dlg.exec_() 
    685  
    686     if rval == EditLinksDialog.Accepted: 
    687         edited_links = dlg.links() 
    688  
    689         # Differences 
    690         links_to_add = set(edited_links) - set(existing_links) 
    691         links_to_remove = set(existing_links) - set(edited_links) 
    692         return rval, list(links_to_add), list(links_to_remove) 
    693     else: 
    694         return rval, [], [] 
    695  
    696  
    697 def add_links_plan(scheme, links, force_replace=False): 
    698     """ 
    699     Return a plan for adding a list of links to the scheme. 
    700     """ 
    701     links_to_add = list(links) 
    702     links_to_remove = [conflicting_single_link(scheme, link) 
    703                        for link in links] 
    704     links_to_remove = filter(None, links_to_remove) 
    705  
    706     if not force_replace: 
    707         links_to_add, links_to_remove = remove_duplicates(links_to_add, 
    708                                                           links_to_remove) 
    709     return links_to_add, links_to_remove 
    710  
    711  
    712 def conflicting_single_link(scheme, link): 
    713     """ 
    714     Find and return an existing link in `scheme` connected to the same 
    715     input channel as `link` if the channel has the 'single' flag. 
    716     If no such channel exists (or sink channel is not 'single') 
    717     return `None`. 
    718  
    719     """ 
    720  
    721     if link.sink_channel.single: 
    722         existing = scheme.find_links( 
    723             sink_node=link.sink_node, 
    724             sink_channel=link.sink_channel 
    725         ) 
    726  
    727         if existing: 
    728             assert len(existing) == 1 
    729             return existing[0] 
    730     return None 
    731  
    732  
    733 def remove_duplicates(links_to_add, links_to_remove): 
    734     def link_key(link): 
    735         return (link.source_node, link.source_channel, 
    736                 link.sink_node, link.sink_channel) 
    737  
    738     add_keys = map(link_key, links_to_add) 
    739     remove_keys = map(link_key, links_to_remove) 
    740     duplicate_keys = set(add_keys).intersection(remove_keys) 
    741  
    742     def not_duplicate(link): 
    743         return link_key(link) not in duplicate_keys 
    744  
    745     links_to_add = filter(not_duplicate, links_to_add) 
    746     links_to_remove = filter(not_duplicate, links_to_remove) 
    747     return links_to_add, links_to_remove 
    748  
    749  
    750526class NewNodeAction(UserInteraction): 
    751     """ 
    752     Present the user with a quick menu for node selection and 
     527    """Present the user with a quick menu for node selection and 
    753528    create the selected node. 
    754529 
     
    761536 
    762537    def create_new(self, pos): 
    763         """ 
    764         Create a new widget with a `QuickMenu` at `pos` (in screen 
    765         coordinates). 
     538        """Create a new widget with a QuickWidgetMenu at `pos` 
     539        (in screen coordinates). 
    766540 
    767541        """ 
     
    784558 
    785559class RectangleSelectionAction(UserInteraction): 
    786     """ 
    787     Select items in the scene using a Rectangle selection 
     560    """Select items in the scene using a Rectangle selection 
    788561    """ 
    789562    def __init__(self, document, *args, **kwargs): 
    790563        UserInteraction.__init__(self, document, *args, **kwargs) 
    791         # The initial selection at drag start 
    792564        self.initial_selection = None 
    793         # Selection when last updated in a mouseMoveEvent 
    794565        self.last_selection = None 
    795         # A selection rect (`QRectF`) 
    796566        self.selection_rect = None 
    797         # Keyboard modifiers 
    798567        self.modifiers = 0 
    799568 
     
    834603    def mouseMoveEvent(self, event): 
    835604        if not self.rect_item.scene(): 
    836             # Add the rect item to the scene when the mouse moves. 
    837605            self.scene.addItem(self.rect_item) 
    838606        self.update_selection(event) 
     
    850618 
    851619    def update_selection(self, event): 
    852         """ 
    853         Update the selection rectangle from a QGraphicsSceneMouseEvent 
    854         `event` instance. 
    855  
    856         """ 
    857620        if self.initial_selection is None: 
    858621            self.initial_selection = set(self.scene.selectedItems()) 
     
    862625        self.selection_rect = QRectF(self.selection_rect.topLeft(), pos) 
    863626 
    864         # Make sure the rect_item does not cause the scene rect to grow. 
    865627        rect = self._bound_selection_rect(self.selection_rect.normalized()) 
    866628 
    867         # Need that 0.5 constant otherwise the sceneRect will still 
    868         # grow (anti-aliasing correction by QGraphicsScene?) 
     629        # Need that constant otherwise the sceneRect will still grow 
    869630        pw = self.rect_item.pen().width() + 0.5 
    870631 
     
    901662 
    902663    def viewport_rect(self): 
    903         """ 
    904         Return the bounding rect of the document's viewport on the scene. 
     664        """Return the bounding rect of the document's viewport on the 
     665        scene. 
     666 
    905667        """ 
    906668        view = self.document.view() 
     
    910672 
    911673    def _bound_selection_rect(self, rect): 
    912         """ 
    913         Bound the selection `rect` to a sensible size. 
     674        """Bound the selection `rect` to a sensible size. 
    914675        """ 
    915676        srect = self.scene.sceneRect() 
     
    920681 
    921682class EditNodeLinksAction(UserInteraction): 
    922     """ 
    923     Edit multiple links between two :class:`SchemeNode` instances using 
    924     a :class:`EditLinksDialog` 
    925  
    926     Parameters 
    927     ---------- 
    928     document : :class:`SchemeEditWidget` 
    929         The editor widget. 
    930     source_node : :class:`SchemeNode` 
    931         The source (link start) node for the link editor. 
    932     sink_node : :class:`SchemeNode` 
    933         The sink (link end) node for the link editor. 
    934  
    935     """ 
    936683    def __init__(self, document, source_node, sink_node, *args, **kwargs): 
    937684        UserInteraction.__init__(self, document, *args, **kwargs) 
     
    942689        """ 
    943690        Show and execute the `EditLinksDialog`. 
    944         Optional `initial_links` list can provide a list of initial 
     691        Optional `initial_links` list can provide the initial 
    945692        `(source, sink)` channel tuples to show in the view, otherwise 
    946         the dialog is populated with existing links in the scheme (passing 
    947         an empty list will disable all initial links). 
    948  
    949         """ 
     693        the dialog is populated with existing links in the scheme 
     694        (pass an empty list to disable all initial links). 
     695 
     696        """ 
     697        from ..canvas.editlinksdialog import EditLinksDialog 
     698 
    950699        log.info("Constructing a Link Editor dialog.") 
    951700 
    952         dlg = EditLinksDialog(self.document) 
     701        parent = self.scene.views()[0] 
     702        dlg = EditLinksDialog(parent) 
    953703 
    954704        links = self.scheme.find_links(source_node=self.source_node, 
     
    975725            stack.beginMacro("Edit Links") 
    976726 
    977             # First remove links into a 'Single' sink channel, 
     727            # First remove links into a single sink channel, 
    978728            # but only the ones that do not have self.source_node as 
    979729            # a source (they will be removed later from links_to_remove) 
     
    1010760 
    1011761def point_to_tuple(point): 
    1012     """ 
    1013     Convert a QPointF into a (x, y) tuple. 
    1014     """ 
    1015     return (point.x(), point.y()) 
     762    return point.x(), point.y() 
    1016763 
    1017764 
    1018765class NewArrowAnnotation(UserInteraction): 
    1019     """ 
    1020     Create a new arrow annotation handler. 
     766    """Create a new arrow annotation. 
    1021767    """ 
    1022768    def __init__(self, document, *args, **kwargs): 
     
    1043789 
    1044790    def setColor(self, color): 
    1045         """ 
    1046         Set the color for the new arrow. 
    1047         """ 
    1048791        self.color = color 
    1049792 
     
    1109852 
    1110853def rect_to_tuple(rect): 
    1111     """ 
    1112     Convert a QRectF into a (x, y, width, height) tuple. 
    1113     """ 
    1114854    return rect.x(), rect.y(), rect.width(), rect.height() 
    1115855 
    1116856 
    1117857class NewTextAnnotation(UserInteraction): 
    1118     """ 
    1119     A New Text Annotation interaction handler 
    1120     """ 
    1121858    def __init__(self, document, *args, **kwargs): 
    1122859        UserInteraction.__init__(self, document, *args, **kwargs) 
     
    1147884 
    1148885    def createNewAnnotation(self, rect): 
    1149         """ 
    1150         Create a new TextAnnotation at with `rect` as the geometry. 
     886        """Create a new TextAnnotation at with `rect` as the geometry. 
    1151887        """ 
    1152888        annot = scheme.SchemeTextAnnotation(rect_to_tuple(rect)) 
     
    1216952 
    1217953    def defaultTextGeometry(self, point): 
    1218         """ 
    1219         Return the default text geometry. Used in case the user single 
    1220         clicked in the scene. 
     954        """Return the default text geometry. Used in case the user 
     955        single clicked in the scene. 
    1221956 
    1222957        """ 
     
    1248983 
    1249984class ResizeTextAnnotation(UserInteraction): 
    1250     """ 
    1251     Resize a Text Annotation interaction handler. 
    1252     """ 
    1253985    def __init__(self, document, *args, **kwargs): 
    1254986        UserInteraction.__init__(self, document, *args, **kwargs) 
     
    12901022 
    12911023    def commit(self): 
    1292         """ 
    1293         Commit the current item geometry state to the document. 
     1024        """Commit the current item geometry state to the document. 
    12941025        """ 
    12951026        rect = self.item.geometry() 
     
    13371068 
    13381069class ResizeArrowAnnotation(UserInteraction): 
    1339     """ 
    1340     Resize an Arrow Annotation interaction handler. 
    1341     """ 
    13421070    def __init__(self, document, *args, **kwargs): 
    13431071        UserInteraction.__init__(self, document, *args, **kwargs) 
  • Orange/OrangeCanvas/document/schemeedit.py

    r11451 r11425  
    449449            self.__quickMenuTriggers = triggers 
    450450 
    451     def quickMenuTriggers(self): 
     451    def quickMenuTriggres(self): 
    452452        """ 
    453453        Return quick menu trigger flags. 
  • Orange/OrangeCanvas/gui/lineedit.py

    r11452 r11366  
    107107        slot = _ActionSlot(position, action, button, False) 
    108108        self.__actions[position - 1] = slot 
    109  
    110         if not self.testAttribute(Qt.WA_Resized): 
    111             # Need some sensible height to do the layout. 
    112             self.adjustSize() 
    113  
    114109        self.__layoutActions() 
    115110 
  • Orange/OrangeCanvas/gui/toolbox.py

    r11441 r11417  
    6262    def setNativeStyling(self, state): 
    6363        """ 
    64         Render tab buttons as native (or css styled) :class:`QToolButtons`. 
    65         If set to `False` (default) the button is pained using a custom 
    66         paint routine. 
     64        Render tab buttons as native :class:`QToolButtons`. 
     65        If set to `False` (default) the button is pained using a 
     66        custom routine. 
    6767 
    6868        """ 
     
    231231            self.__tabActionGroup.setExclusive(exclusive) 
    232232            checked = self.__tabActionGroup.checkedAction() 
    233             if checked is None: 
    234                 # The action group can be out of sync with the actions state 
    235                 # when switching between exclusive states. 
    236                 actions_checked = [page.action for page in self.__pages 
    237                                    if page.action.isChecked()] 
    238                 if actions_checked: 
    239                     checked = actions_checked[0] 
    240  
    241233            # Trigger/toggle remaining open pages 
    242234            if exclusive and checked is not None: 
  • Orange/OrangeCanvas/registry/__init__.py

    r11440 r11418  
    3838     "yellow": "#F0EC4F", 
    3939     } 
    40  
    41  
    42 # default color when the category does not provide it 
    43 DEFAULT_COLOR = "light-yellow" 
    4440 
    4541 
  • Orange/OrangeCanvas/registry/qt.py

    r11440 r11393  
    2121from ..resources import icon_loader 
    2222 
    23 from . import cache, NAMED_COLORS, DEFAULT_COLOR 
     23from . import cache, NAMED_COLORS 
    2424 
    2525 
     
    219219            background = desc.background 
    220220        else: 
    221             background = DEFAULT_COLOR 
     221            background = "light-yellow" 
    222222 
    223223        background = NAMED_COLORS.get(background, background) 
     
    254254        elif category.background: 
    255255            background = category.background 
    256         else: 
    257             background = DEFAULT_COLOR 
    258256 
    259257        if background is not None: 
  • docs/canvas/canvas.items.nodeitem.rst

    r11442 r11369  
    1010.. autoclass:: NodeItem 
    1111   :members: 
    12    :exclude-members: 
    13       from_node, 
    14       from_node_meta, 
    15       setupGraphics, 
    16       setProgressMessage, 
    17       positionChanged, 
    18       anchorGeometryChanged, 
    19       activated, 
    20       hovered 
     12   :exclude-members: from_node, from_node_meta, setupGraphics,  setProgressMessage 
    2113   :member-order: bysource 
    2214   :show-inheritance: 
     
    2416   .. autoattribute:: positionChanged() 
    2517 
     18      Signal emitted when the scene position of the node has changes. 
     19 
    2620   .. autoattribute:: anchorGeometryChanged() 
     21 
     22      Signal emitted when the geometry of the channel anchors changes. 
    2723 
    2824   .. autoattribute:: activated() 
    2925 
    30  
    31 .. autoclass:: AnchorPoint 
    32    :members: 
    33    :exclude-members: 
    34       scenePositionChanged, 
    35       anchorDirectionChanged 
    36    :member-order: bysource 
    37    :show-inheritance: 
    38  
    39    .. autoattribute:: scenePositionChanged(QPointF) 
    40  
    41    .. autoattribute:: anchorDirectionChanged(QPointF) 
     26      Signal emitted when the item has been activated (by a mouse double 
     27      click or a keyboard) 
  • docs/canvas/canvas.scene.rst

    r11442 r11369  
    4646 
    4747   .. autoattribute:: link_item_hovered(LinkItem) 
    48  
    49  
    50 .. autofunction:: grab_svg 
Note: See TracChangeset for help on using the changeset viewer.