Merge branch 'main' into dev

This commit is contained in:
Veronica K. B. Olsen
2021-02-06 14:03:22 +01:00
9 changed files with 71 additions and 56 deletions
-2
View File
@@ -213,7 +213,6 @@ class nwQuotes():
"""Allowed quotation marks.
Source: https://en.wikipedia.org/wiki/Quotation_mark
"""
SYMBOLS = {
"\u0027" : "Straight single quotation mark",
"\u0022" : "Straight double quotation mark",
@@ -244,7 +243,6 @@ class nwQuotes():
class nwUnicode:
"""Supported unicode character constants and their HTML equivalents.
"""
# Unicode Constants
# =================
+2 -3
View File
@@ -417,9 +417,7 @@ class GuiDocEditor(QTextEdit):
self.theIndex.scanText(tHandle, docText)
if self._updateHeaders(checkLevel=True):
if self.theParent.projTabs.currentIndex() == self.theParent.idxNovelView:
logger.verbose("Document headers have changed, updating novel tree")
self.theParent.novelView.refreshTree()
self.theParent.requestNovelTreeRefresh()
else:
self.theParent.novelView.updateWordCounts(tHandle)
@@ -2004,6 +2002,7 @@ class GuiDocEditSearch(QFrame):
if theText is not None:
self.searchBox.setText(theText)
self.searchBox.setFocus()
self.searchBox.selectAll()
if self.isRegEx:
self._alertSearchValid(True)
logger.verbose("Setting search text to '%s'" % theText)
+41 -38
View File
@@ -227,55 +227,58 @@ class GuiItemDetails(QWidget):
def updateViewBox(self, tHandle):
"""Populate the details box from a given handle.
"""
self.theHandle = tHandle
nwItem = self.theProject.projTree[tHandle]
if tHandle is None:
self.clearDetails()
return
nwItem = self.theProject.projTree[tHandle]
if nwItem is None:
self.clearDetails()
return
self.theHandle = tHandle
theLabel = nwItem.itemName
if len(theLabel) > 100:
theLabel = theLabel[:96].rstrip()+" ..."
itStatus = nwItem.itemStatus
if nwItem.itemClass == nwItemClass.NOVEL:
itStatus = self.theProject.statusItems.checkEntry(itStatus) # Make sure it's valid
flagIcon = self.theParent.statusIcons[itStatus]
else:
theLabel = nwItem.itemName
if len(theLabel) > 100:
theLabel = theLabel[:96].rstrip()+" ..."
itStatus = self.theProject.importItems.checkEntry(itStatus) # Make sure it's valid
flagIcon = self.theParent.importIcons[itStatus]
itStatus = nwItem.itemStatus
if nwItem.itemClass == nwItemClass.NOVEL:
itStatus = self.theProject.statusItems.checkEntry(itStatus) # Make sure it's valid
flagIcon = self.theParent.statusIcons[itStatus]
if nwItem.itemType == nwItemType.FILE:
if nwItem.isExported:
self.labelFlag.setPixmap(self.expCheck)
else:
itStatus = self.theProject.importItems.checkEntry(itStatus) # Make sure it's valid
flagIcon = self.theParent.importIcons[itStatus]
self.labelFlag.setPixmap(self.expCross)
else:
self.labelFlag.setPixmap(QPixmap(1, 1))
if nwItem.itemType == nwItemType.FILE:
if nwItem.isExported:
self.labelFlag.setPixmap(self.expCheck)
else:
self.labelFlag.setPixmap(self.expCross)
else:
self.labelFlag.setPixmap(QPixmap(1, 1))
iPx = int(round(0.8*self.theTheme.baseIconSize))
self.statusFlag.setPixmap(flagIcon.pixmap(iPx, iPx))
self.classFlag.setText(nwLabels.CLASS_FLAG[nwItem.itemClass])
iPx = int(round(0.8*self.theTheme.baseIconSize))
self.statusFlag.setPixmap(flagIcon.pixmap(iPx, iPx))
self.classFlag.setText(nwLabels.CLASS_FLAG[nwItem.itemClass])
if nwItem.itemLayout == nwItemLayout.NO_LAYOUT:
self.layoutFlag.setText("-")
else:
self.layoutFlag.setText(nwLabels.LAYOUT_FLAG[nwItem.itemLayout])
if nwItem.itemLayout == nwItemLayout.NO_LAYOUT:
self.layoutFlag.setText("-")
else:
self.layoutFlag.setText(nwLabels.LAYOUT_FLAG[nwItem.itemLayout])
self.labelData.setText(theLabel)
self.statusData.setText(nwItem.itemStatus)
self.classData.setText(nwLabels.CLASS_NAME[nwItem.itemClass])
self.layoutData.setText(nwLabels.LAYOUT_NAME[nwItem.itemLayout])
self.labelData.setText(theLabel)
self.statusData.setText(nwItem.itemStatus)
self.classData.setText(nwLabels.CLASS_NAME[nwItem.itemClass])
self.layoutData.setText(nwLabels.LAYOUT_NAME[nwItem.itemLayout])
if nwItem.itemType == nwItemType.FILE:
self.cCountData.setText(f"{nwItem.charCount:n}")
self.wCountData.setText(f"{nwItem.wordCount:n}")
self.pCountData.setText(f"{nwItem.paraCount:n}")
else:
self.cCountData.setText("")
self.wCountData.setText("")
self.pCountData.setText("")
if nwItem.itemType == nwItemType.FILE:
self.cCountData.setText(f"{nwItem.charCount:n}")
self.wCountData.setText(f"{nwItem.wordCount:n}")
self.pCountData.setText(f"{nwItem.paraCount:n}")
else:
self.cCountData.setText("")
self.wCountData.setText("")
self.pCountData.setText("")
return
+2 -1
View File
@@ -131,10 +131,11 @@ class GuiNovelTree(QTreeWidget):
def refreshTree(self, overRide=False):
"""Called whenever the Novel tab is activated.
"""
logger.verbose("Requesting refresh of the novel tree")
treeChanged = self.theParent.treeView.changedSince(self._lastBuild)
indexChanged = self.theIndex.novelChangedSince(self._lastBuild)
if not (treeChanged or indexChanged):
logger.verbose("No changes made to the novel")
logger.verbose("No changes have been made to the novel index")
return
selItem = self.selectedItems()
+10 -6
View File
@@ -129,6 +129,9 @@ class GuiProjectLoad(QDialog):
self.newButton = self.buttonBox.addButton("New", QDialogButtonBox.ActionRole)
self.newButton.clicked.connect(self._doNewProject)
self.delButton = self.buttonBox.addButton("Remove", QDialogButtonBox.ActionRole)
self.delButton.clicked.connect(self._doDeleteRecent)
self.outerBox.addLayout(self.innerBox)
self.outerBox.addWidget(self.buttonBox)
self.setLayout(self.outerBox)
@@ -138,7 +141,7 @@ class GuiProjectLoad(QDialog):
keyDelete = QShortcut(self.listBox)
keyDelete.setKey(QKeySequence(Qt.Key_Delete))
keyDelete.activated.connect(self._keyPressDelete)
keyDelete.activated.connect(self._doDeleteRecent)
logger.debug("GuiProjectLoad initialisation complete")
@@ -212,15 +215,16 @@ class GuiProjectLoad(QDialog):
self.accept()
return
def _keyPressDelete(self):
def _doDeleteRecent(self):
"""Remove an entry from the recent projects list.
"""
selList = self.listBox.selectedItems()
if selList:
msgYes = self.theParent.askQuestion(
"Remove Entry",
"Remove the selected entry from the recent projects list?"
)
projName = selList[0].text(self.C_NAME)
msgYes = self.theParent.askQuestion("Remove Entry", (
"Remove '%s' from the recent projects list? "
"The project files will not be deleted."
) % projName)
if msgYes:
self.mainConf.removeFromRecentCache(
selList[0].data(self.C_NAME, Qt.UserRole)
+8
View File
@@ -817,6 +817,14 @@ class GuiMain(QMainWindow):
self.novelView.refreshTree()
return
def requestNovelTreeRefresh(self):
"""Update the novel tree, but only if it is visible.
"""
if self.projTabs.currentIndex() == self.idxNovelView and self.hasProject:
self.novelView.refreshTree()
return True
return False
def rebuildIndex(self, beQuiet=False):
"""Rebuild the entire index.
"""