Esempio n. 1
0
    def __init__(self,
                 data,
                 parent=None,
                 view=None,
                 parentWidget=None,
                 isChild=False,
                 styleIfChild=True,
                 rootDepthForHash=1,
                 model=None):
        self._data = data
        self._children = []
        self._parent = parent
        self._rootNodeHash = ""
        self._view = view
        self._parentWidget = parentWidget
        self._model = model

        if parent is not None:
            parent.addChild(self)
            #Inherit view from parent
            self._view = parent.treeView()
            self._parentWidget = parent.parentWidget()
        '''
        Set the hash of the node that will be taken as the root parent node.
        In this case it will be level one.
        Level zero will not have any hash specified (just be an empty string).
        '''
        if self.depth() == rootDepthForHash:
            self._rootNodeHash = gen_random_string()
        elif self.depth() > rootDepthForHash:
            self._rootNodeHash = self._parent.rootHash()

        #Separator for child text
        self.separator = ": "

        if isChild:
            if styleIfChild:
                self._styleIfChild = True
        else:
            self._styleIfChild = False

        #Default actions that will be most commonly used by the nodes with data management capabilities
        self.editAction = QAction(
            EDIT_ICON, QApplication.translate("BaseSTRNode", "Edit..."), None)
        self.deleteAction = QAction(
            DELETE_ICON, QApplication.translate("BaseSTRNode", "Delete"), None)

        self._expand_action = QAction(
            QApplication.translate("BaseSTRNode", "Expand"),
            self._parentWidget)
        self._collapse_action = QAction(
            QApplication.translate("BaseSTRNode", "Collapse"),
            self._parentWidget)
Esempio n. 2
0
File: nodes.py Progetto: gltn/stdm
    def __init__(self, data, parent=None, view=None, parentWidget=None,
                 isChild=False, styleIfChild=True, rootDepthForHash=1,
                 model=None):
        self._data = data
        self._children = []
        self._parent = parent
        self._rootNodeHash = ""
        self._view = view
        self._parentWidget = parentWidget
        self._model = model

        if parent is not None:
            parent.addChild(self)
            #Inherit view from parent
            self._view = parent.treeView()
            self._parentWidget = parent.parentWidget()

        '''
        Set the hash of the node that will be taken as the root parent node.
        In this case it will be level one.
        Level zero will not have any hash specified (just be an empty string).
        '''
        if self.depth() == rootDepthForHash:
            self._rootNodeHash = gen_random_string()
        elif self.depth() > rootDepthForHash:
            self._rootNodeHash = self._parent.rootHash()

        #Separator for child text
        self.separator = ": "

        if isChild:
            if styleIfChild:
                self._styleIfChild = True
        else:
            self._styleIfChild = False

        #Default actions that will be most commonly used by the nodes with data management capabilities
        self.editAction = QAction(EDIT_ICON,
                             QApplication.translate("BaseSTRNode","Edit..."),None)
        self.deleteAction = QAction(DELETE_ICON,
                             QApplication.translate("BaseSTRNode","Delete"),None)

        self._expand_action = QAction(QApplication.translate("BaseSTRNode","Expand"),
                                      self._parentWidget)
        self._collapse_action = QAction(QApplication.translate("BaseSTRNode","Collapse"),
                                      self._parentWidget)