From 8278bcec9efa1086c19881e453963ced382d2354 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 11 Aug 2019 19:42:42 +0200 Subject: [PATCH 1/4] Make the auto-replace list in project settings sorted --- nw/gui/projecteditor.py | 3 +++ sample/sampleNovel/nwProject.nwx | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/nw/gui/projecteditor.py b/nw/gui/projecteditor.py index 88da6ca6..5ba2e558 100644 --- a/nw/gui/projecteditor.py +++ b/nw/gui/projecteditor.py @@ -336,6 +336,9 @@ class GuiProjectEditReplace(QWidget): newItem = QTreeWidgetItem(["<%s>" % aKey, aVal]) self.listBox.addTopLevelItem(newItem) + self.listBox.sortByColumn(0, Qt.AscendingOrder) + self.listBox.setSortingEnabled(True) + self.editKey = QLineEdit() self.editValue = QLineEdit() self.saveButton = QPushButton(QIcon.fromTheme("document-save"),"") diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index 5f27329d..e0347637 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project @@ -14,6 +14,7 @@ 581 B + E D From cc2190a4c20b68371f53e79b8008c4884921d061 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 11 Aug 2019 19:52:46 +0200 Subject: [PATCH 2/4] Update test --- tests/test_gui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_gui.py b/tests/test_gui.py index f7840805..9c5ad51c 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -327,7 +327,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef): projEdit.tabReplace.listBox.clearSelection() qtbot.mouseClick(projEdit.tabReplace.addButton, Qt.LeftButton) - projEdit.tabReplace.listBox.topLevelItem(1).setSelected(True) + projEdit.tabReplace.listBox.topLevelItem(0).setSelected(True) for c in "Delete": qtbot.keyClick(projEdit.tabReplace.editKey, c, delay=keyDelay) for c in "This Stuff": @@ -335,7 +335,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef): qtbot.mouseClick(projEdit.tabReplace.saveButton, Qt.LeftButton) projEdit.tabReplace.listBox.clearSelection() - projEdit.tabReplace.listBox.topLevelItem(1).setSelected(True) + projEdit.tabReplace.listBox.topLevelItem(0).setSelected(True) qtbot.mouseClick(projEdit.tabReplace.delButton, Qt.LeftButton) projEdit._doSave() From b4a89ede9fe7e9d5e9d0bac8b1f95249a197ef5a Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 11 Aug 2019 20:08:06 +0200 Subject: [PATCH 3/4] Dropping tests for Python 3.5 due to problems with unordered dictionaries and file comparison --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d40b1c68..7b537003 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ addons: - python3-pyqt5 - python3-pyqt5.qtsvg python: - - "3.5" + - "3.6" - "3.7" install: - pip install -r requirements.txt From 6a19807310960f1ecd341baa15a805a412c022a1 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Sun, 11 Aug 2019 20:21:06 +0200 Subject: [PATCH 4/4] All xml attributes are now added to the etree class in alphabetical order to ensure it writes the same on different versions --- .travis.yml | 2 +- nw/project/item.py | 2 +- nw/project/project.py | 2 +- nw/project/status.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7b537003..d40b1c68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ addons: - python3-pyqt5 - python3-pyqt5.qtsvg python: - - "3.6" + - "3.5" - "3.7" install: - pip install -r requirements.txt diff --git a/nw/project/item.py b/nw/project/item.py index 367167c8..55d532a1 100644 --- a/nw/project/item.py +++ b/nw/project/item.py @@ -55,8 +55,8 @@ class NWItem(): def packXML(self, xParent): xPack = etree.SubElement(xParent,"item",attrib={ "handle" : str(self.itemHandle), - "parent" : str(self.parHandle), "order" : str(self.itemOrder), + "parent" : str(self.parHandle), }) xSub = self._subPack(xPack,"name", text=str(self.itemName)) xSub = self._subPack(xPack,"type", text=str(self.itemType.name)) diff --git a/nw/project/project.py b/nw/project/project.py index bdc1b8b3..c41d4115 100644 --- a/nw/project/project.py +++ b/nw/project/project.py @@ -288,8 +288,8 @@ class NWProject(): # Root element and project details logger.debug("Writing project meta") nwXML = etree.Element("novelWriterXML",attrib={ - "fileVersion" : "1.0", "appVersion" : str(nw.__version__), + "fileVersion" : "1.0", "timeStamp" : datetime.now().strftime("%Y-%m-%d %H:%M:%S"), }) diff --git a/nw/project/status.py b/nw/project/status.py index 1d19bf34..ea1a045a 100644 --- a/nw/project/status.py +++ b/nw/project/status.py @@ -89,9 +89,9 @@ class NWStatus(): def packEntries(self, xParent): for n in range(self.theLength): xSub = etree.SubElement(xParent,"entry",attrib={ - "red" : str(self.theColours[n][0]), - "green" : str(self.theColours[n][1]), "blue" : str(self.theColours[n][2]), + "green" : str(self.theColours[n][1]), + "red" : str(self.theColours[n][0]), }) xSub.text = self.theLabels[n] return True