From 0faf1f9986c3172cb45f63e19f723e085eab1616 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 10 May 2020 23:24:32 +0200 Subject: [PATCH] The isExported option should only apply to files --- nw/core/project.py | 2 +- nw/gui/dialogs/itemeditor.py | 9 +++++++-- nw/gui/elements/docdetails.py | 11 +++++++---- nw/gui/elements/doctree.py | 18 ++++++++++++------ sample/sampleNovel/nwProject.nwx | 8 +------- tests/reference/gui/0_nwProject.nwx | 7 +------ tests/reference/gui/1_nwProject.nwx | 7 +------ tests/reference/gui/2_nwProject.nwx | 7 +------ tests/reference/gui/3_nwProject.nwx | 9 ++------- tests/reference/proj/1_nwProject.nwx | 7 +------ tests/reference/proj/2_nwProject.nwx | 11 +---------- tests/test_gui.py | 3 +++ tests/test_item.py | 4 ++-- 13 files changed, 40 insertions(+), 63 deletions(-) diff --git a/nw/core/project.py b/nw/core/project.py index a0396c02..0dcb60b9 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -1350,8 +1350,8 @@ class NWItem(): xSub = self._subPack(xPack,"class", text=str(self.itemClass.name)) xSub = self._subPack(xPack,"status", text=str(self.itemStatus)) xSub = self._subPack(xPack,"expanded", text=str(self.isExpanded)) - xSub = self._subPack(xPack,"exported", text=str(self.isExported)) if self.itemType == nwItemType.FILE: + xSub = self._subPack(xPack,"exported", text=str(self.isExported)) xSub = self._subPack(xPack,"layout", text=str(self.itemLayout.name)) xSub = self._subPack(xPack,"charCount", text=str(self.charCount), none=False) xSub = self._subPack(xPack,"wordCount", text=str(self.wordCount), none=False) diff --git a/nw/gui/dialogs/itemeditor.py b/nw/gui/dialogs/itemeditor.py index 432ddb08..fee4a74f 100644 --- a/nw/gui/dialogs/itemeditor.py +++ b/nw/gui/dialogs/itemeditor.py @@ -105,9 +105,14 @@ class GuiItemEditor(QDialog): if itemLayout in self.validLayouts: self.editLayout.addItem(nwLabels.LAYOUT_NAME[itemLayout],itemLayout) - self.editExport = QSwitch() - self.editExport.setChecked(self.theItem.isExported) self.textExport = QLabel("Include when building project") + self.editExport = QSwitch() + if self.theItem.itemType == nwItemType.FILE: + self.editExport.setEnabled(True) + self.editExport.setChecked(self.theItem.isExported) + else: + self.editExport.setEnabled(False) + self.editExport.setChecked(False) self.mainForm.addWidget(QLabel("Label"), 0, 0) self.mainForm.addWidget(self.editName, 0, 1, 1, 2) diff --git a/nw/gui/elements/docdetails.py b/nw/gui/elements/docdetails.py index de547c06..8c231fa6 100644 --- a/nw/gui/elements/docdetails.py +++ b/nw/gui/elements/docdetails.py @@ -32,7 +32,7 @@ from PyQt5.QtCore import Qt from PyQt5.QtGui import QFont from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel -from nw.constants import nwLabels, nwItemClass, nwUnicode +from nw.constants import nwLabels, nwItemClass, nwItemType, nwUnicode logger = logging.getLogger(__name__) @@ -170,10 +170,13 @@ class GuiDocDetails(QFrame): iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's valid flagIcon = self.theParent.importIcons[iStatus] - if nwItem.isExported: - exportFlag = nwUnicode.U_CHECK + if nwItem.itemType == nwItemType.FILE: + if nwItem.isExported: + exportFlag = nwUnicode.U_CHECK + else: + exportFlag = " " else: - exportFlag = " " + exportFlag = "+" self.labelFlag.setText(exportFlag) self.statusFlag.setPixmap(flagIcon.pixmap(10, 10)) diff --git a/nw/gui/elements/doctree.py b/nw/gui/elements/doctree.py index 0c6b8bb2..4b0a3ed2 100644 --- a/nw/gui/elements/doctree.py +++ b/nw/gui/elements/doctree.py @@ -412,13 +412,19 @@ class GuiDocTree(QTreeWidget): tHandle = nwItem.itemHandle pHandle = nwItem.parHandle - if nwItem.isExported: - tStatus = nwUnicode.U_CHECK - else: - tStatus = " " - tStatus += " "+nwLabels.CLASS_FLAG[nwItem.itemClass] + stExport = " " + stClass = nwLabels.CLASS_FLAG[nwItem.itemClass] + stLayout = "" + if nwItem.itemType == nwItemType.FILE: - tStatus += "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout] + stLayout = "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout] + if nwItem.isExported: + stExport = nwUnicode.U_CHECK + else: + stExport = "+" + + tStatus = stExport+" "+stClass+stLayout + iStatus = nwItem.itemStatus if tClass == nwItemClass.NOVEL: iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's valid diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index 7b76aea0..eb89f47c 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project @@ -51,7 +51,6 @@ NOVEL Started True - True Title Page @@ -72,7 +71,6 @@ NOVEL 1st Draft True - True Chapter One @@ -171,7 +169,6 @@ CHARACTER None True - True Main Characters @@ -179,7 +176,6 @@ CHARACTER None True - True John Smith @@ -213,7 +209,6 @@ WORLD None True - True Earth @@ -260,7 +255,6 @@ TRASH None True - True Delete Me! diff --git a/tests/reference/gui/0_nwProject.nwx b/tests/reference/gui/0_nwProject.nwx index 3007ae93..db1151d3 100644 --- a/tests/reference/gui/0_nwProject.nwx +++ b/tests/reference/gui/0_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -42,7 +42,6 @@ NOVEL New False - True New Chapter @@ -50,7 +49,6 @@ NOVEL New False - True New Scene @@ -71,7 +69,6 @@ CHARACTER New False - True Plot @@ -79,7 +76,6 @@ PLOT New False - True World @@ -87,7 +83,6 @@ WORLD New False - True diff --git a/tests/reference/gui/1_nwProject.nwx b/tests/reference/gui/1_nwProject.nwx index 38708ab2..bf16def6 100644 --- a/tests/reference/gui/1_nwProject.nwx +++ b/tests/reference/gui/1_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -42,7 +42,6 @@ NOVEL New True - True New Chapter @@ -50,7 +49,6 @@ NOVEL New True - True New Scene @@ -71,7 +69,6 @@ CHARACTER New True - True New File @@ -92,7 +89,6 @@ PLOT New True - True New File @@ -113,7 +109,6 @@ WORLD New True - True New File diff --git a/tests/reference/gui/2_nwProject.nwx b/tests/reference/gui/2_nwProject.nwx index 58b80897..bf3c5b61 100644 --- a/tests/reference/gui/2_nwProject.nwx +++ b/tests/reference/gui/2_nwProject.nwx @@ -1,5 +1,5 @@ - + Project Name Project Title @@ -46,7 +46,6 @@ NOVEL New False - True New Chapter @@ -54,7 +53,6 @@ NOVEL New False - True New Scene @@ -75,7 +73,6 @@ CHARACTER New False - True Plot @@ -83,7 +80,6 @@ PLOT New False - True World @@ -91,7 +87,6 @@ WORLD New False - True diff --git a/tests/reference/gui/3_nwProject.nwx b/tests/reference/gui/3_nwProject.nwx index 7c5d8511..bee4eb0a 100644 --- a/tests/reference/gui/3_nwProject.nwx +++ b/tests/reference/gui/3_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -42,7 +42,6 @@ NOVEL New False - True New Chapter @@ -50,7 +49,6 @@ NOVEL New False - True Just a Page @@ -58,7 +56,7 @@ NOVEL Note False - True + False PAGE 0 0 @@ -71,7 +69,6 @@ CHARACTER New False - True Plot @@ -79,7 +76,6 @@ PLOT New False - True World @@ -87,7 +83,6 @@ WORLD New False - True diff --git a/tests/reference/proj/1_nwProject.nwx b/tests/reference/proj/1_nwProject.nwx index febdc50e..0e537470 100644 --- a/tests/reference/proj/1_nwProject.nwx +++ b/tests/reference/proj/1_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -42,7 +42,6 @@ NOVEL New False - True Characters @@ -50,7 +49,6 @@ CHARACTER New False - True Plot @@ -58,7 +56,6 @@ PLOT New False - True World @@ -66,7 +63,6 @@ WORLD New False - True New Chapter @@ -74,7 +70,6 @@ NOVEL New False - True New Scene diff --git a/tests/reference/proj/2_nwProject.nwx b/tests/reference/proj/2_nwProject.nwx index b64d0071..eb98cc9f 100644 --- a/tests/reference/proj/2_nwProject.nwx +++ b/tests/reference/proj/2_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -42,7 +42,6 @@ NOVEL New False - True Characters @@ -50,7 +49,6 @@ CHARACTER New False - True Plot @@ -58,7 +56,6 @@ PLOT New False - True World @@ -66,7 +63,6 @@ WORLD New False - True New Chapter @@ -74,7 +70,6 @@ NOVEL New False - True New Scene @@ -95,7 +90,6 @@ TIMELINE New False - True Object @@ -103,7 +97,6 @@ OBJECT New False - True Custom1 @@ -111,7 +104,6 @@ CUSTOM New False - True Custom2 @@ -119,7 +111,6 @@ CUSTOM New False - True diff --git a/tests/test_gui.py b/tests/test_gui.py index 9e2cd53d..c32e8168 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -361,6 +361,9 @@ def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp): layoutIdx = itemEdit.editLayout.findData(nwItemLayout.PAGE) itemEdit.editLayout.setCurrentIndex(layoutIdx) + itemEdit.editExport.setChecked(False) + assert not itemEdit.editExport.isChecked() + itemEdit._doSave() itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "31489056e0916") diff --git a/tests/test_item.py b/tests/test_item.py index 19f663f6..1bab7447 100644 --- a/tests/test_item.py +++ b/tests/test_item.py @@ -197,8 +197,8 @@ def testItemXMLPackUnpack(): assert etree.tostring(xContent, pretty_print=False, encoding="utf-8") == ( b"" b"" - b"A NameTRASHTRASHMain" - b"TrueTrue" + b"A NameTRASHTRASH" + b"MainTrue" b"" b"" )