forked from openlp/openlp
Refactor and rename listviews for DnD
Wizard refactors Cleanups bzr-revno: 1290
This commit is contained in:
commit
695cf68bf2
@ -6,18 +6,18 @@ Object Library
|
||||
.. 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`
|
||||
-----------------------
|
||||
|
||||
|
@ -319,6 +319,7 @@ def check_directory_exists(dir):
|
||||
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 dockwidget import OpenLPDockWidget
|
||||
from renderer import Renderer
|
||||
from rendermanager import RenderManager
|
||||
from mediamanageritem import MediaManagerItem
|
||||
from baselistwithdnd import BaseListWithDnD
|
||||
|
@ -28,17 +28,17 @@ Extend QListWidget to handle drag and drop functionality
|
||||
"""
|
||||
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 @@ class BaseListWithDnD(QtGui.QListWidget):
|
||||
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)
|
||||
mimeData.setText(self.mimeDataText)
|
||||
drag.start(QtCore.Qt.CopyAction)
|
@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
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 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
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 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
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(
|
||||
|
@ -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
|
||||
|
||||
|
@ -216,8 +216,8 @@ class Ui_MainWindow(object):
|
||||
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')
|
||||
|
@ -70,6 +70,12 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
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 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
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)
|
||||
|
@ -727,33 +727,6 @@ class BibleImportForm(OpenLPWizard):
|
||||
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.
|
||||
|
@ -28,8 +28,8 @@ import logging
|
||||
|
||||
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 @@ from openlp.plugins.bibles.lib import get_reference_match
|
||||
|
||||
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 @@ class BibleMediaItem(MediaManagerItem):
|
||||
|
||||
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 = {}
|
||||
|
@ -28,18 +28,13 @@ import logging
|
||||
|
||||
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 @@ class CustomMediaItem(MediaManagerItem):
|
||||
|
||||
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
|
||||
|
@ -29,21 +29,14 @@ import os
|
||||
|
||||
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 @@ class ImageMediaItem(MediaManagerItem):
|
||||
|
||||
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)
|
||||
|
@ -29,18 +29,12 @@ import os
|
||||
|
||||
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 @@ class MediaMediaItem(MediaManagerItem):
|
||||
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)
|
||||
|
@ -179,9 +179,8 @@ class ImpressController(PresentationController):
|
||||
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')
|
||||
|
@ -29,24 +29,13 @@ import os
|
||||
|
||||
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 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
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(),
|
||||
|
@ -87,7 +87,8 @@ class SongExportForm(OpenLPWizard):
|
||||
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 @@ class SongExportForm(OpenLPWizard):
|
||||
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.
|
||||
|
@ -442,33 +442,6 @@ class SongImportForm(OpenLPWizard):
|
||||
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 @@ class SongImportForm(OpenLPWizard):
|
||||
"""
|
||||
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.
|
||||
|
@ -31,8 +31,8 @@ import re
|
||||
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 @@ from openlp.core.lib.searchedit import SearchEdit
|
||||
|
||||
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 @@ class SongMediaItem(MediaManagerItem):
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user