openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #06160
[Merge] lp:~meths/openlp/trivialfixes into lp:openlp
Jon Tibble has proposed merging lp:~meths/openlp/trivialfixes into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/49277
Refactor and rename listviews for DnD
Wizard refactors
Cleanups
--
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/49277
Your team OpenLP Core is requested to review the proposed merge of lp:~meths/openlp/trivialfixes into lp:openlp.
=== modified file 'documentation/api/source/core/lib.rst'
--- documentation/api/source/core/lib.rst 2010-10-16 22:50:36 +0000
+++ documentation/api/source/core/lib.rst 2011-02-10 19:44:14 +0000
@@ -6,18 +6,18 @@
.. automodule:: openlp.core.lib
:members:
-:mod:`BaseListWithDnD`
-----------------------
-
-.. autoclass:: openlp.core.lib.baselistwithdnd.BaseListWithDnD
- :members:
-
:mod:`EventReceiver`
--------------------
.. autoclass:: openlp.core.lib.eventreceiver.EventReceiver
:members:
+:mod:`ListWidgetWithDnD`
+----------------------
+
+.. autoclass:: openlp.core.lib.listwidgetwithdnd.ListWidgetWithDnD
+ :members:
+
:mod:`MediaManagerItem`
-----------------------
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2011-02-02 19:30:06 +0000
+++ openlp/core/lib/__init__.py 2011-02-10 19:44:14 +0000
@@ -319,6 +319,7 @@
if not os.path.exists(dir):
os.makedirs(dir)
+from listwidgetwithdnd import ListWidgetWithDnD
from theme import ThemeLevel, ThemeXML, BackgroundGradientType, \
BackgroundType, HorizontalType, VerticalType
from displaytags import DisplayTags
@@ -339,4 +340,3 @@
from renderer import Renderer
from rendermanager import RenderManager
from mediamanageritem import MediaManagerItem
-from baselistwithdnd import BaseListWithDnD
=== renamed file 'openlp/core/lib/baselistwithdnd.py' => 'openlp/core/lib/listwidgetwithdnd.py'
--- openlp/core/lib/baselistwithdnd.py 2010-12-26 11:04:47 +0000
+++ openlp/core/lib/listwidgetwithdnd.py 2011-02-10 19:44:14 +0000
@@ -28,17 +28,17 @@
"""
from PyQt4 import QtCore, QtGui
-class BaseListWithDnD(QtGui.QListWidget):
+class ListWidgetWithDnD(QtGui.QListWidget):
"""
Provide a list widget to store objects and handle drag and drop events
"""
- def __init__(self, parent=None):
+ def __init__(self, parent=None, name=u''):
"""
Initialise the list widget
"""
QtGui.QListWidget.__init__(self, parent)
- # this must be set by the class which is inheriting
- assert(self.PluginName)
+ self.mimeDataText = name
+ assert(self.mimeDataText)
def mouseMoveEvent(self, event):
"""
@@ -47,9 +47,10 @@
just tell it what plugin to call
"""
if event.buttons() != QtCore.Qt.LeftButton:
+ event.ignore()
return
drag = QtGui.QDrag(self)
mimeData = QtCore.QMimeData()
drag.setMimeData(mimeData)
- mimeData.setText(self.PluginName)
- drag.start(QtCore.Qt.CopyAction)
\ No newline at end of file
+ mimeData.setText(self.mimeDataText)
+ drag.start(QtCore.Qt.CopyAction)
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2011-02-10 04:06:16 +0000
+++ openlp/core/lib/mediamanageritem.py 2011-02-10 19:44:14 +0000
@@ -33,7 +33,7 @@
from openlp.core.lib import context_menu_action, context_menu_separator, \
SettingsManager, OpenLPToolbar, ServiceItem, StringContent, build_icon, \
- translate, Receiver
+ translate, Receiver, ListWidgetWithDnD
log = logging.getLogger(__name__)
@@ -73,11 +73,6 @@
assumes that the new action is to load a file. If not, you
need to override the ``OnNew`` method.
- ``self.ListViewWithDnD_class``
- This must be a **class**, not an object, descended from
- ``openlp.core.lib.BaseListWithDnD`` that is not used in any
- other part of OpenLP.
-
``self.PreviewFunction``
This must be a method which returns a QImage to represent the
item (usually a preview). No scaling is required, that is
@@ -263,7 +258,7 @@
Creates the main widget for listing items the media item is tracking
"""
# Add the List widget
- self.listView = self.ListViewWithDnD_class(self)
+ self.listView = ListWidgetWithDnD(self, self.title)
self.listView.uniformItemSizes = True
self.listView.setSpacing(1)
self.listView.setSelectionMode(
=== modified file 'openlp/core/ui/filerenameform.py'
--- openlp/core/ui/filerenameform.py 2011-02-10 00:36:00 +0000
+++ openlp/core/ui/filerenameform.py 2011-02-10 19:44:14 +0000
@@ -24,7 +24,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
-from PyQt4 import QtCore, QtGui
+from PyQt4 import QtGui
from filerenamedialog import Ui_FileRenameDialog
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2011-02-10 18:35:59 +0000
+++ openlp/core/ui/mainwindow.py 2011-02-10 19:44:14 +0000
@@ -216,8 +216,8 @@
self.ToolsAddToolItem = icon_action(mainWindow, u'ToolsAddToolItem',
u':/tools/tools_add.png')
mainWindow.actionList.add_action(self.ToolsAddToolItem, u'Tools')
- self.ToolsOpenDataFolder = icon_action(mainWindow, u'ToolsOpenDataFolder',
- u':/general/general_open.png')
+ self.ToolsOpenDataFolder = icon_action(mainWindow,
+ u'ToolsOpenDataFolder', u':/general/general_open.png')
mainWindow.actionList.add_action(self.ToolsOpenDataFolder, u'Tools')
self.settingsPluginListItem = icon_action(mainWindow,
u'settingsPluginListItem', u':/system/settings_plugin_list.png')
=== modified file 'openlp/core/ui/wizard.py'
--- openlp/core/ui/wizard.py 2011-02-02 19:17:48 +0000
+++ openlp/core/ui/wizard.py 2011-02-10 19:44:14 +0000
@@ -70,6 +70,12 @@
self.retranslateUi()
QtCore.QMetaObject.connectSlotsByName(self)
+ def registerFields(self):
+ """
+ Hook method for wizards to register any fields they need.
+ """
+ pass
+
def addProgressPage(self):
"""
Add the progress page for the wizard. This page informs the user how
@@ -146,3 +152,30 @@
self.finishButton.setVisible(True)
self.cancelButton.setVisible(False)
Receiver.send_message(u'openlp_process_events')
+
+ def getFileName(self, title, editbox, filters=u''):
+ """
+ Opens a QFileDialog and saves the filename to the given editbox.
+
+ ``title``
+ The title of the dialog (unicode).
+
+ ``editbox``
+ A editbox (QLineEdit).
+
+ ``filters``
+ The file extension filters. It should contain the file description
+ as well as the file extension. For example::
+
+ u'OpenLP 2.0 Databases (*.sqlite)'
+ """
+ if filters:
+ filters += u';;'
+ filters += u'%s (*)' % UiStrings.AllFiles
+ filename = QtGui.QFileDialog.getOpenFileName(self, title,
+ os.path.dirname(SettingsManager.get_last_dir(
+ self.plugin.settingsSection, 1)), filters)
+ if filename:
+ editbox.setText(filename)
+ SettingsManager.set_last_dir(self.plugin.settingsSection,
+ filename, 1)
=== modified file 'openlp/plugins/bibles/forms/bibleimportform.py'
--- openlp/plugins/bibles/forms/bibleimportform.py 2011-02-09 05:04:12 +0000
+++ openlp/plugins/bibles/forms/bibleimportform.py 2011-02-10 19:44:14 +0000
@@ -727,33 +727,6 @@
if books_file:
books_file.close()
- def getFileName(self, title, editbox, filters=u''):
- """
- Opens a QFileDialog and saves the filename to the given editbox.
-
- ``title``
- The title of the dialog (unicode).
-
- ``editbox``
- A editbox (QLineEdit).
-
- ``filters``
- The file extension filters. It should contain the file description
- as well as the file extension. For example::
-
- u'openlp.org 1.x bible (*.bible)'
- """
- if filters:
- filters += u';;'
- filters += u'%s (*)' % UiStrings.AllFiles
- filename = QtGui.QFileDialog.getOpenFileName(self, title,
- os.path.dirname(SettingsManager.get_last_dir(
- self.plugin.settingsSection, 1)), filters)
- if filename:
- editbox.setText(filename)
- SettingsManager.set_last_dir(
- self.plugin.settingsSection, filename, 1)
-
def preWizard(self):
"""
Prepare the UI for the import.
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2011-02-10 04:06:16 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2011-02-10 19:44:14 +0000
@@ -28,8 +28,8 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import MediaManagerItem, Receiver, BaseListWithDnD, \
- ItemCapabilities, translate
+from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
+ translate
from openlp.core.lib.ui import UiStrings, add_widget_completer, \
media_item_combo_box, critical_error_message_box
from openlp.plugins.bibles.forms import BibleImportForm
@@ -37,15 +37,6 @@
log = logging.getLogger(__name__)
-class BibleListView(BaseListWithDnD):
- """
- Custom list view descendant, required for drag and drop.
- """
- def __init__(self, parent=None):
- self.PluginName = u'Bibles'
- BaseListWithDnD.__init__(self, parent)
-
-
class BibleMediaItem(MediaManagerItem):
"""
This is the custom media manager item for Bibles.
@@ -54,7 +45,6 @@
def __init__(self, parent, plugin, icon):
self.IconPath = u'songs/song'
- self.ListViewWithDnD_class = BibleListView
MediaManagerItem.__init__(self, parent, plugin, icon)
# Place to store the search results for both bibles.
self.search_results = {}
=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py 2011-02-04 18:42:37 +0000
+++ openlp/plugins/custom/lib/mediaitem.py 2011-02-10 19:44:14 +0000
@@ -28,18 +28,13 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import MediaManagerItem, BaseListWithDnD, \
- Receiver, ItemCapabilities, translate, check_item_selected
+from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
+ translate, check_item_selected
from openlp.plugins.custom.lib import CustomXMLParser
from openlp.plugins.custom.lib.db import CustomSlide
log = logging.getLogger(__name__)
-class CustomListView(BaseListWithDnD):
- def __init__(self, parent=None):
- self.PluginName = u'Custom'
- BaseListWithDnD.__init__(self, parent)
-
class CustomMediaItem(MediaManagerItem):
"""
This is the custom media manager item for Custom Slides.
@@ -48,9 +43,6 @@
def __init__(self, parent, plugin, icon):
self.IconPath = u'custom/custom'
- # this next is a class, not an instance of a class - it will
- # be instanced by the base MediaManagerItem
- self.ListViewWithDnD_class = CustomListView
MediaManagerItem.__init__(self, parent, self, icon)
self.singleServiceItem = False
# Holds information about whether the edit is remotly triggered and
=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py 2011-02-10 00:36:00 +0000
+++ openlp/plugins/images/lib/mediaitem.py 2011-02-10 19:44:14 +0000
@@ -29,21 +29,14 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
- ItemCapabilities, SettingsManager, translate, check_item_selected, \
- check_directory_exists, Receiver
+from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
+ SettingsManager, translate, check_item_selected, check_directory_exists, \
+ Receiver
from openlp.core.lib.ui import UiStrings, critical_error_message_box
from openlp.core.utils import AppLocation, delete_file, get_images_filter
log = logging.getLogger(__name__)
-# We have to explicitly create separate classes for each plugin
-# in order for DnD to the Service manager to work correctly.
-class ImageListView(BaseListWithDnD):
- def __init__(self, parent=None):
- self.PluginName = u'Images'
- BaseListWithDnD.__init__(self, parent)
-
class ImageMediaItem(MediaManagerItem):
"""
This is the custom media manager item for images.
@@ -52,9 +45,6 @@
def __init__(self, parent, plugin, icon):
self.IconPath = u'images/image'
- # This next is a class, not an instance of a class - it will
- # be instanced by the base MediaManagerItem.
- self.ListViewWithDnD_class = ImageListView
MediaManagerItem.__init__(self, parent, self, icon)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'live_theme_changed'), self.liveThemeChanged)
=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py 2011-02-10 00:36:00 +0000
+++ openlp/plugins/media/lib/mediaitem.py 2011-02-10 19:44:14 +0000
@@ -29,18 +29,12 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
- ItemCapabilities, SettingsManager, translate, check_item_selected, Receiver
+from openlp.core.lib import MediaManagerItem, build_icon, ItemCapabilities, \
+ SettingsManager, translate, check_item_selected, Receiver
from openlp.core.lib.ui import UiStrings, critical_error_message_box
log = logging.getLogger(__name__)
-class MediaListView(BaseListWithDnD):
- def __init__(self, parent=None):
- self.PluginName = u'Media'
- BaseListWithDnD.__init__(self, parent)
-
-
class MediaMediaItem(MediaManagerItem):
"""
This is the custom media manager item for Media Slides.
@@ -50,9 +44,6 @@
def __init__(self, parent, plugin, icon):
self.IconPath = u'images/image'
self.background = False
- # this next is a class, not an instance of a class - it will
- # be instanced by the base MediaManagerItem
- self.ListViewWithDnD_class = MediaListView
self.PreviewFunction = QtGui.QPixmap(
u':/media/media_video.png').toImage()
MediaManagerItem.__init__(self, parent, self, icon)
=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py 2011-02-10 04:19:38 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py 2011-02-10 19:44:14 +0000
@@ -179,9 +179,8 @@
desktop = self.get_com_desktop()
except:
log.exception(u'Failed to find an OpenOffice desktop to terminate')
- finally:
- if not desktop:
- return
+ if not desktop:
+ return
docs = desktop.getComponents()
if docs.hasElements():
log.debug(u'OpenOffice not terminated as docs are still open')
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2011-02-07 19:37:07 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2011-02-10 19:44:14 +0000
@@ -29,24 +29,13 @@
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
- SettingsManager, translate, check_item_selected, Receiver, ItemCapabilities
+from openlp.core.lib import MediaManagerItem, build_icon, SettingsManager, \
+ translate, check_item_selected, Receiver, ItemCapabilities
from openlp.core.lib.ui import critical_error_message_box, media_item_combo_box
from openlp.plugins.presentations.lib import MessageListener
log = logging.getLogger(__name__)
-class PresentationListView(BaseListWithDnD):
- """
- Class for the list of Presentations
-
- We have to explicitly create separate classes for each plugin
- in order for DnD to the Service manager to work correctly.
- """
- def __init__(self, parent=None):
- self.PluginName = u'Presentations'
- BaseListWithDnD.__init__(self, parent)
-
class PresentationMediaItem(MediaManagerItem):
"""
This is the Presentation media manager item for Presentation Items.
@@ -61,9 +50,6 @@
self.controllers = controllers
self.IconPath = u'presentations/presentation'
self.Automatic = u''
- # this next is a class, not an instance of a class - it will
- # be instanced by the base MediaManagerItem
- self.ListViewWithDnD_class = PresentationListView
MediaManagerItem.__init__(self, parent, self, icon)
self.message_listener = MessageListener(self)
QtCore.QObject.connect(Receiver.get_receiver(),
=== modified file 'openlp/plugins/songs/forms/songexportform.py'
--- openlp/plugins/songs/forms/songexportform.py 2011-02-09 20:11:23 +0000
+++ openlp/plugins/songs/forms/songexportform.py 2011-02-10 19:44:14 +0000
@@ -87,7 +87,8 @@
Song wizard specific signals.
"""
QtCore.QObject.connect(self.availableListWidget,
- QtCore.SIGNAL(u'itemActivated(QListWidgetItem*)'), self.onItemPressed)
+ QtCore.SIGNAL(u'itemActivated(QListWidgetItem*)'),
+ self.onItemPressed)
QtCore.QObject.connect(self.searchLineEdit,
QtCore.SIGNAL(u'textEdited(const QString&)'),
self.onSearchLineEditChanged)
@@ -241,12 +242,6 @@
self.selectedListWidget.clear()
return True
- def registerFields(self):
- """
- Register song export wizard fields.
- """
- pass
-
def setDefaults(self):
"""
Set default form values for the song export wizard.
=== modified file 'openlp/plugins/songs/forms/songimportform.py'
--- openlp/plugins/songs/forms/songimportform.py 2011-02-10 00:36:00 +0000
+++ openlp/plugins/songs/forms/songimportform.py 2011-02-10 19:44:14 +0000
@@ -442,33 +442,6 @@
elif self.currentPage() == self.progressPage:
return True
- def getFileName(self, title, editbox, filters=u''):
- """
- Opens a QFileDialog and writes the filename to the given editbox.
-
- ``title``
- The title of the dialog (unicode).
-
- ``editbox``
- A editbox (QLineEdit).
-
- ``filters``
- The file extension filters. It should contain the file descriptions
- as well as the file extensions. For example::
-
- u'OpenLP 2.0 Databases (*.sqlite)'
- """
- if filters:
- filters += u';;'
- filters += u'%s (*)' % UiStrings.AllFiles
- filename = QtGui.QFileDialog.getOpenFileName(self, title,
- SettingsManager.get_last_dir(self.plugin.settingsSection, 1),
- filters)
- if filename:
- editbox.setText(filename)
- SettingsManager.set_last_dir(self.plugin.settingsSection,
- os.path.split(unicode(filename))[0], 1)
-
def getFiles(self, title, listbox, filters=u''):
"""
Opens a QFileDialog and writes the filenames to the given listbox.
@@ -671,12 +644,6 @@
"""
self.removeSelectedItems(self.songBeamerFileListWidget)
- def registerFields(self):
- """
- Register song import wizard fields.
- """
- pass
-
def setDefaults(self):
"""
Set default form values for the song import wizard.
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2011-02-09 15:00:04 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2011-02-10 19:44:14 +0000
@@ -31,8 +31,8 @@
from PyQt4 import QtCore, QtGui
from sqlalchemy.sql import or_
-from openlp.core.lib import MediaManagerItem, BaseListWithDnD, Receiver, \
- ItemCapabilities, translate, check_item_selected, PluginStatus
+from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \
+ translate, check_item_selected, PluginStatus
from openlp.core.lib.ui import UiStrings
from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm, \
SongImportForm, SongExportForm
@@ -42,12 +42,6 @@
log = logging.getLogger(__name__)
-class SongListView(BaseListWithDnD):
- def __init__(self, parent=None):
- self.PluginName = u'Songs'
- BaseListWithDnD.__init__(self, parent)
-
-
class SongMediaItem(MediaManagerItem):
"""
This is the custom media manager item for Songs.
@@ -56,7 +50,6 @@
def __init__(self, parent, plugin, icon):
self.IconPath = u'songs/song'
- self.ListViewWithDnD_class = SongListView
MediaManagerItem.__init__(self, parent, self, icon)
self.edit_song_form = EditSongForm(self, self.parent.manager)
self.openLyrics = OpenLyrics(self.parent.manager)
Follow ups