openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #01594
[Merge] lp:~trb143/openlp/working into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/working into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
This is a Request for Review NOT a merge request as it will need fixes when Raoul merges his changes in.
The change in this is to move the SongEdit dialog from a QListWidget to a QTableWidget so we can show the verse tags against the verses. This is the same change made to the SlideControllers.
I have done some testing and plan some more before the final merge request but as it may EAT songs can we have some testing before it is committed.
Thanks
--
https://code.launchpad.net/~trb143/openlp/working/+merge/25704
Your team OpenLP Core is requested to review the proposed merge of lp:~trb143/openlp/working into lp:openlp.
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2010-05-16 15:33:31 +0000
+++ openlp/core/ui/mainwindow.py 2010-05-20 17:04:28 +0000
@@ -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 @@
"""
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 @@
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 @@
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)
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2010-05-16 15:18:05 +0000
+++ openlp/core/ui/slidecontroller.py 2010-05-20 17:04:28 +0000
@@ -155,7 +155,6 @@
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
=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
--- openlp/plugins/songs/forms/editsongdialog.py 2010-05-01 19:45:06 +0000
+++ openlp/plugins/songs/forms/editsongdialog.py 2010-05-20 17:04:28 +0000
@@ -70,8 +70,12 @@
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)
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py 2010-05-17 20:48:16 +0000
+++ openlp/plugins/songs/forms/editsongform.py 2010-05-20 17:04:28 +0000
@@ -47,6 +47,8 @@
"""
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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'')
Follow ups