Ignore:
Timestamp:
02/26/13 12:49:36 (14 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Docstring fixes in document package.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeCanvas/document/schemeedit.py

    r11343 r11371  
    6969 
    7070class SchemeEditWidget(QWidget): 
     71    """ 
     72    An editor for a :class:`Scheme` instance. 
     73 
     74    """ 
     75    #: Undo command has become available/unavailable. 
    7176    undoAvailable = Signal(bool) 
     77 
     78    #: Redo command has become available/unavailable. 
    7279    redoAvailable = Signal(bool) 
     80 
     81    #: Document modified state has changed. 
    7382    modificationChanged = Signal(bool) 
     83 
     84    #: Undo command was added to the undo stack. 
    7485    undoCommandAdded = Signal() 
     86 
     87    #: Item selection has changed. 
    7588    selectionChanged = Signal() 
    7689 
     90    #: Document title has changed. 
    7791    titleChanged = Signal(unicode) 
    7892 
     93    #: Document path has changed. 
    7994    pathChanged = Signal(unicode) 
    8095 
     
    351366 
    352367    def toolbarActions(self): 
    353         """Return a list of actions that can be inserted into a toolbar. 
     368        """ 
     369        Return a list of actions that can be inserted into a toolbar. 
    354370        """ 
    355371        return [self.__zoomAction, 
     
    359375 
    360376    def menuBarActions(self): 
    361         """Return a list of actions that can be inserted into a QMenuBar. 
    362         These actions should have a menu. 
     377        """ 
     378        Return a list of actions that can be inserted into a QMenuBar. 
     379        These actions should have a menu (i.e. a 'File' action should 
     380        have a menu with "New", "Open", ...) 
    363381 
    364382        """ 
     
    366384 
    367385    def isModified(self): 
    368         """Is the document modified. 
     386        """ 
     387        Is the document is a modified state. 
    369388        """ 
    370389        return self.__modified or not self.__undoStack.isClean() 
    371390 
    372391    def setModified(self, modified): 
     392        """ 
     393        Set the document modified state. 
     394        """ 
    373395        if self.__modified != modified: 
    374396            self.__modified = modified 
     
    383405 
    384406    def isModifiedStrict(self): 
    385         """Is the document modified. Run a strict check against all node 
     407        """ 
     408        Is the document modified. Run a strict check against all node 
    386409        properties as they were at the time when the last call to 
    387410        `setModified(True)` was made. 
     
    400423 
    401424    def setQuickMenuTriggers(self, triggers): 
    402         """Set quick menu triggers. 
     425        """ 
     426        Set quick menu trigger flags. 
    403427        """ 
    404428        if self.__quickMenuTriggers != triggers: 
     
    406430 
    407431    def quickMenuTriggres(self): 
     432        """ 
     433        Return quick menu trigger flags. 
     434        """ 
    408435        return self.__quickMenuTriggers 
    409436 
    410437    def setChannelNamesVisible(self, visible): 
    411         """Set channel names visibility state. When enabled the links 
    412         in the view will have a visible source/sink channel names 
    413         displayed over them. 
     438        """ 
     439        Set channel names visibility state. When enabled the links 
     440        in the view will have a source/sink channel names displayed over 
     441        them. 
    414442 
    415443        """ 
     
    419447 
    420448    def channelNamesVisible(self): 
    421         """Return the channel name visibility state. 
     449        """ 
     450        Return the channel name visibility state. 
    422451        """ 
    423452        return self.__channelNamesVisible 
    424453 
    425454    def undoStack(self): 
    426         """Return the undo stack. 
     455        """ 
     456        Return the undo stack. 
    427457        """ 
    428458        return self.__undoStack 
    429459 
    430460    def setPath(self, path): 
    431         """Set the path associated with the current scheme. 
     461        """ 
     462        Set the path associated with the current scheme. 
    432463 
    433464        .. note:: Calling `setScheme` will invalidate the path (i.e. set it 
     
    440471 
    441472    def path(self): 
    442         """Return the path associated with the scene 
     473        """ 
     474        Return the path associated with the scheme 
    443475        """ 
    444476        return self.__path 
    445477 
    446478    def setScheme(self, scheme): 
     479        """ 
     480        Set the :class:`Scheme` instance to display/edit. 
     481 
     482        """ 
    447483        if self.__scheme is not scheme: 
    448484            if self.__scheme: 
     
    533569 
    534570    def scheme(self): 
    535         """Return the :class:`Scheme` edited by the widget. 
     571        """ 
     572        Return the :class:`Scheme` edited by the widget. 
    536573        """ 
    537574        return self.__scheme 
    538575 
    539576    def scene(self): 
    540         """Return the QGraphicsScene instance used to display the scheme. 
     577        """ 
     578        Return the :class:`QGraphicsScene` instance used to display the 
     579        current scheme. 
     580 
    541581        """ 
    542582        return self.__scene 
    543583 
    544584    def view(self): 
    545         """Return the QGraphicsView instance used to display the scene. 
     585        """ 
     586        Return the class:`QGraphicsView` instance used to display the 
     587        current scene. 
     588 
    546589        """ 
    547590        return self.__view 
    548591 
    549592    def setRegistry(self, registry): 
    550         # Is this method necessary 
     593        # Is this method necessary? 
     594        # It should be removed when the scene (items) is fixed 
     595        # so all information regarding the visual appearance is 
     596        # included in the node/widget description. 
    551597        self.__registry = registry 
    552598        if self.__scene: 
     
    555601 
    556602    def quickMenu(self): 
    557         """Return a quick menu instance for quick new node creation. 
     603        """ 
     604        Return a quick menu instance for quick new node creation. 
    558605        """ 
    559606        if self.__quickMenu is None: 
     
    589636    def createNewNode(self, description, title=None, position=None): 
    590637        """ 
    591         Create a new `SchemeNode` and add it to the document. The new 
    592         node is constructed using `newNodeHelper` method. 
     638        Create a new :class:`SchemeNode` and add it to the document. The new 
     639        node is constructed using :ref:`newNodeHelper` method. 
    593640 
    594641        """ 
     
    600647    def newNodeHelper(self, description, title=None, position=None): 
    601648        """ 
    602         Return a new initialized `SchemeNode`. If title and position are 
    603         not supplied they are initialized to a sensible defaults. 
     649        Return a new initialized :class:`SchemeNode`. If `title` and 
     650        `position` are not supplied they are initialized to sensible 
     651        defaults. 
    604652 
    605653        """ 
     
    614662    def enumerateTitle(self, title): 
    615663        """ 
    616         Enumerate a title string (i.e. add a number in parentheses) so it is 
    617         not equal to any node title in the current scheme. 
     664        Enumerate a `title` string (i.e. add a number in parentheses) so 
     665        it is not equal to any node title in the current scheme. 
    618666 
    619667        """ 
     
    642690 
    643691    def removeNode(self, node): 
    644         """Remove a `node` (:class:`SchemeNode`) from the scheme 
     692        """ 
     693        Remove a `node` (:class:`SchemeNode`) from the scheme 
    645694        """ 
    646695        command = commands.RemoveNodeCommand(self.__scheme, node) 
     
    648697 
    649698    def renameNode(self, node, title): 
    650         """Rename a `node` (:class:`SchemeNode`) to `title`. 
     699        """ 
     700        Rename a `node` (:class:`SchemeNode`) to `title`. 
    651701        """ 
    652702        command = commands.RenameNodeCommand(self.__scheme, node, title) 
     
    654704 
    655705    def addLink(self, link): 
    656         """Add a `link` (:class:`SchemeLink`) to the scheme. 
     706        """ 
     707        Add a `link` (:class:`SchemeLink`) to the scheme. 
    657708        """ 
    658709        command = commands.AddLinkCommand(self.__scheme, link) 
     
    660711 
    661712    def removeLink(self, link): 
    662         """Remove a link (:class:`SchemeLink`) from the scheme. 
     713        """ 
     714        Remove a link (:class:`SchemeLink`) from the scheme. 
    663715        """ 
    664716        command = commands.RemoveLinkCommand(self.__scheme, link) 
     
    666718 
    667719    def addAnnotation(self, annotation): 
    668         """Add `annotation` (:class:`BaseSchemeAnnotation`) to the scheme 
     720        """ 
     721        Add `annotation` (:class:`BaseSchemeAnnotation`) to the scheme 
    669722        """ 
    670723        command = commands.AddAnnotationCommand(self.__scheme, annotation) 
     
    672725 
    673726    def removeAnnotation(self, annotation): 
    674         """Remove `annotation` (:class:`BaseSchemeAnnotation`) from the scheme. 
     727        """ 
     728        Remove `annotation` (:class:`BaseSchemeAnnotation`) from the scheme. 
    675729        """ 
    676730        command = commands.RemoveAnnotationCommand(self.__scheme, annotation) 
     
    678732 
    679733    def removeSelected(self): 
    680         """Remove all selected items in the scheme. 
     734        """ 
     735        Remove all selected items in the scheme. 
    681736        """ 
    682737        selected = self.scene().selectedItems() 
     
    699754 
    700755    def selectAll(self): 
    701         """Select all selectable items in the scheme. 
     756        """ 
     757        Select all selectable items in the scheme. 
    702758        """ 
    703759        for item in self.__scene.items(): 
     
    706762 
    707763    def toogleZoom(self, zoom): 
     764        """ 
     765        Toggle view zoom. If `zoom` is True the scheme is displayed 
     766        scaled to 150%. 
     767 
     768        """ 
    708769        view = self.view() 
    709770        if zoom: 
     
    713774 
    714775    def alignToGrid(self): 
    715         """Align nodes to a grid. 
    716         """ 
     776        """ 
     777        Align nodes to a grid. 
     778        """ 
     779        # TODO: The the current layout implementation is BAD (fix is urgent). 
    717780        tile_size = 150 
    718781        tiles = {} 
     
    741804 
    742805    def focusNode(self): 
    743         """Return the current focused `SchemeNode` or None if no 
     806        """ 
     807        Return the current focused :class:`SchemeNode` or ``None`` if no 
    744808        node has focus. 
    745809 
     
    757821 
    758822    def selectedNodes(self): 
    759         """Return all selected `SchemeNode` items. 
     823        """ 
     824        Return all selected :class:`SchemeNode` items. 
    760825        """ 
    761826        return map(self.scene().node_for_item, 
     
    763828 
    764829    def selectedAnnotations(self): 
    765         """Return all selected `SchemeAnnotation` items. 
     830        """ 
     831        Return all selected :class:`SchemeAnnotation` items. 
    766832        """ 
    767833        return map(self.scene().annotation_for_item, 
     
    769835 
    770836    def openSelected(self): 
    771         """Open (show and raise) all widgets for selected nodes. 
     837        """ 
     838        Open (show and raise) all widgets for the current selected nodes. 
    772839        """ 
    773840        selected = self.scene().selected_node_items() 
     
    776843 
    777844    def editNodeTitle(self, node): 
    778         """Edit the `node`'s title. 
     845        """ 
     846        Edit (rename) the `node`'s title. Opens an input dialog. 
    779847        """ 
    780848        name, ok = QInputDialog.getText( 
     
    10351103 
    10361104    def _setUserInteractionHandler(self, handler): 
    1037         """Helper method for setting the user interaction handlers. 
     1105        """ 
     1106        Helper method for setting the user interaction handlers. 
    10381107        """ 
    10391108        if self.__scene.user_interaction_handler: 
     
    11881257 
    11891258    def __onItemFocusedIn(self, item): 
    1190         """Annotation item has gained focus. 
     1259        """ 
     1260        Annotation item has gained focus. 
    11911261        """ 
    11921262        if not self.__scene.user_interaction_handler: 
     
    11941264 
    11951265    def __onItemFocusedOut(self, item): 
    1196         """Annotation item lost focus. 
     1266        """ 
     1267        Annotation item lost focus. 
    11971268        """ 
    11981269        self.__endControlPointEdit() 
    11991270 
    12001271    def __onEditingFinished(self, item): 
    1201         """Text annotation editing has finished. 
     1272        """ 
     1273        Text annotation editing has finished. 
    12021274        """ 
    12031275        annot = self.__scene.annotation_for_item(item) 
     
    12111283    def __toggleNewArrowAnnotation(self, checked): 
    12121284        if self.__newTextAnnotationAction.isChecked(): 
     1285            # Uncheck the text annotation action if needed. 
    12131286            self.__newTextAnnotationAction.setChecked(not checked) 
    12141287 
     
    12161289 
    12171290        if not checked: 
     1291            # The action was unchecked (canceled by the user) 
    12181292            handler = self.__scene.user_interaction_handler 
    12191293            if isinstance(handler, interactions.NewArrowAnnotation): 
     
    12341308    def __onFontSizeTriggered(self, action): 
    12351309        if not self.__newTextAnnotationAction.isChecked(): 
    1236             # Trigger the action 
     1310            # When selecting from the (font size) menu the 'Text' 
     1311            # action does not get triggered automatically. 
    12371312            self.__newTextAnnotationAction.trigger() 
    12381313        else: 
    1239             # just update the preferred font on the interaction handler 
     1314            # Update the preferred font on the interaction handler. 
    12401315            handler = self.__scene.user_interaction_handler 
    12411316            if isinstance(handler, interactions.NewTextAnnotation): 
     
    12441319    def __toggleNewTextAnnotation(self, checked): 
    12451320        if self.__newArrowAnnotationAction.isChecked(): 
     1321            # Uncheck the arrow annotation if needed. 
    12461322            self.__newArrowAnnotationAction.setChecked(not checked) 
    12471323 
     
    12491325 
    12501326        if not checked: 
     1327            # The action was unchecked (canceled by the user) 
    12511328            handler = self.__scene.user_interaction_handler 
    12521329            if isinstance(handler, interactions.NewTextAnnotation): 
     
    12671344    def __onArrowColorTriggered(self, action): 
    12681345        if not self.__newArrowAnnotationAction.isChecked(): 
    1269             # Trigger the action 
     1346            # When selecting from the (color) menu the 'Arrow' 
     1347            # action does not get triggered automatically. 
    12701348            self.__newArrowAnnotationAction.trigger() 
    12711349        else: 
    1272             # just update the preferred color on the interaction handler 
     1350            # Update the preferred color on the interaction handler 
    12731351            handler = self.__scene.user_interaction_handler 
    12741352            if isinstance(handler, interactions.NewArrowAnnotation): 
     
    12941372 
    12951373    def __onRenameAction(self): 
     1374        """ 
     1375        Rename was requested for the selected widget. 
     1376        """ 
    12961377        selected = self.selectedNodes() 
    12971378        if len(selected) == 1: 
     
    12991380 
    13001381    def __onHelpAction(self): 
    1301         """Help was requested for the selected widget. 
     1382        """ 
     1383        Help was requested for the selected widget. 
    13021384        """ 
    13031385        nodes = self.selectedNodes() 
     
    13251407 
    13261408    def __toggleLinkEnabled(self, enabled): 
    1327         """Link enabled state was toggled in the context menu. 
     1409        """ 
     1410        Link 'enabled' state was toggled in the context menu. 
    13281411        """ 
    13291412        if self.__contextMenuTarget: 
     
    13351418 
    13361419    def __linkRemove(self): 
    1337         """Remove link was requested from the context menu. 
     1420        """ 
     1421        Remove link was requested from the context menu. 
    13381422        """ 
    13391423        if self.__contextMenuTarget: 
     
    13411425 
    13421426    def __linkReset(self): 
    1343         """Link reset from the context menu was requested. 
     1427        """ 
     1428        Link reset from the context menu was requested. 
    13441429        """ 
    13451430        if self.__contextMenuTarget: 
     
    13511436 
    13521437    def __startControlPointEdit(self, item): 
    1353         """Start a control point edit interaction for item. 
     1438        """ 
     1439        Start a control point edit interaction for `item`. 
    13541440        """ 
    13551441        if isinstance(item, items.ArrowAnnotation): 
     
    13671453 
    13681454    def __endControlPointEdit(self): 
    1369         """End the current control point edit interaction. 
     1455        """ 
     1456        End the current control point edit interaction. 
    13701457        """ 
    13711458        handler = self.__scene.user_interaction_handler 
     
    13791466 
    13801467    def __updateFont(self): 
     1468        """ 
     1469        Update the font for the "Text size' menu and the default font 
     1470        used in the `CanvasScene`. 
     1471 
     1472        """ 
    13811473        actions = self.__fontActionGroup.actions() 
    13821474        font = self.font() 
     
    14031495 
    14041496def mouse_drag_distance(event, button=Qt.LeftButton): 
    1405     """Return the (manhattan) distance between the (screen position) 
     1497    """ 
     1498    Return the (manhattan) distance between the mouse position 
    14061499    when the `button` was pressed and the current mouse position. 
    14071500 
     
    14121505 
    14131506def set_enabled_all(objects, enable): 
    1414     """Set enabled properties on all objects (QObjects with setEnabled). 
     1507    """ 
     1508    Set `enabled` properties on all objects (objects with `setEnabled` method). 
    14151509    """ 
    14161510    for obj in objects: 
Note: See TracChangeset for help on using the changeset viewer.