Add verse number code to song plugin

This commit is contained in:
Tim Bentley 2009-11-22 20:33:39 +00:00
parent 56c69bd8e8
commit 388a596922
5 changed files with 255 additions and 78 deletions

View File

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################

View File

@ -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)

View File

@ -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))

View File

@ -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):

View File

@ -1,45 +1,157 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditVerseDialog</class>
<widget class="QDialog" name="EditVerseDialog" >
<property name="geometry" >
<widget class="QDialog" name="EditVerseDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>492</width>
<height>373</height>
<height>494</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="modal" >
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="DialogLayout" >
<property name="spacing" >
<number>8</number>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>8</x>
<y>11</y>
<width>471</width>
<height>461</height>
</rect>
</property>
<property name="margin" >
<number>8</number>
</property>
<item>
<widget class="QTextEdit" name="VerseTextEdit" >
<property name="acceptRichText" >
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="ButtonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
</layout>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="VerseListComboBox">
<item>
<property name="text">
<string/>
</property>
</item>
<item>
<property name="text">
<string>Verse</string>
</property>
</item>
<item>
<property name="text">
<string>Chorus</string>
</property>
</item>
<item>
<property name="text">
<string>Bridge</string>
</property>
</item>
<item>
<property name="text">
<string>1</string>
</property>
</item>
<item>
<property name="text">
<string>2</string>
</property>
</item>
<item>
<property name="text">
<string>3</string>
</property>
</item>
<item>
<property name="text">
<string>4</string>
</property>
</item>
<item>
<property name="text">
<string>5</string>
</property>
</item>
<item>
<property name="text">
<string>6</string>
</property>
</item>
<item>
<property name="text">
<string>7</string>
</property>
</item>
<item>
<property name="text">
<string>9</string>
</property>
</item>
<item>
<property name="text">
<string>8</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="SubVerseListComboBox">
<item>
<property name="text">
<string/>
</property>
</item>
<item>
<property name="text">
<string>a</string>
</property>
</item>
<item>
<property name="text">
<string>b</string>
</property>
</item>
<item>
<property name="text">
<string>c</string>
</property>
</item>
<item>
<property name="text">
<string>d</string>
</property>
</item>
<item>
<property name="text">
<string>e</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="VerseTextEdit">
<property name="acceptRichText">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="ButtonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
@ -49,11 +161,11 @@
<receiver>EditVerseDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
@ -65,11 +177,11 @@
<receiver>EditVerseDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>