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