From d473615ccf7b94297c92f765503522f7826a63f5 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 25 Apr 2021 17:10:12 +0200 Subject: [PATCH 1/5] Rename open and save document to read and write in NWDoc --- nw/core/document.py | 8 +++---- nw/core/index.py | 2 +- nw/core/project.py | 30 +++++++++++++------------- nw/core/tokenizer.py | 7 ++++-- nw/dialogs/docmerge.py | 9 ++++---- nw/dialogs/docsplit.py | 15 ++++++++----- nw/gui/doceditor.py | 6 +++--- nw/gui/projtree.py | 7 ++++-- nw/guimain.py | 8 ++----- tests/test_core/test_core_document.py | 30 +++++++++++++------------- tests/test_core/test_core_tokenizer.py | 4 ++-- 11 files changed, 67 insertions(+), 59 deletions(-) diff --git a/nw/core/document.py b/nw/core/document.py index 1d7600c2..d9fe3268 100644 --- a/nw/core/document.py +++ b/nw/core/document.py @@ -68,8 +68,8 @@ class NWDoc(): self._docMeta = {} return - def openDocument(self, tHandle, showStatus=True, isOrphan=False): - """Open a document from handle, capturing potential file system + def readDocument(self, tHandle, showStatus=True, isOrphan=False): + """Read a document from handle, capturing potential file system errors and parse meta data. If the document doesn't exist on disk, return an empty string. If something went wrong, return None. @@ -134,8 +134,8 @@ class NWDoc(): return theText - def saveDocument(self, docText): - """Save the document. The file is saved via a temp file in case + def writeDocument(self, docText): + """Write the document. The file is saved via a temp file in case of save failure. Returns True if successful, False if not. """ if self._docHandle is None: diff --git a/nw/core/index.py b/nw/core/index.py index 986e4f93..6b8f53e3 100644 --- a/nw/core/index.py +++ b/nw/core/index.py @@ -117,7 +117,7 @@ class NWIndex(): return False theDoc = NWDoc(self.theProject, self.theParent) - theText = theDoc.openDocument(tHandle, showStatus=False) + theText = theDoc.readDocument(tHandle, showStatus=False) if theText: self.scanText(tHandle, theText) diff --git a/nw/core/project.py b/nw/core/project.py index 99bd0d1a..832e9c9b 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -284,16 +284,16 @@ class NWProject(): self.projTree.setFileItemLayout(xHandle[5], nwItemLayout.TITLE) self.projTree.setFileItemLayout(xHandle[7], nwItemLayout.CHAPTER) - aDoc.openDocument(xHandle[5], showStatus=False) - aDoc.saveDocument(titlePage) + aDoc.readDocument(xHandle[5], showStatus=False) + aDoc.writeDocument(titlePage) aDoc.clearDocument() - aDoc.openDocument(xHandle[7], showStatus=False) - aDoc.saveDocument("## %s\n\n" % self.tr("New Chapter")) + aDoc.readDocument(xHandle[7], showStatus=False) + aDoc.writeDocument("## %s\n\n" % self.tr("New Chapter")) aDoc.clearDocument() - aDoc.openDocument(xHandle[8], showStatus=False) - aDoc.saveDocument("### %s\n\n" % self.tr("New Scene")) + aDoc.readDocument(xHandle[8], showStatus=False) + aDoc.writeDocument("### %s\n\n" % self.tr("New Scene")) aDoc.clearDocument() elif popCustom: @@ -311,8 +311,8 @@ class NWProject(): tHandle = self.newFile(self.tr("Title Page"), nwItemClass.NOVEL, nHandle) self.projTree.setFileItemLayout(tHandle, nwItemLayout.TITLE) - aDoc.openDocument(tHandle, showStatus=False) - aDoc.saveDocument(titlePage) + aDoc.readDocument(tHandle, showStatus=False) + aDoc.writeDocument(titlePage) aDoc.clearDocument() # Create chapters and scenes @@ -331,8 +331,8 @@ class NWProject(): cHandle = self.newFile(chTitle, nwItemClass.NOVEL, pHandle) self.projTree.setFileItemLayout(cHandle, nwItemLayout.CHAPTER) - aDoc.openDocument(cHandle, showStatus=False) - aDoc.saveDocument("## %s\n\n" % chTitle) + aDoc.readDocument(cHandle, showStatus=False) + aDoc.writeDocument("## %s\n\n" % chTitle) aDoc.clearDocument() # Create chapter scenes @@ -341,8 +341,8 @@ class NWProject(): scTitle = self.tr("Scene {0}").format(f"{ch+1:d}.{sc+1:d}") sHandle = self.newFile(scTitle, nwItemClass.NOVEL, pHandle) - aDoc.openDocument(sHandle, showStatus=False) - aDoc.saveDocument("### %s\n\n" % scTitle) + aDoc.readDocument(sHandle, showStatus=False) + aDoc.writeDocument("### %s\n\n" % scTitle) aDoc.clearDocument() # Create scenes (no chapters) @@ -351,8 +351,8 @@ class NWProject(): scTitle = self.tr("Scene {0}").format(f"{sc+1:d}") sHandle = self.newFile(scTitle, nwItemClass.NOVEL, nHandle) - aDoc.openDocument(sHandle, showStatus=False) - aDoc.saveDocument("### %s\n\n" % scTitle) + aDoc.readDocument(sHandle, showStatus=False) + aDoc.writeDocument("### %s\n\n" % scTitle) aDoc.clearDocument() # Finalise @@ -1404,7 +1404,7 @@ class NWProject(): oParent = None oClass = None oLayout = None - if aDoc.openDocument(oHandle, showStatus=False, isOrphan=True) is not None: + if aDoc.readDocument(oHandle, showStatus=False, isOrphan=True) is not None: oName, oParent, oClass, oLayout = aDoc.getMeta() if oName: diff --git a/nw/core/tokenizer.py b/nw/core/tokenizer.py index 921f7cef..713d2dd5 100644 --- a/nw/core/tokenizer.py +++ b/nw/core/tokenizer.py @@ -278,13 +278,16 @@ class Tokenizer(): if self.theItem is None: return False + self.theText = "" if theText is not None: # If the text is set, just use that self.theText = theText else: # Otherwise, load it from file - theDocument = NWDoc(self.theProject, self.theParent) - self.theText = theDocument.openDocument(theHandle) + theDoc = NWDoc(self.theProject, self.theParent) + theText = theDoc.readDocument(theHandle) + if theText: + self.theText = theText docSize = len(self.theText) if docSize > nwConst.MAX_DOCSIZE: diff --git a/nw/dialogs/docmerge.py b/nw/dialogs/docmerge.py index 4a6fe00f..4dd397c5 100644 --- a/nw/dialogs/docmerge.py +++ b/nw/dialogs/docmerge.py @@ -110,8 +110,9 @@ class GuiDocMerge(QDialog): theDoc = NWDoc(self.theProject, self.theParent) theText = "" for tHandle in finalOrder: - theText += theDoc.openDocument(tHandle, False).rstrip("\n") - theText += "\n\n" + docText = theDoc.readDocument(tHandle, False).rstrip("\n") + if docText: + theText += docText+"\n\n" if self.sourceItem is None: self.theParent.makeAlert( @@ -130,8 +131,8 @@ class GuiDocMerge(QDialog): newItem = self.theProject.projTree[nHandle] newItem.setStatus(srcItem.itemStatus) - theDoc.openDocument(nHandle, False) - theDoc.saveDocument(theText) + theDoc.readDocument(nHandle, False) + theDoc.writeDocument(theText) self.theParent.treeView.revealNewTreeItem(nHandle) self.theParent.openDocument(nHandle, doScroll=True) diff --git a/nw/dialogs/docsplit.py b/nw/dialogs/docsplit.py index da5b27f0..184e7089 100644 --- a/nw/dialogs/docsplit.py +++ b/nw/dialogs/docsplit.py @@ -127,8 +127,11 @@ class GuiDocSplit(QDialog): ) return - theDoc = NWDoc(self.theProject, self.theParent) - theText = theDoc.openDocument(self.sourceItem, False) + theDoc = NWDoc(self.theProject, self.theParent) + theText = theDoc.readDocument(self.sourceItem, False) + if theText is None: + theText = "" + theLines = theText.splitlines() nLines = len(theLines) theLines.insert(0, "%Split Doc") @@ -214,8 +217,8 @@ class GuiDocSplit(QDialog): theText = "\n".join(theLines[iStart:iEnd]) theText = theText.rstrip("\n") + "\n\n" - theDoc.openDocument(nHandle, False) - theDoc.saveDocument(theText) + theDoc.readDocument(nHandle, False) + theDoc.writeDocument(theText) theDoc.clearDocument() self.theParent.treeView.revealNewTreeItem(nHandle) @@ -257,7 +260,9 @@ class GuiDocSplit(QDialog): self.listBox.clear() theDoc = NWDoc(self.theProject, self.theParent) - theText = theDoc.openDocument(self.sourceItem, False) + theText = theDoc.readDocument(self.sourceItem, False) + if theText is None: + theText = "" spLevel = self.splitLevel.currentData() self.optState.setValue("GuiDocSplit", "spLevel", spLevel) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 91abfce9..6e6f74c9 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -297,7 +297,7 @@ class GuiDocEditor(QTextEdit): document is new (empty string), we set up the editor for editing the file. """ - theDoc = self.nwDocument.openDocument(tHandle, showStatus=showStatus) + theDoc = self.nwDocument.readDocument(tHandle, showStatus=showStatus) if theDoc is None: # There was an io error self.clearEditor() @@ -438,7 +438,7 @@ class GuiDocEditor(QTextEdit): theItem.setParaCount(self.paraCount) self.saveCursorPosition() - self.nwDocument.saveDocument(docText) + self.nwDocument.writeDocument(docText) self.setDocumentChanged(False) self.theIndex.scanText(tHandle, docText) @@ -454,7 +454,7 @@ class GuiDocEditor(QTextEdit): if self.theProject.projTree.updateItemLayout(tHandle, hLevel): self.theParent.treeView.setTreeItemValues(tHandle) - self.nwDocument.saveDocument(docText) + self.nwDocument.writeDocument(docText) self.docFooter.updateInfo() return True diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index e0d5b4b3..dfa71b67 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -287,7 +287,10 @@ class GuiProjectTree(QTreeWidget): # This is a new files, so let's add some content newDoc = NWDoc(self.theProject, self.theParent) - curTxt = newDoc.openDocument(tHandle, showStatus=False) + curTxt = newDoc.readDocument(tHandle, showStatus=False) + if curTxt is None: + curTxt = "" + if curTxt == "": if nwItem.itemLayout == nwItemLayout.CHAPTER: newText = f"## {nwItem.itemName}\n\n" @@ -299,7 +302,7 @@ class GuiProjectTree(QTreeWidget): newText = f"# {nwItem.itemName}\n\n" # Save the text and index it - newDoc.saveDocument(newText) + newDoc.writeDocument(newText) self.theIndex.scanText(tHandle, newText) # Get Word Counts diff --git a/nw/guimain.py b/nw/guimain.py index 300c00a7..aff3bea0 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -48,7 +48,7 @@ from nw.dialogs import ( GuiProjectLoad, GuiProjectSettings, GuiWordList ) from nw.tools import GuiBuildNovel, GuiProjectWizard, GuiWritingStats -from nw.core import NWProject, NWDoc, NWIndex +from nw.core import NWProject, NWIndex from nw.enum import nwItemType, nwItemClass, nwAlert, nwWidget from nw.common import getGuiItem, hexToInt from nw.constants import nwLists @@ -878,7 +878,6 @@ class GuiMain(QMainWindow): self.treeView.saveTreeOrder() self.theIndex.clearIndex() - theDoc = NWDoc(self.theProject, self) for nDone, tItem in enumerate(self.theProject.projTree): if tItem is not None: @@ -888,10 +887,7 @@ class GuiMain(QMainWindow): if tItem is not None and tItem.itemType == nwItemType.FILE: logger.verbose("Scanning: %s" % tItem.itemName) - theText = theDoc.openDocument(tItem.itemHandle, showStatus=False) - - # Build tag index - self.theIndex.scanText(tItem.itemHandle, theText) + self.theIndex.reIndexHandle(tItem.itemHandle) # Get Word Counts cC, wC, pC = self.theIndex.getCounts(tItem.itemHandle) diff --git a/tests/test_core/test_core_document.py b/tests/test_core/test_core_document.py index 1eab9824..df02ea1b 100644 --- a/tests/test_core/test_core_document.py +++ b/tests/test_core/test_core_document.py @@ -41,10 +41,10 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal): sHandle = "8c659a11cd429" # Not a valid handle - assert theDoc.openDocument("dummy") is None + assert theDoc.readDocument("dummy") is None # Non-existent handle - assert theDoc.openDocument("0000000000000") is None + assert theDoc.readDocument("0000000000000") is None # Cause open() to fail while loading def dummyOpen(*args, **kwargs): @@ -52,29 +52,29 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal): with monkeypatch.context() as mp: mp.setattr("builtins.open", dummyOpen) - assert theDoc.openDocument(sHandle) is None + assert theDoc.readDocument(sHandle) is None # Load the text - assert theDoc.openDocument(sHandle) == "### New Scene\n\n" + assert theDoc.readDocument(sHandle) == "### New Scene\n\n" # Try to open a new (non-existent) file nHandle = theProject.projTree.findRoot(nwItemClass.NOVEL) assert nHandle is not None xHandle = theProject.newFile("New File", nwItemClass.NOVEL, nHandle) - assert theDoc.openDocument(xHandle) == "" + assert theDoc.readDocument(xHandle) == "" # Check cached item assert isinstance(theDoc._theItem, NWItem) - assert theDoc.openDocument(xHandle, isOrphan=True) == "" + assert theDoc.readDocument(xHandle, isOrphan=True) == "" assert theDoc._theItem is None # Set handle and save again theText = "### Test File\n\nText ...\n\n" - assert theDoc.openDocument(xHandle) == "" - assert theDoc.saveDocument(theText) + assert theDoc.readDocument(xHandle) == "" + assert theDoc.writeDocument(theText) # Save again to ensure temp file and previous file is handled - assert theDoc.saveDocument(theText) + assert theDoc.writeDocument(theText) # Check file content docPath = os.path.join(nwMinimal, "content", xHandle+".nwd") @@ -89,7 +89,7 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal): # Force no meta data theDoc._theItem = None - assert theDoc.saveDocument(theText) + assert theDoc.writeDocument(theText) with open(docPath, mode="r", encoding="utf8") as inFile: assert inFile.read() == theText @@ -97,11 +97,11 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal): # Cause open() to fail while saving with monkeypatch.context() as mp: mp.setattr("builtins.open", causeOSError) - assert not theDoc.saveDocument(theText) + assert not theDoc.writeDocument(theText) # Saving with no handle theDoc.clearDocument() - assert not theDoc.saveDocument(theText) + assert not theDoc.writeDocument(theText) # Delete the last document assert not theDoc.deleteDocument("dummy") @@ -130,7 +130,7 @@ def testCoreDocument_Methods(monkeypatch, dummyGUI, nwMinimal): sHandle = "8c659a11cd429" docPath = os.path.join(nwMinimal, "content", sHandle+".nwd") - assert theDoc.openDocument(sHandle) == "### New Scene\n\n" + assert theDoc.readDocument(sHandle) == "### New Scene\n\n" # Check location assert theDoc.getFileLocation() == docPath @@ -147,7 +147,7 @@ def testCoreDocument_Methods(monkeypatch, dummyGUI, nwMinimal): assert theLayout == nwItemLayout.SCENE # Add meta data garbage - assert theDoc.saveDocument("%%~ stuff\n### Test File\n\nText ...\n\n") + assert theDoc.writeDocument("%%~ stuff\n### Test File\n\nText ...\n\n") with open(docPath, mode="r", encoding="utf8") as inFile: assert inFile.read() == ( "%%~name: New Scene\n" @@ -158,6 +158,6 @@ def testCoreDocument_Methods(monkeypatch, dummyGUI, nwMinimal): "Text ...\n\n" ) - assert theDoc.openDocument(sHandle) == "### Test File\n\nText ...\n\n" + assert theDoc.readDocument(sHandle) == "### Test File\n\nText ...\n\n" # END Test testCoreDocument_Methods diff --git a/tests/test_core/test_core_tokenizer.py b/tests/test_core/test_core_tokenizer.py index 4062f710..743c45f5 100644 --- a/tests/test_core/test_core_tokenizer.py +++ b/tests/test_core/test_core_tokenizer.py @@ -138,8 +138,8 @@ def testCoreToken_TextOps(monkeypatch, nwMinimal, dummyGUI): docTextR = docText.replace("", "this").replace("", "that") nDoc = NWDoc(theProject, dummyGUI) - nDoc.openDocument(sHandle) - nDoc.saveDocument(docText) + nDoc.readDocument(sHandle) + nDoc.writeDocument(docText) nDoc.clearDocument() theProject.setAutoReplace({"A": "this", "B": "that"}) From 45f726669ea4920720a4b165815930e5ef9257e9 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 25 Apr 2021 17:16:57 +0200 Subject: [PATCH 2/5] Remove the showStatus flag from document handling --- nw/core/document.py | 12 +----------- nw/core/index.py | 2 +- nw/core/project.py | 16 ++++++++-------- nw/dialogs/docmerge.py | 4 ++-- nw/dialogs/docsplit.py | 6 +++--- nw/gui/doceditor.py | 15 +++++++++++++-- nw/gui/projtree.py | 2 +- 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/nw/core/document.py b/nw/core/document.py index d9fe3268..e158cf87 100644 --- a/nw/core/document.py +++ b/nw/core/document.py @@ -68,7 +68,7 @@ class NWDoc(): self._docMeta = {} return - def readDocument(self, tHandle, showStatus=True, isOrphan=False): + def readDocument(self, tHandle, isOrphan=False): """Read a document from handle, capturing potential file system errors and parse meta data. If the document doesn't exist on disk, return an empty string. If something went wrong, return @@ -127,11 +127,6 @@ class NWDoc(): logger.debug("The requested document does not exist.") return "" - if showStatus and not isOrphan: - self.theParent.setStatus( - self.tr("Opened Document: {0}").format(self._theItem.itemName) - ) - return theText def writeDocument(self, docText): @@ -173,11 +168,6 @@ class NWDoc(): os.unlink(docPath) os.rename(docTemp, docPath) - if self._theItem is not None: - self.theParent.setStatus( - self.tr("Saved Document: {0}").format(self._theItem.itemName) - ) - return True def deleteDocument(self, tHandle): diff --git a/nw/core/index.py b/nw/core/index.py index 6b8f53e3..8d6f04c3 100644 --- a/nw/core/index.py +++ b/nw/core/index.py @@ -117,7 +117,7 @@ class NWIndex(): return False theDoc = NWDoc(self.theProject, self.theParent) - theText = theDoc.readDocument(tHandle, showStatus=False) + theText = theDoc.readDocument(tHandle) if theText: self.scanText(tHandle, theText) diff --git a/nw/core/project.py b/nw/core/project.py index 832e9c9b..75aaafa9 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -284,15 +284,15 @@ class NWProject(): self.projTree.setFileItemLayout(xHandle[5], nwItemLayout.TITLE) self.projTree.setFileItemLayout(xHandle[7], nwItemLayout.CHAPTER) - aDoc.readDocument(xHandle[5], showStatus=False) + aDoc.readDocument(xHandle[5]) aDoc.writeDocument(titlePage) aDoc.clearDocument() - aDoc.readDocument(xHandle[7], showStatus=False) + aDoc.readDocument(xHandle[7]) aDoc.writeDocument("## %s\n\n" % self.tr("New Chapter")) aDoc.clearDocument() - aDoc.readDocument(xHandle[8], showStatus=False) + aDoc.readDocument(xHandle[8]) aDoc.writeDocument("### %s\n\n" % self.tr("New Scene")) aDoc.clearDocument() @@ -311,7 +311,7 @@ class NWProject(): tHandle = self.newFile(self.tr("Title Page"), nwItemClass.NOVEL, nHandle) self.projTree.setFileItemLayout(tHandle, nwItemLayout.TITLE) - aDoc.readDocument(tHandle, showStatus=False) + aDoc.readDocument(tHandle) aDoc.writeDocument(titlePage) aDoc.clearDocument() @@ -331,7 +331,7 @@ class NWProject(): cHandle = self.newFile(chTitle, nwItemClass.NOVEL, pHandle) self.projTree.setFileItemLayout(cHandle, nwItemLayout.CHAPTER) - aDoc.readDocument(cHandle, showStatus=False) + aDoc.readDocument(cHandle) aDoc.writeDocument("## %s\n\n" % chTitle) aDoc.clearDocument() @@ -341,7 +341,7 @@ class NWProject(): scTitle = self.tr("Scene {0}").format(f"{ch+1:d}.{sc+1:d}") sHandle = self.newFile(scTitle, nwItemClass.NOVEL, pHandle) - aDoc.readDocument(sHandle, showStatus=False) + aDoc.readDocument(sHandle) aDoc.writeDocument("### %s\n\n" % scTitle) aDoc.clearDocument() @@ -351,7 +351,7 @@ class NWProject(): scTitle = self.tr("Scene {0}").format(f"{sc+1:d}") sHandle = self.newFile(scTitle, nwItemClass.NOVEL, nHandle) - aDoc.readDocument(sHandle, showStatus=False) + aDoc.readDocument(sHandle) aDoc.writeDocument("### %s\n\n" % scTitle) aDoc.clearDocument() @@ -1404,7 +1404,7 @@ class NWProject(): oParent = None oClass = None oLayout = None - if aDoc.readDocument(oHandle, showStatus=False, isOrphan=True) is not None: + if aDoc.readDocument(oHandle, isOrphan=True) is not None: oName, oParent, oClass, oLayout = aDoc.getMeta() if oName: diff --git a/nw/dialogs/docmerge.py b/nw/dialogs/docmerge.py index 4dd397c5..8dbaaa98 100644 --- a/nw/dialogs/docmerge.py +++ b/nw/dialogs/docmerge.py @@ -110,7 +110,7 @@ class GuiDocMerge(QDialog): theDoc = NWDoc(self.theProject, self.theParent) theText = "" for tHandle in finalOrder: - docText = theDoc.readDocument(tHandle, False).rstrip("\n") + docText = theDoc.readDocument(tHandle).rstrip("\n") if docText: theText += docText+"\n\n" @@ -131,7 +131,7 @@ class GuiDocMerge(QDialog): newItem = self.theProject.projTree[nHandle] newItem.setStatus(srcItem.itemStatus) - theDoc.readDocument(nHandle, False) + theDoc.readDocument(nHandle) theDoc.writeDocument(theText) self.theParent.treeView.revealNewTreeItem(nHandle) self.theParent.openDocument(nHandle, doScroll=True) diff --git a/nw/dialogs/docsplit.py b/nw/dialogs/docsplit.py index 184e7089..bf5f2d1f 100644 --- a/nw/dialogs/docsplit.py +++ b/nw/dialogs/docsplit.py @@ -128,7 +128,7 @@ class GuiDocSplit(QDialog): return theDoc = NWDoc(self.theProject, self.theParent) - theText = theDoc.readDocument(self.sourceItem, False) + theText = theDoc.readDocument(self.sourceItem) if theText is None: theText = "" @@ -217,7 +217,7 @@ class GuiDocSplit(QDialog): theText = "\n".join(theLines[iStart:iEnd]) theText = theText.rstrip("\n") + "\n\n" - theDoc.readDocument(nHandle, False) + theDoc.readDocument(nHandle) theDoc.writeDocument(theText) theDoc.clearDocument() self.theParent.treeView.revealNewTreeItem(nHandle) @@ -260,7 +260,7 @@ class GuiDocSplit(QDialog): self.listBox.clear() theDoc = NWDoc(self.theProject, self.theParent) - theText = theDoc.readDocument(self.sourceItem, False) + theText = theDoc.readDocument(self.sourceItem) if theText is None: theText = "" diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 6e6f74c9..7cbb761e 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -288,7 +288,7 @@ class GuiDocEditor(QTextEdit): return True - def loadText(self, tHandle, tLine=None, showStatus=True): + def loadText(self, tHandle, tLine=None): """Load text from a document into the editor. If we have an io error, we must handle this and clear the editor so that we don't risk overwriting the file if it exists. This can for instance @@ -297,7 +297,7 @@ class GuiDocEditor(QTextEdit): document is new (empty string), we set up the editor for editing the file. """ - theDoc = self.nwDocument.readDocument(tHandle, showStatus=showStatus) + theDoc = self.nwDocument.readDocument(tHandle) if theDoc is None: # There was an io error self.clearEditor() @@ -377,6 +377,12 @@ class GuiDocEditor(QTextEdit): self.setPlainText("") self.setCursorPosition(0) + # Update the status bar + if theItem is not None: + self.theParent.setStatus( + self.tr("Opened Document: {0}").format(theItem.itemName) + ) + return True def updateTagHighLighting(self, forceBigDoc=False): @@ -457,6 +463,11 @@ class GuiDocEditor(QTextEdit): self.nwDocument.writeDocument(docText) self.docFooter.updateInfo() + # Update the status bar + self.theParent.setStatus( + self.tr("Saved Document: {0}").format(theItem.itemName) + ) + return True def updateDocMargins(self): diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index dfa71b67..005e4d2f 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -287,7 +287,7 @@ class GuiProjectTree(QTreeWidget): # This is a new files, so let's add some content newDoc = NWDoc(self.theProject, self.theParent) - curTxt = newDoc.readDocument(tHandle, showStatus=False) + curTxt = newDoc.readDocument(tHandle) if curTxt is None: curTxt = "" From 48695651e192ec8dc2112125761c96c45258a0cc Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 25 Apr 2021 17:39:52 +0200 Subject: [PATCH 3/5] Core classes should only init with project class and if needed access main gui via project --- nw/core/document.py | 4 ++-- nw/core/index.py | 11 +++-------- nw/core/project.py | 4 ++-- nw/core/tohtml.py | 4 ++-- nw/core/tokenizer.py | 6 +++--- nw/core/tomd.py | 4 ++-- nw/core/toodt.py | 4 ++-- nw/dialogs/docmerge.py | 2 +- nw/dialogs/docsplit.py | 4 ++-- nw/gui/doceditor.py | 2 +- nw/gui/docviewer.py | 2 +- nw/gui/projtree.py | 4 ++-- nw/guimain.py | 2 +- nw/tools/build.py | 16 ++++++++-------- tests/test_core/test_core_document.py | 4 ++-- tests/test_core/test_core_index.py | 18 +++++++++--------- tests/test_core/test_core_tohtml.py | 12 ++++++------ tests/test_core/test_core_tokenizer.py | 10 +++++----- tests/test_core/test_core_toodt.py | 4 ++-- 19 files changed, 56 insertions(+), 61 deletions(-) diff --git a/nw/core/document.py b/nw/core/document.py index e158cf87..c645a840 100644 --- a/nw/core/document.py +++ b/nw/core/document.py @@ -38,10 +38,10 @@ logger = logging.getLogger(__name__) class NWDoc(): - def __init__(self, theProject, theParent): + def __init__(self, theProject): self.theProject = theProject - self.theParent = theParent + self.theParent = theProject.theParent # Internal Variables self._theItem = None # The currently open item diff --git a/nw/core/index.py b/nw/core/index.py index 8d6f04c3..d7b09ec4 100644 --- a/nw/core/index.py +++ b/nw/core/index.py @@ -32,7 +32,7 @@ import os from time import time -from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert +from nw.enum import nwItemType, nwItemClass, nwItemLayout from nw.common import isHandle, isTitleTag, isItemClass, isItemLayout from nw.constants import nwFiles, nwKeyWords, nwUnicode from nw.core.document import NWDoc @@ -44,12 +44,11 @@ class NWIndex(): H_VALID = ("H0", "H1", "H2", "H3", "H4") H_LEVEL = {"H0": 0, "H1": 1, "H2": 2, "H3": 3, "H4": 4} - def __init__(self, theProject, theParent): + def __init__(self, theProject): # Internal self.mainConf = nw.CONFIG self.theProject = theProject - self.theParent = theParent self.indexBroken = False # Indices @@ -116,7 +115,7 @@ class NWIndex(): if tItem.itemType != nwItemType.FILE: return False - theDoc = NWDoc(self.theProject, self.theParent) + theDoc = NWDoc(self.theProject) theText = theDoc.readDocument(tHandle) if theText: self.scanText(tHandle, theText) @@ -157,10 +156,6 @@ class NWIndex(): logger.error("Failed to load index file") nw.logException() self.indexBroken = True - self.theParent.makeAlert( - "Could not load cached index file. Rebuilding index.", - nwAlert.WARN - ) return False self._tagIndex = theData.get("tagIndex", {}) diff --git a/nw/core/project.py b/nw/core/project.py index 75aaafa9..e0e978ee 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -266,7 +266,7 @@ class NWProject(): titlePage = "%s%s %s\n" % (titlePage, self.tr("By"), self.getAuthors()) # Document object for writing files - aDoc = NWDoc(self, self.theParent) + aDoc = NWDoc(self) if popMinimal: # Creating a minimal project with a few root folders and a @@ -1393,7 +1393,7 @@ class NWProject(): return # Handle orphans - aDoc = NWDoc(self, self.theParent) + aDoc = NWDoc(self) nOrph = 0 noWhere = False oPrefix = self.tr("Recovered") diff --git a/nw/core/tohtml.py b/nw/core/tohtml.py index 412efe4f..180c2da8 100644 --- a/nw/core/tohtml.py +++ b/nw/core/tohtml.py @@ -37,8 +37,8 @@ class ToHtml(Tokenizer): M_EXPORT = 1 # Tweak output for saving to HTML or printing M_EBOOK = 2 # Tweak output for converting to epub - def __init__(self, theProject, theParent): - Tokenizer.__init__(self, theProject, theParent) + def __init__(self, theProject): + Tokenizer.__init__(self, theProject) self.genMode = self.M_EXPORT self.cssStyles = True diff --git a/nw/core/tokenizer.py b/nw/core/tokenizer.py index 713d2dd5..d04ffe47 100644 --- a/nw/core/tokenizer.py +++ b/nw/core/tokenizer.py @@ -76,10 +76,10 @@ class Tokenizer(): A_Z_TOPMRG = 0x0100 # Zero top margin A_Z_BTMMRG = 0x0200 # Zero bottom margin - def __init__(self, theProject, theParent): + def __init__(self, theProject): self.theProject = theProject - self.theParent = theParent + self.theParent = theProject.theParent # Data Variables self.theText = "" # The raw text to be tokenized @@ -284,7 +284,7 @@ class Tokenizer(): self.theText = theText else: # Otherwise, load it from file - theDoc = NWDoc(self.theProject, self.theParent) + theDoc = NWDoc(self.theProject) theText = theDoc.readDocument(theHandle) if theText: self.theText = theText diff --git a/nw/core/tomd.py b/nw/core/tomd.py index 53e3ab80..684a23fb 100644 --- a/nw/core/tomd.py +++ b/nw/core/tomd.py @@ -36,8 +36,8 @@ class ToMarkdown(Tokenizer): M_STD = 0 # Standard Markdown M_GH = 1 # GitHub Markdown - def __init__(self, theProject, theParent): - Tokenizer.__init__(self, theProject, theParent) + def __init__(self, theProject): + Tokenizer.__init__(self, theProject) self.genMode = self.M_STD self.fullMD = [] diff --git a/nw/core/toodt.py b/nw/core/toodt.py index 89b74148..ca06cacf 100644 --- a/nw/core/toodt.py +++ b/nw/core/toodt.py @@ -65,8 +65,8 @@ class ToOdt(Tokenizer): X_BRK = 0x08 # Line break X_TAB = 0x10 # Tab - def __init__(self, theProject, theParent, isFlat): - Tokenizer.__init__(self, theProject, theParent) + def __init__(self, theProject, isFlat): + Tokenizer.__init__(self, theProject) self.mainConf = nw.CONFIG diff --git a/nw/dialogs/docmerge.py b/nw/dialogs/docmerge.py index 8dbaaa98..a609e63d 100644 --- a/nw/dialogs/docmerge.py +++ b/nw/dialogs/docmerge.py @@ -107,7 +107,7 @@ class GuiDocMerge(QDialog): ) return - theDoc = NWDoc(self.theProject, self.theParent) + theDoc = NWDoc(self.theProject) theText = "" for tHandle in finalOrder: docText = theDoc.readDocument(tHandle).rstrip("\n") diff --git a/nw/dialogs/docsplit.py b/nw/dialogs/docsplit.py index bf5f2d1f..74fbedfa 100644 --- a/nw/dialogs/docsplit.py +++ b/nw/dialogs/docsplit.py @@ -127,7 +127,7 @@ class GuiDocSplit(QDialog): ) return - theDoc = NWDoc(self.theProject, self.theParent) + theDoc = NWDoc(self.theProject) theText = theDoc.readDocument(self.sourceItem) if theText is None: theText = "" @@ -259,7 +259,7 @@ class GuiDocSplit(QDialog): return self.listBox.clear() - theDoc = NWDoc(self.theProject, self.theParent) + theDoc = NWDoc(self.theProject) theText = theDoc.readDocument(self.sourceItem) if theText is None: theText = "" diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 7cbb761e..759c0053 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -75,7 +75,7 @@ class GuiDocEditor(QTextEdit): self.theTheme = theParent.theTheme self.theIndex = theParent.theIndex self.theProject = theParent.theProject - self.nwDocument = NWDoc(self.theProject, self.theParent) + self.nwDocument = NWDoc(self.theProject) self.docChanged = False # Flag for changed status of document self.spellCheck = False # Flag for spell checking enabled diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index 0feaa101..8ba3fbef 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -168,7 +168,7 @@ class GuiDocViewer(QTextBrowser): qApp.setOverrideCursor(QCursor(Qt.WaitCursor)) sPos = self.verticalScrollBar().value() - aDoc = ToHtml(self.theProject, self.theParent) + aDoc = ToHtml(self.theProject) aDoc.setPreview(self.mainConf.viewComments, self.mainConf.viewSynopsis) aDoc.setLinkHeaders(True) diff --git a/nw/gui/projtree.py b/nw/gui/projtree.py index 005e4d2f..84415f80 100644 --- a/nw/gui/projtree.py +++ b/nw/gui/projtree.py @@ -286,7 +286,7 @@ class GuiProjectTree(QTreeWidget): return True # This is a new files, so let's add some content - newDoc = NWDoc(self.theProject, self.theParent) + newDoc = NWDoc(self.theProject) curTxt = newDoc.readDocument(tHandle) if curTxt is None: curTxt = "" @@ -527,7 +527,7 @@ class GuiProjectTree(QTreeWidget): if self.theParent.docEditor.theHandle == tHandle: self.theParent.closeDocument() - theDoc = NWDoc(self.theProject, self.theParent) + theDoc = NWDoc(self.theProject) theDoc.deleteDocument(tHandle) self.theIndex.deleteHandle(tHandle) self._deleteTreeItem(tHandle) diff --git a/nw/guimain.py b/nw/guimain.py index aff3bea0..8c97d6d5 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -88,7 +88,7 @@ class GuiMain(QMainWindow): # Core Classes and Settings self.theTheme = GuiTheme(self) self.theProject = NWProject(self) - self.theIndex = NWIndex(self.theProject, self) + self.theIndex = NWIndex(self.theProject) self.hasProject = False self.isFocusMode = False self.idleRefTime = time() diff --git a/nw/tools/build.py b/nw/tools/build.py index 58526af5..a3093cea 100644 --- a/nw/tools/build.py +++ b/nw/tools/build.py @@ -608,7 +608,7 @@ class GuiBuildNovel(QDialog): # Build Preview # ============= - makeHtml = ToHtml(self.theProject, self.theParent) + makeHtml = ToHtml(self.theProject) self._doBuild(makeHtml, isPreview=True) if replaceTabs: makeHtml.replaceTabs() @@ -875,7 +875,7 @@ class GuiBuildNovel(QDialog): wSuccess = False if theFmt == self.FMT_ODT: - makeOdt = ToOdt(self.theProject, self.theParent, isFlat=False) + makeOdt = ToOdt(self.theProject, isFlat=False) self._doBuild(makeOdt) try: makeOdt.saveOpenDocText(savePath) @@ -884,7 +884,7 @@ class GuiBuildNovel(QDialog): errMsg = str(e) elif theFmt == self.FMT_FODT: - makeOdt = ToOdt(self.theProject, self.theParent, isFlat=True) + makeOdt = ToOdt(self.theProject, isFlat=True) self._doBuild(makeOdt) try: makeOdt.saveFlatXML(savePath) @@ -893,7 +893,7 @@ class GuiBuildNovel(QDialog): errMsg = str(e) elif theFmt == self.FMT_HTM: - makeHtml = ToHtml(self.theProject, self.theParent) + makeHtml = ToHtml(self.theProject) self._doBuild(makeHtml) if replaceTabs: makeHtml.replaceTabs() @@ -905,7 +905,7 @@ class GuiBuildNovel(QDialog): errMsg = str(e) elif theFmt == self.FMT_NWD: - makeNwd = ToMarkdown(self.theProject, self.theParent) + makeNwd = ToMarkdown(self.theProject) makeNwd.setKeepMarkdown(True) self._doBuild(makeNwd, doConvert=False) if replaceTabs: @@ -918,7 +918,7 @@ class GuiBuildNovel(QDialog): errMsg = str(e) elif theFmt in (self.FMT_MD, self.FMT_GH): - makeMd = ToMarkdown(self.theProject, self.theParent) + makeMd = ToMarkdown(self.theProject) if theFmt == self.FMT_GH: makeMd.setGitHubMarkdown() else: @@ -945,7 +945,7 @@ class GuiBuildNovel(QDialog): } if theFmt == self.FMT_JSON_H: - makeHtml = ToHtml(self.theProject, self.theParent) + makeHtml = ToHtml(self.theProject) self._doBuild(makeHtml) if replaceTabs: makeHtml.replaceTabs() @@ -959,7 +959,7 @@ class GuiBuildNovel(QDialog): } elif theFmt == self.FMT_JSON_M: - makeMd = ToHtml(self.theProject, self.theParent) + makeMd = ToHtml(self.theProject) makeMd.setKeepMarkdown(True) self._doBuild(makeMd, doConvert=False) if replaceTabs: diff --git a/tests/test_core/test_core_document.py b/tests/test_core/test_core_document.py index df02ea1b..056b212e 100644 --- a/tests/test_core/test_core_document.py +++ b/tests/test_core/test_core_document.py @@ -37,7 +37,7 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal): assert theProject.openProject(nwMinimal) assert theProject.projPath == nwMinimal - theDoc = NWDoc(theProject, dummyGUI) + theDoc = NWDoc(theProject) sHandle = "8c659a11cd429" # Not a valid handle @@ -126,7 +126,7 @@ def testCoreDocument_Methods(monkeypatch, dummyGUI, nwMinimal): assert theProject.openProject(nwMinimal) assert theProject.projPath == nwMinimal - theDoc = NWDoc(theProject, dummyGUI) + theDoc = NWDoc(theProject) sHandle = "8c659a11cd429" docPath = os.path.join(nwMinimal, "content", sHandle+".nwd") diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index 95b83a81..7dc5c9f8 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -48,7 +48,7 @@ def testCoreIndex_LoadSave(monkeypatch, nwLipsum, dummyGUI, outDir, refDir): monkeypatch.setattr("nw.core.index.time", lambda: 123.4) - theIndex = NWIndex(theProject, dummyGUI) + theIndex = NWIndex(theProject) notIndexable = { "b3643d0f92e32": False, # Novel ROOT "45e6b01ca35c1": False, # Chapter One FOLDER @@ -132,7 +132,7 @@ def testCoreIndex_ScanThis(nwMinimal, dummyGUI): theProject.projTree.setSeed(42) assert theProject.openProject(nwMinimal) - theIndex = NWIndex(theProject, dummyGUI) + theIndex = NWIndex(theProject) isValid, theBits, thePos = theIndex.scanThis("tag: this, and this") assert not isValid @@ -183,7 +183,7 @@ def testCoreIndex_CheckThese(nwMinimal, dummyGUI): theProject.projTree.setSeed(42) assert theProject.openProject(nwMinimal) - theIndex = NWIndex(theProject, dummyGUI) + theIndex = NWIndex(theProject) nHandle = theProject.newFile("Hello", nwItemClass.NOVEL, "a508bb932959c") cHandle = theProject.newFile("Jane", nwItemClass.CHARACTER, "afb3043c7b2b3") nItem = theProject.projTree[nHandle] @@ -244,7 +244,7 @@ def testCoreIndex_ScanText(nwMinimal, dummyGUI): theProject.projTree.setSeed(42) assert theProject.openProject(nwMinimal) - theIndex = NWIndex(theProject, dummyGUI) + theIndex = NWIndex(theProject) # Some items for fail to scan tests dHandle = theProject.newFolder("Folder", nwItemClass.NOVEL, "a508bb932959c") @@ -449,7 +449,7 @@ def testCoreIndex_ExtractData(nwMinimal, dummyGUI): theProject.projTree.setSeed(42) assert theProject.openProject(nwMinimal) - theIndex = NWIndex(theProject, dummyGUI) + theIndex = NWIndex(theProject) nHandle = theProject.newFile("Hello", nwItemClass.NOVEL, "a508bb932959c") cHandle = theProject.newFile("Jane", nwItemClass.CHARACTER, "afb3043c7b2b3") @@ -678,7 +678,7 @@ def testCoreIndex_CheckTagIndex(dummyGUI): """Test the tag index checker. """ theProject = NWProject(dummyGUI) - theIndex = NWIndex(theProject, dummyGUI) + theIndex = NWIndex(theProject) # Valid Index theIndex._tagIndex = { @@ -742,7 +742,7 @@ def testCoreIndex_CheckRefIndex(dummyGUI): """Test the reference index checker. """ theProject = NWProject(dummyGUI) - theIndex = NWIndex(theProject, dummyGUI) + theIndex = NWIndex(theProject) # Valid Index theIndex._refIndex = { @@ -864,7 +864,7 @@ def testCoreIndex_CheckNovelNoteIndex(dummyGUI): """Test the novel and note index checkers. """ theProject = NWProject(dummyGUI) - theIndex = NWIndex(theProject, dummyGUI) + theIndex = NWIndex(theProject) # Valid Index theIndex._novelIndex = { @@ -1122,7 +1122,7 @@ def testCoreIndex_CheckTextCounts(dummyGUI): """Test the text counts checker. """ theProject = NWProject(dummyGUI) - theIndex = NWIndex(theProject, dummyGUI) + theIndex = NWIndex(theProject) # Valid Index theIndex._textCounts = { diff --git a/tests/test_core/test_core_tohtml.py b/tests/test_core/test_core_tohtml.py index 8e25b432..8706c0c9 100644 --- a/tests/test_core/test_core_tohtml.py +++ b/tests/test_core/test_core_tohtml.py @@ -32,8 +32,8 @@ def testCoreToHtml_Format(dummyGUI): """Test all the formatters for the ToHtml class. """ theProject = NWProject(dummyGUI) - dummyGUI.theIndex = NWIndex(theProject, dummyGUI) - theHtml = ToHtml(theProject, dummyGUI) + dummyGUI.theIndex = NWIndex(theProject) + theHtml = ToHtml(theProject) # Export Mode # =========== @@ -84,8 +84,8 @@ def testCoreToHtml_Convert(dummyGUI): """Test the converter of the ToHtml class. """ theProject = NWProject(dummyGUI) - dummyGUI.theIndex = NWIndex(theProject, dummyGUI) - theHtml = ToHtml(theProject, dummyGUI) + dummyGUI.theIndex = NWIndex(theProject) + theHtml = ToHtml(theProject) # Export Mode # =========== @@ -348,7 +348,7 @@ def testCoreToHtml_Complex(dummyGUI, fncDir): """Test the ave method of the ToHtml class. """ theProject = NWProject(dummyGUI) - theHtml = ToHtml(theProject, dummyGUI) + theHtml = ToHtml(theProject) # Build Project # ============= @@ -421,7 +421,7 @@ def testCoreToHtml_Methods(dummyGUI): """Test all the other methods of the ToHtml class. """ theProject = NWProject(dummyGUI) - theHtml = ToHtml(theProject, dummyGUI) + theHtml = ToHtml(theProject) theHtml.setKeepMarkdown(True) # Auto-Replace, keep Unicode diff --git a/tests/test_core/test_core_tokenizer.py b/tests/test_core/test_core_tokenizer.py index 743c45f5..6d13faee 100644 --- a/tests/test_core/test_core_tokenizer.py +++ b/tests/test_core/test_core_tokenizer.py @@ -33,7 +33,7 @@ def testCoreToken_Setters(dummyGUI): """Test all the setters for the Tokenizer class. """ theProject = NWProject(dummyGUI) - theToken = Tokenizer(theProject, dummyGUI) + theToken = Tokenizer(theProject) # Verify defaults assert theToken.fmtTitle == "%title%" @@ -120,7 +120,7 @@ def testCoreToken_TextOps(monkeypatch, nwMinimal, dummyGUI): theProject.projLang = "en" theProject._loadProjectLocalisation() - theToken = Tokenizer(theProject, dummyGUI) + theToken = Tokenizer(theProject) theToken.setKeepMarkdown(True) assert theProject.openProject(nwMinimal) @@ -137,7 +137,7 @@ def testCoreToken_TextOps(monkeypatch, nwMinimal, dummyGUI): ) docTextR = docText.replace("", "this").replace("", "that") - nDoc = NWDoc(theProject, dummyGUI) + nDoc = NWDoc(theProject) nDoc.readDocument(sHandle) nDoc.writeDocument(docText) nDoc.clearDocument() @@ -200,7 +200,7 @@ def testCoreToken_Tokenize(dummyGUI): """Test the tokenization of the Tokenizer class. """ theProject = NWProject(dummyGUI) - theToken = Tokenizer(theProject, dummyGUI) + theToken = Tokenizer(theProject) theToken.setKeepMarkdown(True) # Header 1 @@ -417,7 +417,7 @@ def testCoreToken_Headers(dummyGUI): theProject = NWProject(dummyGUI) theProject.projLang = "en" theProject._loadProjectLocalisation() - theToken = Tokenizer(theProject, dummyGUI) + theToken = Tokenizer(theProject) # Nothing theToken.theText = "Some text ...\n" diff --git a/tests/test_core/test_core_toodt.py b/tests/test_core/test_core_toodt.py index 9cad2f7d..955963e7 100644 --- a/tests/test_core/test_core_toodt.py +++ b/tests/test_core/test_core_toodt.py @@ -48,8 +48,8 @@ def testCoreToOdt_Convert(dummyGUI): """Test the converter of the ToHtml class. """ theProject = NWProject(dummyGUI) - dummyGUI.theIndex = NWIndex(theProject, dummyGUI) - theDoc = ToOdt(theProject, dummyGUI, isFlat=True) + dummyGUI.theIndex = NWIndex(theProject) + theDoc = ToOdt(theProject, isFlat=True) # Export Mode # =========== From 746268c3efe5ab5768c0ea4017d6d95454b48cdd Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 25 Apr 2021 17:50:11 +0200 Subject: [PATCH 4/5] GUI classes should only init with main GUI as parent --- nw/dialogs/docmerge.py | 4 ++-- nw/dialogs/docsplit.py | 6 +++--- nw/dialogs/itemeditor.py | 4 ++-- nw/dialogs/preferences.py | 4 ++-- nw/dialogs/projsettings.py | 6 +++--- nw/dialogs/quotes.py | 2 +- nw/dialogs/wordlist.py | 6 +++--- nw/gui/projdetails.py | 6 +++--- nw/guimain.py | 18 +++++++++--------- nw/tools/build.py | 6 +++--- nw/tools/writingstats.py | 6 +++--- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/nw/dialogs/docmerge.py b/nw/dialogs/docmerge.py index a609e63d..80c0f0e6 100644 --- a/nw/dialogs/docmerge.py +++ b/nw/dialogs/docmerge.py @@ -41,7 +41,7 @@ logger = logging.getLogger(__name__) class GuiDocMerge(QDialog): - def __init__(self, theParent, theProject): + def __init__(self, theParent): QDialog.__init__(self, theParent) logger.debug("Initialising GuiDocMerge ...") @@ -49,7 +49,7 @@ class GuiDocMerge(QDialog): self.mainConf = nw.CONFIG self.theParent = theParent - self.theProject = theProject + self.theProject = theParent.theProject self.sourceItem = None self.outerBox = QVBoxLayout() diff --git a/nw/dialogs/docsplit.py b/nw/dialogs/docsplit.py index 74fbedfa..1944c875 100644 --- a/nw/dialogs/docsplit.py +++ b/nw/dialogs/docsplit.py @@ -42,7 +42,7 @@ logger = logging.getLogger(__name__) class GuiDocSplit(QDialog): - def __init__(self, theParent, theProject): + def __init__(self, theParent): QDialog.__init__(self, theParent) logger.debug("Initialising GuiDocSplit ...") @@ -50,8 +50,8 @@ class GuiDocSplit(QDialog): self.mainConf = nw.CONFIG self.theParent = theParent - self.theProject = theProject - self.optState = self.theProject.optState + self.theProject = theParent.theProject + self.optState = theParent.theProject.optState self.sourceItem = None self.outerBox = QVBoxLayout() diff --git a/nw/dialogs/itemeditor.py b/nw/dialogs/itemeditor.py index b2c0f496..b8fa07f7 100644 --- a/nw/dialogs/itemeditor.py +++ b/nw/dialogs/itemeditor.py @@ -41,15 +41,15 @@ logger = logging.getLogger(__name__) class GuiItemEditor(QDialog): - def __init__(self, theParent, theProject, tHandle): + def __init__(self, theParent, tHandle): QDialog.__init__(self, theParent) logger.debug("Initialising GuiItemEditor ...") self.setObjectName("GuiItemEditor") self.mainConf = nw.CONFIG - self.theProject = theProject self.theParent = theParent + self.theProject = theParent.theProject ## # Build GUI diff --git a/nw/dialogs/preferences.py b/nw/dialogs/preferences.py index 66315e1d..5ed23996 100644 --- a/nw/dialogs/preferences.py +++ b/nw/dialogs/preferences.py @@ -45,7 +45,7 @@ logger = logging.getLogger(__name__) class GuiPreferences(PagedDialog): - def __init__(self, theParent, theProject): + def __init__(self, theParent): PagedDialog.__init__(self, theParent) logger.debug("Initialising GuiPreferences ...") @@ -53,7 +53,7 @@ class GuiPreferences(PagedDialog): self.mainConf = nw.CONFIG self.theParent = theParent - self.theProject = theProject + self.theProject = theParent.theProject self.setWindowTitle(self.tr("Preferences")) diff --git a/nw/dialogs/projsettings.py b/nw/dialogs/projsettings.py index 55fd3d8c..38952eed 100644 --- a/nw/dialogs/projsettings.py +++ b/nw/dialogs/projsettings.py @@ -42,7 +42,7 @@ logger = logging.getLogger(__name__) class GuiProjectSettings(PagedDialog): - def __init__(self, theParent, theProject): + def __init__(self, theParent): PagedDialog.__init__(self, theParent) logger.debug("Initialising GuiProjectSettings ...") @@ -50,8 +50,8 @@ class GuiProjectSettings(PagedDialog): self.mainConf = nw.CONFIG self.theParent = theParent - self.theProject = theProject - self.optState = theProject.optState + self.theProject = theParent.theProject + self.optState = theParent.theProject.optState self.theProject.countStatus() self.setWindowTitle(self.tr("Project Settings")) diff --git a/nw/dialogs/quotes.py b/nw/dialogs/quotes.py index 7c129332..f1c9bd26 100644 --- a/nw/dialogs/quotes.py +++ b/nw/dialogs/quotes.py @@ -42,7 +42,7 @@ class GuiQuoteSelect(QDialog): selectedQuote = "" - def __init__(self, theParent=None, currentQuote="\""): + def __init__(self, theParent=None, currentQuote='"'): QDialog.__init__(self, parent=theParent) self.mainConf = nw.CONFIG diff --git a/nw/dialogs/wordlist.py b/nw/dialogs/wordlist.py index 7b7d810f..6870c271 100644 --- a/nw/dialogs/wordlist.py +++ b/nw/dialogs/wordlist.py @@ -41,7 +41,7 @@ logger = logging.getLogger(__name__) class GuiWordList(QDialog): - def __init__(self, theParent, theProject): + def __init__(self, theParent): QDialog.__init__(self, theParent) logger.debug("Initialising GuiWordList ...") @@ -50,8 +50,8 @@ class GuiWordList(QDialog): self.mainConf = nw.CONFIG self.theParent = theParent self.theTheme = theParent.theTheme - self.theProject = theProject - self.optState = theProject.optState + self.theProject = theParent.theProject + self.optState = theParent.theProject.optState self.setWindowTitle(self.tr("Project Word List")) diff --git a/nw/gui/projdetails.py b/nw/gui/projdetails.py index 74e315c4..9fb13ef5 100644 --- a/nw/gui/projdetails.py +++ b/nw/gui/projdetails.py @@ -43,7 +43,7 @@ logger = logging.getLogger(__name__) class GuiProjectDetails(PagedDialog): - def __init__(self, theParent, theProject): + def __init__(self, theParent): PagedDialog.__init__(self, theParent) logger.debug("Initialising GuiProjectDetails ...") @@ -51,8 +51,8 @@ class GuiProjectDetails(PagedDialog): self.mainConf = nw.CONFIG self.theParent = theParent - self.theProject = theProject - self.optState = theProject.optState + self.theProject = theParent.theProject + self.optState = theParent.theProject.optState self.setWindowTitle(self.tr("Project Details")) diff --git a/nw/guimain.py b/nw/guimain.py index 8c97d6d5..529606ca 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -756,7 +756,7 @@ class GuiMain(QMainWindow): logger.error("No project open") return False - dlgMerge = GuiDocMerge(self, self.theProject) + dlgMerge = GuiDocMerge(self) dlgMerge.exec_() return True @@ -768,7 +768,7 @@ class GuiMain(QMainWindow): logger.error("No project open") return False - dlgSplit = GuiDocSplit(self, self.theProject) + dlgSplit = GuiDocSplit(self) dlgSplit.exec_() return True @@ -837,7 +837,7 @@ class GuiMain(QMainWindow): return logger.verbose("Requesting change to item %s" % tHandle) - dlgProj = GuiItemEditor(self, self.theProject, tHandle) + dlgProj = GuiItemEditor(self, tHandle) dlgProj.exec_() if dlgProj.result() == QDialog.Accepted: self.treeView.setTreeItemValues(tHandle) @@ -958,7 +958,7 @@ class GuiMain(QMainWindow): def showPreferencesDialog(self): """Open the preferences dialog. """ - dlgConf = GuiPreferences(self, self.theProject) + dlgConf = GuiPreferences(self) dlgConf.exec_() if dlgConf.result() == QDialog.Accepted: @@ -982,7 +982,7 @@ class GuiMain(QMainWindow): logger.error("No project open") return - dlgProj = GuiProjectSettings(self, self.theProject) + dlgProj = GuiProjectSettings(self) dlgProj.exec_() if dlgProj.result() == QDialog.Accepted: @@ -1001,7 +1001,7 @@ class GuiMain(QMainWindow): self.treeView.flushTreeOrder() - dlgDetails = GuiProjectDetails(self, self.theProject) + dlgDetails = GuiProjectDetails(self) dlgDetails.setModal(False) dlgDetails.show() @@ -1016,7 +1016,7 @@ class GuiMain(QMainWindow): dlgBuild = getGuiItem("GuiBuildNovel") if dlgBuild is None: - dlgBuild = GuiBuildNovel(self, self.theProject) + dlgBuild = GuiBuildNovel(self) dlgBuild.setModal(False) dlgBuild.show() @@ -1032,7 +1032,7 @@ class GuiMain(QMainWindow): logger.error("No project open") return - dlgWords = GuiWordList(self, self.theProject) + dlgWords = GuiWordList(self) dlgWords.exec_() if dlgWords.result() == QDialog.Accepted: @@ -1050,7 +1050,7 @@ class GuiMain(QMainWindow): dlgStats = getGuiItem("GuiWritingStats") if dlgStats is None: - dlgStats = GuiWritingStats(self, self.theProject) + dlgStats = GuiWritingStats(self) dlgStats.setModal(False) dlgStats.show() diff --git a/nw/tools/build.py b/nw/tools/build.py index a3093cea..ce3ad47d 100644 --- a/nw/tools/build.py +++ b/nw/tools/build.py @@ -66,17 +66,17 @@ class GuiBuildNovel(QDialog): FMT_JSON_H = 8 # HTML5 wrapped in JSON FMT_JSON_M = 9 # nW Markdown wrapped in JSON - def __init__(self, theParent, theProject): + def __init__(self, theParent): QDialog.__init__(self, theParent) logger.debug("Initialising GuiBuildNovel ...") self.setObjectName("GuiBuildNovel") self.mainConf = nw.CONFIG - self.theProject = theProject self.theParent = theParent self.theTheme = theParent.theTheme - self.optState = self.theProject.optState + self.theProject = theParent.theProject + self.optState = theParent.theProject.optState self.htmlText = [] # List of html documents self.htmlStyle = [] # List of html styles diff --git a/nw/tools/writingstats.py b/nw/tools/writingstats.py index cd50a3dd..55dfc8ea 100644 --- a/nw/tools/writingstats.py +++ b/nw/tools/writingstats.py @@ -56,7 +56,7 @@ class GuiWritingStats(QDialog): FMT_JSON = 0 FMT_CSV = 1 - def __init__(self, theParent, theProject): + def __init__(self, theParent): QDialog.__init__(self, theParent) logger.debug("Initialising GuiWritingStats ...") @@ -64,9 +64,9 @@ class GuiWritingStats(QDialog): self.mainConf = nw.CONFIG self.theParent = theParent - self.theProject = theProject self.theTheme = theParent.theTheme - self.optState = theProject.optState + self.theProject = theParent.theProject + self.optState = theParent.theProject.optState self.logData = [] self.filterData = [] From f8243f69341c595b0ab685bd9fd2962ef05d2e77 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 25 Apr 2021 17:52:07 +0200 Subject: [PATCH 5/5] Update translation files --- i18n/nw_en_US.ts | 198 +++++++++++++++++++++++------------------------ i18n/nw_fr.ts | 198 +++++++++++++++++++++++------------------------ i18n/nw_nb_NO.ts | 198 +++++++++++++++++++++++------------------------ i18n/nw_pt.ts | 198 +++++++++++++++++++++++------------------------ 4 files changed, 396 insertions(+), 396 deletions(-) diff --git a/i18n/nw_en_US.ts b/i18n/nw_en_US.ts index 404338ef..fb56ab76 100644 --- a/i18n/nw_en_US.ts +++ b/i18n/nw_en_US.ts @@ -798,22 +798,22 @@ GuiDocEditFooter - + Status - + Line: {0} ({1}) - + Words: {0} ({1}) - + Document size is {0} bytes @@ -821,22 +821,22 @@ GuiDocEditHeader - + Edit document meta - + Search document - + Toggle Focus Mode - + Close the document @@ -844,97 +844,97 @@ GuiDocEditSearch - + Search - + Replace - + Case Sensitive - + Match case - + Whole Words Only - + Match whole words - + RegEx Mode - + Search using regular expressions - + Loop Search - + Loop the search when reaching the end - + Search Next File - + Continue searching in the next file - + Preserve Case - + Preserve case on replace - + Close Search - + Close the search box [{0}] - + Show/hide the replace text box - + Find in current document - + Find and replace in current document @@ -947,85 +947,95 @@ - + The text you are trying to add is too big. The text size is {0} MB. The maximum size allowed is {1} MB. - + Spell check complete - + File Location - + The currently open file is saved in: - + The document has grown too big and you cannot add more text to it. The maximum size of a single novelWriter document is {0} MB. - + Follow Tag - + Cut - + Copy - + Paste - + Select All - + Select Word - + Select Paragraph - + Spelling Suggestion(s) - + No Suggestions - + Add Word to Dictionary - + Please select some text before calling replace quotes. + + + Opened Document: {0} + + + + + Saved Document: {0} + + GuiDocMerge @@ -1050,17 +1060,17 @@ - + No source document selected. Nothing to do. - + Could not parse source document. - + Element selected in the project tree must be a folder. @@ -1068,7 +1078,7 @@ GuiDocSplit - + Split Document @@ -1113,27 +1123,27 @@ - + No headers found. Nothing to do. - + Cannot add new folder for the document split. Maximum folder depth has been reached. Please move the file to another level in the project tree. - + The document will be split into {0} file(s) in a new folder. The original document will remain intact. - + Continue with the splitting process? - + Element selected in the project tree must be a file. @@ -1379,7 +1389,7 @@ - + Changes are saved automatically. @@ -1464,57 +1474,57 @@ - + Indexing: '{0}' - + Unknown item - + Indexing completed in {0} ms - + The project index has been successfully rebuilt. - + Information - + Warning - + Error - + This is a bug! - + Internal Error - + Exit - + Do you want to exit novelWriter? @@ -3940,57 +3950,57 @@ - + There is currently no Trash folder in this project. - + The Trash folder is already empty. - + Empty Trash - + Permanently delete {0} file(s) from Trash? - + Delete File - + Permanently delete file '{0}'? - + Move file '{0}' to Trash? - + Cannot delete folder. It is not empty. Recursive deletion is not supported. Please delete the content first. - + Cannot delete root folder. It is not empty. Recursive deletion is not supported. Please delete the content first. - + The item cannot be moved to that location. - + There is nowhere to add item with name '{0}'. @@ -3998,52 +4008,52 @@ GuiProjectTreeMenu - + Edit Project Item - + Open Document - + View Document - + Toggle Included Flag - + New File - + New Folder - + Delete Item - + Empty Trash - + Move Item Up - + Move Item Down @@ -4240,22 +4250,12 @@ - - Opened Document: {0} - - - - + Could not save document. - - Saved Document: {0} - - - - + Could not delete document file. @@ -4923,12 +4923,12 @@ - + Document '{0}' is too big ({1} MB). Skipping. - + ERROR diff --git a/i18n/nw_fr.ts b/i18n/nw_fr.ts index 8761c05d..e3630f05 100644 --- a/i18n/nw_fr.ts +++ b/i18n/nw_fr.ts @@ -798,22 +798,22 @@ GuiDocEditFooter - + Status État - + Line: {0} ({1}) Ligne: {0} ({1}) - + Words: {0} ({1}) Mots: {0} ({1}) - + Document size is {0} bytes La taille du document est de {0} octets @@ -821,22 +821,22 @@ GuiDocEditHeader - + Edit document meta Modifier les métadonnées du document - + Search document Chercher dans le document - + Toggle Focus Mode Basculer le mode focus - + Close the document Fermer le document @@ -844,97 +844,97 @@ GuiDocEditSearch - + Search Chercher - + Replace Remplacer - + Case Sensitive Sensible à la casse - + Match case Respecter la casse - + Whole Words Only Mots entiers uniquement - + Match whole words Ne vérifier la correspondance que sur des mots entiers - + RegEx Mode Expressions régulières - + Search using regular expressions Chercher en utilisant des expressions régulières - + Loop Search Recherche en boucle - + Loop the search when reaching the end Reprendre la recherche au début du texte lorsque la fin est atteinte - + Search Next File Chercher dans le fichier suivant - + Continue searching in the next file Continuer la recherche dans le fichier suivant - + Preserve Case Conserver la casse - + Preserve case on replace Conserver la casse lors d'un remplacement - + Close Search Terminer la recherche - + Close the search box [{0}] Fermer la boîte de recherche [{0}] - + Show/hide the replace text box Montrer/cacher le texte de remplacement - + Find in current document Chercher dans le document actuel - + Find and replace in current document Chercher et remplacer dans le document actuel @@ -947,85 +947,95 @@ Le document que vous essayez d'ouvrir est trop grand. La taille du document est de {0} MB alors que la taille maximale est de {1} MB. - + The text you are trying to add is too big. The text size is {0} MB. The maximum size allowed is {1} MB. Le texte que vous voulez ajouter est trop grand. La taille du texte est de {0} MB alors que la taille maximale est de {1} MB. - + Spell check complete La vérification orthographique est terminée - + File Location Emplacement du fichier - + The currently open file is saved in: Le fichier actuellement ouvert est enregistré dans : - + The document has grown too big and you cannot add more text to it. The maximum size of a single novelWriter document is {0} MB. Le document est devenu trop grand et vous ne pouvez plus lui ajouter de texte. La taille maximale d'un fichier novelWriter est de {0} MB. - + Follow Tag Suivre cette étiquette - + Cut Couper - + Copy Copier - + Paste Coller - + Select All Sélectionner tout - + Select Word Sélectionner le mot - + Select Paragraph Sélectionner le paragraphe - + Spelling Suggestion(s) Orthographe suggérée - + No Suggestions Pas de suggestion - + Add Word to Dictionary Ajouter ce mot au dictionnaire - + Please select some text before calling replace quotes. Veuillez sélectionner du texte avant de demander le remplacement des guillemets. + + + Opened Document: {0} + Document ouvert : {0} + + + + Saved Document: {0} + Document enregistré : {0} + GuiDocMerge @@ -1050,17 +1060,17 @@ Pas de document source trouvé. Aucune action. - + No source document selected. Nothing to do. Pas de document source sélectionné. Aucune action. - + Could not parse source document. Impossible d'interpréter le nom du document source. - + Element selected in the project tree must be a folder. L'élement selectionné dans l'arborescence doit être un dossier. @@ -1068,7 +1078,7 @@ GuiDocSplit - + Split Document Découper un document @@ -1113,27 +1123,27 @@ Impossible d'interpréter le nom du document source. - + No headers found. Nothing to do. Pas d'en-tête trouvé. Aucune action. - + Cannot add new folder for the document split. Maximum folder depth has been reached. Please move the file to another level in the project tree. Impossible d'ajouter un nouveau dossier lors du découpage. Le nombre maximum de dossiers a été atteint. Veuillez placer ce fichier à un autre niveau dans l'arborescence. - + The document will be split into {0} file(s) in a new folder. The original document will remain intact. Ce document va être découpé en {0} fichier(s) dans un nouveau dossier. Le document d'origine restera intact. - + Continue with the splitting process? Continuer le découpage ? - + Element selected in the project tree must be a file. L'élément sélectionné dans l'arborescence doit être un fichier. @@ -1379,7 +1389,7 @@ Fermer le projet en cours ? - + Changes are saved automatically. Les changements sont enregistrés automatiquement. @@ -1464,57 +1474,57 @@ Le contenu du fichier importé va remplacer le contenu actuel du document. Faut-il continuer ? - + Indexing: '{0}' Indexation d e: '{0}' - + Unknown item Item inconnu - + Indexing completed in {0} ms Indexation effectuée en {0} ms - + The project index has been successfully rebuilt. L'index du projet a été correctement reconstruit. - + Information Information - + Warning Avertissement - + Error Erreur - + This is a bug! Ceci est un bug ! - + Internal Error Erreur interne - + Exit Sortir - + Do you want to exit novelWriter? Voulez-vous sortir de novelWriter ? @@ -3940,57 +3950,57 @@ Nouveau dossier - + There is currently no Trash folder in this project. Il n'existe pas actuellement de dossier Corbeille pour ce projet. - + The Trash folder is already empty. Le dossier Corbeille est déjà vide. - + Empty Trash Vider la Corbeille - + Permanently delete {0} file(s) from Trash? Effacer définitivement {0} fichier(s) dans la Corbeille ? - + Delete File Effacer un fichier - + Permanently delete file '{0}'? Effacer définitivement le fichier '{0}' ? - + Move file '{0}' to Trash? Mettre le fichier '{0}' dans la Corbeille ? - + Cannot delete folder. It is not empty. Recursive deletion is not supported. Please delete the content first. Impossible d'effacer le dossier car il n'est pas vide. Les effacements récursifs n'étant pas permis vous devez d'abord effacer le contenu. - + Cannot delete root folder. It is not empty. Recursive deletion is not supported. Please delete the content first. Impossible d'effacer le dossier racine car il n'est pas vide. Les effacements récursifs n'étant pas permis vous devez d'abord effacer le contenu. - + The item cannot be moved to that location. Impossible de déplacer cet item vers cet emplacement. - + There is nowhere to add item with name '{0}'. Il n'y a pas d'emplacement pour ajouter l'item nommé '{0}'. @@ -3998,52 +4008,52 @@ GuiProjectTreeMenu - + Edit Project Item Éditer les caractéristiques - + Open Document Ouvrir ce document - + View Document Afficher ce document - + Toggle Included Flag Basculer le marqueur d'inclusion - + New File Nouveau fichier - + New Folder Nouveau dossier - + Delete Item Supprimer ce composant - + Empty Trash Vider la corbeille - + Move Item Up Faire monter ce composant - + Move Item Down Faire descendre ce composant @@ -4240,22 +4250,12 @@ Impossible d'ouvrir le document. - - Opened Document: {0} - Document ouvert : {0} - - - + Could not save document. Impossible d'enregistrer le document. - - Saved Document: {0} - Document enregistré : {0} - - - + Could not delete document file. Impossible d'effacer le document. @@ -4923,12 +4923,12 @@ Synopsis - + Document '{0}' is too big ({1} MB). Skipping. Le document '{0}' est trop grand ({1} Mo). Ignoré. - + ERROR ERREUR diff --git a/i18n/nw_nb_NO.ts b/i18n/nw_nb_NO.ts index d27e4cfa..e8bc9641 100644 --- a/i18n/nw_nb_NO.ts +++ b/i18n/nw_nb_NO.ts @@ -798,22 +798,22 @@ GuiDocEditFooter - + Status Status - + Line: {0} ({1}) Linje: {0} ({1}) - + Words: {0} ({1}) Ord: {0} ({1}) - + Document size is {0} bytes Dokumentet er {0} byte @@ -821,22 +821,22 @@ GuiDocEditHeader - + Edit document meta Rediger dokumentinstillinger - + Search document Søk i dokumentet - + Toggle Focus Mode Slå av/på "Fokus-modus" - + Close the document Lukk dokumentet @@ -844,97 +844,97 @@ GuiDocEditSearch - + Search Søk - + Replace Erstatt - + Case Sensitive Skill store/små bokstaver - + Match case Søket skiller mellom store og små bokstaver - + Whole Words Only Kun hele ord - + Match whole words Søk kun etter hele ord - + RegEx Mode RegEx-modus - + Search using regular expressions Søk ved hjelp av "regular expressions" - + Loop Search Søk rundt - + Loop the search when reaching the end Begynn søket på nytt når enden er nådd - + Search Next File Søk i neste file - + Continue searching in the next file Fortsett søket i neste fil - + Preserve Case Behold store/små bokstaver - + Preserve case on replace Behold store og små bokstaver på samme sted ved erstatt - + Close Search Lukk søk - + Close the search box [{0}] Lukk søkeboksen [{0}] - + Show/hide the replace text box Vis/skjul erstatt-boksen - + Find in current document Søk i det åpne dokumentet - + Find and replace in current document Søk og erstatt i det åpne dokumentet @@ -947,85 +947,95 @@ Dokumentet du prøver å åpne er for stort. Dokumenter er på {0} MB. Den maksimale størrelsen tillat er {1} MB. - + The text you are trying to add is too big. The text size is {0} MB. The maximum size allowed is {1} MB. Teksten du forsøker å legge til er for stor. Teksten er {0} MB. Den maksimale tillatte størrelsen er {1} MB. - + Spell check complete Stavekontrollen er ferdig - + File Location Filens plassering - + The currently open file is saved in: Det åpne dokumentet er lagret på følgende sted: - + The document has grown too big and you cannot add more text to it. The maximum size of a single novelWriter document is {0} MB. Dokumentet har blitt for stort og du kan ikke legge til mer tekst. Den maksimale tillatte størrelsen for et novelWriter-dokument er {0} MB. - + Follow Tag Følg knagg - + Cut Klipp - + Copy Kopier - + Paste Lim inn - + Select All Velg hele teksten - + Select Word Velg hele ordet - + Select Paragraph Velg hele avsnittet - + Spelling Suggestion(s) Forslag fra stavekontrollen - + No Suggestions Ingen forslag - + Add Word to Dictionary Legg til ord i ordbok - + Please select some text before calling replace quotes. Venligst velg en del av teksten før du velger å erstatte sitattegn. + + + Opened Document: {0} + Åpnet dokument: {0} + + + + Saved Document: {0} + Lagret dokument: {0} + GuiDocMerge @@ -1050,17 +1060,17 @@ Ingen kilde-dokument funnet. Det er ingenting å gjøre. - + No source document selected. Nothing to do. Ingen kilde-dokument er valgt. Det er ingenting å gjøre. - + Could not parse source document. Klarte ikke å lese kilde-dokumentet. - + Element selected in the project tree must be a folder. Elementet som er valgt i prosjekttreet må være en mappe. @@ -1068,7 +1078,7 @@ GuiDocSplit - + Split Document Del opp dokument @@ -1113,27 +1123,27 @@ Klarte ikke å lese kilde-dokumentet. - + No headers found. Nothing to do. Ingen overskrifter ble funnet i dokumentet. Det er ikke noe å gjøre. - + Cannot add new folder for the document split. Maximum folder depth has been reached. Please move the file to another level in the project tree. Kan ikke legge til ny mappe for å dele opp dokumentet. Dokumentet har allerede maksimal dybde i prosjekttreet. Flytt dokumentet til et annet nivå først. - + The document will be split into {0} file(s) in a new folder. The original document will remain intact. Dokumentet vil nå bli delt opp i {0} nye filer i en ny mappe. Det originale dokumentet vil ikke bli endret eller fjernet. - + Continue with the splitting process? Fortsette med oppdelingen? - + Element selected in the project tree must be a file. Elementet som er valgt i prosjekttreet må være et dokument. @@ -1374,7 +1384,7 @@ Ønsker du å lukke dette prosjektet? - + Changes are saved automatically. Endringer lagres automatisk. @@ -1459,57 +1469,57 @@ Å importere filen vil overskrive all eksisterende tekst i dokumentet. Ønsker du å fortsette? - + Indexing: '{0}' Indekserer: '{0}' - + Unknown item Ukjent enhet - + Indexing completed in {0} ms Indekseringen tok {0} ms - + The project index has been successfully rebuilt. Prosjektets indeks har blitt bygget på nytt. - + Information Informasjon - + Warning Advarsel - + Error Feil - + This is a bug! Dette er en systemfeil! - + Internal Error Intern feil - + Exit Avslutt - + Do you want to exit novelWriter? Ønsker du å avslutte novelWriter? @@ -3935,52 +3945,52 @@ Ny mappe - + There is currently no Trash folder in this project. Det er for øyeblikket ingen søppel-mappe i dette prosjektet. - + The Trash folder is already empty. Søppel-mappen er allerede tom. - + Empty Trash Tøm søppel - + Permanently delete {0} file(s) from Trash? Vil du slette {0} filer i søppel-mappen for godt? - + Delete File Slett fil - + Permanently delete file '{0}'? Slette filen '{0}' for godt? - + Move file '{0}' to Trash? Vil du flytte filen '{0}' til søpla? - + Cannot delete folder. It is not empty. Recursive deletion is not supported. Please delete the content first. Kan ikke slette mappen da den ikke er tom. Rekursiv sletting er ikke støttet. Du må slette innholdet først. - + Cannot delete root folder. It is not empty. Recursive deletion is not supported. Please delete the content first. Kan ikke slette hovedmappen da den ikke er tom. Rekursiv sletting er ikke støttet. Du må slette innholdet først. - + The item cannot be moved to that location. Denne enheten kan ikke flyttes til denne lokasjonen. @@ -3990,7 +4000,7 @@ Kan ikke legge til nye filer eller mapper til søppel-mappen. - + There is nowhere to add item with name '{0}'. Fant ikke noe sted å legge til enheten med navn '{0}'. @@ -3998,52 +4008,52 @@ GuiProjectTreeMenu - + Edit Project Item Endre enhet - + Open Document Åpne dokument - + View Document Vis dokument - + Toggle Included Flag Slå av/på inkludering - + New File Ny fil - + New Folder Ny mappe - + Delete Item Slett enhet - + Empty Trash Tøm søppel - + Move Item Up Flytt enhet opp - + Move Item Down Flytt enhet ned @@ -4240,22 +4250,12 @@ Kunne ikke åpne dokumentets fil. - - Opened Document: {0} - Åpnet dokument: {0} - - - + Could not save document. Kunne ikke lagre dokumentet. - - Saved Document: {0} - Lagret dokumentet: {0} - - - + Could not delete document file. Kunne ikke slette dokumentets fil. @@ -4918,12 +4918,12 @@ Tokenizer - + Document '{0}' is too big ({1} MB). Skipping. Dokumentet '{0}' er for stort ({1} MB). Hopper over. - + ERROR diff --git a/i18n/nw_pt.ts b/i18n/nw_pt.ts index ec69bf37..b9008aec 100644 --- a/i18n/nw_pt.ts +++ b/i18n/nw_pt.ts @@ -798,22 +798,22 @@ GuiDocEditFooter - + Line: {0} ({1}) Linha: {0} ({1}) - + Words: {0} ({1}) Palavras: {0} ({1}) - + Status Estado - + Document size is {0} bytes O tamanho do documento é {0} bytes @@ -821,22 +821,22 @@ GuiDocEditHeader - + Edit document meta Editar os meta-dados do documento - + Search document Procurar no documento - + Toggle Focus Mode Alternar o "Modo Foco" - + Close the document Fechar o documento @@ -844,97 +844,97 @@ GuiDocEditSearch - + Search Pesquisa - + Replace Substituir - + Case Sensitive Diferenciar Maiúsculas e Minúsculas - + Match case Diferencia Maiúsculas e Minúsculas - + Whole Words Only Apenas Palavras Inteiras - + Match whole words Encontra apenas palavras inteiras - + RegEx Mode Expressão Regular - + Loop Search Pesquisa do Início - + Loop the search when reaching the end Pesquisa do início quando chega no final do documento - + Search Next File Busca no Próximo Arquivo - + Continue searching in the next file Continua a busca no próximo arquivo - + Preserve Case Preserva Maiúsculas e Minúsculas - + Preserve case on replace Preserva maiúsculas e minúsculas ao substituir - + Close Search Fechar a Busca - + Show/hide the replace text box Mostrar/Ocultar a caixa substituição - + Find in current document Encontrar no documento atual - + Find and replace in current document Encontrar e substituir no documento atual - + Close the search box [{0}] Fechar a caixa de busca [{0}] - + Search using regular expressions Busca usando expressões regulares @@ -942,12 +942,12 @@ GuiDocEditor - + Spell check complete Verificação ortográfica completa - + No Suggestions Sem Sugestões @@ -957,75 +957,85 @@ O documento que você está tentando abrir é muito grande. O tamanho do documento é {0} MB. O tamanho máximo permitido é {1} MB. - + The text you are trying to add is too big. The text size is {0} MB. The maximum size allowed is {1} MB. O texto que você está tentando adicionar é muito grande. O tamanho do texto é {0} MB. O tamanho máximo permitido é {1} MB. - + File Location Localização do Arquivo - + Follow Tag Seguir Etiqueta - + Cut Recortar - + Copy Copiar - + Paste Colar - + Select All Selecionar Tudo - + Select Word Selecionar Palavra - + Select Paragraph Selecionar Parágrafo - + Spelling Suggestion(s) Sugestão de Ortografia - + Add Word to Dictionary Adicionar Palavra ao Dicionário - + Please select some text before calling replace quotes. Por favor, selecione algum texto antes de invocar a substituição de aspas. - + The currently open file is saved in: O arquivo aberto atualmente está salvo em: - + The document has grown too big and you cannot add more text to it. The maximum size of a single novelWriter document is {0} MB. O tamanho do documento aumentou muito e você não pode adicionar mais texto nele. O tamanho máximo de um único documento do novelWriter é {0} MB. + + + Opened Document: {0} + Documento Aberto: {0} + + + + Saved Document: {0} + Documento Salvo: {0} + GuiDocMerge @@ -1050,17 +1060,17 @@ Nenhum documento-fonte foi encontrado. Nada para fazer. - + No source document selected. Nothing to do. Nenhum documento de origem selecionado. Nada a ser feito. - + Could not parse source document. Não foi possível interpretar o documento. - + Element selected in the project tree must be a folder. O elemento selecionado na árvore do projeto deve ser um diretório. @@ -1098,7 +1108,7 @@ Dividir até os cabeçalhos de nível 4 (Seção) - + Split Document Divisão de Documento @@ -1113,27 +1123,27 @@ Não foi possível interpretar o documento. - + No headers found. Nothing to do. Nenhum cabeçalho foi encontrado. Nada para fazer. - + Cannot add new folder for the document split. Maximum folder depth has been reached. Please move the file to another level in the project tree. Não é possível adicionar um novo diretório para a divisão do documento. A profundidade máxima dos diretórios foi alcançada. Por favor mova o arquivo para outro nível na árvore do projeto. - + Continue with the splitting process? Continuar com o processo de divisão? - + Element selected in the project tree must be a file. O elemento selecionado na árvore do projeto deve ser um arquivo. - + The document will be split into {0} file(s) in a new folder. The original document will remain intact. O documento será dividio em {0} arquivo(s) em um novo diretório. O documento original será mantido intacto. @@ -1329,32 +1339,32 @@ Nota: Se o programa ou o computador sofreu uma falha anteriormente, o bloqueio pode ser sobrescrito com segurança. Se, no entanto, outra instância do novelWriter esteja com o projeto aberto, sobrescrever o bloqueio pode corromper o projeto e não é recomendado. - + Unknown item Item desconhecido - + Information Informação - + Warning Alerta - + Error Erro - + This is a bug! Isto é um bug! - + Internal Error Erro Interno @@ -1389,7 +1399,7 @@ Fechar o projeto atual? - + Changes are saved automatically. As alterações serão salvas automaticamente. @@ -1434,22 +1444,22 @@ Importar o arquivo vai sobrescrever o conteúdo atual do documento. Você deseja continuar? - + The project index has been successfully rebuilt. O índice do projeto foi reconstruído com sucesso. - + Exit Sair - + Do you want to exit novelWriter? Você deseja realmente sair do novelWriter? - + Indexing completed in {0} ms Indexação completa em {0} ms @@ -1489,7 +1499,7 @@ O projeto foi bloqueado pelo computador '{0}' ({1} {2}), ativo pela última vez em {3}. - + Indexing: '{0}' Indexando: '{0}' @@ -3885,27 +3895,27 @@ A profundidade máxima de diretórios foi alcançada. - + There is currently no Trash folder in this project. Não exite um diretório de Lixeira neste projeto. - + The Trash folder is already empty. O diretório de Lixeira já está vazio. - + Empty Trash Esvaziar a Lixeira - + Delete File Remover Arquivo - + The item cannot be moved to that location. O item não pode ser movido para este local. @@ -3960,27 +3970,27 @@ Novo Diretório - + Permanently delete {0} file(s) from Trash? Permanentemente remover {0} arquivo(s) da Lixeira? - + Permanently delete file '{0}'? Permanentemente remover o arquivo '{0}'? - + Move file '{0}' to Trash? Mover o arquivo '{0}' para a Lixeira? - + Cannot delete folder. It is not empty. Recursive deletion is not supported. Please delete the content first. Não foi possível remover o diretório. O diretório não está vazio. Exclusão recursiva não é suportada. Por favor remova todo o conteúdo primeiro. - + Cannot delete root folder. It is not empty. Recursive deletion is not supported. Please delete the content first. Não foi possível remover o diretório-raiz. O diretório não está vazio. Exclusão recursiva não é suportada. Por favor remova todo o conteúdo primeiro. @@ -3990,7 +4000,7 @@ Não foi possível adicionar novos arquivos ou diretórios à Lixeira. - + There is nowhere to add item with name '{0}'. Não há lugar para adicionar o item com o nome '{0}'. @@ -3998,52 +4008,52 @@ GuiProjectTreeMenu - + Edit Project Item Editar Item do Projeto - + Open Document Abrir Documento - + View Document Ver Documento - + Toggle Included Flag Alternar Opção de Inclusão - + New File Novo Arquivo - + New Folder Novo Diretório - + Delete Item Remover Item - + Empty Trash Esvaziar a Lixeira - + Move Item Up Mover Item Acima - + Move Item Down Mover Item Abaixo @@ -4240,22 +4250,12 @@ Houve uma falha ao abrir o arquivo do documento. - - Opened Document: {0} - Documento Aberto: {0} - - - + Could not save document. Não foi possível salvar o documento. - - Saved Document: {0} - Documento Salvo: {0} - - - + Could not delete document file. Não foi possível remover o arquivo do documento. @@ -4918,12 +4918,12 @@ Tokenizer - + ERROR ERRO - + Document '{0}' is too big ({1} MB). Skipping. O documento '{0}' é muito grande ({1} MB). Ignorando.