forked from openlp/openlp
Verse editor cleanups
bzr-revno: 820
This commit is contained in:
commit
4e5abf5802
@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
@ -155,7 +155,6 @@ class SlideController(QtGui.QWidget):
|
|||||||
self.PreviewListWidget = SlideList(self)
|
self.PreviewListWidget = SlideList(self)
|
||||||
self.PreviewListWidget.setColumnCount(1)
|
self.PreviewListWidget.setColumnCount(1)
|
||||||
self.PreviewListWidget.horizontalHeader().setVisible(False)
|
self.PreviewListWidget.horizontalHeader().setVisible(False)
|
||||||
#self.PreviewListWidget.verticalHeader().setVisible(False)
|
|
||||||
self.PreviewListWidget.setColumnWidth(
|
self.PreviewListWidget.setColumnWidth(
|
||||||
0, self.Controller.width())
|
0, self.Controller.width())
|
||||||
self.PreviewListWidget.isLive = self.isLive
|
self.PreviewListWidget.isLive = self.isLive
|
||||||
|
@ -70,8 +70,12 @@ class Ui_EditSongDialog(object):
|
|||||||
QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
|
QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
|
||||||
self.LyricsLabel.setObjectName(u'LyricsLabel')
|
self.LyricsLabel.setObjectName(u'LyricsLabel')
|
||||||
self.LyricsTabLayout.addWidget(self.LyricsLabel, 2, 0, 1, 1)
|
self.LyricsTabLayout.addWidget(self.LyricsLabel, 2, 0, 1, 1)
|
||||||
self.VerseListWidget = QtGui.QListWidget(self.LyricsTab)
|
self.VerseListWidget = QtGui.QTableWidget(self.LyricsTab)
|
||||||
self.VerseListWidget.setSpacing(2)
|
self.VerseListWidget.setColumnCount(1)
|
||||||
|
self.VerseListWidget.horizontalHeader().setVisible(False)
|
||||||
|
self.VerseListWidget.setSelectionBehavior(1)
|
||||||
|
self.VerseListWidget.setEditTriggers(
|
||||||
|
QtGui.QAbstractItemView.NoEditTriggers)
|
||||||
self.VerseListWidget.setAlternatingRowColors(True)
|
self.VerseListWidget.setAlternatingRowColors(True)
|
||||||
self.VerseListWidget.setObjectName(u'VerseListWidget')
|
self.VerseListWidget.setObjectName(u'VerseListWidget')
|
||||||
self.LyricsTabLayout.addWidget(self.VerseListWidget, 2, 1, 1, 1)
|
self.LyricsTabLayout.addWidget(self.VerseListWidget, 2, 1, 1, 1)
|
||||||
|
@ -47,6 +47,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
"""
|
"""
|
||||||
QtGui.QDialog.__init__(self, parent)
|
QtGui.QDialog.__init__(self, parent)
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
|
#can this be automated?
|
||||||
|
self.width = 400
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
# Connecting signals and slots
|
# Connecting signals and slots
|
||||||
QtCore.QObject.connect(self.AuthorAddButton,
|
QtCore.QObject.connect(self.AuthorAddButton,
|
||||||
@ -77,7 +79,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
QtCore.QObject.connect(self.VerseDeleteButton,
|
QtCore.QObject.connect(self.VerseDeleteButton,
|
||||||
QtCore.SIGNAL(u'clicked()'), self.onVerseDeleteButtonClicked)
|
QtCore.SIGNAL(u'clicked()'), self.onVerseDeleteButtonClicked)
|
||||||
QtCore.QObject.connect(self.VerseListWidget,
|
QtCore.QObject.connect(self.VerseListWidget,
|
||||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'),
|
||||||
self.onVerseListViewPressed)
|
self.onVerseListViewPressed)
|
||||||
QtCore.QObject.connect(self.SongbookCombo,
|
QtCore.QObject.connect(self.SongbookCombo,
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onSongBookComboChanged)
|
QtCore.SIGNAL(u'activated(int)'), self.onSongBookComboChanged)
|
||||||
@ -182,6 +184,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.CommentsEdit.setText(u'')
|
self.CommentsEdit.setText(u'')
|
||||||
self.CCLNumberEdit.setText(u'')
|
self.CCLNumberEdit.setText(u'')
|
||||||
self.VerseListWidget.clear()
|
self.VerseListWidget.clear()
|
||||||
|
self.VerseListWidget.setRowCount(0)
|
||||||
self.AuthorsListView.clear()
|
self.AuthorsListView.clear()
|
||||||
self.TopicsListView.clear()
|
self.TopicsListView.clear()
|
||||||
self.TitleEditItem.setFocus(QtCore.Qt.OtherFocusReason)
|
self.TitleEditItem.setFocus(QtCore.Qt.OtherFocusReason)
|
||||||
@ -223,6 +226,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
else:
|
else:
|
||||||
self.CopyrightEditItem.setText(u'')
|
self.CopyrightEditItem.setText(u'')
|
||||||
self.VerseListWidget.clear()
|
self.VerseListWidget.clear()
|
||||||
|
self.VerseListWidget.setRowCount(0)
|
||||||
if self.song.verse_order:
|
if self.song.verse_order:
|
||||||
self.VerseOrderEdit.setText(self.song.verse_order)
|
self.VerseOrderEdit.setText(self.song.verse_order)
|
||||||
else:
|
else:
|
||||||
@ -236,21 +240,30 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
else:
|
else:
|
||||||
self.CCLNumberEdit.setText(u'')
|
self.CCLNumberEdit.setText(u'')
|
||||||
#lazy xml migration for now
|
#lazy xml migration for now
|
||||||
|
self.VerseListWidget.clear()
|
||||||
|
self.VerseListWidget.setRowCount(0)
|
||||||
|
self.VerseListWidget.setColumnWidth(0, self.width)
|
||||||
if self.song.lyrics.startswith(u'<?xml version='):
|
if self.song.lyrics.startswith(u'<?xml version='):
|
||||||
songXML = SongXMLParser(self.song.lyrics)
|
songXML = SongXMLParser(self.song.lyrics)
|
||||||
verseList = songXML.get_verses()
|
verseList = songXML.get_verses()
|
||||||
for verse in verseList:
|
for count, verse in enumerate(verseList):
|
||||||
|
self.VerseListWidget.setRowCount(
|
||||||
|
self.VerseListWidget.rowCount() + 1)
|
||||||
variant = u'%s:%s' % (verse[0][u'type'], verse[0][u'label'])
|
variant = u'%s:%s' % (verse[0][u'type'], verse[0][u'label'])
|
||||||
item = QtGui.QListWidgetItem(verse[1])
|
item = QtGui.QTableWidgetItem(verse[1])
|
||||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
|
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
|
||||||
self.VerseListWidget.addItem(item)
|
self.VerseListWidget.setItem(count, 0, item)
|
||||||
else:
|
else:
|
||||||
verses = self.song.lyrics.split(u'\n\n')
|
verses = self.song.lyrics.split(u'\n\n')
|
||||||
for count, verse in enumerate(verses):
|
for count, verse in enumerate(verses):
|
||||||
item = QtGui.QListWidgetItem(verse)
|
self.VerseListWidget.setRowCount(
|
||||||
|
self.VerseListWidget.rowCount() + 1)
|
||||||
|
item = QtGui.QTableWidgetItem(verse)
|
||||||
variant = u'Verse:%s' % unicode(count + 1)
|
variant = u'Verse:%s' % unicode(count + 1)
|
||||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
|
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
|
||||||
self.VerseListWidget.addItem(item)
|
self.VerseListWidget.setItem(count, 0, item)
|
||||||
|
self.VerseListWidget.resizeRowsToContents()
|
||||||
|
self.tagRows()
|
||||||
# clear the results
|
# clear the results
|
||||||
self.AuthorsListView.clear()
|
self.AuthorsListView.clear()
|
||||||
for author in self.song.authors:
|
for author in self.song.authors:
|
||||||
@ -270,6 +283,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
if preview:
|
if preview:
|
||||||
self.previewButton.setVisible(True)
|
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):
|
def onAuthorAddButtonClicked(self):
|
||||||
item = int(self.AuthorsSelectionComboItem.currentIndex())
|
item = int(self.AuthorsSelectionComboItem.currentIndex())
|
||||||
if item > -1:
|
if item > -1:
|
||||||
@ -340,10 +366,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
if self.verse_form.exec_():
|
if self.verse_form.exec_():
|
||||||
afterText, verse, subVerse = self.verse_form.getVerse()
|
afterText, verse, subVerse = self.verse_form.getVerse()
|
||||||
data = u'%s:%s' % (verse, subVerse)
|
data = u'%s:%s' % (verse, subVerse)
|
||||||
item = QtGui.QListWidgetItem(afterText)
|
item = QtGui.QTableWidgetItem(afterText)
|
||||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
|
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
|
||||||
item.setText(afterText)
|
item.setText(afterText)
|
||||||
self.VerseListWidget.addItem(item)
|
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.tagRows()
|
||||||
|
|
||||||
def onVerseEditButtonClicked(self):
|
def onVerseEditButtonClicked(self):
|
||||||
item = self.VerseListWidget.currentItem()
|
item = self.VerseListWidget.currentItem()
|
||||||
@ -360,24 +391,26 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
if len(tempText.split(u'\n')) != len(afterText.split(u'\n')):
|
if len(tempText.split(u'\n')) != len(afterText.split(u'\n')):
|
||||||
tempList = {}
|
tempList = {}
|
||||||
tempId = {}
|
tempId = {}
|
||||||
for row in range(0, self.VerseListWidget.count()):
|
for row in range(0, self.VerseListWidget.rowCount()):
|
||||||
tempList[row] = self.VerseListWidget.item(row).text()
|
tempList[row] = self.VerseListWidget.item(row, 0).text()
|
||||||
tempId[row] = self.VerseListWidget.item(row).\
|
tempId[row] = self.VerseListWidget.item(row, 0).\
|
||||||
data(QtCore.Qt.UserRole)
|
data(QtCore.Qt.UserRole)
|
||||||
self.VerseListWidget.clear()
|
self.VerseListWidget.clear()
|
||||||
for row in range (0, len(tempList)):
|
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])
|
item.setData(QtCore.Qt.UserRole, tempId[row])
|
||||||
self.VerseListWidget.addItem(item)
|
self.VerseListWidget.setItem(row, 0, item)
|
||||||
|
self.VerseListWidget.resizeRowsToContents()
|
||||||
self.VerseListWidget.repaint()
|
self.VerseListWidget.repaint()
|
||||||
self.VerseEditButton.setEnabled(False)
|
self.VerseEditButton.setEnabled(False)
|
||||||
self.VerseDeleteButton.setEnabled(False)
|
self.VerseDeleteButton.setEnabled(False)
|
||||||
|
self.tagRows()
|
||||||
|
|
||||||
def onVerseEditAllButtonClicked(self):
|
def onVerseEditAllButtonClicked(self):
|
||||||
verse_list = u''
|
verse_list = u''
|
||||||
if self.VerseListWidget.count() > 0:
|
if self.VerseListWidget.rowCount() > 0:
|
||||||
for row in range(0, self.VerseListWidget.count()):
|
for row in range(0, self.VerseListWidget.rowCount()):
|
||||||
item = self.VerseListWidget.item(row)
|
item = self.VerseListWidget.item(row, 0)
|
||||||
field = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
field = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
||||||
verse_list += u'---[%s]---\n' % field
|
verse_list += u'---[%s]---\n' % field
|
||||||
verse_list += item.text()
|
verse_list += item.text()
|
||||||
@ -389,6 +422,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
verse_list = self.verse_form.getVerseAll()
|
verse_list = self.verse_form.getVerseAll()
|
||||||
verse_list = unicode(verse_list.replace(u'\r\n', u'\n'))
|
verse_list = unicode(verse_list.replace(u'\r\n', u'\n'))
|
||||||
self.VerseListWidget.clear()
|
self.VerseListWidget.clear()
|
||||||
|
self.VerseListWidget.setRowCount(0)
|
||||||
for row in self.findVerseSplit.split(verse_list):
|
for row in self.findVerseSplit.split(verse_list):
|
||||||
for match in row.split(u'---['):
|
for match in row.split(u'---['):
|
||||||
for count, parts in enumerate(match.split(u']---\n')):
|
for count, parts in enumerate(match.split(u']---\n')):
|
||||||
@ -400,13 +434,20 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
else:
|
else:
|
||||||
if parts.endswith(u'\n'):
|
if parts.endswith(u'\n'):
|
||||||
parts = parts.rstrip(u'\n')
|
parts = parts.rstrip(u'\n')
|
||||||
item = QtGui.QListWidgetItem(parts)
|
item = QtGui.QTableWidgetItem(parts)
|
||||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
|
item.setData(
|
||||||
self.VerseListWidget.addItem(item)
|
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.VerseListWidget.repaint()
|
||||||
|
self.tagRows()
|
||||||
|
|
||||||
def onVerseDeleteButtonClicked(self):
|
def onVerseDeleteButtonClicked(self):
|
||||||
self.VerseListWidget.takeItem(self.VerseListWidget.currentRow())
|
self.VerseListWidget.removeRow(self.VerseListWidget.currentRow())
|
||||||
self.VerseEditButton.setEnabled(False)
|
self.VerseEditButton.setEnabled(False)
|
||||||
self.VerseDeleteButton.setEnabled(False)
|
self.VerseDeleteButton.setEnabled(False)
|
||||||
|
|
||||||
@ -421,12 +462,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.SongTabWidget.setCurrentIndex(0)
|
self.SongTabWidget.setCurrentIndex(0)
|
||||||
self.TitleEditItem.setFocus()
|
self.TitleEditItem.setFocus()
|
||||||
return False, self.trUtf8('You need to enter a song title.')
|
return False, self.trUtf8('You need to enter a song title.')
|
||||||
if self.VerseListWidget.count() == 0:
|
if self.VerseListWidget.rowCount() == 0:
|
||||||
self.SongTabWidget.setCurrentIndex(0)
|
self.SongTabWidget.setCurrentIndex(0)
|
||||||
self.VerseListWidget.setFocus()
|
self.VerseListWidget.setFocus()
|
||||||
return False, self.trUtf8('You need to enter some verses.')
|
return False, self.trUtf8('You need to enter some verses.')
|
||||||
if self.AuthorsListView.count() == 0:
|
if self.AuthorsListView.count() == 0:
|
||||||
self.SongTabWidget.setCurrentIndex(2)
|
self.SongTabWidget.setCurrentIndex(1)
|
||||||
self.AuthorsListView.setFocus()
|
self.AuthorsListView.setFocus()
|
||||||
#split the verse list by space and mark lower case for testing
|
#split the verse list by space and mark lower case for testing
|
||||||
taglist = unicode(self.trUtf8(' bitped'))
|
taglist = unicode(self.trUtf8(' bitped'))
|
||||||
@ -479,6 +520,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.loadTopics()
|
self.loadTopics()
|
||||||
|
|
||||||
def onPreview(self, button):
|
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')
|
log.debug(u'onPreview')
|
||||||
if button.text() == unicode(self.trUtf8('Save && Preview')) \
|
if button.text() == unicode(self.trUtf8('Save && Preview')) \
|
||||||
and self.saveSong():
|
and self.saveSong():
|
||||||
@ -520,12 +565,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
sxml.new_document()
|
sxml.new_document()
|
||||||
sxml.add_lyrics_to_song()
|
sxml.add_lyrics_to_song()
|
||||||
text = u' '
|
text = u' '
|
||||||
for i in range (0, self.VerseListWidget.count()):
|
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())
|
verseId = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
||||||
bits = verseId.split(u':')
|
bits = verseId.split(u':')
|
||||||
sxml.add_verse_to_lyrics(bits[0], bits[1], unicode(item.text()))
|
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'')
|
text = text.replace(u',', u'')
|
||||||
text = text.replace(u';', u'')
|
text = text.replace(u';', u'')
|
||||||
|
Loading…
Reference in New Issue
Block a user