Add a bunch of None checks, even if many may be redundant
This commit is contained in:
@@ -117,7 +117,7 @@ class GuiDocMerge(QDialog):
|
|||||||
finalItems = []
|
finalItems = []
|
||||||
for i in range(self.listBox.count()):
|
for i in range(self.listBox.count()):
|
||||||
item = self.listBox.item(i)
|
item = self.listBox.item(i)
|
||||||
if item.checkState() == Qt.Checked:
|
if item is not None and item.checkState() == Qt.Checked:
|
||||||
finalItems.append(item.data(Qt.UserRole))
|
finalItems.append(item.data(Qt.UserRole))
|
||||||
|
|
||||||
self._data["moveToTrash"] = self.trashSwitch.isChecked()
|
self._data["moveToTrash"] = self.trashSwitch.isChecked()
|
||||||
|
|||||||
@@ -145,9 +145,12 @@ class GuiDocSplit(QDialog):
|
|||||||
headerList = []
|
headerList = []
|
||||||
for i in range(self.listBox.count()):
|
for i in range(self.listBox.count()):
|
||||||
item = self.listBox.item(i)
|
item = self.listBox.item(i)
|
||||||
headerList.append(
|
if item is not None:
|
||||||
(item.data(self.LINE_ROLE), item.data(self.LEVEL_ROLE), item.data(self.LABEL_ROLE))
|
headerList.append((
|
||||||
)
|
item.data(self.LINE_ROLE),
|
||||||
|
item.data(self.LEVEL_ROLE),
|
||||||
|
item.data(self.LABEL_ROLE),
|
||||||
|
))
|
||||||
|
|
||||||
spLevel = self.splitLevel.currentData()
|
spLevel = self.splitLevel.currentData()
|
||||||
intoFolder = self.folderSwitch.isChecked()
|
intoFolder = self.folderSwitch.isChecked()
|
||||||
|
|||||||
@@ -365,11 +365,12 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
newList = []
|
newList = []
|
||||||
for n in range(self.listBox.topLevelItemCount()):
|
for n in range(self.listBox.topLevelItemCount()):
|
||||||
item = self.listBox.topLevelItem(n)
|
item = self.listBox.topLevelItem(n)
|
||||||
newList.append({
|
if item is not None:
|
||||||
"key": item.data(self.COL_LABEL, self.KEY_ROLE),
|
newList.append({
|
||||||
"name": item.text(self.COL_LABEL),
|
"key": item.data(self.COL_LABEL, self.KEY_ROLE),
|
||||||
"cols": item.data(self.COL_LABEL, self.COL_ROLE),
|
"name": item.text(self.COL_LABEL),
|
||||||
})
|
"cols": item.data(self.COL_LABEL, self.COL_ROLE),
|
||||||
|
})
|
||||||
return newList, self.colDeleted
|
return newList, self.colDeleted
|
||||||
|
|
||||||
return [], []
|
return [], []
|
||||||
@@ -468,7 +469,8 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
self.listBox.insertTopLevelItem(nIndex, cItem)
|
self.listBox.insertTopLevelItem(nIndex, cItem)
|
||||||
self.listBox.clearSelection()
|
self.listBox.clearSelection()
|
||||||
|
|
||||||
cItem.setSelected(True)
|
if cItem is not None:
|
||||||
|
cItem.setSelected(True)
|
||||||
self.colChanged = True
|
self.colChanged = True
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -617,10 +619,11 @@ class GuiProjectEditReplace(QWidget):
|
|||||||
newList = {}
|
newList = {}
|
||||||
for n in range(self.listBox.topLevelItemCount()):
|
for n in range(self.listBox.topLevelItemCount()):
|
||||||
tItem = self.listBox.topLevelItem(n)
|
tItem = self.listBox.topLevelItem(n)
|
||||||
aKey = self._stripNotAllowed(tItem.text(0))
|
if tItem is not None:
|
||||||
aVal = tItem.text(1)
|
aKey = self._stripNotAllowed(tItem.text(0))
|
||||||
if len(aKey) > 0:
|
aVal = tItem.text(1)
|
||||||
newList[aKey] = aVal
|
if len(aKey) > 0:
|
||||||
|
newList[aKey] = aVal
|
||||||
|
|
||||||
return newList
|
return newList
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class GuiUpdates(QDialog):
|
|||||||
logException()
|
logException()
|
||||||
|
|
||||||
relVersion = rawData.get("tag_name", "Unknown")
|
relVersion = rawData.get("tag_name", "Unknown")
|
||||||
relDate = rawData.get("created_at", None)
|
relDate = rawData.get("created_at", "")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
relDate = datetime.strptime(relDate[:10], "%Y-%m-%d").strftime("%x")
|
relDate = datetime.strptime(relDate[:10], "%Y-%m-%d").strftime("%x")
|
||||||
|
|||||||
@@ -156,7 +156,9 @@ class GuiWordList(QDialog):
|
|||||||
try:
|
try:
|
||||||
with open(tmpFile, mode="w", encoding="utf-8") as outFile:
|
with open(tmpFile, mode="w", encoding="utf-8") as outFile:
|
||||||
for i in range(self.listBox.count()):
|
for i in range(self.listBox.count()):
|
||||||
outFile.write(self.listBox.item(i).text() + "\n")
|
item = self.listBox.item(i)
|
||||||
|
if item is not None:
|
||||||
|
outFile.write(item.text() + "\n")
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.error("Could not save new word list")
|
logger.error("Could not save new word list")
|
||||||
|
|||||||
@@ -508,16 +508,17 @@ class GuiNovelTree(QTreeWidget):
|
|||||||
self._actHandle = tHandle
|
self._actHandle = tHandle
|
||||||
for i in range(self.topLevelItemCount()):
|
for i in range(self.topLevelItemCount()):
|
||||||
tItem = self.topLevelItem(i)
|
tItem = self.topLevelItem(i)
|
||||||
if tItem.data(self.C_TITLE, self.D_HANDLE) == tHandle:
|
if tItem is not None:
|
||||||
tItem.setBackground(self.C_TITLE, self.palette().alternateBase())
|
if tItem.data(self.C_TITLE, self.D_HANDLE) == tHandle:
|
||||||
tItem.setBackground(self.C_WORDS, self.palette().alternateBase())
|
tItem.setBackground(self.C_TITLE, self.palette().alternateBase())
|
||||||
tItem.setBackground(self.C_EXTRA, self.palette().alternateBase())
|
tItem.setBackground(self.C_WORDS, self.palette().alternateBase())
|
||||||
tItem.setBackground(self.C_MORE, self.palette().alternateBase())
|
tItem.setBackground(self.C_EXTRA, self.palette().alternateBase())
|
||||||
else:
|
tItem.setBackground(self.C_MORE, self.palette().alternateBase())
|
||||||
tItem.setBackground(self.C_TITLE, self.palette().base())
|
else:
|
||||||
tItem.setBackground(self.C_WORDS, self.palette().base())
|
tItem.setBackground(self.C_TITLE, self.palette().base())
|
||||||
tItem.setBackground(self.C_EXTRA, self.palette().base())
|
tItem.setBackground(self.C_WORDS, self.palette().base())
|
||||||
tItem.setBackground(self.C_MORE, self.palette().base())
|
tItem.setBackground(self.C_EXTRA, self.palette().base())
|
||||||
|
tItem.setBackground(self.C_MORE, self.palette().base())
|
||||||
|
|
||||||
logger.debug("Highlighted Novel Tree in %.3f ms", (time() - tStart)*1000)
|
logger.debug("Highlighted Novel Tree in %.3f ms", (time() - tStart)*1000)
|
||||||
|
|
||||||
|
|||||||
@@ -675,9 +675,10 @@ class GuiOutlineTree(QTreeWidget):
|
|||||||
self.setColumnHidden(self._colIdx[nwOutline.TITLE], False)
|
self.setColumnHidden(self._colIdx[nwOutline.TITLE], False)
|
||||||
|
|
||||||
headItem = self.headerItem()
|
headItem = self.headerItem()
|
||||||
headItem.setTextAlignment(self._colIdx[nwOutline.CCOUNT], Qt.AlignRight)
|
if headItem is not None:
|
||||||
headItem.setTextAlignment(self._colIdx[nwOutline.WCOUNT], Qt.AlignRight)
|
headItem.setTextAlignment(self._colIdx[nwOutline.CCOUNT], Qt.AlignRight)
|
||||||
headItem.setTextAlignment(self._colIdx[nwOutline.PCOUNT], Qt.AlignRight)
|
headItem.setTextAlignment(self._colIdx[nwOutline.WCOUNT], Qt.AlignRight)
|
||||||
|
headItem.setTextAlignment(self._colIdx[nwOutline.PCOUNT], Qt.AlignRight)
|
||||||
|
|
||||||
novStruct = self.theProject.index.novelStructure(rootHandle=rootHandle, skipExcl=True)
|
novStruct = self.theProject.index.novelStructure(rootHandle=rootHandle, skipExcl=True)
|
||||||
for _, tHandle, sTitle, novIdx in novStruct:
|
for _, tHandle, sTitle, novIdx in novStruct:
|
||||||
|
|||||||
@@ -1309,7 +1309,8 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
self._postItemMove(sHandle, wCount)
|
self._postItemMove(sHandle, wCount)
|
||||||
self._recordLastMove(sItem, pItem, pIndex)
|
self._recordLastMove(sItem, pItem, pIndex)
|
||||||
self._alertTreeChange(sHandle, flush=True)
|
self._alertTreeChange(sHandle, flush=True)
|
||||||
sItem.setExpanded(isExpanded)
|
if sItem is not None:
|
||||||
|
sItem.setExpanded(isExpanded)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -112,9 +112,10 @@ class GuiWritingStats(QDialog):
|
|||||||
self.listBox.setColumnWidth(self.C_COUNT, wCol3)
|
self.listBox.setColumnWidth(self.C_COUNT, wCol3)
|
||||||
|
|
||||||
hHeader = self.listBox.headerItem()
|
hHeader = self.listBox.headerItem()
|
||||||
hHeader.setTextAlignment(self.C_LENGTH, Qt.AlignRight)
|
if hHeader is not None:
|
||||||
hHeader.setTextAlignment(self.C_IDLE, Qt.AlignRight)
|
hHeader.setTextAlignment(self.C_LENGTH, Qt.AlignRight)
|
||||||
hHeader.setTextAlignment(self.C_COUNT, Qt.AlignRight)
|
hHeader.setTextAlignment(self.C_IDLE, Qt.AlignRight)
|
||||||
|
hHeader.setTextAlignment(self.C_COUNT, Qt.AlignRight)
|
||||||
|
|
||||||
sortCol = minmax(pOptions.getInt("GuiWritingStats", "sortCol", 0), 0, 2)
|
sortCol = minmax(pOptions.getInt("GuiWritingStats", "sortCol", 0), 0, 2)
|
||||||
sortOrder = checkIntTuple(
|
sortOrder = checkIntTuple(
|
||||||
|
|||||||
Reference in New Issue
Block a user