From 388a5969226921fd3c925f86b6d79b332645b794 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 22 Nov 2009 20:33:39 +0000 Subject: [PATCH] Add verse number code to song plugin --- openlp/core/lib/renderer.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 19 +- openlp/plugins/songs/forms/editversedialog.py | 106 +++++++---- openlp/plugins/songs/forms/editverseform.py | 26 ++- resources/forms/editversedialog.ui | 180 ++++++++++++++---- 5 files changed, 255 insertions(+), 78 deletions(-) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index b8d9b7172..4c666c38e 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- + # -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 714442de1..547613def 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -216,11 +216,19 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): songXML = SongXMLParser(self.song.lyrics) verseList = songXML.get_verses() for verse in verseList: - self.VerseListWidget.addItem(verse[1]) + if verse[0][u'type'] == u'Verse': + variant = verse[0][u'label'] + else: + variant = verse[0][u'type'] + item = QtGui.QListWidgetItem(verse[1]) + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant)) + self.VerseListWidget.addItem(item) else: verses = self.song.lyrics.split(u'\n\n') - for verse in verses: - self.VerseListWidget.addItem(verse) + for count, verse in enumerate(verses): + item = QtGui.QListWidgetItem(verse) + item.setData(QtCore.Qt.UserRole, QtCore.QVariant(count + 1)) + self.VerseListWidget.addItem(item) # clear the results self.AuthorsListView.clear() for author in self.song.authors: @@ -314,7 +322,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): item = self.VerseListWidget.currentItem() if item: tempText = item.text() - self.verse_form.setVerse(tempText) + verseId = unicode((item.data(QtCore.Qt.UserRole)).toString()[0]) + self.verse_form.setVerse(tempText, True, verseId) self.verse_form.exec_() afterText = self.verse_form.getVerse() item.setText(afterText) @@ -335,6 +344,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): if self.VerseListWidget.count() > 0: for row in range(0, self.VerseListWidget.count()): item = self.VerseListWidget.item(row) + verse_list += u'<%s>\n' % \ + unicode((item.data(QtCore.Qt.UserRole)).toString()[0]) verse_list += item.text() verse_list += u'\n---\n' self.verse_form.setVerse(verse_list) diff --git a/openlp/plugins/songs/forms/editversedialog.py b/openlp/plugins/songs/forms/editversedialog.py index f69a2fe6f..ca9b44fa3 100644 --- a/openlp/plugins/songs/forms/editversedialog.py +++ b/openlp/plugins/songs/forms/editversedialog.py @@ -1,52 +1,84 @@ # -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2009 Raoul Snyman # -# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # -# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### +# Form implementation generated from reading ui file 'editversedialog.ui' +# +# Created: Sun Nov 22 13:33:41 2009 +# by: PyQt4 UI code generator 4.5.4 +# +# WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui class Ui_EditVerseDialog(object): def setupUi(self, EditVerseDialog): - EditVerseDialog.setObjectName(u'EditVerseDialog') - EditVerseDialog.resize(492, 373) + EditVerseDialog.setObjectName("EditVerseDialog") + EditVerseDialog.resize(492, 494) EditVerseDialog.setModal(True) - self.DialogLayout = QtGui.QVBoxLayout(EditVerseDialog) - self.DialogLayout.setSpacing(8) - self.DialogLayout.setMargin(8) - self.DialogLayout.setObjectName(u'DialogLayout') - self.VerseTextEdit = QtGui.QTextEdit(EditVerseDialog) + self.widget = QtGui.QWidget(EditVerseDialog) + self.widget.setGeometry(QtCore.QRect(8, 11, 471, 461)) + self.widget.setObjectName("widget") + self.verticalLayout = QtGui.QVBoxLayout(self.widget) + self.verticalLayout.setObjectName("verticalLayout") + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.VerseListComboBox = QtGui.QComboBox(self.widget) + self.VerseListComboBox.setObjectName("VerseListComboBox") + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.setItemText(0, "") + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.VerseListComboBox.addItem(QtCore.QString()) + self.horizontalLayout.addWidget(self.VerseListComboBox) + self.SubVerseListComboBox = QtGui.QComboBox(self.widget) + self.SubVerseListComboBox.setObjectName("SubVerseListComboBox") + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.setItemText(0, "") + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.SubVerseListComboBox.addItem(QtCore.QString()) + self.horizontalLayout.addWidget(self.SubVerseListComboBox) + self.verticalLayout.addLayout(self.horizontalLayout) + self.VerseTextEdit = QtGui.QTextEdit(self.widget) self.VerseTextEdit.setAcceptRichText(False) - self.VerseTextEdit.setObjectName(u'VerseTextEdit') - self.DialogLayout.addWidget(self.VerseTextEdit) - self.ButtonBox = QtGui.QDialogButtonBox(EditVerseDialog) + self.VerseTextEdit.setObjectName("VerseTextEdit") + self.verticalLayout.addWidget(self.VerseTextEdit) + self.ButtonBox = QtGui.QDialogButtonBox(self.widget) self.ButtonBox.setOrientation(QtCore.Qt.Horizontal) self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save) - self.ButtonBox.setObjectName(u'ButtonBox') - self.DialogLayout.addWidget(self.ButtonBox) + self.ButtonBox.setObjectName("ButtonBox") + self.verticalLayout.addWidget(self.ButtonBox) + self.retranslateUi(EditVerseDialog) - QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), EditVerseDialog.accept) - QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), EditVerseDialog.reject) + QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("accepted()"), EditVerseDialog.accept) + QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("rejected()"), EditVerseDialog.reject) QtCore.QMetaObject.connectSlotsByName(EditVerseDialog) - self.VerseTextEdit.setFocus(QtCore.Qt.OtherFocusReason) def retranslateUi(self, EditVerseDialog): - EditVerseDialog.setWindowTitle(self.trUtf8(u'Edit Verse')) + EditVerseDialog.setWindowTitle(QtGui.QApplication.translate("EditVerseDialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(1, QtGui.QApplication.translate("EditVerseDialog", "Chorus", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(2, QtGui.QApplication.translate("EditVerseDialog", "Bridge", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(3, QtGui.QApplication.translate("EditVerseDialog", "1", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(4, QtGui.QApplication.translate("EditVerseDialog", "2", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(5, QtGui.QApplication.translate("EditVerseDialog", "3", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(6, QtGui.QApplication.translate("EditVerseDialog", "4", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(7, QtGui.QApplication.translate("EditVerseDialog", "5", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(8, QtGui.QApplication.translate("EditVerseDialog", "6", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(9, QtGui.QApplication.translate("EditVerseDialog", "7", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(11, QtGui.QApplication.translate("EditVerseDialog", "9", None, QtGui.QApplication.UnicodeUTF8)) + self.VerseListComboBox.setItemText(10, QtGui.QApplication.translate("EditVerseDialog", "8", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(1, QtGui.QApplication.translate("EditVerseDialog", "a", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(2, QtGui.QApplication.translate("EditVerseDialog", "b", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(3, QtGui.QApplication.translate("EditVerseDialog", "c", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(4, QtGui.QApplication.translate("EditVerseDialog", "d", None, QtGui.QApplication.UnicodeUTF8)) + self.SubVerseListComboBox.setItemText(5, QtGui.QApplication.translate("EditVerseDialog", "e", None, QtGui.QApplication.UnicodeUTF8)) + diff --git a/openlp/plugins/songs/forms/editverseform.py b/openlp/plugins/songs/forms/editverseform.py index 93f5040d9..2d13b5537 100644 --- a/openlp/plugins/songs/forms/editverseform.py +++ b/openlp/plugins/songs/forms/editverseform.py @@ -38,8 +38,30 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog): QtGui.QDialog.__init__(self, parent) self.setupUi(self) - def setVerse(self, verse): - self.VerseTextEdit.setPlainText(verse) + def setVerse(self, text, single=False, id=0): + posVerse = 0 + posSub = 0 + if single: + if len(id) <= 2: + if len(id) == 1: + posVerse = self.VerseListComboBox.findText(id, QtCore.Qt.MatchExactly) + else: + posVerse = self.VerseListComboBox.findText(id[0], QtCore.Qt.MatchExactly) + posSub = self.SubVerseListComboBox.findText(id[1], QtCore.Qt.MatchExactly) + else: + posVerse = self.VerseListComboBox.findText(id, QtCore.Qt.MatchExactly) + if posVerse == -1: + posVerse = 0 + if posSub == -1: + posSub = 0 + self.VerseListComboBox.setEnabled(True) + self.SubVerseListComboBox.setEnabled(True) + else: + self.VerseListComboBox.setEnabled(False) + self.SubVerseListComboBox.setEnabled(False) + self.VerseListComboBox.setCurrentIndex(posVerse) + self.SubVerseListComboBox.setCurrentIndex(posSub) + self.VerseTextEdit.setPlainText(text) self.VerseTextEdit.setFocus(QtCore.Qt.OtherFocusReason) def getVerse(self): diff --git a/resources/forms/editversedialog.ui b/resources/forms/editversedialog.ui index 68417ed41..822807f1b 100644 --- a/resources/forms/editversedialog.ui +++ b/resources/forms/editversedialog.ui @@ -1,45 +1,157 @@ - + + EditVerseDialog - - + + 0 0 492 - 373 + 494 - + Dialog - + true - - - 8 + + + + 8 + 11 + 471 + 461 + - - 8 - - - - - false - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Save - - - - + + + + + + + + + + + + + Verse + + + + + Chorus + + + + + Bridge + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 9 + + + + + 8 + + + + + + + + + + + + + + a + + + + + b + + + + + c + + + + + d + + + + + e + + + + + + + + + + false + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Save + + + + + @@ -49,11 +161,11 @@ EditVerseDialog accept() - + 248 254 - + 157 274 @@ -65,11 +177,11 @@ EditVerseDialog reject() - + 316 260 - + 286 274