示例#1
0
 def editChildList(self, textList):
     """Update child names and order from textList, update undos and view"""
     if len(textList) == len(self.childList):
         # assume rename if length is same
         for child, text in zip(self.childList, textList):
             if child.title() != text:
                 child.setTitle(text, True)
                 globalref.updateViewItem(child)
     else:                # find new child positions if length differs
         oldLen = len(self.childList)
         nodeFormat = self.nodeFormat()
         newType = globalref.docRef.treeFormats.get(nodeFormat.childType,
                                                    None)
         if not newType:
             newType = oldLen and self.childList[0].nodeFormat() or \
                       nodeFormat
         globalref.docRef.undoStore.addChildListUndo(self)
         newChildList = []
         for text in textList:
             try:
                 newChildList.append(self.childList.pop(\
                  [child.title() for child in self.childList].index(text)))
             except ValueError:
                 newItem = TreeItem(self, newType.name)
                 newItem.setInitDefaultData()
                 newItem.setTitle(text)
                 newItem.setUniqueID(True)
                 newChildList.append(newItem)
         if oldLen == 0 and newChildList:
             self.open = True
         for child in self.childList:
             child.parent = None
         self.childList = newChildList
         globalref.updateLeftView()
         globalref.docRef.modified = True
示例#2
0
 def treeOpenItem(self):
     """Set selection to open"""
     if not self:
         self.change([self.currentItem])
     for item in self:
         item.open = True
         globalref.updateViewItem(item)
 def treeOpenItem(self):
     """Set selection to open"""
     if not self:
         self.change([self.currentItem])
     for item in self:
         item.open = True
         globalref.updateViewItem(item)
 def restoreNextSelect(self):
     """Go forward to the most recent saved selection"""
     self.validateHistory()
     if self.nextSelects:
         for item in self.nextSelects[-1]:
             item.openParents(False)
             globalref.updateViewItem(item)
         self.prevSelects.append(list(self))
         self[:] = self.nextSelects.pop(-1)
         globalref.updateViewSelection()
     else:
         globalref.updateViewMenuStat()
示例#5
0
 def restoreNextSelect(self):
     """Go forward to the most recent saved selection"""
     self.validateHistory()
     if self.nextSelects:
         for item in self.nextSelects[-1]:
             item.openParents(False)
             globalref.updateViewItem(item)
         self.prevSelects.append(list(self))
         self[:] = self.nextSelects.pop(-1)
         globalref.updateViewSelection()
     else:
         globalref.updateViewMenuStat()
示例#6
0
 def readChange(self):
     """Update doc from edit view contents"""
     textList = filter(None, [u' '.join(text.split()) for text in
                              unicode(self.toPlainText()).split('\n')])
     if self.showChildren and len(globalref.docRef.selection) == 1:
         globalref.docRef.selection[0].editChildList(textList)
         globalref.docRef.selection.validateHistory()
     elif not self.showChildren and \
              len(globalref.docRef.selection) == len(textList):
         for item, text in zip(globalref.docRef.selection, textList):
             if item.title() != text and item.setTitle(text, True):
                 globalref.updateViewItem(item)
     else:
         self.updateView()  # remove illegal changes
     globalref.updateViewMenuStat()
 def treeCloseItem(self):
     """Set selection to closed"""
     if not self:
         self.replace([self.currentItem])
     newSelects = []
     for item in self:
         if item.open and item.childList:
             if item not in newSelects:
                 newSelects.append(item)
         elif item.parent and item.parent not in newSelects:
             newSelects.append(item.parent)
     for item in newSelects:
         item.open = False
         globalref.updateViewItem(item)
     self.change([item for item in newSelects if item.allAncestorsOpen()])
示例#8
0
 def treeCloseItem(self):
     """Set selection to closed"""
     if not self:
         self.replace([self.currentItem])
     newSelects = []
     for item in self:
         if item.open and item.childList:
             if item not in newSelects:
                 newSelects.append(item)
         elif item.parent and item.parent not in newSelects:
             newSelects.append(item.parent)
     for item in newSelects:
         item.open = False
         globalref.updateViewItem(item)
     self.change([item for item in newSelects if item.allAncestorsOpen()])
 def changeSearchOpen(self, selectList):
     """Replace selection with items in list,
        if open search enabled, close previously selected search items,
        open new selected search items"""
     if self == selectList:
         return
     openSearch = globalref.options.boolData('OpenSearchNodes')
     if openSearch:
         for item in self.searchOpenList:
             item.open = False
             globalref.updateViewItem(item)
     self.searchOpenList = []
     for item in selectList:
         parents = item.openParents(openSearch)
         parents.reverse()  # must start with a visible (loaded) node
         self.searchOpenList.extend(parents)
     for item in self.searchOpenList:
         globalref.updateViewItem(item)
     self.addToHistory()
     self[:] = selectList
     globalref.updateViewSelection()
示例#10
0
 def changeSearchOpen(self, selectList):
     """Replace selection with items in list,
        if open search enabled, close previously selected search items,
        open new selected search items"""
     if self == selectList:
         return
     openSearch = globalref.options.boolData('OpenSearchNodes')
     if openSearch:
         for item in self.searchOpenList:
             item.open = False
             globalref.updateViewItem(item)
     self.searchOpenList = []
     for item in selectList:
         parents = item.openParents(openSearch)
         parents.reverse()  # must start with a visible (loaded) node
         self.searchOpenList.extend(parents)
     for item in self.searchOpenList:
         globalref.updateViewItem(item)
     self.addToHistory()
     self[:] = selectList
     globalref.updateViewSelection()
示例#11
0
 def checkTitleChange(self):
     """Update item title based on signal"""
     globalref.updateViewItem(self.item)
     self.setTitle(self.item.formatName)
     self.titleLabel.setText(self.item.title())
     globalref.updateViewMenuStat()