diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9b76447ff..9b780fa75 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -93,8 +93,7 @@ class MediaManagerItem(QtGui.QWidget): QtGui.QWidget.__init__(self) self.parent = parent self.whitespace = re.compile(r'\W+', re.UNICODE) - #TODO: plugin should not be the parent in future - self.plugin = parent # plugin + self.plugin = plugin visible_title = self.plugin.getString(StringContent.VisibleName) self.title = unicode(visible_title[u'title']) self.settingsSection = self.plugin.name.lower() @@ -114,10 +113,10 @@ class MediaManagerItem(QtGui.QWidget): self.retranslateUi() self.autoSelectItem = None QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'%s_service_load' % self.parent.name.lower()), + QtCore.SIGNAL(u'%s_service_load' % self.plugin.name.lower()), self.serviceLoad) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'%s_set_autoselect_item' % self.parent.name.lower()), + QtCore.SIGNAL(u'%s_set_autoselect_item' % self.plugin.name.lower()), self.setAutoSelectItem) def requiredIcons(self): @@ -475,7 +474,7 @@ class MediaManagerItem(QtGui.QWidget): serviceItem = self.buildServiceItem() if serviceItem: serviceItem.from_plugin = True - self.parent.previewController.addServiceItem(serviceItem) + self.plugin.previewController.addServiceItem(serviceItem) if keepFocus: self.listView.setFocus() @@ -503,7 +502,7 @@ class MediaManagerItem(QtGui.QWidget): if serviceItem: if not item_id: serviceItem.from_plugin = True - self.parent.liveController.addServiceItem(serviceItem) + self.plugin.liveController.addServiceItem(serviceItem) def createItemFromId(self, item_id): item = QtGui.QListWidgetItem() @@ -533,7 +532,7 @@ class MediaManagerItem(QtGui.QWidget): serviceItem = self.buildServiceItem(item, True) if serviceItem: serviceItem.from_plugin = False - self.parent.serviceManager.addServiceItem(serviceItem, + self.plugin.serviceManager.addServiceItem(serviceItem, replace=replace) def onAddEditClick(self): @@ -546,14 +545,14 @@ class MediaManagerItem(QtGui.QWidget): 'You must select one or more items.')) else: log.debug(u'%s Add requested', self.plugin.name) - serviceItem = self.parent.serviceManager.getServiceItem() + serviceItem = self.plugin.serviceManager.getServiceItem() if not serviceItem: QtGui.QMessageBox.information(self, UiStrings().NISs, translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.')) elif self.plugin.name.lower() == serviceItem.name.lower(): self.generateSlideData(serviceItem) - self.parent.serviceManager.addServiceItem(serviceItem, + self.plugin.serviceManager.addServiceItem(serviceItem, replace=True) else: # Turn off the remote edit update message indicator @@ -567,8 +566,8 @@ class MediaManagerItem(QtGui.QWidget): """ Common method for generating a service item """ - serviceItem = ServiceItem(self.parent) - serviceItem.add_icon(self.parent.icon_path) + serviceItem = ServiceItem(self.plugin) + serviceItem.add_icon(self.plugin.icon_path) if self.generateSlideData(serviceItem, item, xmlVersion): return serviceItem else: diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 0417446c1..974c59de2 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -215,7 +215,7 @@ class Plugin(QtCore.QObject): you need, and return it for integration into openlp.org. """ if self.media_item_class: - return self.media_item_class(self, self, self.icon) + return self.media_item_class(self.mediadock, self, self.icon) return None def addImportMenuItem(self, importMenu): diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 13cb4503a..92db42723 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -41,7 +41,8 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): Initialise the alert form """ self.manager = plugin.manager - self.parent = plugin + self.plugin = plugin + self.parent = plugin.formparent self.item_id = None QtGui.QDialog.__init__(self, plugin.formparent) self.setupUi(self) @@ -195,7 +196,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.parameterEdit.setFocus() return False text = text.replace(u'<>', unicode(self.parameterEdit.text())) - self.parent.alertsmanager.displayAlert(text) + self.plugin.alertsmanager.displayAlert(text) return True def onCurrentRowChanged(self, row): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 41059f942..baf04995b 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -61,7 +61,7 @@ class BibleMediaItem(MediaManagerItem): self.unlockIcon = QtGui.QIcon(u':/bibles/bibles_search_unlock.png') MediaManagerItem.__init__(self, parent, plugin, icon) # Place to store the search results for both bibles. - self.settings = self.parent.settings_tab + self.settings = self.plugin.settings_tab self.quickPreviewAllowed = True self.hasSearch = True self.search_results = {} @@ -338,7 +338,7 @@ class BibleMediaItem(MediaManagerItem): def initialise(self): log.debug(u'bible manager initialise') - self.parent.manager.media = self + self.plugin.manager.media = self self.loadBibles() bible = QtCore.QSettings().value( self.settingsSection + u'/quick bible', QtCore.QVariant( @@ -365,7 +365,7 @@ class BibleMediaItem(MediaManagerItem): self.quickSecondComboBox.addItem(u'') self.advancedSecondComboBox.addItem(u'') # Get all bibles and sort the list. - bibles = self.parent.manager.get_bibles().keys() + bibles = self.plugin.manager.get_bibles().keys() bibles.sort(cmp=locale.strcoll) # Load the bibles into the combo boxes. for bible in bibles: @@ -386,7 +386,7 @@ class BibleMediaItem(MediaManagerItem): def reloadBibles(self): log.debug(u'Reloading Bibles') - self.parent.manager.reload_bibles() + self.plugin.manager.reload_bibles() self.loadBibles() def initialiseAdvancedBible(self, bible): @@ -400,7 +400,7 @@ class BibleMediaItem(MediaManagerItem): The bible to initialise (unicode). """ log.debug(u'initialiseAdvancedBible %s', bible) - book_data = self.parent.manager.get_books(bible) + book_data = self.plugin.manager.get_books(bible) self.advancedBookComboBox.clear() first = True for book in book_data: @@ -416,7 +416,7 @@ class BibleMediaItem(MediaManagerItem): def initialiseChapterVerse(self, bible, book, chapter_count): log.debug(u'initialiseChapterVerse %s, %s', bible, book) self.chapter_count = chapter_count - verse_count = self.parent.manager.get_verse_count(bible, book, 1) + verse_count = self.plugin.manager.get_verse_count(bible, book, 1) if verse_count == 0: self.advancedSearchButton.setEnabled(False) critical_error_message_box( @@ -445,7 +445,7 @@ class BibleMediaItem(MediaManagerItem): books = [] # We have to do a 'Reference Search'. if self.quickSearchEdit.currentSearchType() == BibleSearch.Reference: - bibles = self.parent.manager.get_bibles() + bibles = self.plugin.manager.get_bibles() bible = unicode(self.quickVersionComboBox.currentText()) if bible: book_data = bibles[bible].get_books() @@ -455,8 +455,8 @@ class BibleMediaItem(MediaManagerItem): def onImportClick(self): if not hasattr(self, u'import_wizard'): - self.import_wizard = BibleImportForm(self, self.parent.manager, - self.parent) + self.import_wizard = BibleImportForm(self, self.plugin.manager, + self.plugin) # If the import was not cancelled then reload. if self.import_wizard.exec_(): self.reloadBibles() @@ -515,7 +515,7 @@ class BibleMediaItem(MediaManagerItem): bible = unicode(self.advancedVersionComboBox.currentText()) book = unicode(self.advancedBookComboBox.currentText()) verse_from = int(self.advancedFromVerse.currentText()) - verse_count = self.parent.manager.get_verse_count(bible, book, + verse_count = self.plugin.manager.get_verse_count(bible, book, chapter_to) self.adjustComboBox(verse_from, verse_count, self.advancedToVerse, True) @@ -527,7 +527,7 @@ class BibleMediaItem(MediaManagerItem): chapter_to = int(self.advancedToChapter.currentText()) verse_from = int(self.advancedFromVerse.currentText()) verse_to = int(self.advancedToVerse.currentText()) - verse_count = self.parent.manager.get_verse_count(bible, book, + verse_count = self.plugin.manager.get_verse_count(bible, book, chapter_to) if chapter_from == chapter_to and verse_from > verse_to: self.adjustComboBox(verse_from, verse_count, self.advancedToVerse) @@ -539,7 +539,7 @@ class BibleMediaItem(MediaManagerItem): book = unicode(self.advancedBookComboBox.currentText()) chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) - verse_count = self.parent.manager.get_verse_count(bible, book, + verse_count = self.plugin.manager.get_verse_count(bible, book, chapter_from) self.adjustComboBox(1, verse_count, self.advancedFromVerse) if chapter_from > chapter_to: @@ -599,9 +599,9 @@ class BibleMediaItem(MediaManagerItem): range_separator + chapter_to + verse_separator + verse_to versetext = u'%s %s' % (book, verse_range) Receiver.send_message(u'cursor_busy') - self.search_results = self.parent.manager.get_verses(bible, versetext) + self.search_results = self.plugin.manager.get_verses(bible, versetext) if second_bible: - self.second_search_results = self.parent.manager.get_verses( + self.second_search_results = self.plugin.manager.get_verses( second_bible, versetext) if not self.advancedLockButton.isChecked(): self.listView.clear() @@ -627,15 +627,15 @@ class BibleMediaItem(MediaManagerItem): text = unicode(self.quickSearchEdit.text()) if self.quickSearchEdit.currentSearchType() == BibleSearch.Reference: # We are doing a 'Reference Search'. - self.search_results = self.parent.manager.get_verses(bible, text) + self.search_results = self.plugin.manager.get_verses(bible, text) if second_bible and self.search_results: - self.second_search_results = self.parent.manager.get_verses( + self.second_search_results = self.plugin.manager.get_verses( second_bible, text) else: # We are doing a 'Text Search'. Receiver.send_message(u'cursor_busy') - bibles = self.parent.manager.get_bibles() - self.search_results = self.parent.manager.verse_search(bible, + bibles = self.plugin.manager.get_bibles() + self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) if second_bible and self.search_results: text = [] @@ -674,19 +674,19 @@ class BibleMediaItem(MediaManagerItem): further action is saved for/in each row. """ verse_separator = get_reference_match(u'sep_v_display') - version = self.parent.manager.get_meta_data(bible, u'Version').value - copyright = self.parent.manager.get_meta_data(bible, u'Copyright').value + version = self.plugin.manager.get_meta_data(bible, u'Version').value + copyright = self.plugin.manager.get_meta_data(bible, u'Copyright').value permissions = \ - self.parent.manager.get_meta_data(bible, u'Permissions').value + self.plugin.manager.get_meta_data(bible, u'Permissions').value second_version = u'' second_copyright = u'' second_permissions = u'' if second_bible: - second_version = self.parent.manager.get_meta_data( + second_version = self.plugin.manager.get_meta_data( second_bible, u'Version').value - second_copyright = self.parent.manager.get_meta_data( + second_copyright = self.plugin.manager.get_meta_data( second_bible, u'Copyright').value - second_permissions = self.parent.manager.get_meta_data( + second_permissions = self.plugin.manager.get_meta_data( second_bible, u'Permissions').value items = [] for count, verse in enumerate(search_results): @@ -879,7 +879,7 @@ class BibleMediaItem(MediaManagerItem): # We are still in the same chapter, but a verse has been skipped. return True elif old_chapter + 1 == chapter and (verse != 1 or - old_verse != self.parent.manager.get_verse_count( + old_verse != self.plugin.manager.get_verse_count( old_bible, old_book, old_chapter)): # We are in the following chapter, but the last verse was not the # last verse of the chapter or the current verse is not the @@ -923,7 +923,7 @@ class BibleMediaItem(MediaManagerItem): Search for some Bible verses (by reference). """ bible = unicode(self.quickVersionComboBox.currentText()) - search_results = self.parent.manager.get_verses(bible, string, False) + search_results = self.plugin.manager.get_verses(bible, string, False) results = [] if search_results: versetext = u' '.join([verse.text for verse in search_results]) @@ -933,6 +933,6 @@ class BibleMediaItem(MediaManagerItem): def createItemFromId(self, item_id): item = QtGui.QListWidgetItem() bible = unicode(self.quickVersionComboBox.currentText()) - search_results = self.parent.manager.get_verses(bible, item_id, False) + search_results = self.plugin.manager.get_verses(bible, item_id, False) items = self.buildDisplayResults(bible, u'', search_results) return items diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 0e4376634..68d11404d 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -43,13 +43,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Class documentation goes here. """ log.info(u'Custom Editor loaded') - def __init__(self, parent): + def __init__(self, plugin): """ Constructor """ - QtGui.QDialog.__init__(self) - self.parent = parent - self.manager = self.parent.manager + self.plugin = plugin + QtGui.QDialog.__init__(self, self.plugin.formparent) + self.manager = self.plugin.manager self.setupUi(self) # Create other objects and forms. self.editSlideForm = EditCustomSlideForm(self) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 43f4afd63..4a9dd8140 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -56,14 +56,14 @@ class CustomMediaItem(MediaManagerItem): def __init__(self, parent, plugin, icon): self.IconPath = u'custom/custom' - MediaManagerItem.__init__(self, parent, self, icon) + MediaManagerItem.__init__(self, parent, plugin, icon) self.singleServiceItem = False self.quickPreviewAllowed = True self.hasSearch = True # Holds information about whether the edit is remotly triggered and # which Custom is required. self.remoteCustom = -1 - self.manager = parent.manager + self.manager = plugin.manager def addEndHeaderBar(self): self.addToolbarSeparator() @@ -151,8 +151,8 @@ class CustomMediaItem(MediaManagerItem): self.listView.setCurrentItem(custom_name) def onNewClick(self): - self.parent.edit_custom_form.loadCustom(0) - self.parent.edit_custom_form.exec_() + self.plugin.edit_custom_form.loadCustom(0) + self.plugin.edit_custom_form.exec_() self.initialise() def onRemoteEditClear(self): @@ -170,9 +170,9 @@ class CustomMediaItem(MediaManagerItem): if valid: self.remoteCustom = fields[1] self.remoteTriggered = fields[0] - self.parent.edit_custom_form.loadCustom(fields[1], + self.plugin.edit_custom_form.loadCustom(fields[1], (fields[0] == u'P')) - self.parent.edit_custom_form.exec_() + self.plugin.edit_custom_form.exec_() def onEditClick(self): """ @@ -181,8 +181,8 @@ class CustomMediaItem(MediaManagerItem): if check_item_selected(self.listView, UiStrings().SelectEdit): item = self.listView.currentItem() item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.parent.edit_custom_form.loadCustom(item_id, False) - self.parent.edit_custom_form.exec_() + self.plugin.edit_custom_form.loadCustom(item_id, False) + self.plugin.edit_custom_form.exec_() self.initialise() def onDeleteClick(self): @@ -195,7 +195,7 @@ class CustomMediaItem(MediaManagerItem): id_list = [(item.data(QtCore.Qt.UserRole)).toInt()[0] for item in self.listView.selectedIndexes()] for id in id_list: - self.parent.manager.delete_object(CustomSlide, id) + self.plugin.manager.delete_object(CustomSlide, id) for row in row_list: self.listView.takeItem(row) @@ -212,7 +212,7 @@ class CustomMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) service_item.add_capability(ItemCapabilities.AllowsVirtualSplit) - customSlide = self.parent.manager.get_object(CustomSlide, item_id) + customSlide = self.plugin.manager.get_object(CustomSlide, item_id) title = customSlide.title credit = customSlide.credits service_item.edit_id = item_id @@ -245,13 +245,13 @@ class CustomMediaItem(MediaManagerItem): search_type = self.searchTextEdit.currentSearchType() if search_type == CustomSearch.Titles: log.debug(u'Titles Search') - search_results = self.parent.manager.get_all_objects(CustomSlide, + search_results = self.plugin.manager.get_all_objects(CustomSlide, CustomSlide.title.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%'), order_by_ref=CustomSlide.title) self.loadList(search_results) elif search_type == CustomSearch.Themes: log.debug(u'Theme Search') - search_results = self.parent.manager.get_all_objects(CustomSlide, + search_results = self.plugin.manager.get_all_objects(CustomSlide, CustomSlide.theme_name.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%'), order_by_ref=CustomSlide.title) self.loadList(search_results) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index f760a984e..921a52ede 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -47,7 +47,7 @@ class ImageMediaItem(MediaManagerItem): def __init__(self, parent, plugin, icon): self.IconPath = u'images/image' - MediaManagerItem.__init__(self, parent, self, icon) + MediaManagerItem.__init__(self, parent, plugin, icon) self.quickPreviewAllowed = True self.hasSearch = True QtCore.QObject.connect(Receiver.get_receiver(), @@ -112,14 +112,14 @@ class ImageMediaItem(MediaManagerItem): def loadList(self, list, initialLoad=False): if not initialLoad: - self.parent.formparent.displayProgressBar(len(list)) + self.plugin.formparent.displayProgressBar(len(list)) # Sort the themes by its filename considering language specific # characters. lower() is needed for windows! list.sort(cmp=locale.strcoll, key=lambda filename: os.path.split(unicode(filename))[1].lower()) for imageFile in list: if not initialLoad: - self.parent.formparent.incrementProgressBar() + self.plugin.formparent.incrementProgressBar() filename = os.path.split(unicode(imageFile))[1] thumb = os.path.join(self.servicePath, filename) if os.path.exists(thumb): @@ -134,7 +134,7 @@ class ImageMediaItem(MediaManagerItem): item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile)) self.listView.addItem(item_name) if not initialLoad: - self.parent.formparent.finishedProgressBar() + self.plugin.formparent.finishedProgressBar() def generateSlideData(self, service_item, item=None, xmlVersion=False): if item: @@ -188,7 +188,7 @@ class ImageMediaItem(MediaManagerItem): Called to reset the Live backgound with the image selected, """ self.resetAction.setVisible(False) - self.parent.liveController.display.resetImage() + self.plugin.liveController.display.resetImage() def liveThemeChanged(self): """ @@ -208,7 +208,7 @@ class ImageMediaItem(MediaManagerItem): filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) if os.path.exists(filename): (path, name) = os.path.split(filename) - self.parent.liveController.display.directImage(name, filename) + self.plugin.liveController.display.directImage(name, filename) self.resetAction.setVisible(True) else: critical_error_message_box(UiStrings().LiveBGError, diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 9dc17f4d3..96b97d25a 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -50,7 +50,7 @@ class MediaMediaItem(MediaManagerItem): self.background = False self.PreviewFunction = QtGui.QPixmap( u':/media/media_video.png').toImage() - MediaManagerItem.__init__(self, parent, self, icon) + MediaManagerItem.__init__(self, parent, plugin, icon) self.singleServiceItem = False self.hasSearch = True self.mediaObject = None @@ -65,8 +65,8 @@ class MediaMediaItem(MediaManagerItem): self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)')) % ( - u' '.join(self.parent.video_extensions_list), - u' '.join(self.parent.audio_extensions_list), UiStrings().AllFiles) + u' '.join(self.plugin.video_extensions_list), + u' '.join(self.plugin.audio_extensions_list), UiStrings().AllFiles) self.replaceAction.setText(UiStrings().ReplaceBG) self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG) self.resetAction.setText(UiStrings().ResetBG) @@ -95,7 +95,7 @@ class MediaMediaItem(MediaManagerItem): Called to reset the Live backgound with the media selected, """ self.resetAction.setVisible(False) - self.parent.liveController.display.resetVideo() + self.plugin.liveController.display.resetVideo() def videobackgroundReplaced(self): """ @@ -114,7 +114,7 @@ class MediaMediaItem(MediaManagerItem): filename = unicode(item.data(QtCore.Qt.UserRole).toString()) if os.path.exists(filename): (path, name) = os.path.split(filename) - self.parent.liveController.display.video(filename, 0, True) + self.plugin.liveController.display.video(filename, 0, True) self.resetAction.setVisible(True) else: critical_error_message_box(UiStrings().LiveBGError, diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index b757b5bfd..e138d4ef9 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -46,14 +46,14 @@ class PresentationMediaItem(MediaManagerItem): """ log.info(u'Presentations Media Item loaded') - def __init__(self, parent, icon, title, controllers): + def __init__(self, parent, plugin, icon, controllers): """ Constructor. Setup defaults """ self.controllers = controllers self.IconPath = u'presentations/presentation' self.Automatic = u'' - MediaManagerItem.__init__(self, parent, self, icon) + MediaManagerItem.__init__(self, parent, plugin, icon) self.message_listener = MessageListener(self) self.hasSearch = True QtCore.QObject.connect(Receiver.get_receiver(), @@ -82,7 +82,7 @@ class PresentationMediaItem(MediaManagerItem): for type in types: if fileType.find(type) == -1: fileType += u'*.%s ' % type - self.parent.serviceManager.supportedSuffixes(type) + self.plugin.serviceManager.supportedSuffixes(type) self.onNewFileMasks = unicode(translate('PresentationPlugin.MediaItem', 'Presentations (%s)')) % fileType @@ -161,14 +161,14 @@ class PresentationMediaItem(MediaManagerItem): titles = [os.path.split(file)[1] for file in currlist] Receiver.send_message(u'cursor_busy') if not initialLoad: - self.parent.formparent.displayProgressBar(len(files)) + self.plugin.formparent.displayProgressBar(len(files)) # Sort the themes by its filename considering language specific # characters. lower() is needed for windows! files.sort(cmp=locale.strcoll, key=lambda filename: os.path.split(unicode(filename))[1].lower()) for file in files: if not initialLoad: - self.parent.formparent.incrementProgressBar() + self.plugin.formparent.incrementProgressBar() if currlist.count(file) > 0: continue filename = os.path.split(unicode(file))[1] @@ -208,7 +208,7 @@ class PresentationMediaItem(MediaManagerItem): self.listView.addItem(item_name) Receiver.send_message(u'cursor_normal') if not initialLoad: - self.parent.formparent.finishedProgressBar() + self.plugin.formparent.finishedProgressBar() def onDeleteClick(self): """ diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 171039d15..313e6258f 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -99,7 +99,7 @@ class PresentationPlugin(Plugin): Create the Media Manager List """ return PresentationMediaItem( - self, self.icon, self.name, self.controllers) + self.mediadock, self, self.icon, self.controllers) def registerControllers(self, controller): """ diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 0ff8bc32e..9d29156f7 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -154,12 +154,12 @@ class HttpServer(object): e.g. http://localhost:4316/send/slidecontroller_live_next http://localhost:4316/send/alerts_text?q=your%20alert%20text """ - def __init__(self, parent): + def __init__(self, plugin): """ Initialise the httpserver, and start the server """ log.debug(u'Initialise httpserver') - self.parent = parent + self.plugin = plugin self.html_dir = os.path.join( AppLocation.get_directory(AppLocation.PluginsDir), u'remotes', u'html') @@ -176,10 +176,10 @@ class HttpServer(object): """ log.debug(u'Start TCP server') port = QtCore.QSettings().value( - self.parent.settingsSection + u'/port', + self.plugin.settingsSection + u'/port', QtCore.QVariant(4316)).toInt()[0] address = QtCore.QSettings().value( - self.parent.settingsSection + u'/ip address', + self.plugin.settingsSection + u'/ip address', QtCore.QVariant(u'0.0.0.0')).toString() self.server = QtNetwork.QTcpServer() self.server.listen(QtNetwork.QHostAddress(address), port) @@ -264,7 +264,7 @@ class HttpConnection(object): def _get_service_items(self): service_items = [] - service_manager = self.parent.parent.serviceManager + service_manager = self.parent.plugin.serviceManager if self.parent.current_item: cur_uuid = self.parent.current_item._uuid else: @@ -457,7 +457,7 @@ class HttpConnection(object): """ if action == u'search': searches = [] - for plugin in self.parent.parent.pluginManager.plugins: + for plugin in self.parent.plugin.pluginManager.plugins: if plugin.status == PluginStatus.Active and \ plugin.mediaItem and plugin.mediaItem.hasSearch: searches.append(plugin.name) @@ -473,7 +473,7 @@ class HttpConnection(object): The plugin name to search in. """ text = json.loads(self.url_params[u'data'][0])[u'request'][u'text'] - plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) + plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) if plugin.status == PluginStatus.Active and \ plugin.mediaItem and plugin.mediaItem.hasSearch: results =plugin.mediaItem.search(text) @@ -488,7 +488,7 @@ class HttpConnection(object): Go live on an item of type ``type``. """ id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] - plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) + plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) if plugin.status == PluginStatus.Active and plugin.mediaItem: plugin.mediaItem.goLive(id) @@ -497,7 +497,7 @@ class HttpConnection(object): Add item of type ``type`` to the end of the service """ id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] - plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) + plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) if plugin.status == PluginStatus.Active and plugin.mediaItem: item_id = plugin.mediaItem.createItemFromId(id) plugin.mediaItem.addToService(item_id) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 393009f82..b6e0c04a8 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -52,7 +52,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): Constructor """ QtGui.QDialog.__init__(self, parent) - self.parent = parent self.song = None # can this be automated? self.width = 400 @@ -90,7 +89,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.onVerseListViewPressed) QtCore.QObject.connect(self.themeAddButton, QtCore.SIGNAL(u'clicked()'), - self.parent.parent.renderer.theme_manager.onAddTheme) + self.parent().plugin.renderer.theme_manager.onAddTheme) QtCore.QObject.connect(self.maintenanceButton, QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked) QtCore.QObject.connect(Receiver.get_receiver(), diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 7fe4d45c4..49ed759ff 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -62,12 +62,12 @@ class SongMediaItem(MediaManagerItem): def __init__(self, parent, plugin, icon): self.IconPath = u'songs/song' - MediaManagerItem.__init__(self, parent, self, icon) - self.edit_song_form = EditSongForm(self, self.parent.manager) - self.openLyrics = OpenLyrics(self.parent.manager) + MediaManagerItem.__init__(self, parent, plugin, icon) + self.edit_song_form = EditSongForm(self, self.plugin.manager) + self.openLyrics = OpenLyrics(self.plugin.manager) self.singleServiceItem = False self.song_maintenance_form = SongMaintenanceForm( - self.parent.manager, self) + self.plugin.manager, self) # Holds information about whether the edit is remotly triggered and # which Song is required. self.remoteSong = -1 @@ -178,31 +178,31 @@ class SongMediaItem(MediaManagerItem): self.displayResultsSong(search_results) elif search_type == SongSearch.Titles: log.debug(u'Titles Search') - search_results = self.parent.manager.get_all_objects(Song, + search_results = self.plugin.manager.get_all_objects(Song, Song.search_title.like(u'%' + self.whitespace.sub(u' ', search_keywords.lower()) + u'%')) self.displayResultsSong(search_results) elif search_type == SongSearch.Lyrics: log.debug(u'Lyrics Search') - search_results = self.parent.manager.get_all_objects(Song, + search_results = self.plugin.manager.get_all_objects(Song, Song.search_lyrics.like(u'%' + search_keywords.lower() + u'%')) self.displayResultsSong(search_results) elif search_type == SongSearch.Authors: log.debug(u'Authors Search') - search_results = self.parent.manager.get_all_objects(Author, + search_results = self.plugin.manager.get_all_objects(Author, Author.display_name.like(u'%' + search_keywords + u'%'), Author.display_name.asc()) self.displayResultsAuthor(search_results) elif search_type == SongSearch.Themes: log.debug(u'Theme Search') - search_results = self.parent.manager.get_all_objects(Song, + search_results = self.plugin.manager.get_all_objects(Song, Song.theme_name.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%')) self.displayResultsSong(search_results) self.check_search_result() def searchEntire(self, search_keywords): - return self.parent.manager.get_all_objects(Song, + return self.plugin.manager.get_all_objects(Song, or_(Song.search_title.like(u'%' + self.whitespace.sub(u' ', search_keywords.lower()) + u'%'), Song.search_lyrics.like(u'%' + search_keywords.lower() + u'%'), @@ -225,7 +225,7 @@ class SongMediaItem(MediaManagerItem): if self.editItem and self.updateServiceOnEdit and \ not self.remoteTriggered: item = self.buildServiceItem(self.editItem) - self.parent.serviceManager.replaceServiceItem(item) + self.plugin.serviceManager.replaceServiceItem(item) self.onRemoteEditClear() self.onSearchTextButtonClick() log.debug(u'onSongListLoad - finished') @@ -284,12 +284,12 @@ class SongMediaItem(MediaManagerItem): def onImportClick(self): if not hasattr(self, u'import_wizard'): - self.import_wizard = SongImportForm(self, self.parent) + self.import_wizard = SongImportForm(self, self.plugin) if self.import_wizard.exec_() == QtGui.QDialog.Accepted: Receiver.send_message(u'songs_load_list') def onExportClick(self): - export_wizard = SongExportForm(self, self.parent) + export_wizard = SongExportForm(self, self.plugin) export_wizard.exec_() def onNewClick(self): @@ -314,7 +314,7 @@ class SongMediaItem(MediaManagerItem): log.debug(u'onRemoteEdit %s' % message) remote_type, song_id = message.split(u':') song_id = int(song_id) - valid = self.parent.manager.get_object(Song, song_id) + valid = self.plugin.manager.get_object(Song, song_id) if valid: self.remoteSong = song_id self.remoteTriggered = remote_type @@ -350,7 +350,7 @@ class SongMediaItem(MediaManagerItem): return for item in items: item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.parent.manager.delete_object(Song, item_id) + self.plugin.manager.delete_object(Song, item_id) self.onSearchTextButtonClick() def generateSlideData(self, service_item, item=None, xmlVersion=False): @@ -362,7 +362,7 @@ class SongMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.OnLoadUpdate) service_item.add_capability(ItemCapabilities.AddIfNewItem) service_item.add_capability(ItemCapabilities.AllowsVirtualSplit) - song = self.parent.manager.get_object(Song, item_id) + song = self.plugin.manager.get_object(Song, item_id) service_item.theme = song.theme_name service_item.edit_id = item_id if song.lyrics.startswith(u'