Use new novel class list to select status or importance list in Item Editor
This commit is contained in:
+31
-16
@@ -28,13 +28,14 @@
|
|||||||
import nw
|
import nw
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from PyQt5.QtCore import pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QDialog, QVBoxLayout, QGridLayout, QLineEdit, QComboBox, QLabel,
|
QDialog, QVBoxLayout, QGridLayout, QLineEdit, QComboBox, QLabel,
|
||||||
QDialogButtonBox
|
QDialogButtonBox
|
||||||
)
|
)
|
||||||
|
|
||||||
from nw.gui.custom import QSwitch
|
from nw.gui.custom import QSwitch
|
||||||
from nw.constants import nwLabels, nwItemLayout, nwItemClass, nwItemType
|
from nw.constants import nwLabels, nwItemLayout, nwItemType, nwLists
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -50,14 +51,15 @@ class GuiItemEditor(QDialog):
|
|||||||
self.theProject = theProject
|
self.theProject = theProject
|
||||||
self.theParent = theParent
|
self.theParent = theParent
|
||||||
|
|
||||||
self.outerBox = QVBoxLayout()
|
##
|
||||||
|
# Build GUI
|
||||||
|
##
|
||||||
|
|
||||||
self.theItem = self.theProject.projTree[tHandle]
|
self.theItem = self.theProject.projTree[tHandle]
|
||||||
if self.theItem is None:
|
if self.theItem is None:
|
||||||
self._doClose()
|
self._doClose()
|
||||||
|
|
||||||
self.setWindowTitle("Item Settings")
|
self.setWindowTitle("Item Settings")
|
||||||
self.setLayout(self.outerBox)
|
|
||||||
|
|
||||||
# Item Label
|
# Item Label
|
||||||
self.editName = QLineEdit()
|
self.editName = QLineEdit()
|
||||||
@@ -66,7 +68,7 @@ class GuiItemEditor(QDialog):
|
|||||||
|
|
||||||
# Item Status
|
# Item Status
|
||||||
self.editStatus = QComboBox()
|
self.editStatus = QComboBox()
|
||||||
if self.theItem.itemClass == nwItemClass.NOVEL:
|
if self.theItem.itemClass in nwLists.CLS_NOVEL:
|
||||||
for sLabel, _, _ 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
|
||||||
@@ -81,7 +83,7 @@ class GuiItemEditor(QDialog):
|
|||||||
self.editLayout = QComboBox()
|
self.editLayout = QComboBox()
|
||||||
self.validLayouts = []
|
self.validLayouts = []
|
||||||
if self.theItem.itemType == nwItemType.FILE:
|
if self.theItem.itemType == nwItemType.FILE:
|
||||||
if self.theItem.itemClass == nwItemClass.NOVEL:
|
if self.theItem.itemClass in nwLists.CLS_NOVEL:
|
||||||
self.validLayouts.append(nwItemLayout.TITLE)
|
self.validLayouts.append(nwItemLayout.TITLE)
|
||||||
self.validLayouts.append(nwItemLayout.BOOK)
|
self.validLayouts.append(nwItemLayout.BOOK)
|
||||||
self.validLayouts.append(nwItemLayout.PAGE)
|
self.validLayouts.append(nwItemLayout.PAGE)
|
||||||
@@ -109,20 +111,27 @@ class GuiItemEditor(QDialog):
|
|||||||
self.editExport.setEnabled(False)
|
self.editExport.setEnabled(False)
|
||||||
self.editExport.setChecked(False)
|
self.editExport.setChecked(False)
|
||||||
|
|
||||||
self.editName.setText(self.theItem.itemName)
|
|
||||||
statusIdx = self.editStatus.findData(self.theItem.itemStatus)
|
|
||||||
if statusIdx != -1:
|
|
||||||
self.editStatus.setCurrentIndex(statusIdx)
|
|
||||||
layoutIdx = self.editLayout.findData(self.theItem.itemLayout)
|
|
||||||
if layoutIdx != -1:
|
|
||||||
self.editLayout.setCurrentIndex(layoutIdx)
|
|
||||||
|
|
||||||
# Buttons
|
# Buttons
|
||||||
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
|
||||||
self.buttonBox.accepted.connect(self._doSave)
|
self.buttonBox.accepted.connect(self._doSave)
|
||||||
self.buttonBox.rejected.connect(self._doClose)
|
self.buttonBox.rejected.connect(self._doClose)
|
||||||
|
|
||||||
# Assemble
|
# Set Current Values
|
||||||
|
self.editName.setText(self.theItem.itemName)
|
||||||
|
self.editName.selectAll()
|
||||||
|
|
||||||
|
statusIdx = self.editStatus.findData(self.theItem.itemStatus)
|
||||||
|
if statusIdx != -1:
|
||||||
|
self.editStatus.setCurrentIndex(statusIdx)
|
||||||
|
|
||||||
|
layoutIdx = self.editLayout.findData(self.theItem.itemLayout)
|
||||||
|
if layoutIdx != -1:
|
||||||
|
self.editLayout.setCurrentIndex(layoutIdx)
|
||||||
|
|
||||||
|
##
|
||||||
|
# Assemble
|
||||||
|
##
|
||||||
|
|
||||||
self.mainForm = QGridLayout()
|
self.mainForm = QGridLayout()
|
||||||
self.mainForm.setVerticalSpacing(self.mainConf.pxInt(4))
|
self.mainForm.setVerticalSpacing(self.mainConf.pxInt(4))
|
||||||
self.mainForm.setHorizontalSpacing(self.mainConf.pxInt(16))
|
self.mainForm.setHorizontalSpacing(self.mainConf.pxInt(16))
|
||||||
@@ -135,6 +144,7 @@ class GuiItemEditor(QDialog):
|
|||||||
self.mainForm.addWidget(self.textExport, 3, 0, 1, 2)
|
self.mainForm.addWidget(self.textExport, 3, 0, 1, 2)
|
||||||
self.mainForm.addWidget(self.editExport, 3, 2, 1, 1)
|
self.mainForm.addWidget(self.editExport, 3, 2, 1, 1)
|
||||||
|
|
||||||
|
self.outerBox = QVBoxLayout()
|
||||||
self.outerBox.setSpacing(self.mainConf.pxInt(16))
|
self.outerBox.setSpacing(self.mainConf.pxInt(16))
|
||||||
self.outerBox.addLayout(self.mainForm)
|
self.outerBox.addLayout(self.mainForm)
|
||||||
self.outerBox.addStretch(1)
|
self.outerBox.addStretch(1)
|
||||||
@@ -142,12 +152,16 @@ class GuiItemEditor(QDialog):
|
|||||||
self.setLayout(self.outerBox)
|
self.setLayout(self.outerBox)
|
||||||
|
|
||||||
self.rejected.connect(self._doClose)
|
self.rejected.connect(self._doClose)
|
||||||
self.editName.selectAll()
|
|
||||||
|
|
||||||
logger.debug("GuiItemEditor initialisation complete")
|
logger.debug("GuiItemEditor initialisation complete")
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
##
|
||||||
|
# Slots
|
||||||
|
##
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doSave(self):
|
def _doSave(self):
|
||||||
"""Save the setting to the item.
|
"""Save the setting to the item.
|
||||||
"""
|
"""
|
||||||
@@ -170,10 +184,11 @@ class GuiItemEditor(QDialog):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _doClose(self):
|
def _doClose(self):
|
||||||
"""Close the dialog without saving the settings.
|
"""Close the dialog without saving the settings.
|
||||||
"""
|
"""
|
||||||
logger.verbose("ItemEditor close button clicked")
|
logger.verbose("ItemEditor cancel button clicked")
|
||||||
self.close()
|
self.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
+7
-13
@@ -535,36 +535,30 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
def setTreeItemValues(self, tHandle):
|
def setTreeItemValues(self, tHandle):
|
||||||
"""Set the name and flag values for a tree item.
|
"""Set the name and flag values for a tree item.
|
||||||
"""
|
"""
|
||||||
trItem = self._getTreeItem(tHandle)
|
trItem = self._getTreeItem(tHandle)
|
||||||
nwItem = self.theProject.projTree[tHandle]
|
nwItem = self.theProject.projTree[tHandle]
|
||||||
tName = nwItem.itemName
|
|
||||||
tClass = nwItem.itemClass
|
|
||||||
tHandle = nwItem.itemHandle
|
|
||||||
|
|
||||||
expIcon = QIcon()
|
expIcon = QIcon()
|
||||||
|
stFlags = nwLabels.CLASS_FLAG[nwItem.itemClass]
|
||||||
stClass = nwLabels.CLASS_FLAG[nwItem.itemClass]
|
|
||||||
stLayout = ""
|
|
||||||
if nwItem.itemType == nwItemType.FILE:
|
if nwItem.itemType == nwItemType.FILE:
|
||||||
stLayout = "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout]
|
stFlags += "."+nwLabels.LAYOUT_FLAG[nwItem.itemLayout]
|
||||||
if nwItem.isExported:
|
if nwItem.isExported:
|
||||||
expIcon = self.theTheme.getIcon("check")
|
expIcon = self.theTheme.getIcon("check")
|
||||||
else:
|
else:
|
||||||
expIcon = self.theTheme.getIcon("cross")
|
expIcon = self.theTheme.getIcon("cross")
|
||||||
tStatus = stClass+stLayout
|
|
||||||
|
|
||||||
iStatus = nwItem.itemStatus
|
iStatus = nwItem.itemStatus
|
||||||
if tClass == nwItemClass.NOVEL:
|
if nwItem.itemClass == nwItemClass.NOVEL:
|
||||||
iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's valid
|
iStatus = self.theProject.statusItems.checkEntry(iStatus) # Make sure it's valid
|
||||||
flagIcon = self.theParent.statusIcons[iStatus]
|
flagIcon = self.theParent.statusIcons[iStatus]
|
||||||
else:
|
else:
|
||||||
iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's valid
|
iStatus = self.theProject.importItems.checkEntry(iStatus) # Make sure it's valid
|
||||||
flagIcon = self.theParent.importIcons[iStatus]
|
flagIcon = self.theParent.importIcons[iStatus]
|
||||||
|
|
||||||
trItem.setText(self.C_NAME, tName)
|
trItem.setText(self.C_NAME, nwItem.itemName)
|
||||||
trItem.setIcon(self.C_EXPORT, expIcon)
|
trItem.setIcon(self.C_EXPORT, expIcon)
|
||||||
trItem.setText(self.C_FLAGS, tStatus)
|
|
||||||
trItem.setIcon(self.C_FLAGS, flagIcon)
|
trItem.setIcon(self.C_FLAGS, flagIcon)
|
||||||
|
trItem.setText(self.C_FLAGS, stFlags)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user