Esempio n. 1
0
    def _handle_history(self, kwargs):
        # Yes, this is a very aggressive way of handling history actions, this
        # is redrawing the whole tree whenever an item is
        # inserted/moved/deleted, however trying to handle each case separately
        # is very complicated and thus causes numerous bugs, because each query
        # in the history group can leave the database in an unstable state
        # (e.g. the queries that update the previous id to the next/previous
        # items when moving an item)
        # It should be quite efficient anyway because self.data is not
        # recalculated except for the items that explicitly requested it, and
        # only the root items and their children are re-added, the rest of the
        # items will be re-added on request (when their parents are expanded
        # again)
        if kwargs['filename'] == self.filename:
            if self.history_tree_reset_request:
                self.dvmodel.Cleared()

                for id_ in core_api.get_root_items(self.filename):
                    item = self.get_tree_item(id_)
                    # For some reason ItemDeleted must be called too first...
                    self.dvmodel.ItemDeleted(self._get_root(), item)
                    self.dvmodel.ItemAdded(self._get_root(), item)
                    self._reset_children(id_, item)

            for id_ in self.history_item_update_requests:
                # id_ may have been deleted by an action in the history group
                if core_api.is_item(self.filename, id_):
                    self.update_tree_item(id_)

            del self.history_item_update_requests[:]
            self.history_tree_reset_request = False
Esempio n. 2
0
    def _handle_history(self, kwargs):
        # Yes, this is a very aggressive way of handling history actions, this
        # is redrawing the whole tree whenever an item is
        # inserted/moved/deleted, however trying to handle each case separately
        # is very complicated and thus causes numerous bugs, because each query
        # in the history group can leave the database in an unstable state
        # (e.g. the queries that update the previous id to the next/previous
        # items when moving an item)
        # It should be quite efficient anyway because self.data is not
        # recalculated except for the items that explicitly requested it, and
        # only the root items and their children are re-added, the rest of the
        # items will be re-added on request (when their parents are expanded
        # again)
        if kwargs['filename'] == self.filename:
            if self.history_tree_reset_request:
                self.dvmodel.Cleared()

                for id_ in core_api.get_root_items(self.filename):
                    item = self.get_tree_item(id_)
                    # For some reason ItemDeleted must be called too first...
                    self.dvmodel.ItemDeleted(self._get_root(), item)
                    self.dvmodel.ItemAdded(self._get_root(), item)
                    self._reset_children(id_, item)

            for id_ in self.history_item_update_requests:
                # id_ may have been deleted by an action in the history group
                if core_api.is_item(self.filename, id_):
                    self.update_tree_item(id_)

            del self.history_item_update_requests[:]
            self.history_tree_reset_request = False
Esempio n. 3
0
    def GetChildren(self, parent, children):
        if not parent:
            ids = core_api.get_root_items(self.filename)
        else:
            pid = self.ItemToObject(parent).get_id()
            ids = core_api.get_item_children(self.filename, pid)

        for id_ in ids:
            children.append(self.ObjectToItem(self.data[id_]))

        return len(ids)
Esempio n. 4
0
    def GetChildren(self, parent, children):
        if not parent:
            ids = core_api.get_root_items(self.filename)
        else:
            pid = self.ItemToObject(parent).get_id()
            ids = core_api.get_item_children(self.filename, pid)

        for id_ in ids:
            children.append(self.ObjectToItem(self.data[id_]))

        return len(ids)