forked from openlp/openlp
Fix up drag and Drop for service items
This commit is contained in:
parent
13922b0599
commit
4ffb7d8a18
@ -215,12 +215,15 @@ class Plugin(QtCore.QObject):
|
||||
"""
|
||||
pass
|
||||
|
||||
def process_add_service_event(self):
|
||||
def process_add_service_event(self, replace=False):
|
||||
"""
|
||||
Generic Drag and drop handler triggered from service_manager.
|
||||
"""
|
||||
log.debug(u'process_add_service_event event called for plugin %s' %
|
||||
self.name)
|
||||
if replace:
|
||||
self.media_item.onAddEditClick()
|
||||
else:
|
||||
self.media_item.onAddClick()
|
||||
|
||||
def about(self):
|
||||
|
@ -48,6 +48,7 @@ class ItemCapabilities(object):
|
||||
AllowsMaintain = 3
|
||||
RequiresMedia = 4
|
||||
AllowsLoop = 5
|
||||
AllowsAdditions = 6
|
||||
|
||||
class ServiceItem(object):
|
||||
"""
|
||||
|
@ -194,12 +194,18 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.parent.serviceSettingsSection + u'/service theme',
|
||||
QtCore.QVariant(u'')).toString())
|
||||
self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
|
||||
#build the drag and drop context menu
|
||||
self.dndMenu = QtGui.QMenu()
|
||||
self.newAction = self.dndMenu.addAction(self.trUtf8('&Add New Item'))
|
||||
self.newAction.setIcon(build_icon(u':/general/general_edit.png'))
|
||||
self.addToAction = self.dndMenu.addAction(self.trUtf8('&Add to Selected Item'))
|
||||
self.addToAction.setIcon(build_icon(u':/general/general_edit.png'))
|
||||
#build the context menu
|
||||
self.menu = QtGui.QMenu()
|
||||
self.editAction = self.menu.addAction(self.trUtf8('&Edit Item'))
|
||||
self.editAction.setIcon(build_icon(u':/general/general_edit.png'))
|
||||
self.maintainAction = self.menu.addAction(self.trUtf8('&Maintain Item'))
|
||||
self.editAction.setIcon(build_icon(u':/general/general_edit.png'))
|
||||
self.maintainAction.setIcon(build_icon(u':/general/general_edit.png'))
|
||||
self.notesAction = self.menu.addAction(self.trUtf8('&Notes'))
|
||||
self.notesAction.setIcon(build_icon(u':/services/service_notes.png'))
|
||||
self.deleteAction = self.menu.addAction(
|
||||
@ -795,6 +801,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
if link.hasText():
|
||||
plugin = event.mimeData().text()
|
||||
item = self.ServiceManagerList.itemAt(event.pos())
|
||||
#ServiceManager started the drag and drop
|
||||
if plugin == u'ServiceManager':
|
||||
startpos, startCount = self.findServiceItem()
|
||||
if item is None:
|
||||
@ -810,11 +817,28 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.serviceItems.insert(newpos, serviceItem)
|
||||
self.repaintServiceList(endpos, startCount)
|
||||
else:
|
||||
#we are not over anything so drop
|
||||
replace = False
|
||||
if item == None:
|
||||
self.droppos = len(self.serviceItems)
|
||||
else:
|
||||
#we are over somthing so lets investigate
|
||||
pos = self._getParentItemData(item) - 1
|
||||
serviceItem = self.serviceItems[pos]
|
||||
if plugin == serviceItem[u'service_item'].name \
|
||||
and serviceItem[u'service_item'].is_capable(ItemCapabilities.AllowsAdditions):
|
||||
action = self.dndMenu.exec_(QtGui.QCursor.pos())
|
||||
#New action required
|
||||
if action == self.newAction:
|
||||
self.droppos = self._getParentItemData(item)
|
||||
Receiver.send_message(u'%s_add_service_item' % plugin)
|
||||
#Append to existing action
|
||||
if action == self.addToAction:
|
||||
self.droppos = self._getParentItemData(item)
|
||||
item.setSelected(True)
|
||||
replace = True
|
||||
else:
|
||||
self.droppos = self._getParentItemData(item)
|
||||
Receiver.send_message(u'%s_add_service_item' % plugin, replace)
|
||||
|
||||
def updateThemeList(self, theme_list):
|
||||
"""
|
||||
|
@ -449,6 +449,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
bible_text = u''
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
service_item.add_capability(ItemCapabilities.AllowsAdditions)
|
||||
#If we want to use a 2nd translation / version
|
||||
bible2 = u''
|
||||
if self.SearchTabWidget.currentIndex() == 0:
|
||||
|
@ -147,6 +147,7 @@ class ImageMediaItem(MediaManagerItem):
|
||||
service_item.add_capability(ItemCapabilities.AllowsMaintain)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
service_item.add_capability(ItemCapabilities.AllowsAdditions)
|
||||
for item in items:
|
||||
bitem = self.ListView.item(item.row())
|
||||
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
||||
|
@ -187,6 +187,7 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
service_item.title = unicode(self.DisplayTypeComboBox.currentText())
|
||||
service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
|
||||
shortname = service_item.shortname
|
||||
if shortname:
|
||||
for item in items:
|
||||
bitem = self.ListView.item(item.row())
|
||||
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
||||
@ -207,6 +208,8 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
img = doc.get_slide_preview_file(i)
|
||||
doc.close_presentation()
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def findControllerByType(self, filename):
|
||||
filetype = os.path.splitext(filename)[1]
|
||||
|
Loading…
Reference in New Issue
Block a user