From ffcdddf92816ea0d960c05a42a80ab21c2b77ff3 Mon Sep 17 00:00:00 2001 From: M2j Date: Wed, 2 Jun 2010 17:33:55 +0200 Subject: [PATCH] fixing string encoding in songmaintenanceform making verses w/o index a alias for the first one --- openlp/plugins/songs/forms/editsongform.py | 2 +- .../songs/forms/songmaintenanceform.py | 34 ++++++++----------- openlp/plugins/songs/lib/mediaitem.py | 10 +++--- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 144081c84..561bf9aa2 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -469,7 +469,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.SongTabWidget.setCurrentIndex(1) self.AuthorsListView.setFocus() #split the verse list by space and mark lower case for testing - taglist = unicode(self.trUtf8(' bitped')) + taglist = unicode(self.trUtf8(' bitpeovc')) for verse in unicode(self.VerseOrderEdit.text()).lower().split(u' '): if len(verse) > 1: if (verse[0:1] == u'%s' % self.trUtf8('v') or diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 1ea1d7f43..8fbd6ae5d 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -129,12 +129,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.authorform.setAutoDisplayName(True) if self.authorform.exec_(): author = Author.populate( - first_name=unicode( - self.authorform.FirstNameEdit.text(), u'utf-8'), - last_name=unicode( - self.authorform.LastNameEdit.text(), u'utf-8'), - display_name=unicode( - self.authorform.DisplayEdit.text(), u'utf-8')) + first_name=unicode(self.authorform.FirstNameEdit.text()), + last_name=unicode(self.authorform.LastNameEdit.text()), + display_name=unicode(self.authorform.DisplayEdit.text())) if self.songmanager.save_author(author): self.resetAuthors() else: @@ -144,8 +141,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onTopicAddButtonClick(self): if self.topicform.exec_(): - topic = Topic.populate( - name=unicode(self.topicform.NameEdit.text(), u'utf-8')) + topic = Topic.populate(name=unicode(self.topicform.NameEdit.text())) if self.songmanager.save_topic(topic): self.resetTopics() else: @@ -156,8 +152,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onBookAddButtonClick(self): if self.bookform.exec_(): book = Book.populate( - name=unicode(self.bookform.NameEdit.text(), u'utf-8'), - publisher=unicode(self.bookform.PublisherEdit.text(), u'utf-8')) + name=unicode(self.bookform.NameEdit.text()), + publisher=unicode(self.bookform.PublisherEdit.text())) if self.songmanager.save_book(book): self.resetBooks() else: @@ -174,12 +170,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.authorform.LastNameEdit.setText(author.last_name) self.authorform.DisplayEdit.setText(author.display_name) if self.authorform.exec_(False): - author.first_name = unicode( - self.authorform.FirstNameEdit.text(), u'utf-8') - author.last_name = unicode( - self.authorform.LastNameEdit.text(), u'utf-8') - author.display_name = unicode( - self.authorform.DisplayEdit.text(), u'utf-8') + author.first_name = unicode( + self.authorform.FirstNameEdit.text()) + author.last_name = unicode(self.authorform.LastNameEdit.text()) + author.display_name = unicode( + self.authorform.DisplayEdit.text()) if self.songmanager.save_author(author): self.resetAuthors() else: @@ -193,7 +188,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): topic = self.songmanager.get_topic(topic_id) self.topicform.NameEdit.setText(topic.name) if self.topicform.exec_(False): - topic.name = unicode(self.topicform.NameEdit.text(), u'utf-8') + topic.name = unicode(self.topicform.NameEdit.text()) if self.songmanager.save_topic(topic): self.resetTopics() else: @@ -208,9 +203,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): self.bookform.NameEdit.setText(book.name) self.bookform.PublisherEdit.setText(book.publisher) if self.bookform.exec_(False): - book.name = unicode(self.bookform.NameEdit.text(), u'utf-8') - book.publisher = unicode( - self.bookform.PublisherEdit.text(), u'utf-8') + book.name = unicode(self.bookform.NameEdit.text()) + book.publisher = unicode(self.bookform.PublisherEdit.text()) if self.songmanager.save_book(book): self.resetBooks() else: diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 6bcfa9f68..31a6f80cf 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -335,16 +335,16 @@ class SongMediaItem(MediaManagerItem): break for verse in verseList: if verse[1]: - if verse[0][u'type'] == "Verse" \ - or verse[0][u'type'] == "Chorus": - if verse[0][u'label'] == order[1:] and \ - verse[0][u'type'][0] == order[0]: + if order[1:]: + if verse[0][u'type'][0] == order[0] and \ + verse[0][u'label'] == order[1:]: verseTag = u'%s:%s' % \ (verse[0][u'type'], verse[0][u'label']) service_item.add_from_text\ (verse[1][:30], verse[1], verseTag) else: - if verse[0][u'type'][0] == order[0]: + if verse[0][u'type'][0] == order[0] and \ + verse[0][u'label'] == u'1': verseTag = u'%s:%s' % \ (verse[0][u'type'], verse[0][u'label']) service_item.add_from_text\