The editable flag for files is now respected by the editor, and trash files are not editable

This commit is contained in:
Veronica K. B. Olsen
2019-10-31 13:37:27 +01:00
parent 7969c58351
commit 9fea45b7df
6 changed files with 67 additions and 34 deletions
+18 -7
View File
@@ -25,11 +25,12 @@ class NWDoc():
def __init__(self, theProject, theParent):
self.mainConf = nw.CONFIG
self.theProject = theProject
self.theParent = theParent
self.theItem = None
self.docHandle = None
self.mainConf = nw.CONFIG
self.theProject = theProject
self.theParent = theParent
self.theItem = None
self.docHandle = None
self.docEditable = False
# Internal Mapping
self.makeAlert = self.theParent.makeAlert
@@ -37,8 +38,9 @@ class NWDoc():
return
def clearDocument(self):
self.theItem = None
self.docHandle = None
self.theItem = None
self.docHandle = None
self.docEditable = False
return
def openDocument(self, tHandle, showStatus=True):
@@ -46,6 +48,15 @@ class NWDoc():
self.docHandle = tHandle
self.theItem = self.theProject.getItem(tHandle)
if self.theItem is None:
self.clearDocument()
return None
# By default, the document is editable. Except for files in the trash folder.
self.docEditable = True
if self.theItem.parHandle == self.theProject.trashRoot:
self.docEditable = False
docDir, docFile = self._assemblePath(self.FILE_MN)
logger.debug("Opening document %s" % path.join(docDir,docFile))
dataDir = path.join(self.theProject.projPath, docDir)