From 0e1383c35d2d7fbcdade859141c8d8a1bad5180a Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Wed, 15 Dec 2010 20:22:25 +0100 Subject: [PATCH 1/6] clean ups --- openlp/core/ui/filerenamedialog.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/openlp/core/ui/filerenamedialog.py b/openlp/core/ui/filerenamedialog.py index 02eefe7ed..4b1cf9411 100644 --- a/openlp/core/ui/filerenamedialog.py +++ b/openlp/core/ui/filerenamedialog.py @@ -30,23 +30,23 @@ from openlp.core.lib import translate class Ui_FileRenameDialog(object): def setupUi(self, FileRenameDialog): - FileRenameDialog.setObjectName("FileRenameDialog") + FileRenameDialog.setObjectName(u'FileRenameDialog') FileRenameDialog.resize(400, 87) self.buttonBox = QtGui.QDialogButtonBox(FileRenameDialog) self.buttonBox.setGeometry(QtCore.QRect(210, 50, 171, 25)) self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName("buttonBox") + self.buttonBox.setObjectName(u'buttonBox') self.widget = QtGui.QWidget(FileRenameDialog) self.widget.setGeometry(QtCore.QRect(10, 10, 381, 35)) - self.widget.setObjectName("widget") + self.widget.setObjectName(u'widget') self.horizontalLayout = QtGui.QHBoxLayout(self.widget) - self.horizontalLayout.setObjectName("horizontalLayout") + self.horizontalLayout.setObjectName(u'horizontalLayout') self.FileRenameLabel = QtGui.QLabel(self.widget) - self.FileRenameLabel.setObjectName("FileRenameLabel") + self.FileRenameLabel.setObjectName(u'FileRenameLabel') self.horizontalLayout.addWidget(self.FileRenameLabel) self.FileNameEdit = QtGui.QLineEdit(self.widget) - self.FileNameEdit.setObjectName("FileNameEdit") + self.FileNameEdit.setObjectName(u'FileNameEdit') self.horizontalLayout.addWidget(self.FileNameEdit) self.retranslateUi(FileRenameDialog) @@ -57,4 +57,3 @@ class Ui_FileRenameDialog(object): 'File Rename')) self.FileRenameLabel.setText(translate('OpenLP.FileRenameForm', 'New File Name:')) - From 4e9d6370b3bf2d6e0bd7683e974b0ae15763a087 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 16 Dec 2010 17:08:10 +0100 Subject: [PATCH 2/6] clean up --- openlp/core/ui/filerenamedialog.py | 14 +++++++------- openlp/core/ui/thememanager.py | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openlp/core/ui/filerenamedialog.py b/openlp/core/ui/filerenamedialog.py index 4b1cf9411..600027940 100644 --- a/openlp/core/ui/filerenamedialog.py +++ b/openlp/core/ui/filerenamedialog.py @@ -42,12 +42,12 @@ class Ui_FileRenameDialog(object): self.widget.setObjectName(u'widget') self.horizontalLayout = QtGui.QHBoxLayout(self.widget) self.horizontalLayout.setObjectName(u'horizontalLayout') - self.FileRenameLabel = QtGui.QLabel(self.widget) - self.FileRenameLabel.setObjectName(u'FileRenameLabel') - self.horizontalLayout.addWidget(self.FileRenameLabel) - self.FileNameEdit = QtGui.QLineEdit(self.widget) - self.FileNameEdit.setObjectName(u'FileNameEdit') - self.horizontalLayout.addWidget(self.FileNameEdit) + self.fileRenameLabel = QtGui.QLabel(self.widget) + self.fileRenameLabel.setObjectName(u'fileRenameLabel') + self.horizontalLayout.addWidget(self.fileRenameLabel) + self.fileNameEdit = QtGui.QLineEdit(self.widget) + self.fileNameEdit.setObjectName(u'fileNameEdit') + self.horizontalLayout.addWidget(self.fileNameEdit) self.retranslateUi(FileRenameDialog) QtCore.QMetaObject.connectSlotsByName(FileRenameDialog) @@ -55,5 +55,5 @@ class Ui_FileRenameDialog(object): def retranslateUi(self, FileRenameDialog): FileRenameDialog.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Rename')) - self.FileRenameLabel.setText(translate('OpenLP.FileRenameForm', + self.fileRenameLabel.setText(translate('OpenLP.FileRenameForm', 'New File Name:')) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index b6e8c3d7a..0b0d8281d 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -225,10 +225,10 @@ class ThemeManager(QtGui.QWidget): """ item = self.themeListWidget.currentItem() oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) - self.fileRenameForm.FileNameEdit.setText(oldThemeName) + self.fileRenameForm.fileNameEdit.setText(oldThemeName) self.saveThemeName = u'' if self.fileRenameForm.exec_(): - newThemeName = unicode(self.fileRenameForm.FileNameEdit.text()) + newThemeName = unicode(self.fileRenameForm.fileNameEdit.text()) oldThemeData = self.getThemeData(oldThemeName) self.deleteTheme(oldThemeName) self.cloneThemeData(oldThemeData, newThemeName) @@ -239,10 +239,10 @@ class ThemeManager(QtGui.QWidget): """ item = self.themeListWidget.currentItem() oldThemeName = unicode(item.data(QtCore.Qt.UserRole).toString()) - self.fileRenameForm.FileNameEdit.setText(oldThemeName) + self.fileRenameForm.fileNameEdit.setText(oldThemeName) self.saveThemeName = u'' if self.fileRenameForm.exec_(): - newThemeName = unicode(self.fileRenameForm.FileNameEdit.text()) + newThemeName = unicode(self.fileRenameForm.fileNameEdit.text()) themeData = self.getThemeData(oldThemeName) self.cloneThemeData(themeData, newThemeName) self.loadThemes() From 95f30dfb6da75c582c509cfe6c75d617da2c4dc2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 16 Dec 2010 18:56:08 +0100 Subject: [PATCH 3/6] fixed bug #690774 --- openlp/plugins/songs/lib/mediaitem.py | 33 +++++++++++++++------------ 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index dc8310e9d..224063c47 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -44,6 +44,7 @@ class SongListView(BaseListWithDnD): self.PluginName = u'Songs' BaseListWithDnD.__init__(self, parent) + class SongMediaItem(MediaManagerItem): """ This is the custom media manager item for Songs. @@ -392,7 +393,7 @@ class SongMediaItem(MediaManagerItem): author_audit.append(unicode(author.display_name)) raw_footer.append(song.title) raw_footer.append(author_list) - raw_footer.append(song.copyright ) + raw_footer.append(song.copyright) raw_footer.append(unicode( translate('SongsPlugin.MediaItem', 'CCLI License: ') + QtCore.QSettings().value(u'general/ccli number', @@ -417,26 +418,30 @@ class SongMediaItem(MediaManagerItem): item.data_string[u'title'].split(u'@')[0].lower() , Song.search_title.asc()) author_list = item.data_string[u'authors'].split(u', ') + # The service item always has an author (at least it has u'' + # as author). However, songs saved in the database do not + # have to have an author. + if u'' in author_list: + author_list.remove(u'') editId = 0 uuid = item._uuid + add_song = True if search_results: for song in search_results: - count = 0 + same_author = True for author in song.authors: - if author.display_name in author_list: - count += 1 - # All Authors the same - if count == len(author_list): + if author.display_name not in author_list: + same_author = False + # All Authors the same, so we can stop here and the song + # does not have to be saved. + if same_author: editId = song.id - else: - # Authors different - if self.addSongFromService: - editId = self.openLyrics. \ - xml_to_song(item.xml_version) - else: - # Title does not match + add_song = False + break + if add_song: + # Authors different if self.addSongFromService: - editId = self.openLyrics.xml_to_song(item.xml_version) + editId = self.openLyrics. xml_to_song(item.xml_version) # Update service with correct song id if editId != 0: Receiver.send_message(u'service_item_update', From fe452bc588b3764f72f4320167dd022c13c5fbc6 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Thu, 16 Dec 2010 20:12:34 +0100 Subject: [PATCH 4/6] removed mistakes --- openlp/plugins/songs/lib/mediaitem.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 224063c47..884cf4a8b 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -418,9 +418,9 @@ class SongMediaItem(MediaManagerItem): item.data_string[u'title'].split(u'@')[0].lower() , Song.search_title.asc()) author_list = item.data_string[u'authors'].split(u', ') - # The service item always has an author (at least it has u'' - # as author). However, songs saved in the database do not - # have to have an author. + # The service item always has an author (at least it has u'' as + # author). However, songs saved in the database do not have to have + # an author. if u'' in author_list: author_list.remove(u'') editId = 0 @@ -428,20 +428,20 @@ class SongMediaItem(MediaManagerItem): add_song = True if search_results: for song in search_results: - same_author = True + same_authors = True for author in song.authors: if author.display_name not in author_list: - same_author = False + same_authors = False # All Authors the same, so we can stop here and the song # does not have to be saved. - if same_author: + if same_authors: editId = song.id add_song = False break if add_song: # Authors different if self.addSongFromService: - editId = self.openLyrics. xml_to_song(item.xml_version) + editId = self.openLyrics.xml_to_song(item.xml_version) # Update service with correct song id if editId != 0: Receiver.send_message(u'service_item_update', From 3cdac511e2955b3d1ba79babed593a2f1cf99650 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 17 Dec 2010 14:30:48 +0100 Subject: [PATCH 5/6] fixed bug #690774 --- openlp/plugins/songs/lib/mediaitem.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 884cf4a8b..e42cb7fa3 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -429,20 +429,26 @@ class SongMediaItem(MediaManagerItem): if search_results: for song in search_results: same_authors = True - for author in song.authors: - if author.display_name not in author_list: - same_authors = False - # All Authors the same, so we can stop here and the song + # If the author counts are different, we do not have to do + # any further checking. This is also important when a song + # does not have any author (because we can not loop over an + # empty list). + if len(song.authors) == len(author_list): + for author in song.authors: + if author.display_name not in author_list: + same_authors = False + else: + same_authors = False + # All authors are the same, so we can stop here and the song # does not have to be saved. if same_authors: - editId = song.id add_song = False + editId = song.id break if add_song: - # Authors different if self.addSongFromService: editId = self.openLyrics.xml_to_song(item.xml_version) - # Update service with correct song id + # Update service with correct song id. if editId != 0: Receiver.send_message(u'service_item_update', u'%s:%s' %(editId, uuid)) From fa79dd2cca89638a936459eac89a67600882f8c9 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 17 Dec 2010 15:28:19 +0100 Subject: [PATCH 6/6] keep copyright field empty if imported song does not have any copyright information --- openlp/core/lib/serviceitem.py | 1 + openlp/plugins/songs/lib/xml.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index b9394030a..9b4a035a5 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -44,6 +44,7 @@ class ServiceItemType(object): Image = 2 Command = 3 + class ItemCapabilities(object): """ Provides an enumeration of a serviceitem's capabilities diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index d26919d79..9d98737dc 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -297,6 +297,8 @@ class OpenLyricsParser(object): song_xml = objectify.fromstring(xml) properties = song_xml.properties song.copyright = unicode(properties.copyright.text) + if song.copyright == u'None': + song.copyright = u'' song.verse_order = unicode(properties.verseOrder.text) if song.verse_order == u'None': song.verse_order = u'' @@ -357,7 +359,7 @@ class OpenLyricsParser(object): def _add_text_to_element(self, tag, parent, text=None, label=None): if label: - element = etree.Element(tag, name = unicode(label)) + element = etree.Element(tag, name=unicode(label)) else: element = etree.Element(tag) if text: