Fixed creating new project, opening and saving of projects.

This commit is contained in:
Veronica K. B. Olsen
2019-05-03 21:56:51 +02:00
parent 665fbb04fe
commit 116150ef01
3 changed files with 76 additions and 37 deletions
+15 -1
View File
@@ -39,9 +39,14 @@ class GuiDocTree(QTreeWidget):
self.debugGUI = self.mainConf.debugGUI
self.theParent = theParent
self.theProject = theProject
self.theMap = {}
# Tree Settings
self.theMap = None
self.orphRoot = None
self.clearTree()
# Build GUI
self.setIconSize(QSize(13,13))
self.setExpandsOnDoubleClick(True)
self.setIndentation(13)
@@ -67,6 +72,15 @@ class GuiDocTree(QTreeWidget):
return
def clearTree(self):
self.clear()
self.theMap = {}
self.orphRoot = None
return
def newTreeItem(self, itemType, itemClass):
pHandle = self.getSelectedHandle()
+6 -3
View File
@@ -103,6 +103,7 @@ class GuiMain(QMainWindow):
def newProject(self):
logger.info("Creating new project")
self.treeView.clearTree()
self.theProject.newProject()
self.treeView.buildTree()
return
@@ -112,6 +113,7 @@ class GuiMain(QMainWindow):
projFile = self.openProjectDialog()
if projFile is None:
return False
self.treeView.clearTree()
self.theProject.openProject(projFile)
self.treeView.buildTree()
self._setWindowTitle(self.theProject.projName)
@@ -184,7 +186,7 @@ class GuiMain(QMainWindow):
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.DontUseNativeDialog
projFile, _ = QFileDialog.getOpenFileName(
self,"Open novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)", options=dlgOpt
self,"Open novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)",options=dlgOpt
)
if projFile:
return projFile
@@ -192,9 +194,10 @@ class GuiMain(QMainWindow):
def saveProjectDialog(self):
dlgOpt = QFileDialog.Options()
dlgOpt |= QFileDialog.ShowDirsOnly
dlgOpt |= QFileDialog.DontUseNativeDialog
projPath, _ = QFileDialog.getSaveFileName(
self,"Save novelWriter Project","","novelWriter Project File (nwProject.nwx);;All Files (*)", options=dlgOpt
projPath = QFileDialog.getExistingDirectory(
self,"Save novelWriter Project","",options=dlgOpt
)
if projPath:
return projPath