Finished saving and loading of document tree and tree state.

This commit is contained in:
Veronica K. B. Olsen
2018-10-30 21:20:12 +01:00
parent 02ed230c24
commit e72e82afca
5 changed files with 65 additions and 27 deletions
+6 -5
View File
@@ -50,21 +50,22 @@ class GuiDocTree(QTreeWidget):
def saveTreeOrder(self):
theList = []
for i in range(self.topLevelItemCount()):
theList = self._scanChildren(theList, self.topLevelItem(i))
theList = self._scanChildren(theList, self.topLevelItem(i), i)
self.theProject.setTreeOrder(theList)
return True
def _scanChildren(self, theList, theItem):
def _scanChildren(self, theList, theItem, theIndex):
tHandle = theItem.text(3)
nwItem = self.theProject.projTree[tHandle]
nwItem.setExpanded(theItem.isExpanded())
nwItem.setOrder(theIndex)
theList.append(tHandle)
for i in range(theItem.childCount()):
self._scanChildren(theList, theItem.child(i))
self._scanChildren(theList, theItem.child(i), i)
return theList
def buildTree(self):
self.clear()
for tHandle in self.theProject.projTree:
nwItem = self.theProject.projTree[tHandle]
tName = nwItem.itemName
@@ -79,7 +80,7 @@ class GuiDocTree(QTreeWidget):
self.addTopLevelItem(newItem)
else:
self.theMap[pHandle].addChild(newItem)
newItem.setExpanded(nwItem.isExpanded)
return True
def getColumnSizes(self):
+2
View File
@@ -86,6 +86,7 @@ class GuiMain(QMainWindow):
self,"Open novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)", options=dlgOpt)
if projPath:
self.theProject.openProject(projPath)
self.treeView.buildTree()
self._setWindowTitle(self.theProject.projName)
else:
return False
@@ -113,6 +114,7 @@ class GuiMain(QMainWindow):
def openRecentProject(self, recentItem):
logger.vverbose("User requested opening recent project #%d" % recentItem)
self.theProject.openProject(self.mainConf.recentList[recentItem])
self.treeView.buildTree()
self._setWindowTitle(self.theProject.projName)
return True