forked from openlp/openlp
Add multiple songs to service manager
This commit is contained in:
parent
1cb25db4e9
commit
b17b83bb27
@ -114,6 +114,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.Toolbar = None
|
||||
self.remoteTriggered = None
|
||||
self.ServiceItemIconName = None
|
||||
self.single_service_item = True
|
||||
self.addToServiceItem = False
|
||||
self.PageLayout = QtGui.QVBoxLayout(self)
|
||||
self.PageLayout.setSpacing(0)
|
||||
@ -401,11 +402,19 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.trUtf8('No Items Selected'),
|
||||
self.trUtf8('You must select one or more items.'))
|
||||
else:
|
||||
if self.single_service_item:
|
||||
log.debug(self.PluginNameShort + u' Add requested')
|
||||
service_item = self.buildServiceItem()
|
||||
if service_item:
|
||||
service_item.from_plugin = False
|
||||
self.parent.service_manager.addServiceItem(service_item)
|
||||
else:
|
||||
items = self.ListView.selectedIndexes()
|
||||
for item in items:
|
||||
service_item = self.buildServiceItem(item)
|
||||
if service_item:
|
||||
service_item.from_plugin = False
|
||||
self.parent.service_manager.addServiceItem(service_item)
|
||||
|
||||
def onAddEditClick(self):
|
||||
if not self.ListView.selectedIndexes() and not self.remoteTriggered:
|
||||
@ -429,7 +438,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
self.trUtf8('Invalid Service Item'),
|
||||
self.trUtf8(unicode('You must select a %s service item.' % self.title)))
|
||||
|
||||
def buildServiceItem(self):
|
||||
def buildServiceItem(self, item=0):
|
||||
"""
|
||||
Common method for generating a service item
|
||||
"""
|
||||
@ -439,7 +448,7 @@ class MediaManagerItem(QtGui.QWidget):
|
||||
else:
|
||||
service_item.addIcon(
|
||||
u':/media/media_' + self.PluginNameShort.lower() + u'.png')
|
||||
if self.generateSlideData(service_item):
|
||||
if self.generateSlideData(service_item, item):
|
||||
return service_item
|
||||
else:
|
||||
return None
|
||||
|
@ -714,7 +714,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
get_config(u'auto preview', u'False')):
|
||||
item += 1
|
||||
if self.serviceItems and item < len(self.serviceItems) and \
|
||||
serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsPreview):
|
||||
self.serviceItems[item][u'service_item'].is_capable(ItemCapabilities.AllowsPreview):
|
||||
self.parent.PreviewController.addServiceManagerItem(
|
||||
self.serviceItems[item][u'service_item'], 0)
|
||||
|
||||
|
@ -440,7 +440,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
if self.search_results:
|
||||
self.displayResults(bible)
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
def generateSlideData(self, service_item, item_id=0):
|
||||
log.debug(u'generating slide data')
|
||||
items = self.ListView.selectedIndexes()
|
||||
if len(items) == 0:
|
||||
|
@ -49,8 +49,9 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.ConfigSection = title
|
||||
self.IconPath = u'songs/song'
|
||||
self.ListViewWithDnD_class = SongListView
|
||||
self.servicePath = None
|
||||
#self.servicePath = None
|
||||
MediaManagerItem.__init__(self, parent, icon, title)
|
||||
self.single_service_item = False
|
||||
self.edit_song_form = EditSongForm(self.parent.songmanager, self)
|
||||
self.song_maintenance_form = SongMaintenanceForm(
|
||||
self.parent.songmanager, self)
|
||||
@ -276,7 +277,7 @@ class SongMediaItem(MediaManagerItem):
|
||||
if len(items) == 1:
|
||||
del_message = self.trUtf8('Delete song?')
|
||||
else:
|
||||
del_message = unicode(self.trUtf8('Delete %d song?')) % len(items)
|
||||
del_message = unicode(self.trUtf8('Delete %d songs?')) % len(items)
|
||||
ans = QtGui.QMessageBox.question(self,
|
||||
self.trUtf8('Delete Confirmation'), del_message,
|
||||
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok|
|
||||
@ -289,11 +290,13 @@ class SongMediaItem(MediaManagerItem):
|
||||
self.parent.songmanager.delete_song(item_id)
|
||||
self.onSearchTextButtonClick()
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
def generateSlideData(self, service_item, item=0):
|
||||
raw_footer = []
|
||||
author_list = u''
|
||||
author_audit = []
|
||||
ccli = u''
|
||||
#Part of a loop so do not work out
|
||||
if item == 0:
|
||||
if self.remoteTriggered is None:
|
||||
item = self.ListView.currentItem()
|
||||
if item is None:
|
||||
@ -301,6 +304,8 @@ class SongMediaItem(MediaManagerItem):
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
else:
|
||||
item_id = self.remoteSong
|
||||
else:
|
||||
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
|
||||
service_item.add_capability(ItemCapabilities.AllowsEdit)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
song = self.parent.songmanager.get_song(item_id)
|
||||
|
Loading…
Reference in New Issue
Block a user