예제 #1
0
    def createItems(self, data, split=None):
        """ 
        Create the items from the given data dict

        :type data: dict
        :type split: str or None

        :rtype: None
        """
        split = split or DEFAULT_SEPARATOR

        self._index = {}

        for key in data:

            root = split.join([key])

            item = None

            if self.isRootVisible():

                text = key.split(split)
                if text:
                    text = text[-1]
                else:
                    text = key

                item = SidebarWidgetItem(self)
                item.setText(0, unicode(text))
                item.setPath(root)
                item.setExpanded(True)

                self._index[root] = item

            def _recursive(parent, children, split=None, root=""):
                for text, val in sorted(children.iteritems()):

                    if not parent:
                        parent = self

                    path = split.join([root, text])
                    path = path.replace("//", "/")

                    child = SidebarWidgetItem(parent)
                    child.setText(0, unicode(text))
                    child.setPath(path)

                    self._index[path] = child

                    _recursive(child, val, split=split, root=path)

            _recursive(item, data[key], split=split, root=root)

        self.update()
        self.refreshFilter()
예제 #2
0
            def _recursive(parent, children, split=None):
                for text, val in sorted(children.iteritems()):

                    path = parent.path()
                    path = split.join([path, text])

                    child = SidebarWidgetItem()
                    child.setText(0, unicode(text))
                    child.setPath(path)

                    parent.addChild(child)

                    _recursive(child, val, split=split)
예제 #3
0
            def _recursive(parent, children, split=None):
                for text, val in sorted(children.iteritems()):

                    path = parent.path()
                    path = split.join([path, text])

                    child = SidebarWidgetItem()
                    child.setText(0, unicode(text))
                    child.setPath(path)

                    parent.addChild(child)
                    self._index[path] = child

                    _recursive(child, val, split=split)
예제 #4
0
            def _recursive(parent, children, split=None):
                for text, val in sorted(children.iteritems(),
                                        key=lambda item: item[0].lower()):

                    path = parent.path()
                    path = split.join([path, text])

                    child = SidebarWidgetItem()
                    child.setText(0, unicode(text))
                    child.setPath(path)

                    parent.addChild(child)
                    self._index[path] = child

                    _recursive(child, val, split=split)
예제 #5
0
            def _recursive(parent, children, split=None, root=""):
                for text, val in sorted(children.iteritems()):

                    if not parent:
                        parent = self

                    path = split.join([root, text])
                    path = path.replace("//", "/")

                    child = SidebarWidgetItem(parent)
                    child.setText(0, unicode(text))
                    child.setPath(path)

                    self._index[path] = child

                    _recursive(child, val, split=split, root=path)
예제 #6
0
    def createItems(self, data, split=None):
        """ 
        Create the items from the given data dict

        :type data: dict
        :type split: str or None

        :rtype: None
        """
        split = split or DEFAULT_SEPARATOR

        self._index = {}

        for key in data:

            path = split.join([key])

            item = SidebarWidgetItem(self)
            item.setText(0, unicode(key))
            item.setPath(path)
            self._index[path] = item

            if self.rootText():
                item.setText(0, self.rootText())
                item.setBold(True)
                item.setIconPath('none')
                item.setExpanded(True)

            def _recursive(parent, children, split=None):
                for text, val in sorted(children.iteritems(),
                                        key=lambda item: item[0].lower()):

                    path = parent.path()
                    path = split.join([path, text])

                    child = SidebarWidgetItem()
                    child.setText(0, unicode(text))
                    child.setPath(path)

                    parent.addChild(child)
                    self._index[path] = child

                    _recursive(child, val, split=split)

            _recursive(item, data[key], split=split)

        self.update()
예제 #7
0
    def createItems(self, data, split=None):
        """ 
        Create the items from the given data dict

        :type data: dict
        :type split: str or None

        :rtype: None
        """
        split = split or DEFAULT_SEPARATOR

        self._index = {}

        for key in data:

            path = split.join([key])

            item = SidebarWidgetItem(self)
            item.setText(0, unicode(key))
            item.setPath(path)
            self._index[path] = item

            if self.rootText():
                item.setText(0, self.rootText())
                item.setBold(True)
                item.setIconPath('none')
                item.setExpanded(True)

            def _recursive(parent, children, split=None):
                for text, val in sorted(children.iteritems()):

                    path = parent.path()
                    path = split.join([path, text])

                    child = SidebarWidgetItem()
                    child.setText(0, unicode(text))
                    child.setPath(path)

                    parent.addChild(child)
                    self._index[path] = child

                    _recursive(child, val, split=split)

            _recursive(item, data[key], split=split)

        self.update()
예제 #8
0
    def createItems(self, data, split=None):
        """ 
        Create the items from the given data dict

        :type data: dict
        :type split: str or None

        :rtype: None
        """
        split = split or SPLIT_TOKEN

        for key in data:

            path = split.join([key])

            item = SidebarWidgetItem(self)
            item.setText(0, unicode(key))
            item.setPath(path)

            def _recursive(parent, children, split=None):
                for text, val in sorted(children.iteritems()):

                    path = parent.path()
                    path = split.join([path, text])

                    child = SidebarWidgetItem()
                    child.setText(0, unicode(text))
                    child.setPath(path)

                    parent.addChild(child)

                    _recursive(child, val, split=split)

            _recursive(item, data[key], split=split)

        self.update()