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 # 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) songXML = SongXMLParser(self.song.lyrics)
verseList = songXML.get_verses() verseList = songXML.get_verses()
for verse in verseList: 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: else:
verses = self.song.lyrics.split(u'\n\n') verses = self.song.lyrics.split(u'\n\n')
for verse in verses: for count, verse in enumerate(verses):
self.VerseListWidget.addItem(verse) item = QtGui.QListWidgetItem(verse)
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(count + 1))
self.VerseListWidget.addItem(item)
# clear the results # clear the results
self.AuthorsListView.clear() self.AuthorsListView.clear()
for author in self.song.authors: for author in self.song.authors:
@ -314,7 +322,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
item = self.VerseListWidget.currentItem() item = self.VerseListWidget.currentItem()
if item: if item:
tempText = item.text() 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_() self.verse_form.exec_()
afterText = self.verse_form.getVerse() afterText = self.verse_form.getVerse()
item.setText(afterText) item.setText(afterText)
@ -335,6 +344,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if self.VerseListWidget.count() > 0: if self.VerseListWidget.count() > 0:
for row in range(0, self.VerseListWidget.count()): for row in range(0, self.VerseListWidget.count()):
item = self.VerseListWidget.item(row) item = self.VerseListWidget.item(row)
verse_list += u'<%s>\n' % \
unicode((item.data(QtCore.Qt.UserRole)).toString()[0])
verse_list += item.text() verse_list += item.text()
verse_list += u'\n---\n' verse_list += u'\n---\n'
self.verse_form.setVerse(verse_list) self.verse_form.setVerse(verse_list)

View File

@ -1,52 +1,84 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
############################################################################### # Form implementation generated from reading ui file 'editversedialog.ui'
# OpenLP - Open Source Lyrics Projection # #
# --------------------------------------------------------------------------- # # Created: Sun Nov 22 13:33:41 2009
# Copyright (c) 2008-2009 Raoul Snyman # # by: PyQt4 UI code generator 4.5.4
# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # #
# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # # WARNING! All changes made in this file will be lost!
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
class Ui_EditVerseDialog(object): class Ui_EditVerseDialog(object):
def setupUi(self, EditVerseDialog): def setupUi(self, EditVerseDialog):
EditVerseDialog.setObjectName(u'EditVerseDialog') EditVerseDialog.setObjectName("EditVerseDialog")
EditVerseDialog.resize(492, 373) EditVerseDialog.resize(492, 494)
EditVerseDialog.setModal(True) EditVerseDialog.setModal(True)
self.DialogLayout = QtGui.QVBoxLayout(EditVerseDialog) self.widget = QtGui.QWidget(EditVerseDialog)
self.DialogLayout.setSpacing(8) self.widget.setGeometry(QtCore.QRect(8, 11, 471, 461))
self.DialogLayout.setMargin(8) self.widget.setObjectName("widget")
self.DialogLayout.setObjectName(u'DialogLayout') self.verticalLayout = QtGui.QVBoxLayout(self.widget)
self.VerseTextEdit = QtGui.QTextEdit(EditVerseDialog) 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.setAcceptRichText(False)
self.VerseTextEdit.setObjectName(u'VerseTextEdit') self.VerseTextEdit.setObjectName("VerseTextEdit")
self.DialogLayout.addWidget(self.VerseTextEdit) self.verticalLayout.addWidget(self.VerseTextEdit)
self.ButtonBox = QtGui.QDialogButtonBox(EditVerseDialog) self.ButtonBox = QtGui.QDialogButtonBox(self.widget)
self.ButtonBox.setOrientation(QtCore.Qt.Horizontal) self.ButtonBox.setOrientation(QtCore.Qt.Horizontal)
self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save) self.ButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Save)
self.ButtonBox.setObjectName(u'ButtonBox') self.ButtonBox.setObjectName("ButtonBox")
self.DialogLayout.addWidget(self.ButtonBox) self.verticalLayout.addWidget(self.ButtonBox)
self.retranslateUi(EditVerseDialog) self.retranslateUi(EditVerseDialog)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'accepted()'), EditVerseDialog.accept) QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("accepted()"), EditVerseDialog.accept)
QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'rejected()'), EditVerseDialog.reject) QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL("rejected()"), EditVerseDialog.reject)
QtCore.QMetaObject.connectSlotsByName(EditVerseDialog) QtCore.QMetaObject.connectSlotsByName(EditVerseDialog)
self.VerseTextEdit.setFocus(QtCore.Qt.OtherFocusReason)
def retranslateUi(self, EditVerseDialog): 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) QtGui.QDialog.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
def setVerse(self, verse): def setVerse(self, text, single=False, id=0):
self.VerseTextEdit.setPlainText(verse) 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) self.VerseTextEdit.setFocus(QtCore.Qt.OtherFocusReason)
def getVerse(self): 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> <class>EditVerseDialog</class>
<widget class="QDialog" name="EditVerseDialog" > <widget class="QDialog" name="EditVerseDialog">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>492</width> <width>492</width>
<height>373</height> <height>494</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<property name="modal" > <property name="modal">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="DialogLayout" > <widget class="QWidget" name="">
<property name="spacing" > <property name="geometry">
<number>8</number> <rect>
<x>8</x>
<y>11</y>
<width>471</width>
<height>461</height>
</rect>
</property> </property>
<property name="margin" > <layout class="QVBoxLayout" name="verticalLayout">
<number>8</number> <item>
</property> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QTextEdit" name="VerseTextEdit" > <widget class="QComboBox" name="VerseListComboBox">
<property name="acceptRichText" > <item>
<bool>false</bool> <property name="text">
</property> <string/>
</widget> </property>
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="ButtonBox" > <property name="text">
<property name="orientation" > <string>Verse</string>
<enum>Qt::Horizontal</enum> </property>
</property> </item>
<property name="standardButtons" > <item>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set> <property name="text">
</property> <string>Chorus</string>
</widget> </property>
</item> </item>
</layout> <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> </widget>
<resources/> <resources/>
<connections> <connections>
@ -49,11 +161,11 @@
<receiver>EditVerseDialog</receiver> <receiver>EditVerseDialog</receiver>
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>248</x> <x>248</x>
<y>254</y> <y>254</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>157</x> <x>157</x>
<y>274</y> <y>274</y>
</hint> </hint>
@ -65,11 +177,11 @@
<receiver>EditVerseDialog</receiver> <receiver>EditVerseDialog</receiver>
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel" > <hint type="sourcelabel">
<x>316</x> <x>316</x>
<y>260</y> <y>260</y>
</hint> </hint>
<hint type="destinationlabel" > <hint type="destinationlabel">
<x>286</x> <x>286</x>
<y>274</y> <y>274</y>
</hint> </hint>