Added capability to edit title of service_item

This commit is contained in:
Dmitriy Marmyshev 2013-04-08 09:03:55 +04:00
parent 637cb09e74
commit eca016c21d
6 changed files with 15 additions and 10 deletions

View File

@ -114,6 +114,10 @@ class ItemCapabilities(object):
``CanAutoStartForLive``
The capability to ignore the do not play if display blank flag.
``CanEditTitle``
The capability to allow the ServiceManager to allow the title of the item to be
edited
"""
CanPreview = 1
CanEdit = 2
@ -131,6 +135,7 @@ class ItemCapabilities(object):
CanWordSplit = 14
HasBackgroundAudio = 15
CanAutoStartForLive = 16
CanEditTitle = 17
class ServiceItem(object):
@ -442,7 +447,7 @@ class ServiceItem(object):
"""
Returns the title of the service item.
"""
if self.is_text() or self.is_image():
if self.is_text() or ItemCapabilities.CanEditTitle in self.capabilities:
return self.title
else:
if ItemCapabilities.HasDetailedTitleDisplay in self.capabilities:

View File

@ -783,8 +783,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
self.auto_start_action.setVisible(False)
if service_item[u'service_item'].is_capable(ItemCapabilities.CanEdit) and service_item[u'service_item'].edit_id:
self.edit_action.setVisible(True)
if not service_item[u'service_item'].is_capable(ItemCapabilities.HasDetailedTitleDisplay)\
and not service_item[u'service_item'].is_capable(ItemCapabilities.CanEdit):
if service_item[u'service_item'].is_capable(ItemCapabilities.CanEditTitle):
self.rename_action.setVisible(True)
if service_item[u'service_item'].is_capable(ItemCapabilities.CanMaintain):
self.maintain_action.setVisible(True)
@ -1404,8 +1403,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
Opens a dialog to rename the service item.
"""
item = self.find_service_item()[0]
if ItemCapabilities.HasDetailedTitleDisplay in self.service_items[item][u'service_item'].capabilities\
or ItemCapabilities.CanEdit in self.service_items[item][u'service_item'].capabilities:
if not service_item[u'service_item'].is_capable(ItemCapabilities.CanEditTitle):
return
title = self.service_items[item][u'service_item'].title
title, ok = QtGui.QInputDialog.getText(self, self.tr(translate('OpenLP.ServiceManager', 'Input title')),

View File

@ -842,6 +842,7 @@ class BibleMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.CanPreview)
service_item.add_capability(ItemCapabilities.CanLoop)
service_item.add_capability(ItemCapabilities.CanWordSplit)
service_item.add_capability(ItemCapabilities.CanEditTitle)
# Service Item: Title
service_item.title = create_separated_list(raw_title)
# Service Item: Theme

View File

@ -553,6 +553,7 @@ class ImageMediaItem(MediaManagerItem):
service_item.add_capability(ItemCapabilities.CanPreview)
service_item.add_capability(ItemCapabilities.CanLoop)
service_item.add_capability(ItemCapabilities.CanAppend)
service_item.add_capability(ItemCapabilities.CanEditTitle)
# force a nonexistent theme
service_item.theme = -1
missing_items = []

View File

@ -181,9 +181,9 @@ class MediaMediaItem(MediaManagerItem):
translate('MediaPlugin.MediaItem', 'Missing Media File'),
translate('MediaPlugin.MediaItem', 'The file %s no longer exists.') % filename)
return False
service_item.title = self.displayTypeComboBox.currentText()
service_item.shortname = service_item.title
service_item.shortname = self.displayTypeComboBox.currentText()
(path, name) = os.path.split(filename)
service_item.title = name
service_item.add_from_command(path, name, CLAPPERBOARD)
# Only get start and end times if going to a service
if context == ServiceItemContext.Service:
@ -192,7 +192,7 @@ class MediaMediaItem(MediaManagerItem):
return False
service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
service_item.add_capability(ItemCapabilities.RequiresMedia)
service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay)
service_item.add_capability(ItemCapabilities.CanEditTitle)
if Settings().value(self.settings_section + u'/media auto start') == QtCore.Qt.Checked:
service_item.will_auto_start = True
# force a non-existent theme

View File

@ -244,10 +244,9 @@ class PresentationMediaItem(MediaManagerItem):
items = self.list_view.selectedItems()
if len(items) > 1:
return False
service_item.title = self.displayTypeComboBox.currentText()
service_item.shortname = self.displayTypeComboBox.currentText()
service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
service_item.add_capability(ItemCapabilities.HasDetailedTitleDisplay)
service_item.add_capability(ItemCapabilities.CanEditTitle)
shortname = service_item.shortname
if not shortname:
return False
@ -260,6 +259,7 @@ class PresentationMediaItem(MediaManagerItem):
return False
controller = self.controllers[service_item.shortname]
(path, name) = os.path.split(filename)
service_item.title = name
doc = controller.add_document(filename)
if doc.get_thumbnail_path(1, True) is None:
doc.load_presentation()