forked from openlp/openlp
Finish tagging the songs
This commit is contained in:
parent
d86f0285c9
commit
0dfda8ff27
@ -47,6 +47,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
"""
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.parent = parent
|
||||
#can this be automated?
|
||||
self.width = 400
|
||||
self.setupUi(self)
|
||||
# Connecting signals and slots
|
||||
QtCore.QObject.connect(self.AuthorAddButton,
|
||||
@ -182,7 +184,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.CommentsEdit.setText(u'')
|
||||
self.CCLNumberEdit.setText(u'')
|
||||
self.VerseListWidget.clear()
|
||||
self.VerseListWidget.serRowCount(0)
|
||||
self.VerseListWidget.setRowCount(0)
|
||||
self.AuthorsListView.clear()
|
||||
self.TopicsListView.clear()
|
||||
self.TitleEditItem.setFocus(QtCore.Qt.OtherFocusReason)
|
||||
@ -240,9 +242,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
#lazy xml migration for now
|
||||
self.VerseListWidget.clear()
|
||||
self.VerseListWidget.setRowCount(0)
|
||||
#can this be automated?
|
||||
self.VerseListWidget.setColumnWidth(0, 400)
|
||||
rowLabel = []
|
||||
self.VerseListWidget.setColumnWidth(0, self.width)
|
||||
if self.song.lyrics.startswith(u'<?xml version='):
|
||||
songXML = SongXMLParser(self.song.lyrics)
|
||||
verseList = songXML.get_verses()
|
||||
@ -250,12 +250,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.VerseListWidget.setRowCount(
|
||||
self.VerseListWidget.rowCount() + 1)
|
||||
variant = u'%s:%s' % (verse[0][u'type'], verse[0][u'label'])
|
||||
rowTag = u'%s\n%s' % (verse[0][u'type'][0:1], verse[0][u'label'])
|
||||
rowLabel.append(rowTag)
|
||||
item = QtGui.QTableWidgetItem(verse[1])
|
||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
|
||||
self.VerseListWidget.setItem(count, 0, item)
|
||||
self.VerseListWidget.setVerticalHeaderLabels(rowLabel)
|
||||
else:
|
||||
verses = self.song.lyrics.split(u'\n\n')
|
||||
for count, verse in enumerate(verses):
|
||||
@ -266,6 +263,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
|
||||
self.VerseListWidget.setItem(count, 0, item)
|
||||
self.VerseListWidget.resizeRowsToContents()
|
||||
self.tagRows()
|
||||
# clear the results
|
||||
self.AuthorsListView.clear()
|
||||
for author in self.song.authors:
|
||||
@ -285,6 +283,20 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
if preview:
|
||||
self.previewButton.setVisible(True)
|
||||
|
||||
def tagRows(self):
|
||||
"""
|
||||
Tag the Song List rows based on the verse list
|
||||
"""
|
||||
rowLabel = []
|
||||
for row in range(0, self.VerseListWidget.rowCount()):
|
||||
item = self.VerseListWidget.item(row, 0)
|
||||
data = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
||||
bit = data.split(u':')
|
||||
rowTag = u'%s\n%s' % (bit[0][0:1], bit[1])
|
||||
rowLabel.append(rowTag)
|
||||
self.VerseListWidget.setVerticalHeaderLabels(rowLabel)
|
||||
|
||||
|
||||
def onAuthorAddButtonClicked(self):
|
||||
item = int(self.AuthorsSelectionComboItem.currentIndex())
|
||||
if item > -1:
|
||||
@ -294,7 +306,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
author_item = QtGui.QListWidgetItem(unicode(author.display_name))
|
||||
author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id))
|
||||
self.AuthorsListView.addItem(author_item)
|
||||
self.VerseListWidget.resizeRowsToContents()
|
||||
|
||||
def onAuthorsListViewPressed(self):
|
||||
if self.AuthorsListView.count() > 1:
|
||||
@ -352,16 +363,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.VerseDeleteButton.setEnabled(True)
|
||||
|
||||
def onVerseAddButtonClicked(self):
|
||||
self.verse_form.setVerse(u'', self.VerseListWidget.count() + 1, True)
|
||||
self.verse_form.setVerse(u'', self.VerseListWidget.rowCount() + 1, True)
|
||||
if self.verse_form.exec_():
|
||||
afterText, verse, subVerse = self.verse_form.getVerse()
|
||||
data = u'%s:%s' % (verse, subVerse)
|
||||
item = QtGui.QListWidgetItem(afterText)
|
||||
item = QtGui.QTableWidgetItem(afterText)
|
||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
|
||||
item.setText(afterText)
|
||||
self.VerseListWidget.setRowCount(
|
||||
self.VerseListWidget.rowCount() + 1)
|
||||
self.VerseListWidget.setItem(count, 0, item)
|
||||
self.VerseListWidget.setItem(int(self.VerseListWidget.rowCount() - 1), 0, item)
|
||||
self.VerseListWidget.setColumnWidth(0, self.width)
|
||||
self.VerseListWidget.resizeRowsToContents()
|
||||
self.tagRows()
|
||||
|
||||
def onVerseEditButtonClicked(self):
|
||||
item = self.VerseListWidget.currentItem()
|
||||
@ -379,18 +393,20 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
if len(tempText.split(u'\n')) != len(afterText.split(u'\n')):
|
||||
tempList = {}
|
||||
tempId = {}
|
||||
for row in range(0, self.VerseListWidget.count()):
|
||||
tempList[row] = self.VerseListWidget.item(row).text()
|
||||
tempId[row] = self.VerseListWidget.item(row).\
|
||||
for row in range(0, self.VerseListWidget.rowCount()):
|
||||
tempList[row] = self.VerseListWidget.item(row, 0).text()
|
||||
tempId[row] = self.VerseListWidget.item(row, 0).\
|
||||
data(QtCore.Qt.UserRole)
|
||||
self.VerseListWidget.clear()
|
||||
for row in range (0, len(tempList)):
|
||||
item = QtGui.QListWidgetItem(tempList[row])
|
||||
item = QtGui.QTableWidgetItem(tempList[row], 0)
|
||||
item.setData(QtCore.Qt.UserRole, tempId[row])
|
||||
self.VerseListWidget.addItem(item)
|
||||
self.VerseListWidget.setItem(row, 0, item)
|
||||
self.VerseListWidget.resizeRowsToContents()
|
||||
self.VerseListWidget.repaint()
|
||||
self.VerseEditButton.setEnabled(False)
|
||||
self.VerseDeleteButton.setEnabled(False)
|
||||
self.tagRows()
|
||||
|
||||
def onVerseEditAllButtonClicked(self):
|
||||
verse_list = u''
|
||||
@ -408,7 +424,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
verse_list = self.verse_form.getVerseAll()
|
||||
verse_list = unicode(verse_list.replace(u'\r\n', u'\n'))
|
||||
self.VerseListWidget.clear()
|
||||
listRow = 0
|
||||
self.VerseListWidget.setRowCount(0)
|
||||
for row in self.findVerseSplit.split(verse_list):
|
||||
for match in row.split(u'---['):
|
||||
for count, parts in enumerate(match.split(u']---\n')):
|
||||
@ -420,15 +436,20 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
else:
|
||||
if parts.endswith(u'\n'):
|
||||
parts = parts.rstrip(u'\n')
|
||||
item = QtGui.QListWidgetItem(parts)
|
||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
|
||||
self.VerseListWidget.setItem(listRow, 0, item)
|
||||
self.VerseListWidget.repaint()
|
||||
item = QtGui.QTableWidgetItem(parts)
|
||||
item.setData(
|
||||
QtCore.Qt.UserRole, QtCore.QVariant(variant))
|
||||
self.VerseListWidget.setRowCount(
|
||||
self.VerseListWidget.rowCount() + 1)
|
||||
self.VerseListWidget.setItem(
|
||||
int(self.VerseListWidget.rowCount() - 1), 0, item)
|
||||
self.VerseListWidget.setColumnWidth(0, self.width)
|
||||
self.VerseListWidget.resizeRowsToContents()
|
||||
self.VerseListWidget.repaint()
|
||||
self.tagRows()
|
||||
|
||||
def onVerseDeleteButtonClicked(self):
|
||||
self.VerseListWidget.takeItem(self.VerseListWidget.currentRow(), 0)
|
||||
self.VerseListWidget.setRowCount(
|
||||
self.VerseListWidget.rowCount() - 1)
|
||||
self.VerseListWidget.removeRow(self.VerseListWidget.currentRow())
|
||||
self.VerseEditButton.setEnabled(False)
|
||||
self.VerseDeleteButton.setEnabled(False)
|
||||
|
||||
@ -448,7 +469,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.VerseListWidget.setFocus()
|
||||
return False, self.trUtf8('You need to enter some verses.')
|
||||
if self.AuthorsListView.count() == 0:
|
||||
self.SongTabWidget.setCurrentIndex(2)
|
||||
self.SongTabWidget.setCurrentIndex(1)
|
||||
self.AuthorsListView.setFocus()
|
||||
#split the verse list by space and mark lower case for testing
|
||||
taglist = unicode(self.trUtf8(' bitped'))
|
||||
@ -501,6 +522,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.loadTopics()
|
||||
|
||||
def onPreview(self, button):
|
||||
"""
|
||||
Save and Preview button pressed.
|
||||
The Song is valid so as the plugin to add it to preview to see.
|
||||
"""
|
||||
log.debug(u'onPreview')
|
||||
if button.text() == unicode(self.trUtf8('Save && Preview')) \
|
||||
and self.saveSong():
|
||||
@ -543,11 +568,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
sxml.add_lyrics_to_song()
|
||||
text = u' '
|
||||
for i in range (0, self.VerseListWidget.rowCount()):
|
||||
item = self.VerseListWidget.item(i)
|
||||
item = self.VerseListWidget.item(i, 0)
|
||||
verseId = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
||||
bits = verseId.split(u':')
|
||||
sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text()))
|
||||
text = text + unicode(self.VerseListWidget.item(i).text()) + u' '
|
||||
text = text + unicode(self.VerseListWidget.item(i, 0).text()) + u' '
|
||||
text = text.replace(u'\'', u'')
|
||||
text = text.replace(u',', u'')
|
||||
text = text.replace(u';', u'')
|
||||
|
Loading…
Reference in New Issue
Block a user