Merge bug fix from release

This commit is contained in:
Veronica Berglyd Olsen
2025-02-09 15:22:20 +01:00
3 changed files with 51 additions and 47 deletions
+47 -43
View File
@@ -68,10 +68,10 @@ class GuiDocSplit(NDialog):
# Values # Values
iPx = SHARED.theme.baseIconHeight iPx = SHARED.theme.baseIconHeight
pOptions = SHARED.project.options options = SHARED.project.options
spLevel = pOptions.getInt("GuiDocSplit", "spLevel", 3) spLevel = options.getInt("GuiDocSplit", "spLevel", 3)
intoFolder = pOptions.getBool("GuiDocSplit", "intoFolder", True) intoFolder = options.getBool("GuiDocSplit", "intoFolder", True)
docHierarchy = pOptions.getBool("GuiDocSplit", "docHierarchy", True) docHierarchy = options.getBool("GuiDocSplit", "docHierarchy", True)
# Heading Selection # Heading Selection
self.listBox = QListWidget(self) self.listBox = QListWidget(self)
@@ -168,10 +168,10 @@ class GuiDocSplit(NDialog):
self._data["moveToTrash"] = moveToTrash self._data["moveToTrash"] = moveToTrash
logger.debug("Saving State: GuiDocSplit") logger.debug("Saving State: GuiDocSplit")
pOptions = SHARED.project.options options = SHARED.project.options
pOptions.setValue("GuiDocSplit", "spLevel", spLevel) options.setValue("GuiDocSplit", "spLevel", spLevel)
pOptions.setValue("GuiDocSplit", "intoFolder", intoFolder) options.setValue("GuiDocSplit", "intoFolder", intoFolder)
pOptions.setValue("GuiDocSplit", "docHierarchy", docHierarchy) options.setValue("GuiDocSplit", "docHierarchy", docHierarchy)
return self._data, self._text return self._data, self._text
@@ -215,42 +215,46 @@ class GuiDocSplit(NDialog):
if not self._text: if not self._text:
self._text = SHARED.project.storage.getDocumentText(sHandle).splitlines() self._text = SHARED.project.storage.getDocumentText(sHandle).splitlines()
for lineNo, aLine in enumerate(self._text): for i, line in enumerate(self._text):
onLine = -1 pos = -1
hLevel = 0 level = 0
hLabel = aLine.strip() label = line.strip()
if aLine.startswith("# ") and spLevel >= 1: if line.startswith("# ") and spLevel >= 1:
onLine = lineNo pos = i
hLevel = 1 level = 1
hLabel = aLine[2:].strip() label = line[2:].strip()
elif aLine.startswith("## ") and spLevel >= 2: elif line.startswith("## ") and spLevel >= 2:
onLine = lineNo pos = i
hLevel = 2 level = 2
hLabel = aLine[3:].strip() label = line[3:].strip()
elif aLine.startswith("### ") and spLevel >= 3: elif line.startswith("### ") and spLevel >= 3:
onLine = lineNo pos = i
hLevel = 3 level = 3
hLabel = aLine[4:].strip() label = line[4:].strip()
elif aLine.startswith("#### ") and spLevel >= 4: elif line.startswith("#### ") and spLevel >= 4:
onLine = lineNo pos = i
hLevel = 4 level = 4
hLabel = aLine[5:].strip() label = line[5:].strip()
elif aLine.startswith("#! ") and spLevel >= 1: elif line.startswith("#! ") and spLevel >= 1:
onLine = lineNo pos = i
hLevel = 1 level = 1
hLabel = aLine[3:].strip() label = line[3:].strip()
elif aLine.startswith("##! ") and spLevel >= 2: elif line.startswith("##! ") and spLevel >= 2:
onLine = lineNo pos = i
hLevel = 2 level = 2
hLabel = aLine[4:].strip() label = line[4:].strip()
elif line.startswith("###! ") and spLevel >= 3:
pos = i
level = 3
label = line[5:].strip()
if onLine >= 0 and hLevel > 0: if pos >= 0 and level > 0:
newItem = QListWidgetItem() trItem = QListWidgetItem()
newItem.setText(aLine.strip()) trItem.setText(line.strip())
newItem.setData(self.LINE_ROLE, onLine) trItem.setData(self.LINE_ROLE, pos)
newItem.setData(self.LEVEL_ROLE, hLevel) trItem.setData(self.LEVEL_ROLE, level)
newItem.setData(self.LABEL_ROLE, hLabel) trItem.setData(self.LABEL_ROLE, label)
self.listBox.addItem(newItem) self.listBox.addItem(trItem)
return return
+2 -2
View File
@@ -43,10 +43,10 @@ def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
"##! Prologue\n\nText\n\n" "##! Prologue\n\nText\n\n"
"## Chapter One\n\nText\n\n" "## Chapter One\n\nText\n\n"
"### Scene One\n\nText\n\n" "### Scene One\n\nText\n\n"
"### Scene Two\n\nText\n\n" "###! Scene Two\n\nText\n\n"
"## Chapter Two\n\nText\n\n" "## Chapter Two\n\nText\n\n"
"### Scene Three\n\nText\n\n" "### Scene Three\n\nText\n\n"
"### Scene Four\n\nText\n\n" "###! Scene Four\n\nText\n\n"
"#! New Title\n\nText\n\n" "#! New Title\n\nText\n\n"
"## New Chapter\n\nText\n\n" "## New Chapter\n\nText\n\n"
"### New Scene\n\nText\n\n" "### New Scene\n\nText\n\n"
+2 -2
View File
@@ -858,10 +858,10 @@ def testGuiProjTree_SplitDocument(qtbot, monkeypatch, nwGUI, projPath, mockRnd,
"##! Prologue\n\nText\n\n" "##! Prologue\n\nText\n\n"
"## Chapter One\n\nText\n\n" "## Chapter One\n\nText\n\n"
"### Scene One\n\nText\n\n" "### Scene One\n\nText\n\n"
"### Scene Two\n\nText\n\n" "###! Scene Two\n\nText\n\n"
"## Chapter Two\n\nText\n\n" "## Chapter Two\n\nText\n\n"
"### Scene Three\n\nText\n\n" "### Scene Three\n\nText\n\n"
"### Scene Four\n\nText\n\n" "###! Scene Four\n\nText\n\n"
"#! New Title\n\nText\n\n" "#! New Title\n\nText\n\n"
"## New Chapter\n\nText\n\n" "## New Chapter\n\nText\n\n"
"### New Scene\n\nText\n\n" "### New Scene\n\nText\n\n"