Manipulating statuses now seem to work, and update correctly.
This commit is contained in:
@@ -76,12 +76,3 @@ class nwAlert(Enum):
|
|||||||
BUG = 3
|
BUG = 3
|
||||||
|
|
||||||
# END Enum nwAlert
|
# END Enum nwAlert
|
||||||
|
|
||||||
class nwChanged(Enum):
|
|
||||||
|
|
||||||
NONE = 0
|
|
||||||
DELETE = 1
|
|
||||||
NEW = 2
|
|
||||||
IGNORE = 3
|
|
||||||
|
|
||||||
# END Enum nwAlert
|
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""novelWriter GUI Document Tabs
|
|
||||||
|
|
||||||
novelWriter – GUI Document Tabs
|
|
||||||
=================================
|
|
||||||
Class holding the document tab view
|
|
||||||
|
|
||||||
File History:
|
|
||||||
Created: 2018-09-29 [0.0.1]
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
import logging
|
|
||||||
import nw
|
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
|
||||||
from PyQt5.QtWidgets import QTabWidget, QWidget, QVBoxLayout
|
|
||||||
|
|
||||||
from nw.gui.doceditor import GuiDocEditor
|
|
||||||
from nw.gui.projecteditor import GuiProjectEditor
|
|
||||||
from nw.gui.aboutview import GuiAboutView
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
class GuiDocTabs(QTabWidget):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
QTabWidget.__init__(self)
|
|
||||||
|
|
||||||
logger.debug("Initialising DocTabs ...")
|
|
||||||
self.mainConf = nw.CONFIG
|
|
||||||
self.tabList = []
|
|
||||||
|
|
||||||
self.resize(900,500)
|
|
||||||
self.setTabsClosable(True)
|
|
||||||
|
|
||||||
self.tabBar().tabCloseRequested.connect(self._doCloseTab)
|
|
||||||
|
|
||||||
self.createTab(None,nw.DOCTYPE_ABOUT)
|
|
||||||
|
|
||||||
logger.debug("DocTabs initialisation complete")
|
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
def createTab(self, theName=None, tabType=None):
|
|
||||||
if tabType == nw.DOCTYPE_ABOUT:
|
|
||||||
self._createTabAbout()
|
|
||||||
return True
|
|
||||||
elif tabType == nw.DOCTYPE_PROJECT:
|
|
||||||
self._createTabProject(theName)
|
|
||||||
return True
|
|
||||||
elif tabType == nw.DOCTYPE_DOC:
|
|
||||||
self._createTabDoc(theName)
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
#
|
|
||||||
# Internal Functions
|
|
||||||
#
|
|
||||||
|
|
||||||
def _createTabDoc(self, docName=None):
|
|
||||||
if docName is None:
|
|
||||||
tabName = "New Document"
|
|
||||||
else:
|
|
||||||
tabName = docName
|
|
||||||
thisTab = GuiDocEditor()
|
|
||||||
self.addTab(thisTab,tabName)
|
|
||||||
self.setCurrentWidget(thisTab)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _createTabProject(self, projectName=None):
|
|
||||||
"""Display or create the project settings page.
|
|
||||||
"""
|
|
||||||
for i in range(self.count()):
|
|
||||||
thisTab = self.widget(i)
|
|
||||||
if isinstance(thisTab, GuiProjectEditor):
|
|
||||||
self.setCurrentWidget(thisTab)
|
|
||||||
return True
|
|
||||||
if projectName is None:
|
|
||||||
tabName = "New Project"
|
|
||||||
else:
|
|
||||||
tabName = projectName
|
|
||||||
thisTab = GuiProjectEditor()
|
|
||||||
self.addTab(thisTab,tabName)
|
|
||||||
self.setCurrentWidget(thisTab)
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _createTabAbout(self):
|
|
||||||
"""Display or create the About tab.
|
|
||||||
"""
|
|
||||||
for i in range(self.count()):
|
|
||||||
thisTab = self.widget(i)
|
|
||||||
if isinstance(thisTab, GuiAboutView):
|
|
||||||
self.setCurrentWidget(thisTab)
|
|
||||||
return True
|
|
||||||
thisTab = GuiAboutView()
|
|
||||||
self.addTab(thisTab,"About")
|
|
||||||
self.setCurrentWidget(thisTab)
|
|
||||||
return True
|
|
||||||
|
|
||||||
#
|
|
||||||
# Signals
|
|
||||||
#
|
|
||||||
|
|
||||||
def _doCloseTab(self, tabIdx):
|
|
||||||
logger.verbose("User requested tab %d to be closed." % tabIdx)
|
|
||||||
self.removeTab(tabIdx)
|
|
||||||
logger.verbose("Tab %d closed." % tabIdx)
|
|
||||||
return
|
|
||||||
|
|
||||||
# END Class GuiDocTabs
|
|
||||||
+7
-2
@@ -259,10 +259,15 @@ class GuiDocTree(QTreeWidget):
|
|||||||
tStatus = nwLabels.CLASS_FLAG[nwItem.itemClass]
|
tStatus = nwLabels.CLASS_FLAG[nwItem.itemClass]
|
||||||
if nwItem.itemType == nwItemType.FILE:
|
if nwItem.itemType == nwItemType.FILE:
|
||||||
tStatus += "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout]
|
tStatus += "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout]
|
||||||
|
iStatus = nwItem.itemStatus
|
||||||
if tClass == nwItemClass.NOVEL:
|
if tClass == nwItemClass.NOVEL:
|
||||||
flagIcon = self.theParent.statusIcons[nwItem.itemStatus]
|
if iStatus is None:
|
||||||
|
iStatus = self.theProject.statusItems.checkEntry(iStatus)
|
||||||
|
flagIcon = self.theParent.statusIcons[iStatus]
|
||||||
else:
|
else:
|
||||||
flagIcon = self.theParent.importIcons[nwItem.itemStatus]
|
if iStatus is None:
|
||||||
|
iStatus = self.theProject.importItems.checkEntry(iStatus)
|
||||||
|
flagIcon = self.theParent.importIcons[iStatus]
|
||||||
|
|
||||||
trItem.setText(self.C_NAME, tName)
|
trItem.setText(self.C_NAME, tName)
|
||||||
trItem.setText(self.C_FLAGS,tStatus)
|
trItem.setText(self.C_FLAGS,tStatus)
|
||||||
|
|||||||
@@ -55,12 +55,12 @@ class GuiItemEditor(QDialog):
|
|||||||
self.editLayout = QComboBox()
|
self.editLayout = QComboBox()
|
||||||
|
|
||||||
if self.theItem.itemClass == nwItemClass.NOVEL:
|
if self.theItem.itemClass == nwItemClass.NOVEL:
|
||||||
for sLabel, sCol in self.theProject.statusItems:
|
for sLabel, _, _ in self.theProject.statusItems:
|
||||||
self.editStatus.addItem(
|
self.editStatus.addItem(
|
||||||
self.theParent.statusIcons[sLabel], sLabel, sLabel
|
self.theParent.statusIcons[sLabel], sLabel, sLabel
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
for sLabel, sCol in self.theProject.importItems:
|
for sLabel, _, _ in self.theProject.importItems:
|
||||||
self.editStatus.addItem(
|
self.editStatus.addItem(
|
||||||
self.theParent.importIcons[sLabel], sLabel, sLabel
|
self.theParent.importIcons[sLabel], sLabel, sLabel
|
||||||
)
|
)
|
||||||
|
|||||||
+32
-26
@@ -22,8 +22,7 @@ from PyQt5.QtWidgets import (
|
|||||||
QWidget, QTabWidget, QDialogButtonBox, QListWidget, QListWidgetItem, QPushButton,
|
QWidget, QTabWidget, QDialogButtonBox, QListWidget, QListWidgetItem, QPushButton,
|
||||||
QColorDialog
|
QColorDialog
|
||||||
)
|
)
|
||||||
|
from nw.enum import nwAlert
|
||||||
from nw.enum import nwChanged
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -46,6 +45,7 @@ class GuiProjectEditor(QDialog):
|
|||||||
self.svgGradient = QSvgWidget(self.gradPath)
|
self.svgGradient = QSvgWidget(self.gradPath)
|
||||||
self.svgGradient.setFixedWidth(80)
|
self.svgGradient.setFixedWidth(80)
|
||||||
|
|
||||||
|
self.theProject.countStatus()
|
||||||
self.tabMain = GuiProjectEditMain(self.theParent, self.theProject)
|
self.tabMain = GuiProjectEditMain(self.theParent, self.theProject)
|
||||||
self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject.statusItems)
|
self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject.statusItems)
|
||||||
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject.importItems)
|
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject.importItems)
|
||||||
@@ -82,10 +82,10 @@ class GuiProjectEditor(QDialog):
|
|||||||
self.theProject.setBookTitle(bookTitle)
|
self.theProject.setBookTitle(bookTitle)
|
||||||
self.theProject.setBookAuthors(bookAuthors)
|
self.theProject.setBookAuthors(bookAuthors)
|
||||||
|
|
||||||
statusCol, statusChange = self.tabStatus.getNewList()
|
statusCol = self.tabStatus.getNewList()
|
||||||
importCol, importChange = self.tabImport.getNewList()
|
importCol = self.tabImport.getNewList()
|
||||||
self.theProject.setStatusColours(statusCol, statusChange)
|
self.theProject.setStatusColours(statusCol)
|
||||||
self.theProject.setImportColours(importCol, importChange)
|
self.theProject.setImportColours(importCol)
|
||||||
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@@ -135,6 +135,7 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
self.theStatus = theStatus
|
self.theStatus = theStatus
|
||||||
self.colNames = []
|
self.colNames = []
|
||||||
|
self.colCounts = []
|
||||||
self.colChanged = False
|
self.colChanged = False
|
||||||
|
|
||||||
self.mainBox = QHBoxLayout()
|
self.mainBox = QHBoxLayout()
|
||||||
@@ -143,9 +144,10 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
self.listBox = QListWidget()
|
self.listBox = QListWidget()
|
||||||
self.listBox.itemSelectionChanged.connect(self._selectedItem)
|
self.listBox.itemSelectionChanged.connect(self._selectedItem)
|
||||||
|
|
||||||
for iName, iCol in self.theStatus:
|
for iName, iCol, nUse in self.theStatus:
|
||||||
self._addItem(iName, iCol)
|
self._addItem("%s [%d]" % (iName, nUse), iCol)
|
||||||
self.colNames.append(iName)
|
self.colNames.append(iName)
|
||||||
|
self.colCounts.append(nUse)
|
||||||
|
|
||||||
self.editName = QLineEdit()
|
self.editName = QLineEdit()
|
||||||
self.newButton = QPushButton("New")
|
self.newButton = QPushButton("New")
|
||||||
@@ -182,12 +184,12 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
newList = []
|
newList = []
|
||||||
for n in range(self.listBox.count()):
|
for n in range(self.listBox.count()):
|
||||||
nItem = self.listBox.item(n)
|
nItem = self.listBox.item(n)
|
||||||
nName = nItem.text()
|
nName = self._cleanLabel(nItem.text())
|
||||||
nImg = nItem.icon().pixmap(16,16).toImage()
|
nImg = nItem.icon().pixmap(16,16).toImage()
|
||||||
nCol = QColor(nImg.pixel(7,7))
|
nCol = QColor(nImg.pixel(7,7))
|
||||||
newList.append((nName,nCol.red(),nCol.green(),nCol.blue()))
|
newList.append((nName,nCol.red(),nCol.green(),nCol.blue(),self.colNames[n]))
|
||||||
return newList, self.colNames
|
return newList
|
||||||
return None, None
|
return None
|
||||||
|
|
||||||
##
|
##
|
||||||
# User Actions
|
# User Actions
|
||||||
@@ -206,32 +208,29 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def _newItem(self):
|
def _newItem(self):
|
||||||
newItem = self._addItem("New Item", (0, 0, 0))
|
newItem = self._addItem("New Item [0]", (0, 0, 0))
|
||||||
newItem.setBackground(QBrush(QColor(0,255,0,80)))
|
newItem.setBackground(QBrush(QColor(0,255,0,80)))
|
||||||
self.colNames.append(None)
|
self.colNames.append(None)
|
||||||
|
self.colCounts.append(0)
|
||||||
self.colChanged = True
|
self.colChanged = True
|
||||||
return
|
return
|
||||||
|
|
||||||
def _delItem(self):
|
def _delItem(self):
|
||||||
selItem = self._getSelectedItem()
|
selItem = self._getSelectedItem()
|
||||||
colDel = QBrush(QColor(255,0,0,80))
|
iRow = self.listBox.row(selItem)
|
||||||
colNone = QBrush(QColor(0,0,0,0))
|
if self.colCounts[iRow] == 0:
|
||||||
if selItem is not None:
|
self.listBox.takeItem(iRow)
|
||||||
sText = selItem.text()
|
self.colChanged = True
|
||||||
iRow = self.listBox.row(selItem)
|
else:
|
||||||
if sText == "** Delete **":
|
self.theParent.makeAlert("Cannot delete status item that is in use.",nwAlert.ERROR)
|
||||||
selItem.setBackground(colNone)
|
|
||||||
selItem.setText(self.colNames[iRow])
|
|
||||||
else:
|
|
||||||
selItem.setBackground(colDel)
|
|
||||||
selItem.setText("** Delete **")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _saveItem(self):
|
def _saveItem(self):
|
||||||
logger.verbose("Item save button clicked")
|
logger.verbose("Item save button clicked")
|
||||||
selItem = self._getSelectedItem()
|
selItem = self._getSelectedItem()
|
||||||
|
iRow = self.listBox.row(selItem)
|
||||||
if selItem is not None:
|
if selItem is not None:
|
||||||
selItem.setText(self.editName.text().strip())
|
selItem.setText("%s [%d]" % (self.editName.text().strip(), self.colCounts[iRow]))
|
||||||
selItem.setIcon(self.colButton.icon())
|
selItem.setIcon(self.colButton.icon())
|
||||||
self.colChanged = True
|
self.colChanged = True
|
||||||
return
|
return
|
||||||
@@ -250,7 +249,7 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
logger.verbose("Item selected")
|
logger.verbose("Item selected")
|
||||||
selItem = self._getSelectedItem()
|
selItem = self._getSelectedItem()
|
||||||
if selItem is not None:
|
if selItem is not None:
|
||||||
self.editName.setText(selItem.text())
|
self.editName.setText(self._cleanLabel(selItem.text()))
|
||||||
self.colButton.setIcon(selItem.icon())
|
self.colButton.setIcon(selItem.icon())
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -266,4 +265,11 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
return selItem[0]
|
return selItem[0]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def _cleanLabel(self, theText):
|
||||||
|
iPos = theText.rfind("[")
|
||||||
|
if iPos > 0:
|
||||||
|
return theText[:iPos-1]
|
||||||
|
else:
|
||||||
|
return theText
|
||||||
|
|
||||||
# END Class GuiProjectEditStatus
|
# END Class GuiProjectEditStatus
|
||||||
|
|||||||
+2
-2
@@ -396,7 +396,7 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
def _makeStatusIcons(self):
|
def _makeStatusIcons(self):
|
||||||
self.statusIcons = {}
|
self.statusIcons = {}
|
||||||
for sLabel, sCol in self.theProject.statusItems:
|
for sLabel, sCol, _ in self.theProject.statusItems:
|
||||||
theIcon = QPixmap(32,32)
|
theIcon = QPixmap(32,32)
|
||||||
theIcon.fill(QColor(*sCol))
|
theIcon.fill(QColor(*sCol))
|
||||||
self.statusIcons[sLabel] = QIcon(theIcon)
|
self.statusIcons[sLabel] = QIcon(theIcon)
|
||||||
@@ -404,7 +404,7 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
def _makeImportIcons(self):
|
def _makeImportIcons(self):
|
||||||
self.importIcons = {}
|
self.importIcons = {}
|
||||||
for sLabel, sCol in self.theProject.importItems:
|
for sLabel, sCol, _ in self.theProject.importItems:
|
||||||
theIcon = QPixmap(32,32)
|
theIcon = QPixmap(32,32)
|
||||||
theIcon.fill(QColor(*sCol))
|
theIcon.fill(QColor(*sCol))
|
||||||
self.importIcons[sLabel] = QIcon(theIcon)
|
self.importIcons[sLabel] = QIcon(theIcon)
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ import nw
|
|||||||
|
|
||||||
from os import path, mkdir, rename, unlink
|
from os import path, mkdir, rename, unlink
|
||||||
|
|
||||||
from nw.tools.analyse import TextAnalysis
|
from nw.enum import nwAlert
|
||||||
from nw.enum import nwAlert
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
+26
-4
@@ -352,13 +352,25 @@ class NWProject():
|
|||||||
self.setProjectChanged(True)
|
self.setProjectChanged(True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setStatusColours(self, newCols, colChanged):
|
def setStatusColours(self, newCols):
|
||||||
print(newCols,colChanged)
|
replaceMap = self.statusItems.setNewEntries(newCols)
|
||||||
|
if self.projTree is not None:
|
||||||
|
for nwItem in self.projTree.values():
|
||||||
|
if nwItem.itemClass == nwItemClass.NOVEL:
|
||||||
|
if nwItem.itemStatus in replaceMap.keys():
|
||||||
|
nwItem.setStatus(replaceMap[nwItem.itemStatus])
|
||||||
self.setProjectChanged(True)
|
self.setProjectChanged(True)
|
||||||
|
print(self.statusItems.theLabels)
|
||||||
|
print(self.statusItems.theColours)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setImportColours(self, newCols, colChanged):
|
def setImportColours(self, newCols,):
|
||||||
print(newCols,colChanged)
|
replaceMap = self.importItems.setNewEntries(newCols)
|
||||||
|
if self.projTree is not None:
|
||||||
|
for nwItem in self.projTree.values():
|
||||||
|
if nwItem.itemClass != nwItemClass.NOVEL:
|
||||||
|
if nwItem.itemStatus in replaceMap.keys():
|
||||||
|
nwItem.setStatus(replaceMap[nwItem.itemStatus])
|
||||||
self.setProjectChanged(True)
|
self.setProjectChanged(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -435,6 +447,16 @@ class NWProject():
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def countStatus(self):
|
||||||
|
self.statusItems.resetCounts()
|
||||||
|
self.importItems.resetCounts()
|
||||||
|
for nwItem in self.projTree.values():
|
||||||
|
if nwItem.itemClass == nwItemClass.NOVEL:
|
||||||
|
self.statusItems.countEntry(nwItem.itemStatus)
|
||||||
|
else:
|
||||||
|
self.importItems.countEntry(nwItem.itemStatus)
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|||||||
+44
-14
@@ -23,8 +23,9 @@ class NWStatus():
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.theLabels = []
|
self.theLabels = []
|
||||||
self.theColours = []
|
self.theColours = []
|
||||||
|
self.theCounts = []
|
||||||
self.theMap = {}
|
self.theMap = {}
|
||||||
self.theCount = 0
|
self.theLength = 0
|
||||||
self.theIndex = 0
|
self.theIndex = 0
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -33,8 +34,9 @@ class NWStatus():
|
|||||||
if self.lookupEntry(theLabel) is None:
|
if self.lookupEntry(theLabel) is None:
|
||||||
self.theLabels.append(theLabel)
|
self.theLabels.append(theLabel)
|
||||||
self.theColours.append(theColours)
|
self.theColours.append(theColours)
|
||||||
self.theMap[theLabel] = self.theCount
|
self.theCounts.append(0)
|
||||||
self.theCount += 1
|
self.theMap[theLabel] = self.theLength
|
||||||
|
self.theLength += 1
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def lookupEntry(self, theLabel):
|
def lookupEntry(self, theLabel):
|
||||||
@@ -44,34 +46,62 @@ class NWStatus():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def checkEntry(self, theStatus):
|
def checkEntry(self, theStatus):
|
||||||
theStatus = theStatus.strip()
|
|
||||||
if isinstance(theStatus, str):
|
if isinstance(theStatus, str):
|
||||||
|
theStatus = theStatus.strip()
|
||||||
if self.lookupEntry(theStatus) is not None:
|
if self.lookupEntry(theStatus) is not None:
|
||||||
return theStatus
|
return theStatus
|
||||||
theStatus = checkInt(theStatus, None, False)
|
theStatus = checkInt(theStatus, 0, False)
|
||||||
if theStatus is None:
|
if theStatus >= 0 and theStatus < self.theLength:
|
||||||
return None
|
|
||||||
if theStatus >= 0 and theStatus < self.theCount:
|
|
||||||
return self.theLabels[theStatus]
|
return self.theLabels[theStatus]
|
||||||
|
|
||||||
|
def setNewEntries(self, newList):
|
||||||
|
|
||||||
|
replaceMap = {}
|
||||||
|
|
||||||
|
if newList is not None:
|
||||||
|
|
||||||
|
self.theLabels = []
|
||||||
|
self.theColours = []
|
||||||
|
self.theCounts = []
|
||||||
|
self.theMap = {}
|
||||||
|
self.theLength = 0
|
||||||
|
self.theIndex = 0
|
||||||
|
|
||||||
|
for nName, nR, nG, nB, oName in newList:
|
||||||
|
self.addEntry(nName, (nR, nG, nB))
|
||||||
|
if nName != oName and oName is not None:
|
||||||
|
replaceMap[oName] = nName
|
||||||
|
|
||||||
|
return replaceMap
|
||||||
|
|
||||||
|
def resetCounts(self):
|
||||||
|
self.theCounts = [0]*self.theLength
|
||||||
|
return
|
||||||
|
|
||||||
|
def countEntry(self, theLabel):
|
||||||
|
theIndex = self.lookupEntry(theLabel)
|
||||||
|
if theIndex is not None:
|
||||||
|
self.theCounts[theIndex] += 1
|
||||||
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
# Iterator Bits
|
# Iterator Bits
|
||||||
##
|
##
|
||||||
|
|
||||||
def __getitem__(self, n):
|
def __getitem__(self, n):
|
||||||
if n >= 0 and n < self.theCount:
|
if n >= 0 and n < self.theLength:
|
||||||
return self.theLabels[n], self.theColours[n]
|
return self.theLabels[n], self.theColours[n], self.theCounts[n]
|
||||||
return None, None
|
return None, None, None
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
self.theIndex = 0
|
self.theIndex = 0
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __next__(self):
|
def __next__(self):
|
||||||
if self.theIndex < self.theCount:
|
if self.theIndex < self.theLength:
|
||||||
theLabel, theColour = self.__getitem__(self.theIndex)
|
theLabel, theColour, theCount = self.__getitem__(self.theIndex)
|
||||||
self.theIndex += 1
|
self.theIndex += 1
|
||||||
return theLabel, theColour
|
return theLabel, theColour, theCount
|
||||||
else:
|
else:
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user