Exemple #1
0
 def update_item(self, item, where, name, frag, title):
     if isinstance(frag, tuple):
         frag = add_id(self.ebook, name, *frag)
     child = TOC(title, name, frag)
     child.dest_exists = True
     if item is None:
         # New entry at root level
         c = self.create_item(self.root, child)
         self.tocw.setCurrentItem(c, 0, QItemSelectionModel.ClearAndSelect)
         self.tocw.scrollToItem(c)
     else:
         if where is None:
             # Editing existing entry
             self.populate_item(item, child)
         else:
             if where == 'inside':
                 parent = item
                 idx = -1
             else:
                 parent = item.parent() or self.root
                 idx = parent.indexOfChild(item)
                 if where == 'after':
                     idx += 1
             c = self.create_item(parent, child, idx=idx)
             self.tocw.setCurrentItem(c, 0,
                                      QItemSelectionModel.ClearAndSelect)
             self.tocw.scrollToItem(c)
Exemple #2
0
 def update_item(self, item, where, name, frag, title):
     if isinstance(frag, tuple):
         frag = add_id(self.ebook, name, *frag)
     child = TOC(title, name, frag)
     child.dest_exists = True
     if item is None:
         # New entry at root level
         c = self.create_item(self.root, child)
         self.tocw.setCurrentItem(c, 0, QItemSelectionModel.ClearAndSelect)
         self.tocw.scrollToItem(c)
     else:
         if where is None:
             # Editing existing entry
             self.populate_item(item, child)
         else:
             if where == 'inside':
                 parent = item
                 idx = -1
             else:
                 parent = item.parent() or self.root
                 idx = parent.indexOfChild(item)
                 if where == 'after':
                     idx += 1
             c = self.create_item(parent, child, idx=idx)
             self.tocw.setCurrentItem(c, 0, QItemSelectionModel.ClearAndSelect)
             self.tocw.scrollToItem(c)