From 643a301e2d1b82c74ad125699a30fa8df2cdb7fc Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Wed, 5 Feb 2020 00:10:29 +0100 Subject: [PATCH] Some cleanup in the new doc split dialog --- nw/gui/dialogs/docsplit.py | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/nw/gui/dialogs/docsplit.py b/nw/gui/dialogs/docsplit.py index 3e8502b5..739bb14e 100644 --- a/nw/gui/dialogs/docsplit.py +++ b/nw/gui/dialogs/docsplit.py @@ -66,7 +66,7 @@ class GuiDocSplit(QDialog): self.closeButton.clicked.connect(self._doClose) self.doMergeForm.addWidget(self.listBox, 0, 0, 1, 3) - self.doMergeForm.addWidget(self.splitLevel, 1, 0, 1, 2) + self.doMergeForm.addWidget(self.splitLevel, 1, 0, 1, 3) self.doMergeForm.addWidget(self.splitButton, 2, 1) self.doMergeForm.addWidget(self.closeButton, 2, 2) @@ -112,6 +112,9 @@ class GuiDocSplit(QDialog): theLines = theText.splitlines() nLines = len(theLines) theLines.insert(0, "%Split Doc") + logger.debug( + "Splitting document %s with %d lines" % (self.sourceItem,nLines) + ) finalOrder = [] for i in range(self.listBox.count()): @@ -130,6 +133,7 @@ class GuiDocSplit(QDialog): fHandle = self.theProject.newFolder(srcItem.itemName, srcItem.itemClass, srcItem.parHandle) self.theParent.treeView.revealTreeItem(fHandle) + logger.verbose("Creating folder %s" % fHandle) for wTitle, iStart, iEnd in finalOrder: @@ -146,11 +150,13 @@ class GuiDocSplit(QDialog): wTitle = wTitle.lstrip("#") wTitle = wTitle.strip() - print(wTitle, iStart, iEnd) nHandle = self.theProject.newFile(wTitle, srcItem.itemClass, fHandle) newItem = self.theProject.getItem(nHandle) newItem.setLayout(itemLayout) + logger.verbose( + "Creating new document %s with text from line %d to %d" % (nHandle, iStart, iEnd-1) + ) theText = "\n".join(theLines[iStart:iEnd]) theDoc.openDocument(nHandle, False) @@ -158,25 +164,6 @@ class GuiDocSplit(QDialog): theDoc.clearDocument() self.theParent.treeView.revealTreeItem(nHandle) - # theDoc = NWDoc(self.theProject, self.theParent) - # theText = "" - # for tHandle in finalOrder: - # theText += theDoc.openDocument(tHandle, False).rstrip() - # theText += "\n\n" - - # if self.sourceItem is None: - # self.theParent.makeAlert(( - # "Cannot parse source item." - # ), nwAlert.ERROR) - # return - - # srcItem = self.theProject.getItem(self.sourceItem) - # nHandle = self.theProject.newFile(srcItem.itemName, srcItem.itemClass, srcItem.parHandle) - # self.theParent.treeView.revealTreeItem(nHandle) - # theDoc.openDocument(nHandle, False) - # theDoc.saveDocument(theText) - # self.theParent.openDocument(nHandle) - self.close() return