Fix DND for service items

This commit is contained in:
Tim Bentley 2010-03-14 07:56:39 +00:00
parent 3b59525e98
commit df8ffa53b2

View File

@ -100,6 +100,7 @@ class ServiceManager(QtGui.QWidget):
self.parent = parent
self.serviceItems = []
self.serviceName = u''
self.droppos = 0
#is a new service and has not been saved
self.isNew = True
#Indicates if remoteTriggering is active. If it is the next addServiceItem call
@ -639,19 +640,21 @@ class ServiceManager(QtGui.QWidget):
self.repaintServiceList(sitem + 1, 0)
self.parent.LiveController.replaceServiceManagerItem(item)
else:
if sitem == -1:
#nothing selected or dnd
if self.droppos == 0:
self.serviceItems.append({u'service_item': item,
u'order': len(self.serviceItems) + 1,
u'expanded':expand})
self.repaintServiceList(len(self.serviceItems) + 1, 0)
else:
self.serviceItems.insert(sitem + 1, {u'service_item': item,
u'order': len(self.serviceItems)+1,
self.serviceItems.insert(self.droppos, {u'service_item': item,
u'order': self.droppos,
u'expanded':expand})
self.repaintServiceList(sitem + 1, 0)
self.repaintServiceList(self.droppos, 0)
#if rebuilding list make sure live is fixed.
if rebuild:
self.parent.LiveController.replaceServiceManagerItem(item)
self.droppos = 0
self.parent.serviceChanged(False, self.serviceName)
def makePreview(self):
@ -732,9 +735,9 @@ class ServiceManager(QtGui.QWidget):
link = event.mimeData()
if link.hasText():
plugin = event.mimeData().text()
item = self.ServiceManagerList.itemAt(event.pos())
if plugin == u'ServiceManager':
startpos, startCount = self.findServiceItem()
item = self.ServiceManagerList.itemAt(event.pos())
if item is None:
endpos = len(self.serviceItems)
else:
@ -753,6 +756,14 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems.insert(newpos, serviceItem)
self.repaintServiceList(endpos, startCount)
else:
if item == None:
self.droppos = len(self.serviceItems)
else:
parentitem = item.parent()
if parentitem is None:
self.droppos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
else:
self.droppos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
Receiver.send_message(u'%s_add_service_item' % plugin)
def updateThemeList(self, theme_list):