Finished the edit item dialog and now updating tree and project settings.

This commit is contained in:
Veronica K. B. Olsen
2019-04-28 13:17:24 +02:00
parent e00b3b4c20
commit af9aa08fe6
8 changed files with 146 additions and 79 deletions
+47 -11
View File
@@ -15,9 +15,12 @@ import nw
from os import path
from PyQt5.QtWidgets import QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout, QLineEdit, QPushButton
from PyQt5.QtWidgets import QDialog, QHBoxLayout, QVBoxLayout, QGroupBox, QFormLayout, QLineEdit, QPushButton, QComboBox
from PyQt5.QtSvg import QSvgWidget
from nw.enum import nwItemLayout, nwItemClass, nwItemType
from nw.constants import nwLabels
logger = logging.getLogger(__name__)
class GuiItemEditor(QDialog):
@@ -47,16 +50,46 @@ class GuiItemEditor(QDialog):
self.mainForm = QFormLayout()
self.editName = QLineEdit()
self.editStatus = QLineEdit()
self.editLayout = QLineEdit()
self.editStatus = QComboBox()
self.editLayout = QComboBox()
for n in range(len(self.theProject.statusLabels)):
self.editStatus.addItem(
self.theProject.statusIcons[n], self.theProject.statusLabels[n], n
)
self.validLayouts = []
if self.theItem.itemType == nwItemType.FILE:
if self.theItem.itemClass == nwItemClass.NOVEL:
self.validLayouts.append(nwItemLayout.TITLE)
self.validLayouts.append(nwItemLayout.BOOK)
self.validLayouts.append(nwItemLayout.PAGE)
self.validLayouts.append(nwItemLayout.PARTITION)
self.validLayouts.append(nwItemLayout.UNNUMBERED)
self.validLayouts.append(nwItemLayout.CHAPTER)
self.validLayouts.append(nwItemLayout.SCENE)
else:
self.validLayouts.append(nwItemLayout.NOTE)
else:
self.validLayouts.append(nwItemLayout.NO_LAYOUT)
for itemLayout in nwItemLayout:
if itemLayout in self.validLayouts:
self.editLayout.addItem(nwLabels.LAYOUT_NAME[itemLayout],itemLayout)
self.mainForm.addRow("Name", self.editName)
self.mainForm.addRow("Status", self.editStatus)
self.mainForm.addRow("Layout", self.editLayout)
self.editName.setMinimumWidth(200)
self.editName.setText(self.theItem.itemName)
self.editStatus.setText(str(self.theItem.itemStatus))
self.editLayout.setText(str(self.theItem.itemLayout))
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)
self.buttonBox = QHBoxLayout()
self.closeButton = QPushButton("Close")
@@ -79,16 +112,19 @@ class GuiItemEditor(QDialog):
def _doSave(self):
logger.verbose("ItemEditor save button clicked")
# projName = self.editName.text()
# bookTitle = self.editTitle.text()
# bookAuthors = self.editAuthors.toPlainText()
# self.theProject.setProjectName(projName)
# self.theProject.setBookTitle(bookTitle)
# self.theProject.setBookAuthors(bookAuthors)
itemName = self.editName.text()
itemStatus = self.editStatus.currentData()
itemLayout = self.editLayout.currentData()
self.theItem.setName(itemName)
self.theItem.setStatus(itemStatus)
self.theItem.setLayout(itemLayout)
self.accept()
self.close()
return
def _doClose(self):
logger.verbose("ItemEditor close button clicked")
self.reject()
self.close()
return