From 1fc76b0d9543383e8ac0ef0861a0b2032f9c0f29 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 7 Jun 2020 23:19:28 +0200 Subject: [PATCH] Remove the whole document read only logic --- nw/core/document.py | 33 ++++++++++++--------------------- nw/gui/doceditor.py | 6 +----- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/nw/core/document.py b/nw/core/document.py index 8e2ae571..52f1517b 100644 --- a/nw/core/document.py +++ b/nw/core/document.py @@ -39,14 +39,13 @@ class NWDoc(): def __init__(self, theProject, theParent): - self.mainConf = nw.CONFIG - self.theProject = theProject - self.theParent = theParent - self.theItem = None - self.docHandle = None - self.docEditable = False - self.fileLoc = None - self.docMeta = "" + self.mainConf = nw.CONFIG + self.theProject = theProject + self.theParent = theParent + self.theItem = None + self.docHandle = None + self.fileLoc = None + self.docMeta = "" # Internal Mapping self.makeAlert = self.theParent.makeAlert @@ -60,11 +59,10 @@ class NWDoc(): def clearDocument(self): """Clear the document contents. """ - self.theItem = None - self.docHandle = None - self.docEditable = False - self.fileLoc = None - self.docMeta = "" + self.theItem = None + self.docHandle = None + self.fileLoc = None + self.docMeta = "" return def openDocument(self, tHandle, showStatus=True, isOrphan=False): @@ -87,13 +85,6 @@ class NWDoc(): self.clearDocument() 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" logger.debug("Opening document %s" % docFile) @@ -137,7 +128,7 @@ class NWDoc(): """Save the document via temp file in case of save failure, and 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 self.theProject.ensureFolderStructure() diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 7b6ef81b..b81138a9 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -270,11 +270,7 @@ class GuiDocEditor(QTextEdit): self.setDocumentChanged(False) self.theHandle = tHandle - if self.nwDocument.docEditable: - self.setReadOnly(False) - else: - self.theParent.noticeBar.showNote("This document is read only.") - + self.setReadOnly(False) self.docTitle.setTitleFromHandle(self.theHandle) self.updateDocMargins() self.hLight.spellCheck = spTemp