Remove the whole document read only logic
This commit is contained in:
+12
-21
@@ -39,14 +39,13 @@ class NWDoc():
|
|||||||
|
|
||||||
def __init__(self, theProject, theParent):
|
def __init__(self, theProject, theParent):
|
||||||
|
|
||||||
self.mainConf = nw.CONFIG
|
self.mainConf = nw.CONFIG
|
||||||
self.theProject = theProject
|
self.theProject = theProject
|
||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
self.theItem = None
|
self.theItem = None
|
||||||
self.docHandle = None
|
self.docHandle = None
|
||||||
self.docEditable = False
|
self.fileLoc = None
|
||||||
self.fileLoc = None
|
self.docMeta = ""
|
||||||
self.docMeta = ""
|
|
||||||
|
|
||||||
# Internal Mapping
|
# Internal Mapping
|
||||||
self.makeAlert = self.theParent.makeAlert
|
self.makeAlert = self.theParent.makeAlert
|
||||||
@@ -60,11 +59,10 @@ class NWDoc():
|
|||||||
def clearDocument(self):
|
def clearDocument(self):
|
||||||
"""Clear the document contents.
|
"""Clear the document contents.
|
||||||
"""
|
"""
|
||||||
self.theItem = None
|
self.theItem = None
|
||||||
self.docHandle = None
|
self.docHandle = None
|
||||||
self.docEditable = False
|
self.fileLoc = None
|
||||||
self.fileLoc = None
|
self.docMeta = ""
|
||||||
self.docMeta = ""
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def openDocument(self, tHandle, showStatus=True, isOrphan=False):
|
def openDocument(self, tHandle, showStatus=True, isOrphan=False):
|
||||||
@@ -87,13 +85,6 @@ class NWDoc():
|
|||||||
self.clearDocument()
|
self.clearDocument()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# By default, the document is editable.
|
|
||||||
# Except for files in the trash folder.
|
|
||||||
self.docEditable = True
|
|
||||||
if self.theItem is not None:
|
|
||||||
if self.theItem.parHandle == self.theProject.projTree.trashRoot():
|
|
||||||
self.docEditable = False
|
|
||||||
|
|
||||||
docFile = self.docHandle+".nwd"
|
docFile = self.docHandle+".nwd"
|
||||||
logger.debug("Opening document %s" % docFile)
|
logger.debug("Opening document %s" % docFile)
|
||||||
|
|
||||||
@@ -137,7 +128,7 @@ class NWDoc():
|
|||||||
"""Save the document via temp file in case of save failure, and
|
"""Save the document via temp file in case of save failure, and
|
||||||
in any case keep a backup of the file.
|
in any case keep a backup of the file.
|
||||||
"""
|
"""
|
||||||
if self.docHandle is None or not self.docEditable:
|
if self.docHandle is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self.theProject.ensureFolderStructure()
|
self.theProject.ensureFolderStructure()
|
||||||
|
|||||||
+1
-5
@@ -270,11 +270,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.setDocumentChanged(False)
|
self.setDocumentChanged(False)
|
||||||
self.theHandle = tHandle
|
self.theHandle = tHandle
|
||||||
|
|
||||||
if self.nwDocument.docEditable:
|
self.setReadOnly(False)
|
||||||
self.setReadOnly(False)
|
|
||||||
else:
|
|
||||||
self.theParent.noticeBar.showNote("This document is read only.")
|
|
||||||
|
|
||||||
self.docTitle.setTitleFromHandle(self.theHandle)
|
self.docTitle.setTitleFromHandle(self.theHandle)
|
||||||
self.updateDocMargins()
|
self.updateDocMargins()
|
||||||
self.hLight.spellCheck = spTemp
|
self.hLight.spellCheck = spTemp
|
||||||
|
|||||||
Reference in New Issue
Block a user