Merge lp:~trb143/openlp/bugfixes into lp:openlp

Proposed by Tim Bentley
Status: Merged
Merged at revision: not available
Proposed branch: lp:~trb143/openlp/bugfixes
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~trb143/openlp/bugfixes
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+10716@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

Complete removal of EventManager.
With 2 event mechanisms in the application it has been agreed we only need one.
Remove the home grown one and replace it with the QT Slot version.
All references have been converted and tested.

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Looks good.

review: Approve
lp:~trb143/openlp/bugfixes updated
512. By Tim Bentley

Clean up Event Processing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/lib/__init__.py'
2--- openlp/core/lib/__init__.py 2009-07-08 17:18:48 +0000
3+++ openlp/core/lib/__init__.py 2009-08-26 05:00:19 +0000
4@@ -60,12 +60,9 @@
5 from settingsmanager import SettingsManager
6 from pluginconfig import PluginConfig
7 from plugin import Plugin
8-from eventmanager import EventManager
9 from pluginmanager import PluginManager
10 from settingstab import SettingsTab
11 from mediamanageritem import MediaManagerItem
12-from event import Event
13-from event import EventType
14 from xmlrootclass import XmlRootClass
15 from serviceitem import ServiceItem
16 from eventreceiver import Receiver
17
18=== removed file 'openlp/core/lib/event.py'
19--- openlp/core/lib/event.py 2009-08-15 07:33:01 +0000
20+++ openlp/core/lib/event.py 1970-01-01 00:00:00 +0000
21@@ -1,51 +0,0 @@
22-# -*- coding: utf-8 -*-
23-# vim: autoindent shiftwidth=4 expandtab textwidth=80
24-"""
25-OpenLP - Open Source Lyrics Projection
26-
27-Copyright (c) 2008 Raoul Snyman
28-
29-Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Scott Guerreri,
30-Carsten Tingaard, Jonathan Corwin
31-
32-This program is free software; you can redistribute it and/or modify it under
33-the terms of the GNU General Public License as published by the Free Software
34-Foundation; version 2 of the License.
35-
36-This program is distributed in the hope that it will be useful, but WITHOUT ANY
37-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
38-PARTICULAR PURPOSE. See the GNU General Public License for more details.
39-
40-You should have received a copy of the GNU General Public License along with
41-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
42-Place, Suite 330, Boston, MA 02111-1307 USA
43-"""
44-
45-class EventType(object):
46- """
47- Types of events are stored in this class.
48- """
49- # "Default" event - a non-event
50- Default = 0
51- TriggerAlert = 1
52- # General application events
53- Ready = 10
54- # Service events
55- LoadServiceItem = 20
56- # Preview events
57- PreviewShow = 30
58- LiveShow = 31
59- #Theme Related Events
60- ThemeListChanged = 40
61- #Plugin Related Events
62- LoadSongList = 50
63-
64-
65-class Event(object):
66- """
67- Provides an Event class to encapsulate events within openlp.org.
68- """
69- def __init__(self, sender, event_type=EventType.Default, payload=None):
70- self.event_type = event_type
71- self.payload = payload
72- self.sender = sender
73
74=== removed file 'openlp/core/lib/eventmanager.py'
75--- openlp/core/lib/eventmanager.py 2009-08-12 04:57:24 +0000
76+++ openlp/core/lib/eventmanager.py 1970-01-01 00:00:00 +0000
77@@ -1,72 +0,0 @@
78-# -*- coding: utf-8 -*-
79-# vim: autoindent shiftwidth=4 expandtab textwidth=80
80-"""
81-OpenLP - Open Source Lyrics Projection
82-
83-Copyright (c) 2008 Raoul Snyman
84-
85-Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Scott Guerreri,
86-Carsten Tingaard, Jonathan Corwin
87-
88-This program is free software; you can redistribute it and/or modify it under
89-the terms of the GNU General Public License as published by the Free Software
90-Foundation; version 2 of the License.
91-
92-This program is distributed in the hope that it will be useful, but WITHOUT ANY
93-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
94-PARTICULAR PURPOSE. See the GNU General Public License for more details.
95-
96-You should have received a copy of the GNU General Public License along with
97-this program; if not, write to the Free Software Foundation, Inc., 59 Temple
98-Place, Suite 330, Boston, MA 02111-1307 USA
99-"""
100-import os
101-import logging
102-
103-class EventManager(object):
104- """
105- A mechanism to send events to all registered endpoints. The
106- endpoints are registered and listen with a handle_event method.
107- The endpoint will decide whether to do somthing with the event or
108- ignore it.
109- """
110- global log
111- log = logging.getLogger(u'EventManager')
112-
113- def __init__(self):
114- """
115- Defines the class and a list of endpoints
116- """
117- self.endpoints = []
118- log.info(u'Initialising')
119- self.processing = False
120- self.events = []
121-
122- def register(self, plugin):
123- """
124- Called by plugings who wish to receive event notifications
125- """
126- log.debug(u'Class %s registered with EventManager', plugin)
127- self.endpoints.append(plugin)
128-
129- def post_event(self, event):
130- """
131- Called by any part of the system which wants send events to the plugins
132-
133- ``event``
134- The event type to be triggered
135-
136- """
137- log.debug(u'post event called for event %s (%s)', event.event_type, event.sender)
138- self.events.append(event)
139- if not self.processing:
140- self.processing = True
141- while len(self.events) > 0:
142- pEvent = self.events[0]
143- for point in self.endpoints:
144- status = point.handle_event(pEvent)
145- #if call returns true message is finished with
146- if status is not None and status :
147- break
148- self.events.remove(pEvent)
149- self.processing = False
150
151=== modified file 'openlp/core/lib/eventreceiver.py'
152--- openlp/core/lib/eventreceiver.py 2009-08-24 05:10:04 +0000
153+++ openlp/core/lib/eventreceiver.py 2009-08-26 05:00:19 +0000
154@@ -18,6 +18,7 @@
155 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
156 Place, Suite 330, Boston, MA 02111-1307 USA
157 """
158+import logging
159
160 from PyQt4 import QtCore
161
162@@ -25,11 +26,39 @@
163 """
164 Class to allow events to be passed from different parts of the system.
165 This is a private class and should not be used directly but via the Receiver class
166+
167+ ``stop_import``
168+ Stops the Bible Import
169+ ``pre_load_bibles``
170+ Triggers the plugin to relaod the bible lists
171+ ``process_events``
172+ Requests the Application to flush the events queue
173+ ``{preview|live}_slide_first``
174+ display the first slide on the list
175+ ``{preview|live}_slide_previous``
176+ display the previous slide on the list
177+ ``{preview|live}_slide_next``
178+ display the next slide on the list
179+ ``{preview|live}_slide_last``
180+ display the last slide on the list
181+ ``{plugin}_add_service_item ``
182+ ask the plugin to push the selected items to the service item
183+ ``update_themes ``
184+ send out message with new themes
185+ ``update_global_theme ``
186+ Tell the components we have a new global theme
187+ ``load_song_list``
188+ Tells the the song plugin to reload the song list
189+
190 """
191+ global log
192+ log = logging.getLogger(u'EventReceiver')
193+
194 def __init__(self):
195 QtCore.QObject.__init__(self)
196
197 def send_message(self, event, msg=None):
198+ log.debug(u'Event %s passed with payload %s' % (event, msg))
199 self.emit(QtCore.SIGNAL(event), msg)
200
201 class Receiver():
202@@ -39,11 +68,11 @@
203 As there is only one instance of it in the systems the QT signal/slot architecture
204 can send messages across the system
205
206- Send message
207- Receiver().send_message(u'messageid',data)
208+ ``Send message``
209+ Receiver().send_message(u'<<Message ID>>', data)
210
211- Receive Message
212- QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'openlprepaint'),<<ACTION>>)
213+ ``Receive Message``
214+ QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'<<Message ID>>'),<<ACTION>>)
215 """
216 eventreceiver = EventReceiver()
217
218
219=== modified file 'openlp/core/lib/plugin.py'
220--- openlp/core/lib/plugin.py 2009-08-15 11:02:24 +0000
221+++ openlp/core/lib/plugin.py 2009-08-26 05:00:19 +0000
222@@ -19,12 +19,13 @@
223 """
224
225 import logging
226+from PyQt4 import QtCore
227
228 from openlp.core.lib import PluginConfig
229 # why does this not work???
230 # from openlp.core.lib import Event, EventType
231 # so I have to do this???
232-from event import Event, EventType
233+from eventreceiver import Receiver
234
235 class Plugin(object):
236 """
237@@ -122,11 +123,11 @@
238 self.log = logging.getLogger(self.name)
239 self.preview_controller = plugin_helpers[u'preview']
240 self.live_controller = plugin_helpers[u'live']
241- self.event_manager = plugin_helpers[u'event']
242 self.render_manager = plugin_helpers[u'render']
243 self.service_manager = plugin_helpers[u'service']
244 self.settings = plugin_helpers[u'settings']
245- self.dnd_id=None
246+ QtCore.QObject.connect(Receiver.get_receiver(),
247+ QtCore.SIGNAL(u'%s_add_service_item'% self.name), self.process_add_service_event)
248
249 def check_pre_conditions(self):
250 """
251@@ -177,29 +178,13 @@
252 """
253 pass
254
255- def handle_event(self, event):
256- """
257- Handle the event contained in the event object. If you want
258- to use this default behaviour, you must set self.dnd_id equal
259- to that sent by the dnd source - eg the MediaItem
260-
261- ``event``
262- An object describing the event.
263- """
264- # default behaviour - can be overridden if desired
265- log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
266- if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id:
267- log.debug(u'Load Service Item received')
268- self.media_item.onAddClick()
269- return True
270- if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id:
271- log.debug(u'Load Preview Item received')
272- self.media_item.onPreviewClick()
273- return True
274- if event.event_type == EventType.LiveShow and event.payload == self.dnd_id:
275- log.debug(u'Load Live Show Item received')
276- return True
277- self.media_item.onLiveClick()
278+ def process_add_service_event(self):
279+ """
280+ Proxy method as method is not defined early enough
281+ in the processing
282+ """
283+ log.debug(u'process_add_service_event event called for plugin %s' % self.name)
284+ self.media_item.onAddClick()
285
286 def about(self):
287 """
288@@ -208,38 +193,6 @@
289 """
290 pass
291
292- def save(self, data):
293- """
294- Service item data is passed to this function, which should return a
295- string which can be written to the service file.
296-
297- ``data``
298- The data to be saved.
299- """
300- pass
301-
302- def load(self, string):
303- """
304- A string from the service file is passed in. This function parses and
305- sets up the internals of the plugin.
306-
307- ``string``
308- The data to be loaded into the plugin.
309- """
310- pass
311-
312- def render(self, theme, screen=None):
313- """
314- Render the screenth screenful of data using theme settings in theme.
315-
316- ``theme``
317- The theme to use when rendering.
318-
319- ``screen``
320- Defaults to *None*. The screen to render to.
321- """
322- pass
323-
324 def initialise(self):
325 """
326 Called by the plugin Manager to initialise anything it needs.
327
328=== modified file 'openlp/core/lib/pluginmanager.py'
329--- openlp/core/lib/pluginmanager.py 2009-08-15 07:55:16 +0000
330+++ openlp/core/lib/pluginmanager.py 2009-08-26 05:00:19 +0000
331@@ -21,7 +21,7 @@
332 import sys
333 import logging
334
335-from openlp.core.lib import Plugin, EventManager
336+from openlp.core.lib import Plugin
337
338 class PluginManager(object):
339 """
340@@ -50,7 +50,7 @@
341 # this has to happen after the UI is sorted self.find_plugins(dir)
342 log.info(u'Plugin manager done init')
343
344- def find_plugins(self, dir, plugin_helpers, eventmanager):
345+ def find_plugins(self, dir, plugin_helpers):
346 """
347 Scan the directory dir for objects inheriting from ``openlp.plugin``.
348
349@@ -60,8 +60,6 @@
350 ``plugin_helpers``
351 A list of helper objects to pass to the plugins.
352
353- ``eventmanager``
354- The event manager to pass to the plugins.
355 """
356 self.plugin_helpers = plugin_helpers
357 startdepth = len(os.path.abspath(dir).split(os.sep))
358@@ -103,11 +101,9 @@
359 pList = {u'plugin': plugin, u'status': u'Inactive'}
360 if plugin.check_pre_conditions():
361 log.debug(u'Plugin %s active', unicode(plugin.name))
362- eventmanager.register(plugin)
363 pList[u'status'] = u'Active'
364 self.plugins.append(pList)
365
366-
367 def order_by_weight(self, x, y):
368 """
369 Sort two plugins and order them by their weight.
370
371=== modified file 'openlp/core/ui/amendthemeform.py'
372--- openlp/core/ui/amendthemeform.py 2009-08-07 17:19:32 +0000
373+++ openlp/core/ui/amendthemeform.py 2009-08-26 05:00:19 +0000
374@@ -32,11 +32,9 @@
375 def __init__(self, thememanager, parent=None):
376 QtGui.QDialog.__init__(self, parent)
377 self.thememanager = thememanager
378- # Needed here as UI setup generates Events
379 self.path = None
380 self.theme = ThemeXML()
381 self.setupUi(self)
382-
383 #define signals
384 #Buttons
385 QtCore.QObject.connect(self.Color1PushButton ,
386
387=== modified file 'openlp/core/ui/maindisplay.py'
388--- openlp/core/ui/maindisplay.py 2009-08-24 04:30:04 +0000
389+++ openlp/core/ui/maindisplay.py 2009-08-26 05:00:19 +0000
390@@ -21,7 +21,7 @@
391 from PyQt4 import QtCore, QtGui
392
393 from time import sleep
394-from openlp.core.lib import translate, EventManager, Event, EventType, Receiver
395+from openlp.core.lib import translate, Receiver
396
397 class MainDisplay(QtGui.QWidget):
398 """
399@@ -58,20 +58,10 @@
400 self.alertactive = False
401 self.alertTab = None
402 self.timer_id = 0
403- # Register the main form as an event consumer.
404- self.parent.EventManager.register(self)
405 QtCore.QObject.connect(Receiver.get_receiver(),
406 QtCore.SIGNAL(u'live_slide_blank'), self.blankDisplay)
407-
408- def handle_event(self, event):
409- """
410- Accept Events for the system and If It's for Alert
411- action it and Return true to stop futher processing
412- """
413- log.debug(u'MainDisplay received event %s with payload %s'%(event.event_type, event.payload))
414- if event.event_type == EventType.TriggerAlert:
415- self.displayAlert(event.payload)
416- return True
417+ QtCore.QObject.connect(Receiver.get_receiver(),
418+ QtCore.SIGNAL(u'alert_text'), self.displayAlert)
419
420 def setup(self, screenNumber):
421 """
422
423=== modified file 'openlp/core/ui/mainwindow.py'
424--- openlp/core/ui/mainwindow.py 2009-08-15 11:02:24 +0000
425+++ openlp/core/ui/mainwindow.py 2009-08-26 05:00:19 +0000
426@@ -26,8 +26,8 @@
427 ServiceManager, ThemeManager, MainDisplay, SlideController, \
428 PluginForm
429 from openlp.core.lib import translate, Plugin, MediaManagerItem, \
430- SettingsTab, EventManager, RenderManager, PluginConfig, \
431- SettingsManager, PluginManager, EventType
432+ SettingsTab, RenderManager, PluginConfig, \
433+ SettingsManager, PluginManager, Receiver
434
435 class Ui_MainWindow(object):
436 def setupUi(self, MainWindow):
437@@ -416,7 +416,6 @@
438 self.screenList = screens
439 self.oosNotSaved = False
440 self.settingsmanager = SettingsManager(screens)
441- self.EventManager = EventManager()
442 self.mainDisplay = MainDisplay(self, screens)
443 self.generalConfig = PluginConfig(u'General')
444 self.alertForm = AlertForm(self)
445@@ -458,6 +457,8 @@
446 QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked)
447 QtCore.QObject.connect(self.OptionsSettingsItem,
448 QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked)
449+ QtCore.QObject.connect(Receiver.get_receiver(),
450+ QtCore.SIGNAL(u'update_global_theme'), self.defaultThemeChanged)
451 #warning cyclic dependency
452 #RenderManager needs to call ThemeManager and
453 #ThemeManager needs to call RenderManager
454@@ -467,12 +468,10 @@
455 #make the controllers available to the plugins
456 self.plugin_helpers[u'preview'] = self.PreviewController
457 self.plugin_helpers[u'live'] = self.LiveController
458- self.plugin_helpers[u'event'] = self.EventManager
459 self.plugin_helpers[u'render'] = self.RenderManager
460 self.plugin_helpers[u'service'] = self.ServiceManagerContents
461 self.plugin_helpers[u'settings'] = self.settingsForm
462- self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers,
463- self.EventManager)
464+ self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
465 # hook methods have to happen after find_plugins. Find plugins needs the
466 # controllers hence the hooks have moved from setupUI() to here
467
468@@ -490,8 +489,6 @@
469 # Call the initialise method to setup plugins.
470 log.info(u'initialise plugins')
471 self.plugin_manager.initialise_plugins()
472- # Register the main form as an event consumer.
473- self.EventManager.register(self)
474 # Once all components are initialised load the Themes
475 log.info(u'Load Themes')
476 self.ThemeManagerContents.loadThemes()
477@@ -593,9 +590,5 @@
478 title = u'%s - %s*' % (self.mainTitle, service_name)
479 self.setWindowTitle(title)
480
481- def handle_event(self, event):
482- if event.event_type == EventType.ThemeListChanged:
483- self.ServiceManagerContents.updateThemeList(event.payload)
484- self.settingsForm.ThemesTab.updateThemeList(event.payload)
485- self.DefaultThemeLabel.setText(self.defaultThemeText + \
486- self.ThemeManagerContents.getDefault())
487+ def defaultThemeChanged(self, theme):
488+ self.DefaultThemeLabel.setText(self.defaultThemeText + theme)
489
490=== modified file 'openlp/core/ui/servicemanager.py'
491--- openlp/core/ui/servicemanager.py 2009-08-15 07:33:01 +0000
492+++ openlp/core/ui/servicemanager.py 2009-08-25 05:18:09 +0000
493@@ -24,9 +24,9 @@
494 import shutil
495
496 from PyQt4 import QtCore, QtGui
497-from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, Event, \
498- RenderManager, EventType, EventManager, translate, buildIcon, \
499- contextMenuAction, contextMenuSeparator
500+from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \
501+ RenderManager, translate, buildIcon, \
502+ contextMenuAction, contextMenuSeparator, Receiver
503 from openlp.core.utils import ConfigHelper
504
505 class ServiceManagerList(QtGui.QTreeWidget):
506@@ -66,6 +66,7 @@
507 class Iter(QtGui.QTreeWidgetItemIterator):
508 def __init__(self, *args):
509 QtGui.QTreeWidgetItemIterator.__init__(self, *args)
510+
511 def next(self):
512 self.__iadd__(1)
513 value = self.value()
514@@ -158,6 +159,8 @@
515 QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), self.collapsed)
516 QtCore.QObject.connect(self.ServiceManagerList,
517 QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded)
518+ QtCore.QObject.connect(Receiver.get_receiver(),
519+ QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
520 # Last little bits of setting up
521 self.config = PluginConfig(u'ServiceManager')
522 self.servicePath = self.config.get_data_path()
523@@ -488,7 +491,7 @@
524 link = event.mimeData()
525 if link.hasText():
526 plugin = event.mimeData().text()
527- self.parent.EventManager.post_event(Event(u'ServiceManager', EventType.LoadServiceItem, plugin))
528+ Receiver().send_message(u'%s_add_service_item' % plugin)
529
530 def updateThemeList(self, theme_list):
531 """
532
533=== modified file 'openlp/core/ui/thememanager.py'
534--- openlp/core/ui/thememanager.py 2009-08-15 07:33:01 +0000
535+++ openlp/core/ui/thememanager.py 2009-08-26 05:00:19 +0000
536@@ -28,9 +28,9 @@
537
538 from openlp.core.ui import AmendThemeForm, ServiceManager
539 from openlp.core.theme import Theme
540-from openlp.core.lib import PluginConfig, Event, EventType, \
541- EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, \
542- file_to_xml, buildIcon
543+from openlp.core.lib import PluginConfig, \
544+ OpenLPToolbar, ThemeXML, Renderer, translate, \
545+ file_to_xml, buildIcon, Receiver
546 from openlp.core.utils import ConfigHelper
547
548 class ThemeManager(QtGui.QWidget):
549@@ -72,7 +72,9 @@
550 self.Layout.addWidget(self.ThemeListWidget)
551 #Signals
552 QtCore.QObject.connect(self.ThemeListWidget,
553- QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobal)
554+ QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen)
555+ QtCore.QObject.connect(Receiver.get_receiver(),
556+ QtCore.SIGNAL(u'update_global_theme'), self.changeGlobalFromTab)
557 #Variables
558 self.themelist = []
559 self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')
560@@ -86,7 +88,22 @@
561 def getDefault(self):
562 return self.global_theme
563
564- def changeGlobal(self, index):
565+ def changeGlobalFromTab(self, themeName):
566+ log.debug(u'changeGlobalFromTab %s', themeName)
567+ for count in range (0, self.ThemeListWidget.count()):
568+ #reset the old name
569+ item = self.ThemeListWidget.item(count)
570+ oldName = item.text()
571+ newName = unicode(item.data(QtCore.Qt.UserRole).toString())
572+ if oldName != newName:
573+ self.ThemeListWidget.item(count).setText(newName)
574+ #Set the new name
575+ if themeName == newName:
576+ name = u'%s (%s)' % (newName, translate(u'ThemeManager', u'default'))
577+ self.ThemeListWidget.item(count).setText(name)
578+
579+ def changeGlobalFromScreen(self, index):
580+ log.debug(u'changeGlobalFromScreen %s', index)
581 for count in range (0, self.ThemeListWidget.count()):
582 item = self.ThemeListWidget.item(count)
583 oldName = item.text()
584@@ -99,6 +116,7 @@
585 name = u'%s (%s)' % (self.global_theme, translate(u'ThemeManager', u'default'))
586 self.ThemeListWidget.item(count).setText(name)
587 self.config.set_config(u'theme global theme', self.global_theme)
588+ Receiver().send_message(u'update_global_theme', self.global_theme )
589 self.pushThemes()
590
591 def onAddTheme(self):
592@@ -184,7 +202,7 @@
593 self.pushThemes()
594
595 def pushThemes(self):
596- self.parent.EventManager.post_event(Event(u'ThemeManager', EventType.ThemeListChanged, self.getThemes()))
597+ Receiver().send_message(u'update_themes', self.getThemes() )
598
599 def getThemes(self):
600 return self.themelist
601@@ -194,7 +212,6 @@
602 xml_file = os.path.join(self.path, unicode(themename), unicode(themename) + u'.xml')
603 try:
604 xml = file_to_xml(xml_file)
605- #print xml
606 except:
607 newtheme = ThemeXML()
608 newtheme.new_document(u'New Theme')
609@@ -205,9 +222,7 @@
610 unicode(0), unicode(0), unicode(0))
611 xml = newtheme.extract_xml()
612 theme = ThemeXML()
613- #print theme
614 theme.parse(xml)
615- #print "A ", theme
616 theme.extend_image_filename(self.path)
617 return theme
618
619
620=== modified file 'openlp/core/ui/themestab.py'
621--- openlp/core/ui/themestab.py 2009-08-07 19:05:00 +0000
622+++ openlp/core/ui/themestab.py 2009-08-25 20:04:58 +0000
623@@ -20,7 +20,7 @@
624
625 from PyQt4 import QtCore, QtGui
626
627-from openlp.core.lib import SettingsTab, translate
628+from openlp.core.lib import SettingsTab, translate, Receiver
629
630 class ThemesTab(SettingsTab):
631 """
632@@ -88,16 +88,16 @@
633 self.LevelLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
634 self.GlobalLevelLabel)
635 self.ThemesTabLayout.addWidget(self.LevelGroupBox)
636-
637 QtCore.QObject.connect(self.SongLevelRadioButton,
638 QtCore.SIGNAL(u'pressed()'), self.onSongLevelButtonPressed)
639 QtCore.QObject.connect(self.ServiceLevelRadioButton,
640 QtCore.SIGNAL(u'pressed()'), self.onServiceLevelButtonPressed)
641 QtCore.QObject.connect(self.GlobalLevelRadioButton,
642 QtCore.SIGNAL(u'pressed()'), self.onGlobalLevelButtonPressed)
643-
644 QtCore.QObject.connect(self.DefaultComboBox,
645 QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged)
646+ QtCore.QObject.connect(Receiver.get_receiver(),
647+ QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
648
649 def retranslateUi(self):
650 self.GlobalGroupBox.setTitle(translate(u'ThemesTab', u'Global theme'))
651@@ -122,6 +122,7 @@
652 def save(self):
653 self.config.set_config(u'theme global style', self.global_style )
654 self.config.set_config(u'theme global theme',self.global_theme)
655+ Receiver().send_message(u'update_global_theme', self.global_theme )
656
657 def onSongLevelButtonPressed(self):
658 self.global_style= u'Song'
659
660=== modified file 'openlp/plugins/bibles/bibleplugin.py'
661--- openlp/plugins/bibles/bibleplugin.py 2009-08-15 07:33:01 +0000
662+++ openlp/plugins/bibles/bibleplugin.py 2009-08-26 05:00:19 +0000
663@@ -22,7 +22,7 @@
664 from PyQt4 import QtCore, QtGui
665 from PyQt4.QtCore import *
666
667-from openlp.core.lib import Plugin, Event, EventType, translate
668+from openlp.core.lib import Plugin, translate
669
670 from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
671
672@@ -41,9 +41,6 @@
673 QtGui.QIcon.Normal, QtGui.QIcon.Off)
674 #Register the bible Manager
675 self.biblemanager = BibleManager(self.config)
676- # passed with drag and drop messages
677- self.dnd_id = u'Bibles'
678-
679
680 def get_settings_tab(self):
681 self.bibles_tab = BiblesTab()
682@@ -68,18 +65,6 @@
683 export_menu.addAction(self.ExportBibleItem)
684 self.ExportBibleItem.setText(translate(u'BiblePlugin', u'&Bible'))
685
686- def initialise(self):
687- pass
688-
689 def onBibleNewClick(self):
690 self.media_item.onBibleNewClick()
691
692- def handle_event(self, event):
693- """
694- Handle the event contained in the event object.
695- """
696- log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
697- if event.event_type == EventType.ThemeListChanged:
698- log.debug(u'New Theme request received')
699- self.bibles_tab.updateThemeList(event.payload)
700- return Plugin.handle_event(self, event)
701
702=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
703--- openlp/plugins/bibles/forms/bibleimportform.py 2009-08-15 07:55:16 +0000
704+++ openlp/plugins/bibles/forms/bibleimportform.py 2009-08-24 20:05:46 +0000
705@@ -152,9 +152,9 @@
706 def onCancelButtonClicked(self):
707 # tell import to stop
708 self.message = u'Bible import stopped'
709- Receiver().send_message(u'openlpstopimport')
710+ Receiver().send_message(u'stop_import')
711 # tell bibleplugin to reload the bibles
712- Receiver().send_message(u'openlpreloadbibles')
713+ Receiver().send_message(u'pre_load_bibles')
714 self.close()
715
716 def onImportButtonClicked(self):
717@@ -172,7 +172,7 @@
718 self.MessageLabel.setText(message)
719 self.ProgressBar.setValue(self.barmax)
720 # tell bibleplugin to reload the bibles
721- Receiver().send_message(u'openlpreloadbibles')
722+ Receiver().send_message(u'pre_load_bibles')
723 reply = QtGui.QMessageBox.information(self,
724 translate(u'BibleMediaItem', u'Information'),
725 translate(u'BibleMediaItem', message))
726
727=== modified file 'openlp/plugins/bibles/lib/biblestab.py'
728--- openlp/plugins/bibles/lib/biblestab.py 2009-07-23 05:17:26 +0000
729+++ openlp/plugins/bibles/lib/biblestab.py 2009-08-25 05:18:09 +0000
730@@ -21,7 +21,7 @@
731
732 from PyQt4 import Qt, QtCore, QtGui
733
734-from openlp.core.lib import translate, str_to_bool
735+from openlp.core.lib import translate, str_to_bool, Receiver
736 from openlp.core.lib import SettingsTab
737
738 class BiblesTab(SettingsTab):
739@@ -146,6 +146,8 @@
740 QtCore.SIGNAL(u'activated(int)'), self.onBibleThemeComboBoxChanged)
741 QtCore.QObject.connect(self.LayoutStyleComboBox,
742 QtCore.SIGNAL(u'activated(int)'), self.onLayoutStyleComboBoxChanged)
743+ QtCore.QObject.connect(Receiver.get_receiver(),
744+ QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
745
746 def retranslateUi(self):
747 self.VerseDisplayGroupBox.setTitle(translate(u'SettingsForm', u'Verse Display'))
748
749=== modified file 'openlp/plugins/custom/customplugin.py'
750--- openlp/plugins/custom/customplugin.py 2009-08-15 07:33:01 +0000
751+++ openlp/plugins/custom/customplugin.py 2009-08-26 05:00:19 +0000
752@@ -22,7 +22,7 @@
753 from PyQt4 import QtCore, QtGui
754
755 from forms import EditCustomForm
756-from openlp.core.lib import Plugin, Event, EventType
757+from openlp.core.lib import Plugin
758 from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem
759
760
761@@ -42,20 +42,8 @@
762 self.icon = QtGui.QIcon()
763 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_custom.png'),
764 QtGui.QIcon.Normal, QtGui.QIcon.Off)
765- # passed with drag and drop messages
766- self.dnd_id=u'Custom'
767
768 def get_media_manager_item(self):
769 # Create the CustomManagerItem object
770 self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')
771 return self.media_item
772-
773- def handle_event(self, event):
774- """
775- Handle the event contained in the event object.
776- """
777- log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
778- if event.event_type == EventType.ThemeListChanged:
779- log.debug(u'New Theme request received')
780- self.edit_custom_form.loadThemes(event.payload)
781- return Plugin.handle_event(self, event)
782
783=== modified file 'openlp/plugins/custom/forms/editcustomform.py'
784--- openlp/plugins/custom/forms/editcustomform.py 2009-06-17 05:11:16 +0000
785+++ openlp/plugins/custom/forms/editcustomform.py 2009-08-25 20:04:58 +0000
786@@ -20,7 +20,7 @@
787 from PyQt4 import Qt, QtCore, QtGui
788
789 from editcustomdialog import Ui_customEditDialog
790-from openlp.core.lib import SongXMLBuilder, SongXMLParser
791+from openlp.core.lib import SongXMLBuilder, SongXMLParser, Receiver
792 from openlp.plugins.custom.lib.models import CustomSlide
793
794 class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
795@@ -50,6 +50,8 @@
796 QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'), self.onVerseListViewSelected)
797 QtCore.QObject.connect(self.VerseListView,
798 QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onVerseListViewPressed)
799+ QtCore.QObject.connect(Receiver.get_receiver(),
800+ QtCore.SIGNAL(u'update_themes'), self.loadThemes)
801 # Create other objects and forms
802 self.custommanager = custommanager
803 self.initialise()
804
805=== modified file 'openlp/plugins/images/imageplugin.py'
806--- openlp/plugins/images/imageplugin.py 2009-07-03 20:32:33 +0000
807+++ openlp/plugins/images/imageplugin.py 2009-08-26 05:00:19 +0000
808@@ -21,7 +21,7 @@
809
810 from PyQt4 import QtCore, QtGui
811
812-from openlp.core.lib import Plugin, Event, EventType
813+from openlp.core.lib import Plugin
814 from openlp.plugins.images.lib import ImageMediaItem, ImageTab
815
816 class ImagePlugin(Plugin):
817@@ -37,8 +37,6 @@
818 self.icon = QtGui.QIcon()
819 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_image.png'),
820 QtGui.QIcon.Normal, QtGui.QIcon.Off)
821- # passed with drag and drop messages
822- self.dnd_id = u'Image'
823
824 def get_settings_tab(self):
825 self.ImageTab = ImageTab()
826
827=== modified file 'openlp/plugins/images/lib/mediaitem.py'
828--- openlp/plugins/images/lib/mediaitem.py 2009-08-24 17:43:15 +0000
829+++ openlp/plugins/images/lib/mediaitem.py 2009-08-25 05:18:09 +0000
830@@ -28,7 +28,7 @@
831 # in order for DnD to the Service manager to work correctly.
832 class ImageListView(BaseListWithDnD):
833 def __init__(self, parent=None):
834- self.PluginName = u'Image'
835+ self.PluginName = u'Images'
836 BaseListWithDnD.__init__(self, parent)
837
838 class ImageMediaItem(MediaManagerItem):
839
840=== modified file 'openlp/plugins/presentations/presentationplugin.py'
841--- openlp/plugins/presentations/presentationplugin.py 2009-08-15 19:10:59 +0000
842+++ openlp/plugins/presentations/presentationplugin.py 2009-08-24 20:05:46 +0000
843@@ -41,7 +41,6 @@
844 self.icon = QtGui.QIcon()
845 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'),
846 QtGui.QIcon.Normal, QtGui.QIcon.Off)
847- self.dnd_id = u'Presentations'
848
849 def get_settings_tab(self):
850 """
851
852=== modified file 'openlp/plugins/remotes/remoteplugin.py'
853--- openlp/plugins/remotes/remoteplugin.py 2009-08-24 05:10:04 +0000
854+++ openlp/plugins/remotes/remoteplugin.py 2009-08-26 05:00:19 +0000
855@@ -22,7 +22,7 @@
856
857 from PyQt4 import QtNetwork, QtGui, QtCore
858
859-from openlp.core.lib import Plugin, Event, EventType, Receiver
860+from openlp.core.lib import Plugin, Receiver
861 from openlp.plugins.remotes.lib import RemoteTab
862
863 class RemotesPlugin(Plugin):
864@@ -58,7 +58,7 @@
865 event = unicode(datagram[:pos].lower())
866
867 if event == u'alert':
868- self.event_manager.post_event(Event(u'RemotePlugin', EventType.TriggerAlert , unicode(datagram[pos + 1:])))
869+ Receiver().send_message(u'alert_text', unicode(datagram[pos + 1:]))
870 if event == u'next_slide':
871 Receiver().send_message(u'live_slide_next')
872
873
874=== modified file 'openlp/plugins/songs/forms/editsongform.py'
875--- openlp/plugins/songs/forms/editsongform.py 2009-08-15 19:19:34 +0000
876+++ openlp/plugins/songs/forms/editsongform.py 2009-08-26 05:00:19 +0000
877@@ -22,8 +22,8 @@
878
879 from PyQt4 import Qt, QtCore, QtGui
880
881-from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, \
882- EventType, EventManager, translate
883+from openlp.core.lib import SongXMLBuilder, SongXMLParser, \
884+ translate, Receiver
885 from openlp.plugins.songs.forms import EditVerseForm
886 from openlp.plugins.songs.lib.models import Song
887 from editsongdialog import Ui_EditSongDialog
888@@ -36,7 +36,7 @@
889 log = logging.getLogger(u'EditSongForm')
890 log.info(u'Song Editor loaded')
891
892- def __init__(self, songmanager, eventmanager, parent=None):
893+ def __init__(self, songmanager, parent=None):
894 """
895 Constructor
896 """
897@@ -71,9 +71,10 @@
898 QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged)
899 QtCore.QObject.connect(self.MaintenanceButton,
900 QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked)
901+ QtCore.QObject.connect(Receiver.get_receiver(),
902+ QtCore.SIGNAL(u'update_themes'), self.loadThemes)
903 # Create other objects and forms
904 self.songmanager = songmanager
905- self.eventmanager = eventmanager
906 self.parent = parent
907 self.verse_form = EditVerseForm()
908 self.initialise()
909@@ -364,7 +365,7 @@
910 self.processTitle()
911 self.songmanager.save_song(self.song)
912 if self.title_change:
913- self.eventmanager.post_event(Event(u'EditSongForm', EventType.LoadSongList))
914+ Receiver().send_message(u'load_song_list')
915 self.close()
916
917 def processLyrics(self):
918
919=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
920--- openlp/plugins/songs/lib/mediaitem.py 2009-08-15 11:02:24 +0000
921+++ openlp/plugins/songs/lib/mediaitem.py 2009-08-26 05:00:19 +0000
922@@ -22,12 +22,13 @@
923 from PyQt4 import QtCore, QtGui
924
925 from openlp.core.lib import MediaManagerItem, translate, ServiceItem, \
926- SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD
927+ SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD, \
928+ Receiver
929 from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm
930
931 class SongListView(BaseListWithDnD):
932 def __init__(self, parent=None):
933- self.PluginName = u'Song'
934+ self.PluginName = u'Songs'
935 BaseListWithDnD.__init__(self, parent)
936
937 class SongMediaItem(MediaManagerItem):
938@@ -43,7 +44,7 @@
939 self.PluginTextShort = u'Song'
940 self.ConfigSection = u'song'
941 MediaManagerItem.__init__(self, parent, icon, title)
942- self.edit_song_form = EditSongForm(self.parent.songmanager, self.parent.event_manager, self)
943+ self.edit_song_form = EditSongForm(self.parent.songmanager, self)
944 self.song_maintenance_form = SongMaintenanceForm(self.parent.songmanager, self)
945
946 def setupUi(self):
947@@ -127,6 +128,9 @@
948 QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)
949 QtCore.QObject.connect(self.ListView,
950 QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
951+ QtCore.QObject.connect(Receiver.get_receiver(),
952+ QtCore.SIGNAL(u'load_song_list'), self.onSearchTextButtonClick)
953+
954 #define and add the context menu
955 self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
956 self.ListView.addAction(contextMenuAction(self.ListView,
957
958=== modified file 'openlp/plugins/songs/songsplugin.py'
959--- openlp/plugins/songs/songsplugin.py 2009-08-15 07:33:01 +0000
960+++ openlp/plugins/songs/songsplugin.py 2009-08-26 05:00:19 +0000
961@@ -22,7 +22,7 @@
962
963 from PyQt4 import QtCore, QtGui
964
965-from openlp.core.lib import Plugin, Event, EventType, translate
966+from openlp.core.lib import Plugin, translate
967 from openlp.plugins.songs.lib import SongManager, SongsTab, SongMediaItem
968 from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \
969 OpenSongImportForm, OpenLPExportForm
970@@ -46,8 +46,6 @@
971 self.icon = QtGui.QIcon()
972 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_song.png'),
973 QtGui.QIcon.Normal, QtGui.QIcon.Off)
974- # passed with drag and drop messages
975- self.dnd_id=u'Song'
976
977 def get_media_manager_item(self):
978 # Create the MediaManagerItem object
979@@ -128,16 +126,3 @@
980
981 def onExportOpenSongItemClicked(self):
982 self.opensong_export_form.show()
983-
984- def handle_event(self, event):
985- """
986- Handle the event contained in the event object.
987- """
988- log.debug(u'Handle event called with event %s' % event.event_type)
989- if event.event_type == EventType.ThemeListChanged:
990- log.debug(u'New Theme request received')
991- self.media_item.edit_song_form.loadThemes(event.payload)
992- if event.event_type == EventType.LoadSongList :
993- log.debug(u'Load Load Song List Item received')
994- self.media_item.displayResultsSong(self.songmanager.get_songs())
995- return Plugin.handle_event(self, event)