2 Commits

  1. 60
      gui.py

60
gui.py

@ -181,6 +181,9 @@ class DocumentWindow(QMainWindow):
self.window.sectionTableView.clicked.connect(self.sectionClickedAction) self.window.sectionTableView.clicked.connect(self.sectionClickedAction)
self.window.blockTableView.clicked.connect(self.blockClickedAction) self.window.blockTableView.clicked.connect(self.blockClickedAction)
# Set the tab widget to Overview tab
self.window.tabWidget.setCurrentIndex(0)
def UIInitDocument(self): def UIInitDocument(self):
""" """
Fills the window's fields with the values from its document. Fills the window's fields with the values from its document.
@ -509,12 +512,12 @@ class DocumentWindow(QMainWindow):
self.window.chordTableView.populate(self.doc.chordList) self.window.chordTableView.populate(self.doc.chordList)
# remove the chord if any of the blocks have it attached # remove the chord if any of the blocks have it attached
for s in self.doc.sectionList:
for b in s.blockList:
if b.chord:
if b.chord.name == oldName:
b.chord = None
if self.currentSection.blockList is not None:
if self.currentSection is not None:
for s in self.doc.sectionList:
for b in s.blockList:
if b.chord:
if b.chord.name == oldName:
b.chord = None
self.window.blockTableView.populate(self.currentSection.blockList) self.window.blockTableView.populate(self.currentSection.blockList)
self.clearChordLineEdits() self.clearChordLineEdits()
self.updateChordDict() self.updateChordDict()
@ -755,19 +758,21 @@ class DocumentWindow(QMainWindow):
""" """
Update the block list by reading the table. Update the block list by reading the table.
""" """
blockTableList = []
for i in range(self.window.blockTableView.model.rowCount()):
blockLength = float(
self.window.blockTableView.model.item(i, 1).text())
blockChord = self.chordDict[(self.window.blockTableView.model.item(
i, 0).text() if self.window.blockTableView.model.item(i, 0).text() else "None")]
blockNotes = self.window.blockTableView.model.item(i, 2).text(
) if self.window.blockTableView.model.item(i, 2).text() else None
blockTableList.append(
Block(blockLength, chord=blockChord, notes=blockNotes))
section.blockList = blockTableList
if section is None:
BlockMustHaveSectionWarningMessageBox().exec()
else:
blockTableList = []
for i in range(self.window.blockTableView.model.rowCount()):
blockLength = float(
self.window.blockTableView.model.item(i, 1).text())
blockChord = self.chordDict[(self.window.blockTableView.model.item(
i, 0).text() if self.window.blockTableView.model.item(i, 0).text() else "None")]
blockNotes = self.window.blockTableView.model.item(i, 2).text(
) if self.window.blockTableView.model.item(i, 2).text() else None
blockTableList.append(
Block(blockLength, chord=blockChord, notes=blockNotes))
section.blockList = blockTableList
def updateDocument(self): def updateDocument(self):
""" """
@ -947,6 +952,23 @@ class SectionNameWarningMessageBox(QMessageBox):
self.setDefaultButton(QMessageBox.Ok) self.setDefaultButton(QMessageBox.Ok)
class BlockMustHaveSectionWarningMessageBox(QMessageBox):
"""
Message box to warn the user that a block must belong to a section
"""
def __init__(self):
super().__init__()
self.setIcon(QMessageBox.Warning)
self.setWindowTitle("No sections found")
self.setText("Each block must belong to a section, but no sections have yet been created.")
self.setInformativeText(
"Please create a section before adding blocks.")
self.setStandardButtons(QMessageBox.Ok)
self.setDefaultButton(QMessageBox.Ok)
class VoicingWarningMessageBox(QMessageBox): class VoicingWarningMessageBox(QMessageBox):
""" """
Message box to warn the user that the voicing entered could not be parsed Message box to warn the user that the voicing entered could not be parsed

Loading…
Cancel
Save