diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 3752ffc4d..2d563962e 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -541,4 +541,3 @@ class MediaManagerItem(QtGui.QWidget): individual service items need to be processed by the plugins """ pass - diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index ff136de54..362d8c197 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -156,9 +156,11 @@ class PluginManager(object): if plugin.settings_tab: log.debug(u'Inserting settings tab item from %s' % visible_title[u'title']) - settingsform.addTab(visible_title[u'title'], plugin.settings_tab) + settingsform.addTab(visible_title[u'title'], + plugin.settings_tab) else: - log.debug(u'No tab settings in %s' % visible_title[u'title']) + log.debug( + u'No tab settings in %s' % visible_title[u'title']) def hook_import_menu(self, import_menu): """ diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 23d0623c5..f9a768205 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -29,11 +29,10 @@ format it for the output display. """ import logging -from PyQt4 import QtGui, QtCore, QtWebKit - -from openlp.core.lib import resize_image, expand_tags, \ - build_lyrics_format_css, build_lyrics_outline_css, image_to_byte +from PyQt4 import QtWebKit +from openlp.core.lib import expand_tags, build_lyrics_format_css, \ + build_lyrics_outline_css log = logging.getLogger(__name__) @@ -116,18 +115,19 @@ class Renderer(object): html_text = u'' styled_text = u'' for line in text: - styled_line = expand_tags(line) - if styled_text: - styled_text += line_end + styled_line + styled_line = expand_tags(line) + line_end + styled_text += styled_line html = self.page_shell + styled_text + u'' self.web.setHtml(html) # Text too long so go to next page if self.web_frame.contentsSize().height() > self.page_height: + if html_text.endswith(u'
'): + html_text = html_text[:len(html_text)-4] formatted.append(html_text) html_text = u'' styled_text = styled_line html_text += line + line_end - if line_break: + if html_text.endswith(u'
'): html_text = html_text[:len(html_text)-4] formatted.append(html_text) log.debug(u'format_slide - End') diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 9ca0ed6cb..ab57e4328 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -32,9 +32,7 @@ import logging import os import uuid -from PyQt4 import QtGui - -from openlp.core.lib import build_icon, resize_image, clean_tags, expand_tags +from openlp.core.lib import build_icon, clean_tags, expand_tags log = logging.getLogger(__name__) @@ -214,7 +212,7 @@ class ServiceItem(object): self.service_item_type = ServiceItemType.Text title = title.split(u'\n')[0] self._raw_frames.append( - {u'title': title, u'raw_slide': raw_slide, u'verseTag':verse_tag}) + {u'title': title, u'raw_slide': raw_slide, u'verseTag': verse_tag}) self._new_item() def add_from_command(self, path, file_name, image): @@ -232,7 +230,7 @@ class ServiceItem(object): """ self.service_item_type = ServiceItemType.Command self._raw_frames.append( - {u'title': file_name, u'image':image, u'path': path}) + {u'title': file_name, u'image': image, u'path': path}) self._new_item() def get_service_repr(self): @@ -243,17 +241,17 @@ class ServiceItem(object): service_header = { u'name': self.name.lower(), u'plugin': self.name, - u'theme':self.theme, - u'title':self.title, - u'icon':self.icon, - u'footer':self.raw_footer, - u'type':self.service_item_type, - u'audit':self.audit, - u'notes':self.notes, - u'from_plugin':self.from_plugin, - u'capabilities':self.capabilities, - u'search':self.search_string, - u'data':self.data_string + u'theme': self.theme, + u'title': self.title, + u'icon': self.icon, + u'footer': self.raw_footer, + u'type': self.service_item_type, + u'audit': self.audit, + u'notes': self.notes, + u'from_plugin': self.from_plugin, + u'capabilities': self.capabilities, + u'search': self.search_string, + u'data': self.data_string } service_data = [] if self.service_item_type == ServiceItemType.Text: @@ -265,7 +263,7 @@ class ServiceItem(object): elif self.service_item_type == ServiceItemType.Command: for slide in self._raw_frames: service_data.append( - {u'title':slide[u'title'], u'image':slide[u'image']}) + {u'title': slide[u'title'], u'image': slide[u'image']}) return {u'header': service_header, u'data': service_data} def set_from_service(self, serviceitem, path=None): diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index cf1859d0b..fcd3c60ab 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -386,10 +386,11 @@ class ThemeXML(object): for e in element.attrib.iteritems(): if master == u'font_' and e[0] == u'type': master += e[1] + u'_' - elif master == u'display_' and (element.tag == u'shadow' \ - or element.tag == u'outline' ): + elif master == u'display_' and (element.tag == u'shadow' + or element.tag == u'outline'): self._create_attr(master, element.tag, element.text) - self._create_attr(master, element.tag + u'_'+ e[0], e[1]) + self._create_attr(master, element.tag + u'_'+ e[0], + e[1]) else: field = master + e[0] self._create_attr(master, e[0], e[1]) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index f31e4c0ff..ffcade344 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -83,7 +83,8 @@ class AdvancedTab(SettingsTab): self.uiLayout.addWidget(self.doubleClickLiveCheckBox) self.leftLayout.addWidget(self.uiGroupBox) self.expandServiceItemCheckBox = QtGui.QCheckBox(self.uiGroupBox) - self.expandServiceItemCheckBox.setObjectName(u'expandServiceItemCheckBox') + self.expandServiceItemCheckBox.setObjectName( + u'expandServiceItemCheckBox') self.uiLayout.addWidget(self.expandServiceItemCheckBox) # self.sharedDirGroupBox = QtGui.QGroupBox(self.leftWidget) # self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox') diff --git a/openlp/core/ui/filerenamedialog.py b/openlp/core/ui/filerenamedialog.py index 897acf02f..02eefe7ed 100644 --- a/openlp/core/ui/filerenamedialog.py +++ b/openlp/core/ui/filerenamedialog.py @@ -34,7 +34,8 @@ class Ui_FileRenameDialog(object): 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.setStandardButtons(QtGui.QDialogButtonBox.Cancel | + QtGui.QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") self.widget = QtGui.QWidget(FileRenameDialog) self.widget.setGeometry(QtCore.QRect(10, 10, 381, 35)) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 2da71e6ef..84b484878 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -30,8 +30,7 @@ import os from PyQt4 import QtCore, QtGui, QtWebKit from PyQt4.phonon import Phonon -from openlp.core.lib import Receiver, resize_image, build_html, ServiceItem, \ - image_to_byte +from openlp.core.lib import Receiver, build_html, ServiceItem, image_to_byte from openlp.core.ui import HideMode log = logging.getLogger(__name__) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 60b1aacf9..c63f3a7fc 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -270,7 +270,8 @@ class Ui_MainWindow(object): self.SettingsPluginListItem.setIcon( build_icon(u':/system/settings_plugin_list.png')) self.SettingsPluginListItem.setObjectName(u'SettingsPluginListItem') - MainWindow.actionList.add_action(self.SettingsPluginListItem, u'Settings') + MainWindow.actionList.add_action(self.SettingsPluginListItem, + u'Settings') #i18n Language Items self.AutoLanguageItem = QtGui.QAction(MainWindow) self.AutoLanguageItem.setObjectName(u'AutoLanguageItem') @@ -296,7 +297,8 @@ class Ui_MainWindow(object): self.SettingsConfigureItem.setIcon( build_icon(u':/system/system_settings.png')) self.SettingsConfigureItem.setObjectName(u'SettingsConfigureItem') - MainWindow.actionList.add_action(self.SettingsShortcutsItem, u'Settings') + MainWindow.actionList.add_action(self.SettingsShortcutsItem, + u'Settings') self.HelpDocumentationItem = QtGui.QAction(MainWindow) self.HelpDocumentationItem.setIcon( build_icon(u':/system/system_help_contents.png')) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index cbde28ae7..a857caee7 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -107,7 +107,8 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): if self.pluginListWidget.currentItem() is None: self._clearDetails() return - plugin_name_plural = self.pluginListWidget.currentItem().text().split(u' ')[0] + plugin_name_plural = \ + self.pluginListWidget.currentItem().text().split(u' ')[0] self.activePlugin = None for plugin in self.parent.plugin_manager.plugins: name_string = plugin.getString(StringContent.Name) diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 629013cc5..98494861a 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -203,13 +203,13 @@ class ServiceManager(QtGui.QWidget): self.orderToolbar.addSeparator() self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', '&Expand all'), - u':/services/service_top.png', + u':/services/service_expand_all.png', translate('OpenLP.ServiceManager', 'Expand all the service items.'), self.onExpandAll) self.orderToolbar.addToolbarButton( translate('OpenLP.ServiceManager', '&Collapse all'), - u':/services/service_bottom.png', + u':/services/service_collapse_all.png', translate('OpenLP.ServiceManager', 'Collapse all the service items.'), self.onCollapseAll) @@ -306,7 +306,7 @@ class ServiceManager(QtGui.QWidget): self.editAction.setVisible(False) self.maintainAction.setVisible(False) self.notesAction.setVisible(False) - if serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsEdit) \ + if serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsEdit)\ and hasattr(serviceItem[u'service_item'], u'editId'): self.editAction.setVisible(True) if serviceItem[u'service_item']\ @@ -441,7 +441,8 @@ class ServiceManager(QtGui.QWidget): if setSelected: setSelected = False serviceIterator.value().setSelected(True) - elif serviceIterator.value() and serviceIterator.value().isSelected(): + elif serviceIterator.value() and \ + serviceIterator.value().isSelected(): serviceIterator.value().setSelected(False) setSelected = True serviceIterator += 1 @@ -761,7 +762,8 @@ class ServiceManager(QtGui.QWidget): serviceitem.set_from_service(item, self.servicePath) self.validateItem(serviceitem) self.addServiceItem(serviceitem) - if serviceitem.is_capable(ItemCapabilities.OnLoadUpdate): + if serviceitem.is_capable( + ItemCapabilities.OnLoadUpdate): Receiver.send_message(u'%s_service_load' % serviceitem.name.lower(), serviceitem) try: diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index 0316b0ee0..e83c2cc7d 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -69,7 +69,7 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): if event.modifiers() & Qt.AltModifier == Qt.AltModifier: key_string = u'Alt+' + key_string if event.modifiers() & Qt.ShiftModifier == Qt.ShiftModifier: - key_string = u'Shift+' + key_string; + key_string = u'Shift+' + key_string key_sequence = QtGui.QKeySequence(key_string) existing_key = QtGui.QKeySequence("Ctrl+Shift+F8") if key_sequence == existing_key: diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 59ae353cc..61fc78cd3 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -26,7 +26,6 @@ import logging import os -import time from PyQt4 import QtCore, QtGui from PyQt4.phonon import Phonon @@ -794,9 +793,11 @@ class SlideController(QtGui.QWidget): row = self.PreviewListWidget.currentRow() self.selectedRow = 0 if row > -1 and row < self.PreviewListWidget.rowCount(): - if self.serviceItem.is_command() and self.isLive: - Receiver.send_message(u'%s_slide' % self.serviceItem.name.lower(), - [self.serviceItem, self.isLive, row]) + if self.serviceItem.is_command(): + if self.isLive: + Receiver.send_message( + u'%s_slide' % self.serviceItem.name.lower(), + [self.serviceItem, self.isLive, row]) self.updatePreview() else: toDisplay = self.serviceItem.get_rendered_frame(row) diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 893e4adba..31afe93d1 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -79,7 +79,7 @@ class CategoryActionList(object): """ return self.__next__() - def has_key(key): + def has_key(self, key): for weight, action in self.actions: if action.text() == key: return True @@ -144,7 +144,7 @@ class CategoryList(object): return True return False - def append(self, name, actions=[]): + def append(self, name, actions=None): weight = 0 if len(self.categories) > 0: weight = self.categories[-1].weight + 1 @@ -153,7 +153,7 @@ class CategoryList(object): else: self.add(name, weight) - def add(self, name, weight=0, actions=[]): + def add(self, name, weight=0, actions=None): category = ActionCategory(name, weight) if actions: for action in actions: diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index 15b1ed6f9..fbd51a13a 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -85,7 +85,11 @@ class AlertsPlugin(Plugin): self.liveController.alertTab = self.alertsTab def finalise(self): + """ + Tidy up on exit + """ log.info(u'Alerts Finalising') + self.manager.finalise() Plugin.finalise(self) self.toolsAlertItem.setVisible(False) @@ -117,11 +121,3 @@ class AlertsPlugin(Plugin): self.textStrings[StringContent.VisibleName] = { u'title': translate('AlertsPlugin', 'Alerts') } - - def finalise(self): - """ - Time to tidy up on exit - """ - log.info(u'Alerts Finalising') - self.manager.finalise() - Plugin.finalise(self) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 946b4ab93..42976cde6 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -52,7 +52,11 @@ class BiblePlugin(Plugin): self.exportBibleItem.setVisible(True) def finalise(self): + """ + Tidy up on exit + """ log.info(u'Plugin Finalise') + self.manager.finalise() Plugin.finalise(self) self.importBibleItem.setVisible(False) self.exportBibleItem.setVisible(False) @@ -172,11 +176,3 @@ class BiblePlugin(Plugin): u'tooltip': translate('BiblesPlugin', 'Add the selected Bible to the service') } - - def finalise(self): - """ - Time to tidy up on exit - """ - log.info(u'Bible Finalising') - self.manager.finalise() - Plugin.finalise(self) diff --git a/openlp/plugins/media/lib/mediatab.py b/openlp/plugins/media/lib/mediatab.py index cc8a34705..e67da62df 100644 --- a/openlp/plugins/media/lib/mediatab.py +++ b/openlp/plugins/media/lib/mediatab.py @@ -80,5 +80,3 @@ class MediaTab(SettingsTab): QtCore.QSettings().setValue(self.settingsSection + u'/use phonon', QtCore.QVariant(self.usePhonon)) Receiver.send_message(u'config_screen_changed') - - diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 780884075..8ee3e2811 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -61,7 +61,8 @@ class PresentationPlugin(Plugin): Create the settings Tab """ visible_name = self.getString(StringContent.VisibleName) - return PresentationTab(self.name, visible_name[u'title'], self.controllers) + return PresentationTab(self.name, visible_name[u'title'], + self.controllers) def initialise(self): """ @@ -188,4 +189,4 @@ class PresentationPlugin(Plugin): u'title': translate('PresentationPlugin', 'Service'), u'tooltip': translate('PresentationPlugin', 'Add the selected Presentation to the service') - } \ No newline at end of file + } diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 005ca0192..1d7b5f1c2 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -43,7 +43,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ log.info(u'%s EditSongForm loaded', __name__) - def __init__(self, parent, songmanager): + def __init__(self, parent, manager): """ Constructor """ @@ -100,7 +100,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtCore.QObject.connect(self.ButtonBox, QtCore.SIGNAL(u'clicked(QAbstractButton*)'), self.onPreview) # Create other objects and forms - self.songmanager = songmanager + self.manager = manager self.verse_form = EditVerseForm(self) self.initialise() self.AuthorsListView.setSortingEnabled(False) @@ -116,7 +116,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.TopicRemoveButton.setEnabled(False) def loadAuthors(self): - authors = self.songmanager.get_all_objects(Author, + authors = self.manager.get_all_objects(Author, order_by_ref=Author.display_name) self.AuthorsSelectionComboItem.clear() self.AuthorsSelectionComboItem.addItem(u'') @@ -127,8 +127,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): row, QtCore.QVariant(author.id)) def loadTopics(self): - topics = self.songmanager.get_all_objects(Topic, - order_by_ref=Topic.name) + topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name) self.SongTopicCombo.clear() self.SongTopicCombo.addItem(u'') for topic in topics: @@ -137,7 +136,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.SongTopicCombo.setItemData(row, QtCore.QVariant(topic.id)) def loadBooks(self): - books = self.songmanager.get_all_objects(Book, order_by_ref=Book.name) + books = self.manager.get_all_objects(Book, order_by_ref=Book.name) self.SongbookCombo.clear() self.SongbookCombo.addItem(u'') for book in books: @@ -177,15 +176,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.loadAuthors() self.loadTopics() self.loadBooks() - self.song = self.songmanager.get_object(Song, id) + self.song = self.manager.get_object(Song, id) self.TitleEditItem.setText(self.song.title) if self.song.alternate_title: self.AlternativeEdit.setText(self.song.alternate_title) else: self.AlternativeEdit.setText(u'') if self.song.song_book_id != 0: - book_name = self.songmanager.get_object(Book, - self.song.song_book_id) + book_name = self.manager.get_object(Book, self.song.song_book_id) id = self.SongbookCombo.findText( unicode(book_name.name), QtCore.Qt.MatchExactly) if id == -1: @@ -299,7 +297,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): else: author = Author.populate(first_name=text.rsplit(u' ', 1)[0], last_name=text.rsplit(u' ', 1)[1], display_name=text) - self.songmanager.save_object(author) + self.manager.save_object(author) author_item = QtGui.QListWidgetItem( unicode(author.display_name)) author_item.setData(QtCore.Qt.UserRole, @@ -311,7 +309,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): return elif item > 0: item_id = (self.AuthorsSelectionComboItem.itemData(item)).toInt()[0] - author = self.songmanager.get_object(Author, item_id) + author = self.manager.get_object(Author, item_id) if self.AuthorsListView.findItems(unicode(author.display_name), QtCore.Qt.MatchExactly): QtGui.QMessageBox.warning(self, @@ -354,7 +352,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: topic = Topic.populate(name=text) - self.songmanager.save_object(topic) + self.manager.save_object(topic) topic_item = QtGui.QListWidgetItem(unicode(topic.name)) topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) @@ -365,7 +363,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): return elif item > 0: item_id = (self.SongTopicCombo.itemData(item)).toInt()[0] - topic = self.songmanager.get_object(Topic, item_id) + topic = self.manager.get_object(Topic, item_id) if self.TopicsListView.findItems(unicode(topic.name), QtCore.Qt.MatchExactly): QtGui.QMessageBox.warning(self, @@ -598,7 +596,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): The Song is valid so as the plugin to add it to preview to see. """ log.debug(u'onPreview') - if unicode(button.objectName()) == u'previewButton' and self.saveSong(): + if unicode(button.objectName()) == u'previewButton' and \ + self.saveSong(True): Receiver.send_message(u'songs_preview') def closePressed(self): @@ -619,17 +618,20 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: book = Book.populate(name=text, publisher=u'') - self.songmanager.save_object(book) + self.manager.save_object(book) else: return if self.saveSong(): Receiver.send_message(u'songs_load_list') self.close() - def saveSong(self): + def saveSong(self, preview=False): """ Get all the data from the widgets on the form, and then save it to the database. + + ``preview`` + Should be True if song is also previewed. """ self.song.title = unicode(self.TitleEditItem.text()) self.song.alternate_title = unicode(self.AlternativeEdit.text()) @@ -642,7 +644,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.song_number = unicode(self.songBookNumberEdit.text()) book_name = unicode(self.SongbookCombo.currentText()) if book_name: - self.song.book = self.songmanager.get_object_filtered(Book, + self.song.book = self.manager.get_object_filtered(Book, Book.name == book_name) else: self.song.book = None @@ -653,16 +655,16 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): for row in range(self.AuthorsListView.count()): item = self.AuthorsListView.item(row) authorId = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.song.authors.append(self.songmanager.get_object(Author, + self.song.authors.append(self.manager.get_object(Author, authorId)) self.song.topics = [] for row in range(self.TopicsListView.count()): item = self.TopicsListView.item(row) topicId = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.song.topics.append(self.songmanager.get_object(Topic, - topicId)) - self.songmanager.save_object(self.song) - self.song = None + self.song.topics.append(self.manager.get_object(Topic, topicId)) + self.manager.save_object(self.song) + if not preview: + self.song = None return True return False diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index 48f9a5a55..7c13e0989 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -36,13 +36,13 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ Class documentation goes here. """ - def __init__(self, songmanager, parent=None): + def __init__(self, manager, parent=None): """ Constructor """ QtGui.QDialog.__init__(self, parent) self.setupUi(self) - self.songmanager = songmanager + self.manager = manager self.authorform = AuthorsForm(self) self.topicform = TopicsForm(self) self.bookform = SongBookForm(self) @@ -85,12 +85,12 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): del_text, err_text, sel_text): item_id = self._getCurrentItemId(list_widget) if item_id != -1: - item = self.songmanager.get_object(item_class, item_id) + item = self.manager.get_object(item_class, item_id) if item and len(item.songs) == 0: if QtGui.QMessageBox.warning(self, dlg_title, del_text, QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: - self.songmanager.delete_object(item_class, item.id) + self.manager.delete_object(item_class, item.id) reset_func() else: QtGui.QMessageBox.critical(self, dlg_title, err_text) @@ -102,7 +102,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): Reloads the Authors list. """ self.AuthorsListWidget.clear() - authors = self.songmanager.get_all_objects(Author, + authors = self.manager.get_all_objects(Author, order_by_ref=Author.display_name) for author in authors: if author.display_name: @@ -124,8 +124,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): Reloads the Topics list. """ self.TopicsListWidget.clear() - topics = self.songmanager.get_all_objects(Topic, - order_by_ref=Topic.name) + topics = self.manager.get_all_objects(Topic, order_by_ref=Topic.name) for topic in topics: topic_name = QtGui.QListWidgetItem(topic.name) topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) @@ -142,7 +141,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): Reloads the Books list. """ self.BooksListWidget.clear() - books = self.songmanager.get_all_objects(Book, order_by_ref=Book.name) + books = self.manager.get_all_objects(Book, order_by_ref=Book.name) for book in books: book_name = QtGui.QListWidgetItem(u'%s (%s)' % (book.name, book.publisher)) @@ -160,7 +159,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): Returns False if the given Author is already in the list otherwise True. """ - authors = self.songmanager.get_all_objects(Author, + authors = self.manager.get_all_objects(Author, and_(Author.first_name == new_author.first_name, Author.last_name == new_author.last_name, Author.display_name == new_author.display_name)) @@ -182,7 +181,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ Returns False if the given Topic is already in the list otherwise True. """ - topics = self.songmanager.get_all_objects(Topic, + topics = self.manager.get_all_objects(Topic, Topic.name == new_topic.name) if len(topics) > 0: # If we edit an existing Topic, we need to make sure that we do @@ -202,7 +201,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ Returns False if the given Book is already in the list otherwise True. """ - books = self.songmanager.get_all_objects(Book, + books = self.manager.get_all_objects(Book, and_(Book.name == new_book.name, Book.publisher == new_book.publisher)) if len(books) > 0: @@ -227,7 +226,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): last_name=unicode(self.authorform.LastNameEdit.text()), display_name=unicode(self.authorform.DisplayEdit.text())) if self.checkAuthor(author): - if self.songmanager.save_object(author): + if self.manager.save_object(author): self.resetAuthors() else: QtGui.QMessageBox.critical(self, @@ -244,7 +243,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if self.topicform.exec_(): topic = Topic.populate(name=unicode(self.topicform.NameEdit.text())) if self.checkTopic(topic): - if self.songmanager.save_object(topic): + if self.manager.save_object(topic): self.resetTopics() else: QtGui.QMessageBox.critical(self, @@ -262,7 +261,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): book = Book.populate(name=unicode(self.bookform.NameEdit.text()), publisher=unicode(self.bookform.PublisherEdit.text())) if self.checkBook(book): - if self.songmanager.save_object(book): + if self.manager.save_object(book): self.resetBooks() else: QtGui.QMessageBox.critical(self, @@ -278,7 +277,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onAuthorEditButtonClick(self): author_id = self._getCurrentItemId(self.AuthorsListWidget) if author_id != -1: - author = self.songmanager.get_object(Author, author_id) + author = self.manager.get_object(Author, author_id) self.authorform.setAutoDisplayName(False) self.authorform.FirstNameEdit.setText(author.first_name) self.authorform.LastNameEdit.setText(author.last_name) @@ -295,7 +294,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): author.display_name = unicode( self.authorform.DisplayEdit.text()) if self.checkAuthor(author, True): - if self.songmanager.save_object(author): + if self.manager.save_object(author): self.resetAuthors() Receiver.send_message(u'songs_load_list') else: @@ -330,14 +329,14 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onTopicEditButtonClick(self): topic_id = self._getCurrentItemId(self.TopicsListWidget) if topic_id != -1: - topic = self.songmanager.get_object(Topic, topic_id) + topic = self.manager.get_object(Topic, topic_id) self.topicform.NameEdit.setText(topic.name) # Save the topic's name for the case that he has to be restored. temp_name = topic.name if self.topicform.exec_(False): topic.name = unicode(self.topicform.NameEdit.text()) if self.checkTopic(topic, True): - if self.songmanager.save_object(topic): + if self.manager.save_object(topic): self.resetTopics() else: QtGui.QMessageBox.critical(self, @@ -367,7 +366,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): def onBookEditButtonClick(self): book_id = self._getCurrentItemId(self.BooksListWidget) if book_id != -1: - book = self.songmanager.get_object(Book, book_id) + book = self.manager.get_object(Book, book_id) if book.publisher is None: book.publisher = u'' self.bookform.NameEdit.setText(book.name) @@ -380,7 +379,7 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): book.name = unicode(self.bookform.NameEdit.text()) book.publisher = unicode(self.bookform.PublisherEdit.text()) if self.checkBook(book, True): - if self.songmanager.save_object(book): + if self.manager.save_object(book): self.resetBooks() else: QtGui.QMessageBox.critical(self, @@ -410,11 +409,11 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): ``old_author`` The author which will be deleted afterwards. """ - existing_author = self.songmanager.get_object_filtered(Author, + existing_author = self.manager.get_object_filtered(Author, and_(Author.first_name == old_author.first_name, Author.last_name == old_author.last_name, Author.display_name == old_author.display_name)) - songs = self.songmanager.get_all_objects(Song, + songs = self.manager.get_all_objects(Song, Song.authors.contains(old_author)) for song in songs: # We check if the song has already existing_author as author. If @@ -422,8 +421,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if existing_author not in song.authors: song.authors.append(existing_author) song.authors.remove(old_author) - self.songmanager.save_object(song) - self.songmanager.delete_object(Author, old_author.id) + self.manager.save_object(song) + self.manager.delete_object(Author, old_author.id) def mergeTopics(self, old_topic): """ @@ -432,9 +431,9 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): ``old_topic`` The topic which will be deleted afterwards. """ - existing_topic = self.songmanager.get_object_filtered(Topic, + existing_topic = self.manager.get_object_filtered(Topic, Topic.name == old_topic.name) - songs = self.songmanager.get_all_objects(Song, + songs = self.manager.get_all_objects(Song, Song.topics.contains(old_topic)) for song in songs: # We check if the song has already existing_topic as topic. If that @@ -442,8 +441,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): if existing_topic not in song.topics: song.topics.append(existing_topic) song.topics.remove(old_topic) - self.songmanager.save_object(song) - self.songmanager.delete_object(Topic, old_topic.id) + self.manager.save_object(song) + self.manager.delete_object(Topic, old_topic.id) def mergeBooks(self, old_book): """ @@ -452,15 +451,15 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): ``old_book`` The book which will be deleted afterwards. """ - existing_book = self.songmanager.get_object_filtered(Book, + existing_book = self.manager.get_object_filtered(Book, and_(Book.name == old_book.name, Book.publisher == old_book.publisher)) - songs = self.songmanager.get_all_objects(Song, + songs = self.manager.get_all_objects(Song, Song.song_book_id == old_book.id) for song in songs: song.song_book_id = existing_book.id - self.songmanager.save_object(song) - self.songmanager.delete_object(Book, old_book.id) + self.manager.save_object(song) + self.manager.delete_object(Book, old_book.id) def onAuthorDeleteButtonClick(self): """ diff --git a/openlp/plugins/songs/lib/cclifileimport.py b/openlp/plugins/songs/lib/cclifileimport.py index c52343844..b30ec20ce 100644 --- a/openlp/plugins/songs/lib/cclifileimport.py +++ b/openlp/plugins/songs/lib/cclifileimport.py @@ -208,9 +208,9 @@ class CCLIFileImport(SongImport): SongSelect .txt file format:: - Song Title # Contains the song title + Song Title # Contains the song title - Verse type and number # e.g. Verse 1, Chorus 1 + Verse type and number # e.g. Verse 1, Chorus 1 Verse lyrics @@ -218,12 +218,16 @@ class CCLIFileImport(SongImport): Verse lyrics - Song CCLI number # e.g. CCLI Number (e.g.CCLI-Liednummer: 2672885) - Song copyright # e.g. © 1999 Integrity's Hosanna! Music | LenSongs Publishing - Song authors # e.g. Lenny LeBlanc | Paul Baloche - Licencing info # e.g. For use solely with the SongSelect Terms of Use. + Song CCLI number + # e.g. CCLI Number (e.g.CCLI-Liednummer: 2672885) + Song copyright + # e.g. © 1999 Integrity's Hosanna! Music | LenSongs Publishing + Song authors # e.g. Lenny LeBlanc | Paul Baloche + Licencing info + # e.g. For use solely with the SongSelect Terms of Use. All rights Reserved. www.ccli.com - CCLI Licence number of user # e.g. CCL-Liedlizenznummer: 14 / CCLI License No. 14 + CCLI Licence number of user + # e.g. CCL-Liedlizenznummer: 14 / CCLI License No. 14 """ log.debug(u'TXT file text: %s', textList) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 03e4e909c..cd921b9ef 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -389,7 +389,8 @@ class SongMediaItem(MediaManagerItem): service_item.audit = [ song.title, author_audit, song.copyright, unicode(song.ccli_number) ] - service_item.data_string = {u'title':song.search_title, u'authors':author_list} + service_item.data_string = {u'title':song.search_title, + u'authors':author_list} return True def serviceLoad(self, item): @@ -409,7 +410,7 @@ class SongMediaItem(MediaManagerItem): count = 0 for author in song.authors: if author.display_name in author_list: - count += 1 + count += 1 if count == len(author_list): editId = song.id uuid = item._uuid diff --git a/openlp/plugins/songs/lib/opensongimport.py b/openlp/plugins/songs/lib/opensongimport.py index f4be0dc87..47f4ecee5 100644 --- a/openlp/plugins/songs/lib/opensongimport.py +++ b/openlp/plugins/songs/lib/opensongimport.py @@ -229,14 +229,16 @@ class OpenSongImport(SongImport): # drop the square brackets right_bracket = thisline.find(u']') content = thisline[1:right_bracket].upper() - # have we got any digits? If so, versenumber is everything from the digits + # have we got any digits? + # If so, versenumber is everything from the digits # to the end (even if there are some alpha chars on the end) match = re.match(u'(.*)(\d+.*)', content) if match is not None: versetype = match.group(1) versenum = match.group(2) else: - # otherwise we assume number 1 and take the whole prefix as versetype + # otherwise we assume number 1 and take the whole prefix as + # the versetype versetype = content versenum = u'1' continue @@ -301,6 +303,7 @@ class OpenSongImport(SongImport): # Assume it's no.1 if there's no digits tag = tag + u'1' if not versetags.has_key(tag): - log.info(u'Got order %s but not in versetags, dropping this item from presentation order', tag) + log.info(u'Got order %s but not in versetags, dropping this' + u'item from presentation order', tag) else: self.verse_order_list.append(tag) diff --git a/openlp/plugins/songs/lib/songimport.py b/openlp/plugins/songs/lib/songimport.py index d2e0698b3..2c1de83a2 100644 --- a/openlp/plugins/songs/lib/songimport.py +++ b/openlp/plugins/songs/lib/songimport.py @@ -47,8 +47,9 @@ class SongImport(QtCore.QObject): """ Initialise and create defaults for properties - song_manager is an instance of a SongManager, through which all - database access is performed + ``manager`` + An instance of a SongManager, through which all database access is + performed. """ self.manager = manager self.stop_import_flag = False @@ -296,7 +297,8 @@ class SongImport(QtCore.QObject): song.lyrics = unicode(sxml.extract_xml(), u'utf-8') for i, current_verse_tag in enumerate(self.verse_order_list): if verses_changed_to_other.has_key(current_verse_tag): - self.verse_order_list[i] = verses_changed_to_other[current_verse_tag] + self.verse_order_list[i] = \ + verses_changed_to_other[current_verse_tag] song.verse_order = u' '.join(self.verse_order_list) song.copyright = self.copyright song.comments = self.comments diff --git a/openlp/plugins/songs/lib/songstab.py b/openlp/plugins/songs/lib/songstab.py index 03c1e8844..1ffb5bba6 100644 --- a/openlp/plugins/songs/lib/songstab.py +++ b/openlp/plugins/songs/lib/songstab.py @@ -56,8 +56,10 @@ class SongsTab(SettingsTab): self.SongUpdateOnEditCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox) self.SongUpdateOnEditCheckBox.setObjectName(u'SongUpdateOnEditCheckBox') self.SongsModeLayout.addWidget(self.SongUpdateOnEditCheckBox) - self.SongAddFromServiceCheckBox = QtGui.QCheckBox(self.SongsModeGroupBox) - self.SongAddFromServiceCheckBox.setObjectName(u'SongAddFromServiceCheckBox') + self.SongAddFromServiceCheckBox = QtGui.QCheckBox( + self.SongsModeGroupBox) + self.SongAddFromServiceCheckBox.setObjectName( + u'SongAddFromServiceCheckBox') self.SongsModeLayout.addWidget(self.SongAddFromServiceCheckBox) self.SongsLayout.setWidget( 0, QtGui.QFormLayout.LabelRole, self.SongsModeGroupBox) @@ -83,7 +85,8 @@ class SongsTab(SettingsTab): 'Display verses on live tool bar')) self.SongUpdateOnEditCheckBox.setText( translate('SongsPlugin.SongsTab', 'Update service from song edit')) - self.SongAddFromServiceCheckBox.setText(translate('SongsPlugin.SongsTab', + self.SongAddFromServiceCheckBox.setText( + translate('SongsPlugin.SongsTab', 'Add missing songs when opening service')) def onSearchAsTypeCheckBoxChanged(self, check_state): @@ -132,6 +135,8 @@ class SongsTab(SettingsTab): settings.beginGroup(self.settingsSection) settings.setValue(u'search as type', QtCore.QVariant(self.song_search)) settings.setValue(u'display songbar', QtCore.QVariant(self.song_bar)) - settings.setValue(u'update service on edit', QtCore.QVariant(self.update_edit)) - settings.setValue(u'add song from service', QtCore.QVariant(self.update_load)) + settings.setValue(u'update service on edit', + QtCore.QVariant(self.update_edit)) + settings.setValue(u'add song from service', + QtCore.QVariant(self.update_load)) settings.endGroup() diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 124fe2863..a4081a10c 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -29,7 +29,8 @@ from datetime import datetime from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, StringContent, Receiver, build_icon, translate +from openlp.core.lib import Plugin, StringContent, Receiver, build_icon, \ + translate from openlp.core.lib.db import Manager from openlp.plugins.songusage.forms import SongUsageDetailForm, \ SongUsageDeleteForm @@ -123,7 +124,12 @@ class SongUsagePlugin(Plugin): self.SongUsageMenu.menuAction().setVisible(True) def finalise(self): + """ + Tidy up on exit + """ log.info(u'Plugin Finalise') + self.manager.finalise() + Plugin.finalise(self) self.SongUsageMenu.menuAction().setVisible(False) #stop any events being processed self.SongUsageActive = False @@ -176,11 +182,3 @@ class SongUsagePlugin(Plugin): self.textStrings[StringContent.VisibleName] = { u'title': translate('SongUsagePlugin', 'SongUsage') } - - def finalise(self): - """ - Time to tidy up on exit - """ - log.info(u'SongUsage Finalising') - self.manager.finalise() - Plugin.finalise(self) diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index 7e8645441..0ecb87bca 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -83,6 +83,8 @@ wizard_importbible.bmp + service_collapse_all.png + service_expand_all.png service_notes.png service_item_notes.png service_bottom.png diff --git a/resources/images/service_collapse_all.png b/resources/images/service_collapse_all.png new file mode 100644 index 000000000..6e682fc4d Binary files /dev/null and b/resources/images/service_collapse_all.png differ diff --git a/resources/images/service_expand_all.png b/resources/images/service_expand_all.png new file mode 100644 index 000000000..09b4ba394 Binary files /dev/null and b/resources/images/service_expand_all.png differ