示例#1
0
    def __init__(self, spine, toc=None):
        QStandardItemModel.__init__(self)
        self.current_query = {'text': '', 'index': -1, 'items': ()}
        if toc is None:
            toc = MTOC()
        self.all_items = depth_first = []
        for t in toc:
            self.appendRow(TOCItem(spine, t, 0, depth_first))

        for x in depth_first:
            possible_enders = [
                t for t in depth_first
                if t.depth <= x.depth and t.starts_at >= x.starts_at
                and t is not x and t not in x.ancestors
            ]
            if possible_enders:
                min_spine = min(t.starts_at for t in possible_enders)
                possible_enders = {
                    t.fragment
                    for t in possible_enders if t.starts_at == min_spine
                }
            else:
                min_spine = len(spine) - 1
                possible_enders = set()
            x.ends_at = min_spine
            x.possible_end_anchors = possible_enders

        self.currently_viewed_entry = None
示例#2
0
    def __init__(self, spine, toc=None):
        QStandardItemModel.__init__(self)
        if toc is None:
            toc = MTOC()
        self.all_items = depth_first = []
        for t in toc:
            self.appendRow(TOCItem(spine, t, 0, depth_first))
        self.setHorizontalHeaderItem(0, QStandardItem(_('Table of Contents')))

        for x in depth_first:
            possible_enders = [
                t for t in depth_first
                if t.depth <= x.depth and t.starts_at >= x.starts_at
                and t is not x and t not in x.ancestors
            ]
            if possible_enders:
                min_spine = min(t.starts_at for t in possible_enders)
                possible_enders = {
                    t.fragment
                    for t in possible_enders if t.starts_at == min_spine
                }
            else:
                min_spine = len(spine) - 1
                possible_enders = set()
            x.ends_at = min_spine
            x.possible_end_anchors = possible_enders

        self.currently_viewed_entry = None