Plugin Clean up to remove extra code and remove need for Theme_Manager

This commit is contained in:
Tim Bentley 2009-08-15 12:02:24 +01:00
parent 1987258fcb
commit 48bca4155d
6 changed files with 23 additions and 73 deletions

View File

@ -122,7 +122,6 @@ class Plugin(object):
self.log = logging.getLogger(self.name)
self.preview_controller = plugin_helpers[u'preview']
self.live_controller = plugin_helpers[u'live']
#self.theme_manager = plugin_helpers[u'theme']
self.event_manager = plugin_helpers[u'event']
self.render_manager = plugin_helpers[u'render']
self.service_manager = plugin_helpers[u'service']
@ -132,6 +131,7 @@ class Plugin(object):
def check_pre_conditions(self):
"""
Provides the Plugin with a handle to check if it can be loaded.
Failing Preconditions does not stop a settings Tab being created
Returns True or False.
"""

View File

@ -468,7 +468,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
self.plugin_helpers[u'preview'] = self.PreviewController
self.plugin_helpers[u'live'] = self.LiveController
self.plugin_helpers[u'event'] = self.EventManager
self.plugin_helpers[u'theme'] = self.ThemeManagerContents
self.plugin_helpers[u'render'] = self.RenderManager
self.plugin_helpers[u'service'] = self.ServiceManagerContents
self.plugin_helpers[u'settings'] = self.settingsForm

View File

@ -25,30 +25,14 @@ import time
from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate, ServiceItem, MediaManagerItem, \
Receiver, contextMenuAction, contextMenuSeparator
Receiver, contextMenuAction, contextMenuSeparator, BaseListWithDnD
from openlp.plugins.bibles.forms import BibleImportForm
from openlp.plugins.bibles.lib.manager import BibleMode
class BibleList(QtGui.QListWidget):
def __init__(self,parent=None,name=None):
QtGui.QListView.__init__(self,parent)
def mouseMoveEvent(self, event):
"""
Drag and drop event does not care what data is selected
as the recepient will use events to request the data move
just tell it what plugin to call
"""
if event.buttons() != QtCore.Qt.LeftButton:
return
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData)
mimeData.setText(u'Bibles')
dropAction = drag.start(QtCore.Qt.CopyAction)
if dropAction == QtCore.Qt.CopyAction:
self.close()
class BibleListView(BaseListWithDnD):
def __init__(self, parent=None):
self.PluginName = u'Bibles'
BaseListWithDnD.__init__(self, parent)
class BibleMediaItem(MediaManagerItem):
"""
@ -201,7 +185,7 @@ class BibleMediaItem(MediaManagerItem):
self.SearchTabWidget.addTab(self.AdvancedTab, u'Advanced')
# Add the search tab widget to the page layout
self.PageLayout.addWidget(self.SearchTabWidget)
self.ListView = BibleList()
self.ListView = BibleListView()
self.ListView.setAlternatingRowColors(True)
self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
self.ListView.setDragEnabled(True)

View File

@ -21,28 +21,12 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, contextMenuAction, contextMenuSeparator
from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, contextMenuAction, contextMenuSeparator, BaseListWithDnD
class CustomList(QtGui.QListWidget):
def __init__(self,parent=None,name=None):
QtGui.QListView.__init__(self,parent)
def mouseMoveEvent(self, event):
"""
Drag and drop event does not care what data is selected
as the recepient will use events to request the data move
just tell it what plugin to call
"""
if event.buttons() != QtCore.Qt.LeftButton:
return
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData)
mimeData.setText(u'Custom')
dropAction = drag.start(QtCore.Qt.CopyAction)
if dropAction == QtCore.Qt.CopyAction:
self.close()
class CustomListView(BaseListWithDnD):
def __init__(self, parent=None):
self.PluginName = u'Custom'
BaseListWithDnD.__init__(self, parent)
class CustomMediaItem(MediaManagerItem):
"""
@ -95,7 +79,7 @@ class CustomMediaItem(MediaManagerItem):
translate(u'CustomMediaItem',u'Add Custom To Service'),
translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'),
u':/system/system_add.png', self.onCustomAddClick, u'CustomAddItem')
# Add the Customlist widget
# Add the CustomListView widget
self.CustomWidget = QtGui.QWidget(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
@ -105,7 +89,7 @@ class CustomMediaItem(MediaManagerItem):
self.CustomWidget.setObjectName(u'CustomWidget')
# Add the Custom widget to the page layout
self.PageLayout.addWidget(self.CustomWidget)
self.ListView = CustomList()
self.ListView = CustomListView()
self.ListView.setAlternatingRowColors(True)
self.ListView.setDragEnabled(True)
self.PageLayout.addWidget(self.ListView)
@ -129,9 +113,9 @@ class CustomMediaItem(MediaManagerItem):
translate(u'CustomMediaItem',u'&Add to Service'), self.onCustomAddClick))
def initialise(self):
self.loadCustomList(self.parent.custommanager.get_all_slides())
self.loadCustomListView(self.parent.custommanager.get_all_slides())
def loadCustomList(self, list):
def loadCustomListView(self, list):
self.ListView.clear()
for CustomSlide in list:
custom_name = QtGui.QListWidgetItem(CustomSlide.title)

View File

@ -32,7 +32,6 @@ from openlp.core.lib import MediaManagerItem, translate
from openlp.plugins.media.lib import MediaTab
from openlp.plugins.media.lib import FileListData
# from listwithpreviews import ListWithPreviews
from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD, buildIcon
class MediaListView(BaseListWithDnD):

View File

@ -22,29 +22,13 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.lib import MediaManagerItem, translate, ServiceItem, \
SongXMLParser, contextMenuAction, contextMenuSeparator
SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm
class SongList(QtGui.QListWidget):
def __init__(self, parent=None, name=None):
QtGui.QListWidget.__init__(self,parent)
def mouseMoveEvent(self, event):
"""
Drag and drop event does not care what data is selected
as the recepient will use events to request the data move
just tell it what plugin to call
"""
if event.buttons() != QtCore.Qt.LeftButton:
return
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData)
mimeData.setText(u'Song')
dropAction = drag.start(QtCore.Qt.CopyAction)
if dropAction == QtCore.Qt.CopyAction:
self.close()
class SongListView(BaseListWithDnD):
def __init__(self, parent=None):
self.PluginName = u'Song'
BaseListWithDnD.__init__(self, parent)
class SongMediaItem(MediaManagerItem):
"""
@ -97,7 +81,7 @@ class SongMediaItem(MediaManagerItem):
self.addToolbarButton(translate(u'SongMediaItem', u'Song Maintenance'),
translate(u'SongMediaItem', u'Maintain the lists of authors, topics and books'),
':/songs/song_maintenance.png', self.onSongMaintenanceClick, 'SongMaintenanceItem')
## Add the songlist widget ##
## Add the SongListView widget ##
# Create the tab widget
self.SongWidget = QtGui.QWidget(self)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
@ -128,7 +112,7 @@ class SongMediaItem(MediaManagerItem):
self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1)
# Add the song widget to the page layout
self.PageLayout.addWidget(self.SongWidget)
self.ListView = SongList()
self.ListView = SongListView()
self.ListView.setAlternatingRowColors(True)
self.ListView.setDragEnabled(True)
self.ListView.setObjectName(u'ListView')