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 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
@ -332,7 +331,7 @@ class Ui_MainWindow(object):
|
||||
"""
|
||||
MainWindow.mainTitle = translate('MainWindow', 'OpenLP 2.0')
|
||||
MainWindow.language = translate('MainWindow', 'English')
|
||||
MainWindow.defaultThemeText = translate('MainWindow',
|
||||
MainWindow.defaultThemeText = translate('MainWindow',
|
||||
'Default Theme: ')
|
||||
MainWindow.setWindowTitle(MainWindow.mainTitle)
|
||||
self.FileMenu.setTitle(translate('MainWindow', '&File'))
|
||||
@ -341,7 +340,7 @@ class Ui_MainWindow(object):
|
||||
self.OptionsMenu.setTitle(translate('MainWindow', '&Options'))
|
||||
self.OptionsViewMenu.setTitle(translate('MainWindow', '&View'))
|
||||
self.ViewModeMenu.setTitle(translate('MainWindow', 'M&ode'))
|
||||
self.OptionsLanguageMenu.setTitle(translate('MainWindow',
|
||||
self.OptionsLanguageMenu.setTitle(translate('MainWindow',
|
||||
u'&Language'))
|
||||
self.ToolsMenu.setTitle(translate('MainWindow', '&Tools'))
|
||||
self.HelpMenu.setTitle(translate('MainWindow', '&Help'))
|
||||
@ -526,7 +525,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
|
||||
QtCore.SIGNAL(u'triggered()'),
|
||||
self.ServiceManagerContents.onSaveService)
|
||||
#i18n set signals for languages
|
||||
QtCore.QObject.connect(self.AutoLanguageItem,
|
||||
QtCore.QObject.connect(self.AutoLanguageItem,
|
||||
QtCore.SIGNAL(u'toggled(bool)'),
|
||||
self.setAutoLanguage)
|
||||
self.LanguageGroup.triggered.connect(LanguageManager.set_language)
|
||||
|
@ -155,7 +155,6 @@ class SlideController(QtGui.QWidget):
|
||||
self.PreviewListWidget = SlideList(self)
|
||||
self.PreviewListWidget.setColumnCount(1)
|
||||
self.PreviewListWidget.horizontalHeader().setVisible(False)
|
||||
#self.PreviewListWidget.verticalHeader().setVisible(False)
|
||||
self.PreviewListWidget.setColumnWidth(
|
||||
0, self.Controller.width())
|
||||
self.PreviewListWidget.isLive = self.isLive
|
||||
|
@ -70,8 +70,12 @@ class Ui_EditSongDialog(object):
|
||||
QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
|
||||
self.LyricsLabel.setObjectName(u'LyricsLabel')
|
||||
self.LyricsTabLayout.addWidget(self.LyricsLabel, 2, 0, 1, 1)
|
||||
self.VerseListWidget = QtGui.QListWidget(self.LyricsTab)
|
||||
self.VerseListWidget.setSpacing(2)
|
||||
self.VerseListWidget = QtGui.QTableWidget(self.LyricsTab)
|
||||
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.setObjectName(u'VerseListWidget')
|
||||
self.LyricsTabLayout.addWidget(self.VerseListWidget, 2, 1, 1, 1)
|
||||
|
@ -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,
|
||||
@ -77,7 +79,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtCore.QObject.connect(self.VerseDeleteButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onVerseDeleteButtonClicked)
|
||||
QtCore.QObject.connect(self.VerseListWidget,
|
||||
QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'),
|
||||
QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'),
|
||||
self.onVerseListViewPressed)
|
||||
QtCore.QObject.connect(self.SongbookCombo,
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onSongBookComboChanged)
|
||||
@ -182,6 +184,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.CommentsEdit.setText(u'')
|
||||
self.CCLNumberEdit.setText(u'')
|
||||
self.VerseListWidget.clear()
|
||||
self.VerseListWidget.setRowCount(0)
|
||||
self.AuthorsListView.clear()
|
||||
self.TopicsListView.clear()
|
||||
self.TitleEditItem.setFocus(QtCore.Qt.OtherFocusReason)
|
||||
@ -223,6 +226,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
else:
|
||||
self.CopyrightEditItem.setText(u'')
|
||||
self.VerseListWidget.clear()
|
||||
self.VerseListWidget.setRowCount(0)
|
||||
if self.song.verse_order:
|
||||
self.VerseOrderEdit.setText(self.song.verse_order)
|
||||
else:
|
||||
@ -236,21 +240,30 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
else:
|
||||
self.CCLNumberEdit.setText(u'')
|
||||
#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='):
|
||||
songXML = SongXMLParser(self.song.lyrics)
|
||||
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'])
|
||||
item = QtGui.QListWidgetItem(verse[1])
|
||||
item = QtGui.QTableWidgetItem(verse[1])
|
||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
|
||||
self.VerseListWidget.addItem(item)
|
||||
self.VerseListWidget.setItem(count, 0, item)
|
||||
else:
|
||||
verses = self.song.lyrics.split(u'\n\n')
|
||||
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)
|
||||
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
|
||||
self.AuthorsListView.clear()
|
||||
for author in self.song.authors:
|
||||
@ -270,6 +283,19 @@ 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:
|
||||
@ -340,10 +366,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
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.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):
|
||||
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')):
|
||||
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''
|
||||
if self.VerseListWidget.count() > 0:
|
||||
for row in range(0, self.VerseListWidget.count()):
|
||||
item = self.VerseListWidget.item(row)
|
||||
if self.VerseListWidget.rowCount() > 0:
|
||||
for row in range(0, self.VerseListWidget.rowCount()):
|
||||
item = self.VerseListWidget.item(row, 0)
|
||||
field = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
||||
verse_list += u'---[%s]---\n' % field
|
||||
verse_list += item.text()
|
||||
@ -389,6 +422,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()
|
||||
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')):
|
||||
@ -400,13 +434,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.addItem(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())
|
||||
self.VerseListWidget.removeRow(self.VerseListWidget.currentRow())
|
||||
self.VerseEditButton.setEnabled(False)
|
||||
self.VerseDeleteButton.setEnabled(False)
|
||||
|
||||
@ -421,12 +462,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.SongTabWidget.setCurrentIndex(0)
|
||||
self.TitleEditItem.setFocus()
|
||||
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.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'))
|
||||
@ -479,6 +520,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():
|
||||
@ -520,12 +565,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
sxml.new_document()
|
||||
sxml.add_lyrics_to_song()
|
||||
text = u' '
|
||||
for i in range (0, self.VerseListWidget.count()):
|
||||
item = self.VerseListWidget.item(i)
|
||||
for i in range (0, self.VerseListWidget.rowCount()):
|
||||
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