Moved item status recrod keeping into a separate iterable class
This commit is contained in:
@@ -76,3 +76,12 @@ 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
-12
@@ -70,20 +70,9 @@ class GuiDocDetails(QFrame):
|
|||||||
if nwItem is None:
|
if nwItem is None:
|
||||||
colTwo = [""]*4
|
colTwo = [""]*4
|
||||||
else:
|
else:
|
||||||
itemStatus = nwItem.itemStatus
|
|
||||||
if nwItem.itemClass == nwItemClass.NOVEL:
|
|
||||||
if itemStatus < 0 or itemStatus >= len(self.theParent.statusLabels):
|
|
||||||
statusLabel = self.theParent.statusLabels[0]
|
|
||||||
else:
|
|
||||||
statusLabel = self.theParent.statusLabels[itemStatus]
|
|
||||||
else:
|
|
||||||
if itemStatus < 0 or itemStatus >= len(self.theParent.importLabels):
|
|
||||||
statusLabel = self.theParent.importLabels[0]
|
|
||||||
else:
|
|
||||||
statusLabel = self.theParent.importLabels[itemStatus]
|
|
||||||
colTwo = [
|
colTwo = [
|
||||||
nwItem.itemName,
|
nwItem.itemName,
|
||||||
statusLabel,
|
nwItem.itemStatus,
|
||||||
nwLabels.CLASS_NAME[nwItem.itemClass],
|
nwLabels.CLASS_NAME[nwItem.itemClass],
|
||||||
nwLabels.LAYOUT_NAME[nwItem.itemLayout],
|
nwLabels.LAYOUT_NAME[nwItem.itemLayout],
|
||||||
]
|
]
|
||||||
|
|||||||
+3
-10
@@ -259,19 +259,12 @@ 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]
|
||||||
nStatus = nwItem.itemStatus
|
|
||||||
if tClass == nwItemClass.NOVEL:
|
if tClass == nwItemClass.NOVEL:
|
||||||
if nStatus < 0 or nStatus >= len(self.theParent.statusIcons):
|
flagIcon = self.theParent.statusIcons[nwItem.itemStatus]
|
||||||
flagIcon = self.theParent.statusIcons[0]
|
|
||||||
else:
|
|
||||||
flagIcon = self.theParent.statusIcons[nStatus]
|
|
||||||
else:
|
else:
|
||||||
if nStatus < 0 or nStatus >= len(self.theParent.importIcons):
|
flagIcon = self.theParent.importIcons[nwItem.itemStatus]
|
||||||
flagIcon = self.theParent.importIcons[0]
|
|
||||||
else:
|
|
||||||
flagIcon = self.theParent.importIcons[nStatus]
|
|
||||||
|
|
||||||
trItem.setText(self.C_NAME,tName)
|
trItem.setText(self.C_NAME, tName)
|
||||||
trItem.setText(self.C_FLAGS,tStatus)
|
trItem.setText(self.C_FLAGS,tStatus)
|
||||||
trItem.setIcon(self.C_FLAGS,flagIcon)
|
trItem.setIcon(self.C_FLAGS,flagIcon)
|
||||||
|
|
||||||
|
|||||||
@@ -55,14 +55,14 @@ class GuiItemEditor(QDialog):
|
|||||||
self.editLayout = QComboBox()
|
self.editLayout = QComboBox()
|
||||||
|
|
||||||
if self.theItem.itemClass == nwItemClass.NOVEL:
|
if self.theItem.itemClass == nwItemClass.NOVEL:
|
||||||
for n in range(len(self.theParent.statusLabels)):
|
for sLabel, sCol in self.theProject.statusItems:
|
||||||
self.editStatus.addItem(
|
self.editStatus.addItem(
|
||||||
self.theParent.statusIcons[n], self.theParent.statusLabels[n], n
|
self.theParent.statusIcons[sLabel], sLabel, sLabel
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
for n in range(len(self.theParent.statusLabels)):
|
for sLabel, sCol in self.theProject.importItems:
|
||||||
self.editStatus.addItem(
|
self.editStatus.addItem(
|
||||||
self.theParent.importIcons[n], self.theParent.importLabels[n], n
|
self.theParent.importIcons[sLabel], sLabel, sLabel
|
||||||
)
|
)
|
||||||
|
|
||||||
self.validLayouts = []
|
self.validLayouts = []
|
||||||
|
|||||||
+41
-18
@@ -13,9 +13,9 @@
|
|||||||
import logging
|
import logging
|
||||||
import nw
|
import nw
|
||||||
|
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
from PyQt5.QtGui import QIcon, QPixmap, QColor
|
from PyQt5.QtGui import QIcon, QPixmap, QColor, QBrush
|
||||||
from PyQt5.QtSvg import QSvgWidget
|
from PyQt5.QtSvg import QSvgWidget
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QHBoxLayout, QVBoxLayout, QFormLayout, QLineEdit, QPlainTextEdit, QLabel,
|
QDialog, QHBoxLayout, QVBoxLayout, QFormLayout, QLineEdit, QPlainTextEdit, QLabel,
|
||||||
@@ -23,6 +23,8 @@ from PyQt5.QtWidgets import (
|
|||||||
QColorDialog
|
QColorDialog
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from nw.enum import nwChanged
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class GuiProjectEditor(QDialog):
|
class GuiProjectEditor(QDialog):
|
||||||
@@ -45,8 +47,8 @@ class GuiProjectEditor(QDialog):
|
|||||||
self.svgGradient.setFixedWidth(80)
|
self.svgGradient.setFixedWidth(80)
|
||||||
|
|
||||||
self.tabMain = GuiProjectEditMain(self.theParent, self.theProject)
|
self.tabMain = GuiProjectEditMain(self.theParent, self.theProject)
|
||||||
self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject.statusCols)
|
self.tabStatus = GuiProjectEditStatus(self.theParent, self.theProject.statusItems)
|
||||||
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject.importCols)
|
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject.importItems)
|
||||||
|
|
||||||
self.tabWidget = QTabWidget()
|
self.tabWidget = QTabWidget()
|
||||||
self.tabWidget.addTab(self.tabMain, "Settings")
|
self.tabWidget.addTab(self.tabMain, "Settings")
|
||||||
@@ -80,10 +82,10 @@ class GuiProjectEditor(QDialog):
|
|||||||
self.theProject.setBookTitle(bookTitle)
|
self.theProject.setBookTitle(bookTitle)
|
||||||
self.theProject.setBookAuthors(bookAuthors)
|
self.theProject.setBookAuthors(bookAuthors)
|
||||||
|
|
||||||
statusCol = self.tabStatus.getNewList()
|
statusCol, statusChange = self.tabStatus.getNewList()
|
||||||
importCol = self.tabImport.getNewList()
|
importCol, importChange = self.tabImport.getNewList()
|
||||||
self.theProject.setStatusColours(statusCol)
|
self.theProject.setStatusColours(statusCol, statusChange)
|
||||||
self.theProject.setImportColours(importCol)
|
self.theProject.setImportColours(importCol, importChange)
|
||||||
|
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@@ -127,11 +129,12 @@ class GuiProjectEditMain(QWidget):
|
|||||||
|
|
||||||
class GuiProjectEditStatus(QWidget):
|
class GuiProjectEditStatus(QWidget):
|
||||||
|
|
||||||
def __init__(self, theParent, colList):
|
def __init__(self, theParent, theStatus):
|
||||||
QWidget.__init__(self, theParent)
|
QWidget.__init__(self, theParent)
|
||||||
|
|
||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
self.colList = colList.copy()
|
self.theStatus = theStatus
|
||||||
|
self.colNames = []
|
||||||
self.colChanged = False
|
self.colChanged = False
|
||||||
|
|
||||||
self.mainBox = QHBoxLayout()
|
self.mainBox = QHBoxLayout()
|
||||||
@@ -140,8 +143,9 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
self.listBox = QListWidget()
|
self.listBox = QListWidget()
|
||||||
self.listBox.itemSelectionChanged.connect(self._selectedItem)
|
self.listBox.itemSelectionChanged.connect(self._selectedItem)
|
||||||
|
|
||||||
for iName, iR, iG, iB in self.colList:
|
for iName, iCol in self.theStatus:
|
||||||
self._addItem(iName, iR, iG, iB)
|
self._addItem(iName, iCol)
|
||||||
|
self.colNames.append(iName)
|
||||||
|
|
||||||
self.editName = QLineEdit()
|
self.editName = QLineEdit()
|
||||||
self.newButton = QPushButton("New")
|
self.newButton = QPushButton("New")
|
||||||
@@ -153,6 +157,7 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
self.colButton.setIconSize(self.colPixmap.rect().size())
|
self.colButton.setIconSize(self.colPixmap.rect().size())
|
||||||
|
|
||||||
self.newButton.clicked.connect(self._newItem)
|
self.newButton.clicked.connect(self._newItem)
|
||||||
|
self.delButton.clicked.connect(self._delItem)
|
||||||
self.saveButton.clicked.connect(self._saveItem)
|
self.saveButton.clicked.connect(self._saveItem)
|
||||||
self.colButton.clicked.connect(self._selectColour)
|
self.colButton.clicked.connect(self._selectColour)
|
||||||
|
|
||||||
@@ -181,8 +186,8 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
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()))
|
||||||
return newList
|
return newList, self.colNames
|
||||||
return self.colList
|
return None, None
|
||||||
|
|
||||||
##
|
##
|
||||||
# User Actions
|
# User Actions
|
||||||
@@ -201,7 +206,25 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def _newItem(self):
|
def _newItem(self):
|
||||||
self._addItem("New Item", 0, 0, 0)
|
newItem = self._addItem("New Item", (0, 0, 0))
|
||||||
|
newItem.setBackground(QBrush(QColor(0,255,0,80)))
|
||||||
|
self.colNames.append(None)
|
||||||
|
self.colChanged = True
|
||||||
|
return
|
||||||
|
|
||||||
|
def _delItem(self):
|
||||||
|
selItem = self._getSelectedItem()
|
||||||
|
colDel = QBrush(QColor(255,0,0,80))
|
||||||
|
colNone = QBrush(QColor(0,0,0,0))
|
||||||
|
if selItem is not None:
|
||||||
|
sText = selItem.text()
|
||||||
|
iRow = self.listBox.row(selItem)
|
||||||
|
if sText == "** Delete **":
|
||||||
|
selItem.setBackground(colNone)
|
||||||
|
selItem.setText(self.colNames[iRow])
|
||||||
|
else:
|
||||||
|
selItem.setBackground(colDel)
|
||||||
|
selItem.setText("** Delete **")
|
||||||
return
|
return
|
||||||
|
|
||||||
def _saveItem(self):
|
def _saveItem(self):
|
||||||
@@ -213,15 +236,15 @@ class GuiProjectEditStatus(QWidget):
|
|||||||
self.colChanged = True
|
self.colChanged = True
|
||||||
return
|
return
|
||||||
|
|
||||||
def _addItem(self, iName, iR, iG, iB):
|
def _addItem(self, iName, iCol):
|
||||||
logger.verbose("New item button clicked")
|
logger.verbose("New item button clicked")
|
||||||
newIcon = QPixmap(16,16)
|
newIcon = QPixmap(16,16)
|
||||||
newIcon.fill(QColor(iR,iG,iB))
|
newIcon.fill(QColor(*iCol))
|
||||||
newItem = QListWidgetItem()
|
newItem = QListWidgetItem()
|
||||||
newItem.setText(iName)
|
newItem.setText(iName)
|
||||||
newItem.setIcon(QIcon(newIcon))
|
newItem.setIcon(QIcon(newIcon))
|
||||||
self.listBox.addItem(newItem)
|
self.listBox.addItem(newItem)
|
||||||
return
|
return newItem
|
||||||
|
|
||||||
def _selectedItem(self):
|
def _selectedItem(self):
|
||||||
logger.verbose("Item selected")
|
logger.verbose("Item selected")
|
||||||
|
|||||||
+10
-16
@@ -61,10 +61,8 @@ class GuiMain(QMainWindow):
|
|||||||
self.statusBar = GuiMainStatus(self)
|
self.statusBar = GuiMainStatus(self)
|
||||||
|
|
||||||
# Minor Gui Elements
|
# Minor Gui Elements
|
||||||
self.statusIcons = []
|
self.statusIcons = []
|
||||||
self.statusLabels = []
|
self.importIcons = []
|
||||||
self.importIcons = []
|
|
||||||
self.importLabels = []
|
|
||||||
|
|
||||||
# Assemble Main Window
|
# Assemble Main Window
|
||||||
self.treePane = QFrame()
|
self.treePane = QFrame()
|
||||||
@@ -397,23 +395,19 @@ class GuiMain(QMainWindow):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def _makeStatusIcons(self):
|
def _makeStatusIcons(self):
|
||||||
self.statusIcons = []
|
self.statusIcons = {}
|
||||||
self.statusLabels = []
|
for sLabel, sCol in self.theProject.statusItems:
|
||||||
for sLabel, sR, sG, sB in self.theProject.statusCols:
|
|
||||||
theIcon = QPixmap(32,32)
|
theIcon = QPixmap(32,32)
|
||||||
theIcon.fill(QColor(sR,sG,sB))
|
theIcon.fill(QColor(*sCol))
|
||||||
self.statusIcons.append(QIcon(theIcon))
|
self.statusIcons[sLabel] = QIcon(theIcon)
|
||||||
self.statusLabels.append(sLabel)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _makeImportIcons(self):
|
def _makeImportIcons(self):
|
||||||
self.importIcons = []
|
self.importIcons = {}
|
||||||
self.importLabels = []
|
for sLabel, sCol in self.theProject.importItems:
|
||||||
for sLabel, sR, sG, sB in self.theProject.importCols:
|
|
||||||
theIcon = QPixmap(32,32)
|
theIcon = QPixmap(32,32)
|
||||||
theIcon.fill(QColor(sR,sG,sB))
|
theIcon.fill(QColor(*sCol))
|
||||||
self.importIcons.append(QIcon(theIcon))
|
self.importIcons[sLabel] = QIcon(theIcon)
|
||||||
self.importLabels.append(sLabel)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
+8
-4
@@ -26,7 +26,9 @@ class NWItem():
|
|||||||
|
|
||||||
MAX_DEPTH = 8
|
MAX_DEPTH = 8
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, theProject):
|
||||||
|
|
||||||
|
self.theProject = theProject
|
||||||
|
|
||||||
self.itemName = ""
|
self.itemName = ""
|
||||||
self.itemHandle = None
|
self.itemHandle = None
|
||||||
@@ -35,7 +37,7 @@ class NWItem():
|
|||||||
self.itemType = nwItemType.NO_TYPE
|
self.itemType = nwItemType.NO_TYPE
|
||||||
self.itemClass = nwItemClass.NO_CLASS
|
self.itemClass = nwItemClass.NO_CLASS
|
||||||
self.itemLayout = nwItemLayout.NO_LAYOUT
|
self.itemLayout = nwItemLayout.NO_LAYOUT
|
||||||
self.itemStatus = 0
|
self.itemStatus = None
|
||||||
self.isExpanded = False
|
self.isExpanded = False
|
||||||
|
|
||||||
# Document Meta Data
|
# Document Meta Data
|
||||||
@@ -158,8 +160,10 @@ class NWItem():
|
|||||||
return
|
return
|
||||||
|
|
||||||
def setStatus(self, theStatus):
|
def setStatus(self, theStatus):
|
||||||
theStatus = checkInt(theStatus,0)
|
if self.itemClass == nwItemClass.NOVEL:
|
||||||
self.itemStatus = theStatus
|
self.itemStatus = self.theProject.statusItems.checkEntry(theStatus)
|
||||||
|
else:
|
||||||
|
self.itemStatus = self.theProject.importItems.checkEntry(theStatus)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setExpanded(self, expState):
|
def setExpanded(self, expState):
|
||||||
|
|||||||
+31
-30
@@ -13,15 +13,16 @@
|
|||||||
import logging
|
import logging
|
||||||
import nw
|
import nw
|
||||||
|
|
||||||
from os import path, mkdir, listdir
|
from os import path, mkdir, listdir
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert
|
from nw.enum import nwItemType, nwItemClass, nwItemLayout, nwAlert
|
||||||
from nw.common import checkString, checkBool
|
from nw.common import checkString, checkBool
|
||||||
from nw.project.item import NWItem
|
from nw.project.item import NWItem
|
||||||
|
from nw.project.status import NWStatus
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -54,8 +55,8 @@ class NWProject():
|
|||||||
|
|
||||||
# Project Settings
|
# Project Settings
|
||||||
self.spellCheck = False
|
self.spellCheck = False
|
||||||
self.statusCols = None
|
self.statusItems = NWStatus()
|
||||||
self.importCols = None
|
self.importItems = NWStatus()
|
||||||
self.lastEdited = None
|
self.lastEdited = None
|
||||||
self.lastViewed = None
|
self.lastViewed = None
|
||||||
|
|
||||||
@@ -75,7 +76,7 @@ class NWProject():
|
|||||||
if not self.checkRootUnique(rootClass):
|
if not self.checkRootUnique(rootClass):
|
||||||
self.makeAlert("Duplicate root item detected!", nwAlert.ERROR)
|
self.makeAlert("Duplicate root item detected!", nwAlert.ERROR)
|
||||||
return None
|
return None
|
||||||
newItem = NWItem()
|
newItem = NWItem(self)
|
||||||
newItem.setName(rootName)
|
newItem.setName(rootName)
|
||||||
newItem.setType(nwItemType.ROOT)
|
newItem.setType(nwItemType.ROOT)
|
||||||
newItem.setClass(rootClass)
|
newItem.setClass(rootClass)
|
||||||
@@ -83,7 +84,7 @@ class NWProject():
|
|||||||
return newItem.itemHandle
|
return newItem.itemHandle
|
||||||
|
|
||||||
def newFolder(self, folderName, folderClass, pHandle):
|
def newFolder(self, folderName, folderClass, pHandle):
|
||||||
newItem = NWItem()
|
newItem = NWItem(self)
|
||||||
newItem.setName(folderName)
|
newItem.setName(folderName)
|
||||||
newItem.setType(nwItemType.FOLDER)
|
newItem.setType(nwItemType.FOLDER)
|
||||||
newItem.setClass(folderClass)
|
newItem.setClass(folderClass)
|
||||||
@@ -91,7 +92,7 @@ class NWProject():
|
|||||||
return newItem.itemHandle
|
return newItem.itemHandle
|
||||||
|
|
||||||
def newFile(self, fileName, fileClass, pHandle):
|
def newFile(self, fileName, fileClass, pHandle):
|
||||||
newItem = NWItem()
|
newItem = NWItem(self)
|
||||||
newItem.setName(fileName)
|
newItem.setName(fileName)
|
||||||
newItem.setType(nwItemType.FILE)
|
newItem.setType(nwItemType.FILE)
|
||||||
if fileClass == nwItemClass.NOVEL:
|
if fileClass == nwItemClass.NOVEL:
|
||||||
@@ -103,7 +104,7 @@ class NWProject():
|
|||||||
return newItem.itemHandle
|
return newItem.itemHandle
|
||||||
|
|
||||||
def addTrash(self):
|
def addTrash(self):
|
||||||
newItem = NWItem()
|
newItem = NWItem(self)
|
||||||
newItem.setName("Trash")
|
newItem.setName("Trash")
|
||||||
newItem.setType(nwItemType.TRASH)
|
newItem.setType(nwItemType.TRASH)
|
||||||
newItem.setClass(nwItemClass.TRASH)
|
newItem.setClass(nwItemClass.TRASH)
|
||||||
@@ -144,18 +145,16 @@ class NWProject():
|
|||||||
self.bookTitle = ""
|
self.bookTitle = ""
|
||||||
self.bookAuthors = []
|
self.bookAuthors = []
|
||||||
self.spellCheck = False
|
self.spellCheck = False
|
||||||
self.statusCols = [
|
self.statusItems = NWStatus()
|
||||||
("New", 100,100,100),
|
self.statusItems.addEntry("New", (100,100,100))
|
||||||
("Note", 200, 50, 0),
|
self.statusItems.addEntry("Note", (200, 50, 0))
|
||||||
("Draft", 200,150, 0),
|
self.statusItems.addEntry("Draft", (200,150, 0))
|
||||||
("Finished", 50,200, 0),
|
self.statusItems.addEntry("Finished",( 50,200, 0))
|
||||||
]
|
self.importItems = NWStatus()
|
||||||
self.importCols = [
|
self.importItems.addEntry("None", (100,100,100))
|
||||||
("None", 100,100,100),
|
self.importItems.addEntry("Minor", (200, 50, 0))
|
||||||
("Minor", 200, 50, 0),
|
self.importItems.addEntry("Major", (200,150, 0))
|
||||||
("Major", 200,150, 0),
|
self.importItems.addEntry("Main", ( 50,200, 0))
|
||||||
("Main", 50,200, 0),
|
|
||||||
]
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -228,7 +227,7 @@ class NWProject():
|
|||||||
pHandle = itemAttrib["parent"]
|
pHandle = itemAttrib["parent"]
|
||||||
else:
|
else:
|
||||||
pHandle = None
|
pHandle = None
|
||||||
nwItem = NWItem()
|
nwItem = NWItem(self)
|
||||||
for xValue in xItem:
|
for xValue in xItem:
|
||||||
nwItem.setFromTag(xValue.tag,xValue.text)
|
nwItem.setFromTag(xValue.tag,xValue.text)
|
||||||
self._appendItem(tHandle,pHandle,nwItem)
|
self._appendItem(tHandle,pHandle,nwItem)
|
||||||
@@ -353,11 +352,13 @@ class NWProject():
|
|||||||
self.setProjectChanged(True)
|
self.setProjectChanged(True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setStatusColours(self, newCols):
|
def setStatusColours(self, newCols, colChanged):
|
||||||
|
print(newCols,colChanged)
|
||||||
self.setProjectChanged(True)
|
self.setProjectChanged(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
def setImportColours(self, newCols):
|
def setImportColours(self, newCols, colChanged):
|
||||||
|
print(newCols,colChanged)
|
||||||
self.setProjectChanged(True)
|
self.setProjectChanged(True)
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -500,7 +501,7 @@ class NWProject():
|
|||||||
nOrph = 0
|
nOrph = 0
|
||||||
for oHandle in orphanFiles:
|
for oHandle in orphanFiles:
|
||||||
nOrph += 1
|
nOrph += 1
|
||||||
orItem = NWItem()
|
orItem = NWItem(self)
|
||||||
orItem.setName("Orphaned File %d" % nOrph)
|
orItem.setName("Orphaned File %d" % nOrph)
|
||||||
orItem.setType(nwItemType.FILE)
|
orItem.setType(nwItemType.FILE)
|
||||||
orItem.setClass(nwItemClass.NO_CLASS)
|
orItem.setClass(nwItemClass.NO_CLASS)
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""novelWriter Item Status
|
||||||
|
|
||||||
|
novelWriter – Item Status
|
||||||
|
===========================
|
||||||
|
Class holding the project's item statuses
|
||||||
|
|
||||||
|
File History:
|
||||||
|
Created: 2019-05-19 [0.1.3]
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import nw
|
||||||
|
|
||||||
|
from nw.enum import nwItemClass
|
||||||
|
from nw.common import checkInt
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
class NWStatus():
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.theLabels = []
|
||||||
|
self.theColours = []
|
||||||
|
self.theMap = {}
|
||||||
|
self.theCount = 0
|
||||||
|
self.theIndex = 0
|
||||||
|
return
|
||||||
|
|
||||||
|
def addEntry(self, theLabel, theColours):
|
||||||
|
theLabel = theLabel.strip()
|
||||||
|
if self.lookupEntry(theLabel) is None:
|
||||||
|
self.theLabels.append(theLabel)
|
||||||
|
self.theColours.append(theColours)
|
||||||
|
self.theMap[theLabel] = self.theCount
|
||||||
|
self.theCount += 1
|
||||||
|
return True
|
||||||
|
|
||||||
|
def lookupEntry(self, theLabel):
|
||||||
|
theLabel = theLabel.strip()
|
||||||
|
if theLabel in self.theMap.keys():
|
||||||
|
return self.theMap[theLabel]
|
||||||
|
return None
|
||||||
|
|
||||||
|
def checkEntry(self, theStatus):
|
||||||
|
theStatus = theStatus.strip()
|
||||||
|
if isinstance(theStatus, str):
|
||||||
|
if self.lookupEntry(theStatus) is not None:
|
||||||
|
return theStatus
|
||||||
|
theStatus = checkInt(theStatus, None, False)
|
||||||
|
if theStatus is None:
|
||||||
|
return None
|
||||||
|
if theStatus >= 0 and theStatus < self.theCount:
|
||||||
|
return self.theLabels[theStatus]
|
||||||
|
|
||||||
|
##
|
||||||
|
# Iterator Bits
|
||||||
|
##
|
||||||
|
|
||||||
|
def __getitem__(self, n):
|
||||||
|
if n >= 0 and n < self.theCount:
|
||||||
|
return self.theLabels[n], self.theColours[n]
|
||||||
|
return None, None
|
||||||
|
|
||||||
|
def __iter__(self):
|
||||||
|
self.theIndex = 0
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __next__(self):
|
||||||
|
if self.theIndex < self.theCount:
|
||||||
|
theLabel, theColour = self.__getitem__(self.theIndex)
|
||||||
|
self.theIndex += 1
|
||||||
|
return theLabel, theColour
|
||||||
|
else:
|
||||||
|
raise StopIteration
|
||||||
|
|
||||||
|
# END Class NWStatus
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version='1.0' encoding='utf-8'?>
|
<?xml version='1.0' encoding='utf-8'?>
|
||||||
<novelWriterXML appVersion="0.1.3" fileVersion="1.0" timeStamp="2019-05-19 14:27:22">
|
<novelWriterXML appVersion="0.1.3" fileVersion="1.0" timeStamp="2019-05-19 19:03:13">
|
||||||
<project>
|
<project>
|
||||||
<name>Sample Project</name>
|
<name>Sample Project</name>
|
||||||
<title>Sample Project</title>
|
<title>Sample Project</title>
|
||||||
@@ -16,14 +16,14 @@
|
|||||||
<name>Novel</name>
|
<name>Novel</name>
|
||||||
<type>ROOT</type>
|
<type>ROOT</type>
|
||||||
<class>NOVEL</class>
|
<class>NOVEL</class>
|
||||||
<status>0</status>
|
<status>New</status>
|
||||||
<expanded>True</expanded>
|
<expanded>True</expanded>
|
||||||
</item>
|
</item>
|
||||||
<item handle="53b69b83cdafc" order="0" parent="7031beac91f75">
|
<item handle="53b69b83cdafc" order="0" parent="7031beac91f75">
|
||||||
<name>Title Page</name>
|
<name>Title Page</name>
|
||||||
<type>FILE</type>
|
<type>FILE</type>
|
||||||
<class>NOVEL</class>
|
<class>NOVEL</class>
|
||||||
<status>2</status>
|
<status>Draft</status>
|
||||||
<expanded>False</expanded>
|
<expanded>False</expanded>
|
||||||
<layout>TITLE</layout>
|
<layout>TITLE</layout>
|
||||||
<charCount>23</charCount>
|
<charCount>23</charCount>
|
||||||
@@ -35,14 +35,14 @@
|
|||||||
<name>Some Chapter</name>
|
<name>Some Chapter</name>
|
||||||
<type>FOLDER</type>
|
<type>FOLDER</type>
|
||||||
<class>NOVEL</class>
|
<class>NOVEL</class>
|
||||||
<status>1</status>
|
<status>Note</status>
|
||||||
<expanded>True</expanded>
|
<expanded>True</expanded>
|
||||||
</item>
|
</item>
|
||||||
<item handle="96b68994dfa3d" order="0" parent="e7ded148d6e4a">
|
<item handle="96b68994dfa3d" order="0" parent="e7ded148d6e4a">
|
||||||
<name>New Scene</name>
|
<name>New Scene</name>
|
||||||
<type>FILE</type>
|
<type>FILE</type>
|
||||||
<class>NOVEL</class>
|
<class>NOVEL</class>
|
||||||
<status>2</status>
|
<status>Draft</status>
|
||||||
<expanded>False</expanded>
|
<expanded>False</expanded>
|
||||||
<layout>SCENE</layout>
|
<layout>SCENE</layout>
|
||||||
<charCount>2571</charCount>
|
<charCount>2571</charCount>
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
<name>File With Stuff</name>
|
<name>File With Stuff</name>
|
||||||
<type>FILE</type>
|
<type>FILE</type>
|
||||||
<class>NOVEL</class>
|
<class>NOVEL</class>
|
||||||
<status>1</status>
|
<status>Note</status>
|
||||||
<expanded>False</expanded>
|
<expanded>False</expanded>
|
||||||
<layout>SCENE</layout>
|
<layout>SCENE</layout>
|
||||||
<charCount>578</charCount>
|
<charCount>578</charCount>
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
<name>New File</name>
|
<name>New File</name>
|
||||||
<type>FILE</type>
|
<type>FILE</type>
|
||||||
<class>NOVEL</class>
|
<class>NOVEL</class>
|
||||||
<status>0</status>
|
<status>Note</status>
|
||||||
<expanded>False</expanded>
|
<expanded>False</expanded>
|
||||||
<layout>SCENE</layout>
|
<layout>SCENE</layout>
|
||||||
<charCount>69</charCount>
|
<charCount>69</charCount>
|
||||||
@@ -78,21 +78,21 @@
|
|||||||
<name>Characters</name>
|
<name>Characters</name>
|
||||||
<type>ROOT</type>
|
<type>ROOT</type>
|
||||||
<class>CHARACTER</class>
|
<class>CHARACTER</class>
|
||||||
<status>0</status>
|
<status>None</status>
|
||||||
<expanded>True</expanded>
|
<expanded>True</expanded>
|
||||||
</item>
|
</item>
|
||||||
<item handle="f7e2d9f330615" order="0" parent="f6622b4617424">
|
<item handle="f7e2d9f330615" order="0" parent="f6622b4617424">
|
||||||
<name>Main Characters</name>
|
<name>Main Characters</name>
|
||||||
<type>FOLDER</type>
|
<type>FOLDER</type>
|
||||||
<class>CHARACTER</class>
|
<class>CHARACTER</class>
|
||||||
<status>0</status>
|
<status>None</status>
|
||||||
<expanded>True</expanded>
|
<expanded>True</expanded>
|
||||||
</item>
|
</item>
|
||||||
<item handle="14298de4d9524" order="0" parent="f7e2d9f330615">
|
<item handle="14298de4d9524" order="0" parent="f7e2d9f330615">
|
||||||
<name>John Smith</name>
|
<name>John Smith</name>
|
||||||
<type>FILE</type>
|
<type>FILE</type>
|
||||||
<class>CHARACTER</class>
|
<class>CHARACTER</class>
|
||||||
<status>0</status>
|
<status>Minor</status>
|
||||||
<expanded>False</expanded>
|
<expanded>False</expanded>
|
||||||
<layout>NOTE</layout>
|
<layout>NOTE</layout>
|
||||||
<charCount>42</charCount>
|
<charCount>42</charCount>
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
<name>Jane Smith</name>
|
<name>Jane Smith</name>
|
||||||
<type>FILE</type>
|
<type>FILE</type>
|
||||||
<class>CHARACTER</class>
|
<class>CHARACTER</class>
|
||||||
<status>0</status>
|
<status>Major</status>
|
||||||
<expanded>False</expanded>
|
<expanded>False</expanded>
|
||||||
<layout>NOTE</layout>
|
<layout>NOTE</layout>
|
||||||
<charCount>51</charCount>
|
<charCount>51</charCount>
|
||||||
@@ -116,14 +116,14 @@
|
|||||||
<name>Locations</name>
|
<name>Locations</name>
|
||||||
<type>ROOT</type>
|
<type>ROOT</type>
|
||||||
<class>WORLD</class>
|
<class>WORLD</class>
|
||||||
<status>0</status>
|
<status>None</status>
|
||||||
<expanded>True</expanded>
|
<expanded>True</expanded>
|
||||||
</item>
|
</item>
|
||||||
<item handle="b3e74dbc1f584" order="0" parent="15c4492bd5107">
|
<item handle="b3e74dbc1f584" order="0" parent="15c4492bd5107">
|
||||||
<name>Earth</name>
|
<name>Earth</name>
|
||||||
<type>FILE</type>
|
<type>FILE</type>
|
||||||
<class>WORLD</class>
|
<class>WORLD</class>
|
||||||
<status>0</status>
|
<status>None</status>
|
||||||
<expanded>False</expanded>
|
<expanded>False</expanded>
|
||||||
<layout>NOTE</layout>
|
<layout>NOTE</layout>
|
||||||
<charCount>0</charCount>
|
<charCount>0</charCount>
|
||||||
@@ -135,14 +135,14 @@
|
|||||||
<name>Trash</name>
|
<name>Trash</name>
|
||||||
<type>TRASH</type>
|
<type>TRASH</type>
|
||||||
<class>TRASH</class>
|
<class>TRASH</class>
|
||||||
<status>0</status>
|
<status>None</status>
|
||||||
<expanded>True</expanded>
|
<expanded>True</expanded>
|
||||||
</item>
|
</item>
|
||||||
<item handle="4cd0bd12b087d" order="0" parent="98acd8c76c93a">
|
<item handle="4cd0bd12b087d" order="0" parent="98acd8c76c93a">
|
||||||
<name>Orphaned File 2</name>
|
<name>Orphaned File 2</name>
|
||||||
<type>FILE</type>
|
<type>FILE</type>
|
||||||
<class>NO_CLASS</class>
|
<class>NO_CLASS</class>
|
||||||
<status>0</status>
|
<status>None</status>
|
||||||
<expanded>False</expanded>
|
<expanded>False</expanded>
|
||||||
<layout>NO_LAYOUT</layout>
|
<layout>NO_LAYOUT</layout>
|
||||||
<charCount>14</charCount>
|
<charCount>14</charCount>
|
||||||
|
|||||||
Reference in New Issue
Block a user