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
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2009-07-08 17:18:48 +0000
+++ openlp/core/lib/__init__.py 2009-08-26 05:00:19 +0000
@@ -60,12 +60,9 @@
60from settingsmanager import SettingsManager60from settingsmanager import SettingsManager
61from pluginconfig import PluginConfig61from pluginconfig import PluginConfig
62from plugin import Plugin62from plugin import Plugin
63from eventmanager import EventManager
64from pluginmanager import PluginManager63from pluginmanager import PluginManager
65from settingstab import SettingsTab64from settingstab import SettingsTab
66from mediamanageritem import MediaManagerItem65from mediamanageritem import MediaManagerItem
67from event import Event
68from event import EventType
69from xmlrootclass import XmlRootClass66from xmlrootclass import XmlRootClass
70from serviceitem import ServiceItem67from serviceitem import ServiceItem
71from eventreceiver import Receiver68from eventreceiver import Receiver
7269
=== removed file 'openlp/core/lib/event.py'
--- openlp/core/lib/event.py 2009-08-15 07:33:01 +0000
+++ openlp/core/lib/event.py 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=80
3"""
4OpenLP - Open Source Lyrics Projection
5
6Copyright (c) 2008 Raoul Snyman
7
8Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Scott Guerreri,
9Carsten Tingaard, Jonathan Corwin
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GNU General Public License as published by the Free Software
13Foundation; version 2 of the License.
14
15This program is distributed in the hope that it will be useful, but WITHOUT ANY
16WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
17PARTICULAR PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place, Suite 330, Boston, MA 02111-1307 USA
22"""
23
24class EventType(object):
25 """
26 Types of events are stored in this class.
27 """
28 # "Default" event - a non-event
29 Default = 0
30 TriggerAlert = 1
31 # General application events
32 Ready = 10
33 # Service events
34 LoadServiceItem = 20
35 # Preview events
36 PreviewShow = 30
37 LiveShow = 31
38 #Theme Related Events
39 ThemeListChanged = 40
40 #Plugin Related Events
41 LoadSongList = 50
42
43
44class Event(object):
45 """
46 Provides an Event class to encapsulate events within openlp.org.
47 """
48 def __init__(self, sender, event_type=EventType.Default, payload=None):
49 self.event_type = event_type
50 self.payload = payload
51 self.sender = sender
520
=== removed file 'openlp/core/lib/eventmanager.py'
--- openlp/core/lib/eventmanager.py 2009-08-12 04:57:24 +0000
+++ openlp/core/lib/eventmanager.py 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1# -*- coding: utf-8 -*-
2# vim: autoindent shiftwidth=4 expandtab textwidth=80
3"""
4OpenLP - Open Source Lyrics Projection
5
6Copyright (c) 2008 Raoul Snyman
7
8Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Scott Guerreri,
9Carsten Tingaard, Jonathan Corwin
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GNU General Public License as published by the Free Software
13Foundation; version 2 of the License.
14
15This program is distributed in the hope that it will be useful, but WITHOUT ANY
16WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
17PARTICULAR PURPOSE. See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place, Suite 330, Boston, MA 02111-1307 USA
22"""
23import os
24import logging
25
26class EventManager(object):
27 """
28 A mechanism to send events to all registered endpoints. The
29 endpoints are registered and listen with a handle_event method.
30 The endpoint will decide whether to do somthing with the event or
31 ignore it.
32 """
33 global log
34 log = logging.getLogger(u'EventManager')
35
36 def __init__(self):
37 """
38 Defines the class and a list of endpoints
39 """
40 self.endpoints = []
41 log.info(u'Initialising')
42 self.processing = False
43 self.events = []
44
45 def register(self, plugin):
46 """
47 Called by plugings who wish to receive event notifications
48 """
49 log.debug(u'Class %s registered with EventManager', plugin)
50 self.endpoints.append(plugin)
51
52 def post_event(self, event):
53 """
54 Called by any part of the system which wants send events to the plugins
55
56 ``event``
57 The event type to be triggered
58
59 """
60 log.debug(u'post event called for event %s (%s)', event.event_type, event.sender)
61 self.events.append(event)
62 if not self.processing:
63 self.processing = True
64 while len(self.events) > 0:
65 pEvent = self.events[0]
66 for point in self.endpoints:
67 status = point.handle_event(pEvent)
68 #if call returns true message is finished with
69 if status is not None and status :
70 break
71 self.events.remove(pEvent)
72 self.processing = False
730
=== modified file 'openlp/core/lib/eventreceiver.py'
--- openlp/core/lib/eventreceiver.py 2009-08-24 05:10:04 +0000
+++ openlp/core/lib/eventreceiver.py 2009-08-26 05:00:19 +0000
@@ -18,6 +18,7 @@
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place, Suite 330, Boston, MA 02111-1307 USA19Place, Suite 330, Boston, MA 02111-1307 USA
20"""20"""
21import logging
2122
22from PyQt4 import QtCore23from PyQt4 import QtCore
2324
@@ -25,11 +26,39 @@
25 """26 """
26 Class to allow events to be passed from different parts of the system.27 Class to allow events to be passed from different parts of the system.
27 This is a private class and should not be used directly but via the Receiver class28 This is a private class and should not be used directly but via the Receiver class
29
30 ``stop_import``
31 Stops the Bible Import
32 ``pre_load_bibles``
33 Triggers the plugin to relaod the bible lists
34 ``process_events``
35 Requests the Application to flush the events queue
36 ``{preview|live}_slide_first``
37 display the first slide on the list
38 ``{preview|live}_slide_previous``
39 display the previous slide on the list
40 ``{preview|live}_slide_next``
41 display the next slide on the list
42 ``{preview|live}_slide_last``
43 display the last slide on the list
44 ``{plugin}_add_service_item ``
45 ask the plugin to push the selected items to the service item
46 ``update_themes ``
47 send out message with new themes
48 ``update_global_theme ``
49 Tell the components we have a new global theme
50 ``load_song_list``
51 Tells the the song plugin to reload the song list
52
28 """53 """
54 global log
55 log = logging.getLogger(u'EventReceiver')
56
29 def __init__(self):57 def __init__(self):
30 QtCore.QObject.__init__(self)58 QtCore.QObject.__init__(self)
3159
32 def send_message(self, event, msg=None):60 def send_message(self, event, msg=None):
61 log.debug(u'Event %s passed with payload %s' % (event, msg))
33 self.emit(QtCore.SIGNAL(event), msg)62 self.emit(QtCore.SIGNAL(event), msg)
3463
35class Receiver():64class Receiver():
@@ -39,11 +68,11 @@
39 As there is only one instance of it in the systems the QT signal/slot architecture68 As there is only one instance of it in the systems the QT signal/slot architecture
40 can send messages across the system69 can send messages across the system
4170
42 Send message71 ``Send message``
43 Receiver().send_message(u'messageid',data)72 Receiver().send_message(u'<<Message ID>>', data)
4473
45 Receive Message74 ``Receive Message``
46 QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'openlprepaint'),<<ACTION>>)75 QtCore.QObject.connect(Receiver().get_receiver(),QtCore.SIGNAL(u'<<Message ID>>'),<<ACTION>>)
47 """76 """
48 eventreceiver = EventReceiver()77 eventreceiver = EventReceiver()
4978
5079
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py 2009-08-15 11:02:24 +0000
+++ openlp/core/lib/plugin.py 2009-08-26 05:00:19 +0000
@@ -19,12 +19,13 @@
19"""19"""
2020
21import logging21import logging
22from PyQt4 import QtCore
2223
23from openlp.core.lib import PluginConfig24from openlp.core.lib import PluginConfig
24# why does this not work???25# why does this not work???
25# from openlp.core.lib import Event, EventType26# from openlp.core.lib import Event, EventType
26# so I have to do this???27# so I have to do this???
27from event import Event, EventType28from eventreceiver import Receiver
2829
29class Plugin(object):30class Plugin(object):
30 """31 """
@@ -122,11 +123,11 @@
122 self.log = logging.getLogger(self.name)123 self.log = logging.getLogger(self.name)
123 self.preview_controller = plugin_helpers[u'preview']124 self.preview_controller = plugin_helpers[u'preview']
124 self.live_controller = plugin_helpers[u'live']125 self.live_controller = plugin_helpers[u'live']
125 self.event_manager = plugin_helpers[u'event']
126 self.render_manager = plugin_helpers[u'render']126 self.render_manager = plugin_helpers[u'render']
127 self.service_manager = plugin_helpers[u'service']127 self.service_manager = plugin_helpers[u'service']
128 self.settings = plugin_helpers[u'settings']128 self.settings = plugin_helpers[u'settings']
129 self.dnd_id=None129 QtCore.QObject.connect(Receiver.get_receiver(),
130 QtCore.SIGNAL(u'%s_add_service_item'% self.name), self.process_add_service_event)
130131
131 def check_pre_conditions(self):132 def check_pre_conditions(self):
132 """133 """
@@ -177,29 +178,13 @@
177 """178 """
178 pass179 pass
179180
180 def handle_event(self, event):181 def process_add_service_event(self):
181 """182 """
182 Handle the event contained in the event object. If you want183 Proxy method as method is not defined early enough
183 to use this default behaviour, you must set self.dnd_id equal184 in the processing
184 to that sent by the dnd source - eg the MediaItem185 """
185186 log.debug(u'process_add_service_event event called for plugin %s' % self.name)
186 ``event``187 self.media_item.onAddClick()
187 An object describing the event.
188 """
189 # default behaviour - can be overridden if desired
190 log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
191 if event.event_type == EventType.LoadServiceItem and event.payload == self.dnd_id:
192 log.debug(u'Load Service Item received')
193 self.media_item.onAddClick()
194 return True
195 if event.event_type == EventType.PreviewShow and event.payload == self.dnd_id:
196 log.debug(u'Load Preview Item received')
197 self.media_item.onPreviewClick()
198 return True
199 if event.event_type == EventType.LiveShow and event.payload == self.dnd_id:
200 log.debug(u'Load Live Show Item received')
201 return True
202 self.media_item.onLiveClick()
203188
204 def about(self):189 def about(self):
205 """190 """
@@ -208,38 +193,6 @@
208 """193 """
209 pass194 pass
210195
211 def save(self, data):
212 """
213 Service item data is passed to this function, which should return a
214 string which can be written to the service file.
215
216 ``data``
217 The data to be saved.
218 """
219 pass
220
221 def load(self, string):
222 """
223 A string from the service file is passed in. This function parses and
224 sets up the internals of the plugin.
225
226 ``string``
227 The data to be loaded into the plugin.
228 """
229 pass
230
231 def render(self, theme, screen=None):
232 """
233 Render the screenth screenful of data using theme settings in theme.
234
235 ``theme``
236 The theme to use when rendering.
237
238 ``screen``
239 Defaults to *None*. The screen to render to.
240 """
241 pass
242
243 def initialise(self):196 def initialise(self):
244 """197 """
245 Called by the plugin Manager to initialise anything it needs.198 Called by the plugin Manager to initialise anything it needs.
246199
=== modified file 'openlp/core/lib/pluginmanager.py'
--- openlp/core/lib/pluginmanager.py 2009-08-15 07:55:16 +0000
+++ openlp/core/lib/pluginmanager.py 2009-08-26 05:00:19 +0000
@@ -21,7 +21,7 @@
21import sys21import sys
22import logging22import logging
2323
24from openlp.core.lib import Plugin, EventManager24from openlp.core.lib import Plugin
2525
26class PluginManager(object):26class PluginManager(object):
27 """27 """
@@ -50,7 +50,7 @@
50 # this has to happen after the UI is sorted self.find_plugins(dir)50 # this has to happen after the UI is sorted self.find_plugins(dir)
51 log.info(u'Plugin manager done init')51 log.info(u'Plugin manager done init')
5252
53 def find_plugins(self, dir, plugin_helpers, eventmanager):53 def find_plugins(self, dir, plugin_helpers):
54 """54 """
55 Scan the directory dir for objects inheriting from ``openlp.plugin``.55 Scan the directory dir for objects inheriting from ``openlp.plugin``.
5656
@@ -60,8 +60,6 @@
60 ``plugin_helpers``60 ``plugin_helpers``
61 A list of helper objects to pass to the plugins.61 A list of helper objects to pass to the plugins.
6262
63 ``eventmanager``
64 The event manager to pass to the plugins.
65 """63 """
66 self.plugin_helpers = plugin_helpers64 self.plugin_helpers = plugin_helpers
67 startdepth = len(os.path.abspath(dir).split(os.sep))65 startdepth = len(os.path.abspath(dir).split(os.sep))
@@ -103,11 +101,9 @@
103 pList = {u'plugin': plugin, u'status': u'Inactive'}101 pList = {u'plugin': plugin, u'status': u'Inactive'}
104 if plugin.check_pre_conditions():102 if plugin.check_pre_conditions():
105 log.debug(u'Plugin %s active', unicode(plugin.name))103 log.debug(u'Plugin %s active', unicode(plugin.name))
106 eventmanager.register(plugin)
107 pList[u'status'] = u'Active'104 pList[u'status'] = u'Active'
108 self.plugins.append(pList)105 self.plugins.append(pList)
109106
110
111 def order_by_weight(self, x, y):107 def order_by_weight(self, x, y):
112 """108 """
113 Sort two plugins and order them by their weight.109 Sort two plugins and order them by their weight.
114110
=== modified file 'openlp/core/ui/amendthemeform.py'
--- openlp/core/ui/amendthemeform.py 2009-08-07 17:19:32 +0000
+++ openlp/core/ui/amendthemeform.py 2009-08-26 05:00:19 +0000
@@ -32,11 +32,9 @@
32 def __init__(self, thememanager, parent=None):32 def __init__(self, thememanager, parent=None):
33 QtGui.QDialog.__init__(self, parent)33 QtGui.QDialog.__init__(self, parent)
34 self.thememanager = thememanager34 self.thememanager = thememanager
35 # Needed here as UI setup generates Events
36 self.path = None35 self.path = None
37 self.theme = ThemeXML()36 self.theme = ThemeXML()
38 self.setupUi(self)37 self.setupUi(self)
39
40 #define signals38 #define signals
41 #Buttons39 #Buttons
42 QtCore.QObject.connect(self.Color1PushButton ,40 QtCore.QObject.connect(self.Color1PushButton ,
4341
=== modified file 'openlp/core/ui/maindisplay.py'
--- openlp/core/ui/maindisplay.py 2009-08-24 04:30:04 +0000
+++ openlp/core/ui/maindisplay.py 2009-08-26 05:00:19 +0000
@@ -21,7 +21,7 @@
21from PyQt4 import QtCore, QtGui21from PyQt4 import QtCore, QtGui
2222
23from time import sleep23from time import sleep
24from openlp.core.lib import translate, EventManager, Event, EventType, Receiver24from openlp.core.lib import translate, Receiver
2525
26class MainDisplay(QtGui.QWidget):26class MainDisplay(QtGui.QWidget):
27 """27 """
@@ -58,20 +58,10 @@
58 self.alertactive = False58 self.alertactive = False
59 self.alertTab = None59 self.alertTab = None
60 self.timer_id = 060 self.timer_id = 0
61 # Register the main form as an event consumer.
62 self.parent.EventManager.register(self)
63 QtCore.QObject.connect(Receiver.get_receiver(),61 QtCore.QObject.connect(Receiver.get_receiver(),
64 QtCore.SIGNAL(u'live_slide_blank'), self.blankDisplay)62 QtCore.SIGNAL(u'live_slide_blank'), self.blankDisplay)
6563 QtCore.QObject.connect(Receiver.get_receiver(),
66 def handle_event(self, event):64 QtCore.SIGNAL(u'alert_text'), self.displayAlert)
67 """
68 Accept Events for the system and If It's for Alert
69 action it and Return true to stop futher processing
70 """
71 log.debug(u'MainDisplay received event %s with payload %s'%(event.event_type, event.payload))
72 if event.event_type == EventType.TriggerAlert:
73 self.displayAlert(event.payload)
74 return True
7565
76 def setup(self, screenNumber):66 def setup(self, screenNumber):
77 """67 """
7868
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2009-08-15 11:02:24 +0000
+++ openlp/core/ui/mainwindow.py 2009-08-26 05:00:19 +0000
@@ -26,8 +26,8 @@
26 ServiceManager, ThemeManager, MainDisplay, SlideController, \26 ServiceManager, ThemeManager, MainDisplay, SlideController, \
27 PluginForm27 PluginForm
28from openlp.core.lib import translate, Plugin, MediaManagerItem, \28from openlp.core.lib import translate, Plugin, MediaManagerItem, \
29 SettingsTab, EventManager, RenderManager, PluginConfig, \29 SettingsTab, RenderManager, PluginConfig, \
30 SettingsManager, PluginManager, EventType30 SettingsManager, PluginManager, Receiver
3131
32class Ui_MainWindow(object):32class Ui_MainWindow(object):
33 def setupUi(self, MainWindow):33 def setupUi(self, MainWindow):
@@ -416,7 +416,6 @@
416 self.screenList = screens416 self.screenList = screens
417 self.oosNotSaved = False417 self.oosNotSaved = False
418 self.settingsmanager = SettingsManager(screens)418 self.settingsmanager = SettingsManager(screens)
419 self.EventManager = EventManager()
420 self.mainDisplay = MainDisplay(self, screens)419 self.mainDisplay = MainDisplay(self, screens)
421 self.generalConfig = PluginConfig(u'General')420 self.generalConfig = PluginConfig(u'General')
422 self.alertForm = AlertForm(self)421 self.alertForm = AlertForm(self)
@@ -458,6 +457,8 @@
458 QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked)457 QtCore.SIGNAL(u'triggered()'), self.onPluginItemClicked)
459 QtCore.QObject.connect(self.OptionsSettingsItem,458 QtCore.QObject.connect(self.OptionsSettingsItem,
460 QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked)459 QtCore.SIGNAL(u'triggered()'), self.onOptionsSettingsItemClicked)
460 QtCore.QObject.connect(Receiver.get_receiver(),
461 QtCore.SIGNAL(u'update_global_theme'), self.defaultThemeChanged)
461 #warning cyclic dependency462 #warning cyclic dependency
462 #RenderManager needs to call ThemeManager and463 #RenderManager needs to call ThemeManager and
463 #ThemeManager needs to call RenderManager464 #ThemeManager needs to call RenderManager
@@ -467,12 +468,10 @@
467 #make the controllers available to the plugins468 #make the controllers available to the plugins
468 self.plugin_helpers[u'preview'] = self.PreviewController469 self.plugin_helpers[u'preview'] = self.PreviewController
469 self.plugin_helpers[u'live'] = self.LiveController470 self.plugin_helpers[u'live'] = self.LiveController
470 self.plugin_helpers[u'event'] = self.EventManager
471 self.plugin_helpers[u'render'] = self.RenderManager471 self.plugin_helpers[u'render'] = self.RenderManager
472 self.plugin_helpers[u'service'] = self.ServiceManagerContents472 self.plugin_helpers[u'service'] = self.ServiceManagerContents
473 self.plugin_helpers[u'settings'] = self.settingsForm473 self.plugin_helpers[u'settings'] = self.settingsForm
474 self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers,474 self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers)
475 self.EventManager)
476 # hook methods have to happen after find_plugins. Find plugins needs the475 # hook methods have to happen after find_plugins. Find plugins needs the
477 # controllers hence the hooks have moved from setupUI() to here476 # controllers hence the hooks have moved from setupUI() to here
478477
@@ -490,8 +489,6 @@
490 # Call the initialise method to setup plugins.489 # Call the initialise method to setup plugins.
491 log.info(u'initialise plugins')490 log.info(u'initialise plugins')
492 self.plugin_manager.initialise_plugins()491 self.plugin_manager.initialise_plugins()
493 # Register the main form as an event consumer.
494 self.EventManager.register(self)
495 # Once all components are initialised load the Themes492 # Once all components are initialised load the Themes
496 log.info(u'Load Themes')493 log.info(u'Load Themes')
497 self.ThemeManagerContents.loadThemes()494 self.ThemeManagerContents.loadThemes()
@@ -593,9 +590,5 @@
593 title = u'%s - %s*' % (self.mainTitle, service_name)590 title = u'%s - %s*' % (self.mainTitle, service_name)
594 self.setWindowTitle(title)591 self.setWindowTitle(title)
595592
596 def handle_event(self, event):593 def defaultThemeChanged(self, theme):
597 if event.event_type == EventType.ThemeListChanged:594 self.DefaultThemeLabel.setText(self.defaultThemeText + theme)
598 self.ServiceManagerContents.updateThemeList(event.payload)
599 self.settingsForm.ThemesTab.updateThemeList(event.payload)
600 self.DefaultThemeLabel.setText(self.defaultThemeText + \
601 self.ThemeManagerContents.getDefault())
602595
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2009-08-15 07:33:01 +0000
+++ openlp/core/ui/servicemanager.py 2009-08-25 05:18:09 +0000
@@ -24,9 +24,9 @@
24import shutil24import shutil
2525
26from PyQt4 import QtCore, QtGui26from PyQt4 import QtCore, QtGui
27from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, Event, \27from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \
28 RenderManager, EventType, EventManager, translate, buildIcon, \28 RenderManager, translate, buildIcon, \
29 contextMenuAction, contextMenuSeparator29 contextMenuAction, contextMenuSeparator, Receiver
30from openlp.core.utils import ConfigHelper30from openlp.core.utils import ConfigHelper
3131
32class ServiceManagerList(QtGui.QTreeWidget):32class ServiceManagerList(QtGui.QTreeWidget):
@@ -66,6 +66,7 @@
66class Iter(QtGui.QTreeWidgetItemIterator):66class Iter(QtGui.QTreeWidgetItemIterator):
67 def __init__(self, *args):67 def __init__(self, *args):
68 QtGui.QTreeWidgetItemIterator.__init__(self, *args)68 QtGui.QTreeWidgetItemIterator.__init__(self, *args)
69
69 def next(self):70 def next(self):
70 self.__iadd__(1)71 self.__iadd__(1)
71 value = self.value()72 value = self.value()
@@ -158,6 +159,8 @@
158 QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), self.collapsed)159 QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), self.collapsed)
159 QtCore.QObject.connect(self.ServiceManagerList,160 QtCore.QObject.connect(self.ServiceManagerList,
160 QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded)161 QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded)
162 QtCore.QObject.connect(Receiver.get_receiver(),
163 QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
161 # Last little bits of setting up164 # Last little bits of setting up
162 self.config = PluginConfig(u'ServiceManager')165 self.config = PluginConfig(u'ServiceManager')
163 self.servicePath = self.config.get_data_path()166 self.servicePath = self.config.get_data_path()
@@ -488,7 +491,7 @@
488 link = event.mimeData()491 link = event.mimeData()
489 if link.hasText():492 if link.hasText():
490 plugin = event.mimeData().text()493 plugin = event.mimeData().text()
491 self.parent.EventManager.post_event(Event(u'ServiceManager', EventType.LoadServiceItem, plugin))494 Receiver().send_message(u'%s_add_service_item' % plugin)
492495
493 def updateThemeList(self, theme_list):496 def updateThemeList(self, theme_list):
494 """497 """
495498
=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py 2009-08-15 07:33:01 +0000
+++ openlp/core/ui/thememanager.py 2009-08-26 05:00:19 +0000
@@ -28,9 +28,9 @@
2828
29from openlp.core.ui import AmendThemeForm, ServiceManager29from openlp.core.ui import AmendThemeForm, ServiceManager
30from openlp.core.theme import Theme30from openlp.core.theme import Theme
31from openlp.core.lib import PluginConfig, Event, EventType, \31from openlp.core.lib import PluginConfig, \
32 EventManager, OpenLPToolbar, ThemeXML, Renderer, translate, \32 OpenLPToolbar, ThemeXML, Renderer, translate, \
33 file_to_xml, buildIcon33 file_to_xml, buildIcon, Receiver
34from openlp.core.utils import ConfigHelper34from openlp.core.utils import ConfigHelper
3535
36class ThemeManager(QtGui.QWidget):36class ThemeManager(QtGui.QWidget):
@@ -72,7 +72,9 @@
72 self.Layout.addWidget(self.ThemeListWidget)72 self.Layout.addWidget(self.ThemeListWidget)
73 #Signals73 #Signals
74 QtCore.QObject.connect(self.ThemeListWidget,74 QtCore.QObject.connect(self.ThemeListWidget,
75 QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobal)75 QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.changeGlobalFromScreen)
76 QtCore.QObject.connect(Receiver.get_receiver(),
77 QtCore.SIGNAL(u'update_global_theme'), self.changeGlobalFromTab)
76 #Variables78 #Variables
77 self.themelist = []79 self.themelist = []
78 self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')80 self.path = os.path.join(ConfigHelper.get_data_path(), u'themes')
@@ -86,7 +88,22 @@
86 def getDefault(self):88 def getDefault(self):
87 return self.global_theme89 return self.global_theme
8890
89 def changeGlobal(self, index):91 def changeGlobalFromTab(self, themeName):
92 log.debug(u'changeGlobalFromTab %s', themeName)
93 for count in range (0, self.ThemeListWidget.count()):
94 #reset the old name
95 item = self.ThemeListWidget.item(count)
96 oldName = item.text()
97 newName = unicode(item.data(QtCore.Qt.UserRole).toString())
98 if oldName != newName:
99 self.ThemeListWidget.item(count).setText(newName)
100 #Set the new name
101 if themeName == newName:
102 name = u'%s (%s)' % (newName, translate(u'ThemeManager', u'default'))
103 self.ThemeListWidget.item(count).setText(name)
104
105 def changeGlobalFromScreen(self, index):
106 log.debug(u'changeGlobalFromScreen %s', index)
90 for count in range (0, self.ThemeListWidget.count()):107 for count in range (0, self.ThemeListWidget.count()):
91 item = self.ThemeListWidget.item(count)108 item = self.ThemeListWidget.item(count)
92 oldName = item.text()109 oldName = item.text()
@@ -99,6 +116,7 @@
99 name = u'%s (%s)' % (self.global_theme, translate(u'ThemeManager', u'default'))116 name = u'%s (%s)' % (self.global_theme, translate(u'ThemeManager', u'default'))
100 self.ThemeListWidget.item(count).setText(name)117 self.ThemeListWidget.item(count).setText(name)
101 self.config.set_config(u'theme global theme', self.global_theme)118 self.config.set_config(u'theme global theme', self.global_theme)
119 Receiver().send_message(u'update_global_theme', self.global_theme )
102 self.pushThemes()120 self.pushThemes()
103121
104 def onAddTheme(self):122 def onAddTheme(self):
@@ -184,7 +202,7 @@
184 self.pushThemes()202 self.pushThemes()
185203
186 def pushThemes(self):204 def pushThemes(self):
187 self.parent.EventManager.post_event(Event(u'ThemeManager', EventType.ThemeListChanged, self.getThemes()))205 Receiver().send_message(u'update_themes', self.getThemes() )
188206
189 def getThemes(self):207 def getThemes(self):
190 return self.themelist208 return self.themelist
@@ -194,7 +212,6 @@
194 xml_file = os.path.join(self.path, unicode(themename), unicode(themename) + u'.xml')212 xml_file = os.path.join(self.path, unicode(themename), unicode(themename) + u'.xml')
195 try:213 try:
196 xml = file_to_xml(xml_file)214 xml = file_to_xml(xml_file)
197 #print xml
198 except:215 except:
199 newtheme = ThemeXML()216 newtheme = ThemeXML()
200 newtheme.new_document(u'New Theme')217 newtheme.new_document(u'New Theme')
@@ -205,9 +222,7 @@
205 unicode(0), unicode(0), unicode(0))222 unicode(0), unicode(0), unicode(0))
206 xml = newtheme.extract_xml()223 xml = newtheme.extract_xml()
207 theme = ThemeXML()224 theme = ThemeXML()
208 #print theme
209 theme.parse(xml)225 theme.parse(xml)
210 #print "A ", theme
211 theme.extend_image_filename(self.path)226 theme.extend_image_filename(self.path)
212 return theme227 return theme
213228
214229
=== modified file 'openlp/core/ui/themestab.py'
--- openlp/core/ui/themestab.py 2009-08-07 19:05:00 +0000
+++ openlp/core/ui/themestab.py 2009-08-25 20:04:58 +0000
@@ -20,7 +20,7 @@
2020
21from PyQt4 import QtCore, QtGui21from PyQt4 import QtCore, QtGui
2222
23from openlp.core.lib import SettingsTab, translate23from openlp.core.lib import SettingsTab, translate, Receiver
2424
25class ThemesTab(SettingsTab):25class ThemesTab(SettingsTab):
26 """26 """
@@ -88,16 +88,16 @@
88 self.LevelLayout.setWidget(2, QtGui.QFormLayout.FieldRole,88 self.LevelLayout.setWidget(2, QtGui.QFormLayout.FieldRole,
89 self.GlobalLevelLabel)89 self.GlobalLevelLabel)
90 self.ThemesTabLayout.addWidget(self.LevelGroupBox)90 self.ThemesTabLayout.addWidget(self.LevelGroupBox)
91
92 QtCore.QObject.connect(self.SongLevelRadioButton,91 QtCore.QObject.connect(self.SongLevelRadioButton,
93 QtCore.SIGNAL(u'pressed()'), self.onSongLevelButtonPressed)92 QtCore.SIGNAL(u'pressed()'), self.onSongLevelButtonPressed)
94 QtCore.QObject.connect(self.ServiceLevelRadioButton,93 QtCore.QObject.connect(self.ServiceLevelRadioButton,
95 QtCore.SIGNAL(u'pressed()'), self.onServiceLevelButtonPressed)94 QtCore.SIGNAL(u'pressed()'), self.onServiceLevelButtonPressed)
96 QtCore.QObject.connect(self.GlobalLevelRadioButton,95 QtCore.QObject.connect(self.GlobalLevelRadioButton,
97 QtCore.SIGNAL(u'pressed()'), self.onGlobalLevelButtonPressed)96 QtCore.SIGNAL(u'pressed()'), self.onGlobalLevelButtonPressed)
98
99 QtCore.QObject.connect(self.DefaultComboBox,97 QtCore.QObject.connect(self.DefaultComboBox,
100 QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged)98 QtCore.SIGNAL(u'activated(int)'), self.onDefaultComboBoxChanged)
99 QtCore.QObject.connect(Receiver.get_receiver(),
100 QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
101101
102 def retranslateUi(self):102 def retranslateUi(self):
103 self.GlobalGroupBox.setTitle(translate(u'ThemesTab', u'Global theme'))103 self.GlobalGroupBox.setTitle(translate(u'ThemesTab', u'Global theme'))
@@ -122,6 +122,7 @@
122 def save(self):122 def save(self):
123 self.config.set_config(u'theme global style', self.global_style )123 self.config.set_config(u'theme global style', self.global_style )
124 self.config.set_config(u'theme global theme',self.global_theme)124 self.config.set_config(u'theme global theme',self.global_theme)
125 Receiver().send_message(u'update_global_theme', self.global_theme )
125126
126 def onSongLevelButtonPressed(self):127 def onSongLevelButtonPressed(self):
127 self.global_style= u'Song'128 self.global_style= u'Song'
128129
=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py 2009-08-15 07:33:01 +0000
+++ openlp/plugins/bibles/bibleplugin.py 2009-08-26 05:00:19 +0000
@@ -22,7 +22,7 @@
22from PyQt4 import QtCore, QtGui22from PyQt4 import QtCore, QtGui
23from PyQt4.QtCore import *23from PyQt4.QtCore import *
2424
25from openlp.core.lib import Plugin, Event, EventType, translate25from openlp.core.lib import Plugin, translate
2626
27from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem27from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem
2828
@@ -41,9 +41,6 @@
41 QtGui.QIcon.Normal, QtGui.QIcon.Off)41 QtGui.QIcon.Normal, QtGui.QIcon.Off)
42 #Register the bible Manager42 #Register the bible Manager
43 self.biblemanager = BibleManager(self.config)43 self.biblemanager = BibleManager(self.config)
44 # passed with drag and drop messages
45 self.dnd_id = u'Bibles'
46
4744
48 def get_settings_tab(self):45 def get_settings_tab(self):
49 self.bibles_tab = BiblesTab()46 self.bibles_tab = BiblesTab()
@@ -68,18 +65,6 @@
68 export_menu.addAction(self.ExportBibleItem)65 export_menu.addAction(self.ExportBibleItem)
69 self.ExportBibleItem.setText(translate(u'BiblePlugin', u'&Bible'))66 self.ExportBibleItem.setText(translate(u'BiblePlugin', u'&Bible'))
7067
71 def initialise(self):
72 pass
73
74 def onBibleNewClick(self):68 def onBibleNewClick(self):
75 self.media_item.onBibleNewClick()69 self.media_item.onBibleNewClick()
7670
77 def handle_event(self, event):
78 """
79 Handle the event contained in the event object.
80 """
81 log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
82 if event.event_type == EventType.ThemeListChanged:
83 log.debug(u'New Theme request received')
84 self.bibles_tab.updateThemeList(event.payload)
85 return Plugin.handle_event(self, event)
8671
=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
--- openlp/plugins/bibles/forms/bibleimportform.py 2009-08-15 07:55:16 +0000
+++ openlp/plugins/bibles/forms/bibleimportform.py 2009-08-24 20:05:46 +0000
@@ -152,9 +152,9 @@
152 def onCancelButtonClicked(self):152 def onCancelButtonClicked(self):
153 # tell import to stop153 # tell import to stop
154 self.message = u'Bible import stopped'154 self.message = u'Bible import stopped'
155 Receiver().send_message(u'openlpstopimport')155 Receiver().send_message(u'stop_import')
156 # tell bibleplugin to reload the bibles156 # tell bibleplugin to reload the bibles
157 Receiver().send_message(u'openlpreloadbibles')157 Receiver().send_message(u'pre_load_bibles')
158 self.close()158 self.close()
159159
160 def onImportButtonClicked(self):160 def onImportButtonClicked(self):
@@ -172,7 +172,7 @@
172 self.MessageLabel.setText(message)172 self.MessageLabel.setText(message)
173 self.ProgressBar.setValue(self.barmax)173 self.ProgressBar.setValue(self.barmax)
174 # tell bibleplugin to reload the bibles174 # tell bibleplugin to reload the bibles
175 Receiver().send_message(u'openlpreloadbibles')175 Receiver().send_message(u'pre_load_bibles')
176 reply = QtGui.QMessageBox.information(self,176 reply = QtGui.QMessageBox.information(self,
177 translate(u'BibleMediaItem', u'Information'),177 translate(u'BibleMediaItem', u'Information'),
178 translate(u'BibleMediaItem', message))178 translate(u'BibleMediaItem', message))
179179
=== modified file 'openlp/plugins/bibles/lib/biblestab.py'
--- openlp/plugins/bibles/lib/biblestab.py 2009-07-23 05:17:26 +0000
+++ openlp/plugins/bibles/lib/biblestab.py 2009-08-25 05:18:09 +0000
@@ -21,7 +21,7 @@
2121
22from PyQt4 import Qt, QtCore, QtGui22from PyQt4 import Qt, QtCore, QtGui
2323
24from openlp.core.lib import translate, str_to_bool24from openlp.core.lib import translate, str_to_bool, Receiver
25from openlp.core.lib import SettingsTab25from openlp.core.lib import SettingsTab
2626
27class BiblesTab(SettingsTab):27class BiblesTab(SettingsTab):
@@ -146,6 +146,8 @@
146 QtCore.SIGNAL(u'activated(int)'), self.onBibleThemeComboBoxChanged)146 QtCore.SIGNAL(u'activated(int)'), self.onBibleThemeComboBoxChanged)
147 QtCore.QObject.connect(self.LayoutStyleComboBox,147 QtCore.QObject.connect(self.LayoutStyleComboBox,
148 QtCore.SIGNAL(u'activated(int)'), self.onLayoutStyleComboBoxChanged)148 QtCore.SIGNAL(u'activated(int)'), self.onLayoutStyleComboBoxChanged)
149 QtCore.QObject.connect(Receiver.get_receiver(),
150 QtCore.SIGNAL(u'update_themes'), self.updateThemeList)
149151
150 def retranslateUi(self):152 def retranslateUi(self):
151 self.VerseDisplayGroupBox.setTitle(translate(u'SettingsForm', u'Verse Display'))153 self.VerseDisplayGroupBox.setTitle(translate(u'SettingsForm', u'Verse Display'))
152154
=== modified file 'openlp/plugins/custom/customplugin.py'
--- openlp/plugins/custom/customplugin.py 2009-08-15 07:33:01 +0000
+++ openlp/plugins/custom/customplugin.py 2009-08-26 05:00:19 +0000
@@ -22,7 +22,7 @@
22from PyQt4 import QtCore, QtGui22from PyQt4 import QtCore, QtGui
2323
24from forms import EditCustomForm24from forms import EditCustomForm
25from openlp.core.lib import Plugin, Event, EventType25from openlp.core.lib import Plugin
26from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem26from openlp.plugins.custom.lib import CustomManager, CustomTab, CustomMediaItem
2727
2828
@@ -42,20 +42,8 @@
42 self.icon = QtGui.QIcon()42 self.icon = QtGui.QIcon()
43 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_custom.png'),43 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_custom.png'),
44 QtGui.QIcon.Normal, QtGui.QIcon.Off)44 QtGui.QIcon.Normal, QtGui.QIcon.Off)
45 # passed with drag and drop messages
46 self.dnd_id=u'Custom'
4745
48 def get_media_manager_item(self):46 def get_media_manager_item(self):
49 # Create the CustomManagerItem object47 # Create the CustomManagerItem object
50 self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')48 self.media_item = CustomMediaItem(self, self.icon, u'Custom Slides')
51 return self.media_item49 return self.media_item
52
53 def handle_event(self, event):
54 """
55 Handle the event contained in the event object.
56 """
57 log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload))
58 if event.event_type == EventType.ThemeListChanged:
59 log.debug(u'New Theme request received')
60 self.edit_custom_form.loadThemes(event.payload)
61 return Plugin.handle_event(self, event)
6250
=== modified file 'openlp/plugins/custom/forms/editcustomform.py'
--- openlp/plugins/custom/forms/editcustomform.py 2009-06-17 05:11:16 +0000
+++ openlp/plugins/custom/forms/editcustomform.py 2009-08-25 20:04:58 +0000
@@ -20,7 +20,7 @@
20from PyQt4 import Qt, QtCore, QtGui20from PyQt4 import Qt, QtCore, QtGui
2121
22from editcustomdialog import Ui_customEditDialog22from editcustomdialog import Ui_customEditDialog
23from openlp.core.lib import SongXMLBuilder, SongXMLParser23from openlp.core.lib import SongXMLBuilder, SongXMLParser, Receiver
24from openlp.plugins.custom.lib.models import CustomSlide24from openlp.plugins.custom.lib.models import CustomSlide
2525
26class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):26class EditCustomForm(QtGui.QDialog, Ui_customEditDialog):
@@ -50,6 +50,8 @@
50 QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'), self.onVerseListViewSelected)50 QtCore.SIGNAL(u'itemDoubleClicked(QListWidgetItem*)'), self.onVerseListViewSelected)
51 QtCore.QObject.connect(self.VerseListView,51 QtCore.QObject.connect(self.VerseListView,
52 QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onVerseListViewPressed)52 QtCore.SIGNAL(u'itemClicked(QListWidgetItem*)'), self.onVerseListViewPressed)
53 QtCore.QObject.connect(Receiver.get_receiver(),
54 QtCore.SIGNAL(u'update_themes'), self.loadThemes)
53 # Create other objects and forms55 # Create other objects and forms
54 self.custommanager = custommanager56 self.custommanager = custommanager
55 self.initialise()57 self.initialise()
5658
=== modified file 'openlp/plugins/images/imageplugin.py'
--- openlp/plugins/images/imageplugin.py 2009-07-03 20:32:33 +0000
+++ openlp/plugins/images/imageplugin.py 2009-08-26 05:00:19 +0000
@@ -21,7 +21,7 @@
2121
22from PyQt4 import QtCore, QtGui22from PyQt4 import QtCore, QtGui
2323
24from openlp.core.lib import Plugin, Event, EventType24from openlp.core.lib import Plugin
25from openlp.plugins.images.lib import ImageMediaItem, ImageTab25from openlp.plugins.images.lib import ImageMediaItem, ImageTab
2626
27class ImagePlugin(Plugin):27class ImagePlugin(Plugin):
@@ -37,8 +37,6 @@
37 self.icon = QtGui.QIcon()37 self.icon = QtGui.QIcon()
38 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_image.png'),38 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_image.png'),
39 QtGui.QIcon.Normal, QtGui.QIcon.Off)39 QtGui.QIcon.Normal, QtGui.QIcon.Off)
40 # passed with drag and drop messages
41 self.dnd_id = u'Image'
4240
43 def get_settings_tab(self):41 def get_settings_tab(self):
44 self.ImageTab = ImageTab()42 self.ImageTab = ImageTab()
4543
=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py 2009-08-24 17:43:15 +0000
+++ openlp/plugins/images/lib/mediaitem.py 2009-08-25 05:18:09 +0000
@@ -28,7 +28,7 @@
28# in order for DnD to the Service manager to work correctly.28# in order for DnD to the Service manager to work correctly.
29class ImageListView(BaseListWithDnD):29class ImageListView(BaseListWithDnD):
30 def __init__(self, parent=None):30 def __init__(self, parent=None):
31 self.PluginName = u'Image'31 self.PluginName = u'Images'
32 BaseListWithDnD.__init__(self, parent)32 BaseListWithDnD.__init__(self, parent)
3333
34class ImageMediaItem(MediaManagerItem):34class ImageMediaItem(MediaManagerItem):
3535
=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py 2009-08-15 19:10:59 +0000
+++ openlp/plugins/presentations/presentationplugin.py 2009-08-24 20:05:46 +0000
@@ -41,7 +41,6 @@
41 self.icon = QtGui.QIcon()41 self.icon = QtGui.QIcon()
42 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'),42 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_presentation.png'),
43 QtGui.QIcon.Normal, QtGui.QIcon.Off)43 QtGui.QIcon.Normal, QtGui.QIcon.Off)
44 self.dnd_id = u'Presentations'
4544
46 def get_settings_tab(self):45 def get_settings_tab(self):
47 """46 """
4847
=== modified file 'openlp/plugins/remotes/remoteplugin.py'
--- openlp/plugins/remotes/remoteplugin.py 2009-08-24 05:10:04 +0000
+++ openlp/plugins/remotes/remoteplugin.py 2009-08-26 05:00:19 +0000
@@ -22,7 +22,7 @@
2222
23from PyQt4 import QtNetwork, QtGui, QtCore23from PyQt4 import QtNetwork, QtGui, QtCore
2424
25from openlp.core.lib import Plugin, Event, EventType, Receiver25from openlp.core.lib import Plugin, Receiver
26from openlp.plugins.remotes.lib import RemoteTab26from openlp.plugins.remotes.lib import RemoteTab
2727
28class RemotesPlugin(Plugin):28class RemotesPlugin(Plugin):
@@ -58,7 +58,7 @@
58 event = unicode(datagram[:pos].lower())58 event = unicode(datagram[:pos].lower())
5959
60 if event == u'alert':60 if event == u'alert':
61 self.event_manager.post_event(Event(u'RemotePlugin', EventType.TriggerAlert , unicode(datagram[pos + 1:])))61 Receiver().send_message(u'alert_text', unicode(datagram[pos + 1:]))
62 if event == u'next_slide':62 if event == u'next_slide':
63 Receiver().send_message(u'live_slide_next')63 Receiver().send_message(u'live_slide_next')
6464
6565
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py 2009-08-15 19:19:34 +0000
+++ openlp/plugins/songs/forms/editsongform.py 2009-08-26 05:00:19 +0000
@@ -22,8 +22,8 @@
2222
23from PyQt4 import Qt, QtCore, QtGui23from PyQt4 import Qt, QtCore, QtGui
2424
25from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, \25from openlp.core.lib import SongXMLBuilder, SongXMLParser, \
26 EventType, EventManager, translate26 translate, Receiver
27from openlp.plugins.songs.forms import EditVerseForm27from openlp.plugins.songs.forms import EditVerseForm
28from openlp.plugins.songs.lib.models import Song28from openlp.plugins.songs.lib.models import Song
29from editsongdialog import Ui_EditSongDialog29from editsongdialog import Ui_EditSongDialog
@@ -36,7 +36,7 @@
36 log = logging.getLogger(u'EditSongForm')36 log = logging.getLogger(u'EditSongForm')
37 log.info(u'Song Editor loaded')37 log.info(u'Song Editor loaded')
3838
39 def __init__(self, songmanager, eventmanager, parent=None):39 def __init__(self, songmanager, parent=None):
40 """40 """
41 Constructor41 Constructor
42 """42 """
@@ -71,9 +71,10 @@
71 QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged)71 QtCore.SIGNAL(u'activated(int)'), self.onThemeComboChanged)
72 QtCore.QObject.connect(self.MaintenanceButton,72 QtCore.QObject.connect(self.MaintenanceButton,
73 QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked)73 QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked)
74 QtCore.QObject.connect(Receiver.get_receiver(),
75 QtCore.SIGNAL(u'update_themes'), self.loadThemes)
74 # Create other objects and forms76 # Create other objects and forms
75 self.songmanager = songmanager77 self.songmanager = songmanager
76 self.eventmanager = eventmanager
77 self.parent = parent78 self.parent = parent
78 self.verse_form = EditVerseForm()79 self.verse_form = EditVerseForm()
79 self.initialise()80 self.initialise()
@@ -364,7 +365,7 @@
364 self.processTitle()365 self.processTitle()
365 self.songmanager.save_song(self.song)366 self.songmanager.save_song(self.song)
366 if self.title_change:367 if self.title_change:
367 self.eventmanager.post_event(Event(u'EditSongForm', EventType.LoadSongList))368 Receiver().send_message(u'load_song_list')
368 self.close()369 self.close()
369370
370 def processLyrics(self):371 def processLyrics(self):
371372
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2009-08-15 11:02:24 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2009-08-26 05:00:19 +0000
@@ -22,12 +22,13 @@
22from PyQt4 import QtCore, QtGui22from PyQt4 import QtCore, QtGui
2323
24from openlp.core.lib import MediaManagerItem, translate, ServiceItem, \24from openlp.core.lib import MediaManagerItem, translate, ServiceItem, \
25 SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD25 SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD, \
26 Receiver
26from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm27from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm
2728
28class SongListView(BaseListWithDnD):29class SongListView(BaseListWithDnD):
29 def __init__(self, parent=None):30 def __init__(self, parent=None):
30 self.PluginName = u'Song'31 self.PluginName = u'Songs'
31 BaseListWithDnD.__init__(self, parent)32 BaseListWithDnD.__init__(self, parent)
3233
33class SongMediaItem(MediaManagerItem):34class SongMediaItem(MediaManagerItem):
@@ -43,7 +44,7 @@
43 self.PluginTextShort = u'Song'44 self.PluginTextShort = u'Song'
44 self.ConfigSection = u'song'45 self.ConfigSection = u'song'
45 MediaManagerItem.__init__(self, parent, icon, title)46 MediaManagerItem.__init__(self, parent, icon, title)
46 self.edit_song_form = EditSongForm(self.parent.songmanager, self.parent.event_manager, self)47 self.edit_song_form = EditSongForm(self.parent.songmanager, self)
47 self.song_maintenance_form = SongMaintenanceForm(self.parent.songmanager, self)48 self.song_maintenance_form = SongMaintenanceForm(self.parent.songmanager, self)
4849
49 def setupUi(self):50 def setupUi(self):
@@ -127,6 +128,9 @@
127 QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)128 QtCore.SIGNAL(u'textChanged(const QString&)'), self.onSearchTextEditChanged)
128 QtCore.QObject.connect(self.ListView,129 QtCore.QObject.connect(self.ListView,
129 QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)130 QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.onSongPreviewClick)
131 QtCore.QObject.connect(Receiver.get_receiver(),
132 QtCore.SIGNAL(u'load_song_list'), self.onSearchTextButtonClick)
133
130 #define and add the context menu134 #define and add the context menu
131 self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)135 self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
132 self.ListView.addAction(contextMenuAction(self.ListView,136 self.ListView.addAction(contextMenuAction(self.ListView,
133137
=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py 2009-08-15 07:33:01 +0000
+++ openlp/plugins/songs/songsplugin.py 2009-08-26 05:00:19 +0000
@@ -22,7 +22,7 @@
2222
23from PyQt4 import QtCore, QtGui23from PyQt4 import QtCore, QtGui
2424
25from openlp.core.lib import Plugin, Event, EventType, translate25from openlp.core.lib import Plugin, translate
26from openlp.plugins.songs.lib import SongManager, SongsTab, SongMediaItem26from openlp.plugins.songs.lib import SongManager, SongsTab, SongMediaItem
27from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \27from openlp.plugins.songs.forms import OpenLPImportForm, OpenSongExportForm, \
28 OpenSongImportForm, OpenLPExportForm28 OpenSongImportForm, OpenLPExportForm
@@ -46,8 +46,6 @@
46 self.icon = QtGui.QIcon()46 self.icon = QtGui.QIcon()
47 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_song.png'),47 self.icon.addPixmap(QtGui.QPixmap(u':/media/media_song.png'),
48 QtGui.QIcon.Normal, QtGui.QIcon.Off)48 QtGui.QIcon.Normal, QtGui.QIcon.Off)
49 # passed with drag and drop messages
50 self.dnd_id=u'Song'
5149
52 def get_media_manager_item(self):50 def get_media_manager_item(self):
53 # Create the MediaManagerItem object51 # Create the MediaManagerItem object
@@ -128,16 +126,3 @@
128126
129 def onExportOpenSongItemClicked(self):127 def onExportOpenSongItemClicked(self):
130 self.opensong_export_form.show()128 self.opensong_export_form.show()
131
132 def handle_event(self, event):
133 """
134 Handle the event contained in the event object.
135 """
136 log.debug(u'Handle event called with event %s' % event.event_type)
137 if event.event_type == EventType.ThemeListChanged:
138 log.debug(u'New Theme request received')
139 self.media_item.edit_song_form.loadThemes(event.payload)
140 if event.event_type == EventType.LoadSongList :
141 log.debug(u'Load Load Song List Item received')
142 self.media_item.displayResultsSong(self.songmanager.get_songs())
143 return Plugin.handle_event(self, event)