forked from openlp/openlp
Fixes to Service Item Order screen
bzr-revno: 1225
This commit is contained in:
commit
39c6f498b5
@ -25,6 +25,7 @@
|
||||
###############################################################################
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
from serviceitemeditdialog import Ui_ServiceItemEditDialog
|
||||
|
||||
class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||
@ -39,16 +40,18 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||
self.setupUi(self)
|
||||
self.itemList = []
|
||||
# enable drop
|
||||
QtCore.QObject.connect(self.upButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onItemUp)
|
||||
QtCore.QObject.connect(self.downButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onItemDown)
|
||||
QtCore.QObject.connect(self.deleteButton, QtCore.SIGNAL(u'clicked()'),
|
||||
self.onItemDelete)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
|
||||
self.accept)
|
||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
|
||||
self.reject)
|
||||
QtCore.QObject.connect(self.upButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onItemUp)
|
||||
QtCore.QObject.connect(self.downButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onItemDown)
|
||||
QtCore.QObject.connect(self.deleteButton,
|
||||
QtCore.SIGNAL(u'clicked()'), self.onItemDelete)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'accepted()'), self.accept)
|
||||
QtCore.QObject.connect(self.buttonBox,
|
||||
QtCore.SIGNAL(u'rejected()'), self.reject)
|
||||
QtCore.QObject.connect(self.listWidget,
|
||||
QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
|
||||
|
||||
def setServiceItem(self, item):
|
||||
self.item = item
|
||||
@ -58,6 +61,7 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||
for frame in self.item._raw_frames:
|
||||
self.itemList.append(frame)
|
||||
self.loadData()
|
||||
self.listWidget.setCurrentItem(self.listWidget.currentItem())
|
||||
|
||||
def getServiceItem(self):
|
||||
if self.data:
|
||||
@ -69,25 +73,21 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||
return self.item
|
||||
|
||||
def loadData(self):
|
||||
"""
|
||||
Loads the image list.
|
||||
"""
|
||||
self.listWidget.clear()
|
||||
for frame in self.itemList:
|
||||
item_name = QtGui.QListWidgetItem(frame[u'title'])
|
||||
self.listWidget.addItem(item_name)
|
||||
if self.listWidget.count() == 1:
|
||||
self.downButton.setEnabled(False)
|
||||
self.upButton.setEnabled(False)
|
||||
self.deleteButton.setEnabled(False)
|
||||
else:
|
||||
self.downButton.setEnabled(True)
|
||||
self.upButton.setEnabled(True)
|
||||
self.deleteButton.setEnabled(True)
|
||||
|
||||
def onItemDelete(self):
|
||||
"""
|
||||
Delete the selected row
|
||||
Delete the current row.
|
||||
"""
|
||||
items = self.listWidget.selectedItems()
|
||||
for item in items:
|
||||
item = self.listWidget.currentItem()
|
||||
if not item:
|
||||
return
|
||||
row = self.listWidget.row(item)
|
||||
self.itemList.remove(self.itemList[row])
|
||||
self.loadData()
|
||||
@ -98,12 +98,12 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||
|
||||
def onItemUp(self):
|
||||
"""
|
||||
Move the selected row up in the list
|
||||
Move the current row up in the list.
|
||||
"""
|
||||
items = self.listWidget.selectedItems()
|
||||
for item in items:
|
||||
item = self.listWidget.currentItem()
|
||||
if not item:
|
||||
return
|
||||
row = self.listWidget.row(item)
|
||||
if row > 0:
|
||||
temp = self.itemList[row]
|
||||
self.itemList.remove(self.itemList[row])
|
||||
self.itemList.insert(row - 1, temp)
|
||||
@ -112,14 +112,40 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||
|
||||
def onItemDown(self):
|
||||
"""
|
||||
Move the selected row down in the list
|
||||
Move the current row down in the list
|
||||
"""
|
||||
items = self.listWidget.selectedItems()
|
||||
for item in items:
|
||||
item = self.listWidget.currentItem()
|
||||
if not item:
|
||||
return
|
||||
row = self.listWidget.row(item)
|
||||
if row < len(self.itemList) and row is not -1:
|
||||
temp = self.itemList[row]
|
||||
self.itemList.remove(self.itemList[row])
|
||||
self.itemList.insert(row + 1, temp)
|
||||
self.loadData()
|
||||
self.listWidget.setCurrentRow(row + 1)
|
||||
|
||||
def onCurrentRowChanged(self, row):
|
||||
"""
|
||||
Called when the currentRow has changed.
|
||||
|
||||
``row``
|
||||
The row number (int).
|
||||
"""
|
||||
# Disable all buttons, as no row is selected or only one image is left.
|
||||
if row == -1 or self.listWidget.count() == 1:
|
||||
self.downButton.setEnabled(False)
|
||||
self.upButton.setEnabled(False)
|
||||
self.deleteButton.setEnabled(False)
|
||||
else:
|
||||
# Check if we are at the end of the list.
|
||||
if self.listWidget.count() == row + 1:
|
||||
self.downButton.setEnabled(False)
|
||||
else:
|
||||
self.downButton.setEnabled(True)
|
||||
# Check if we are at the beginning of the list.
|
||||
if row == 0:
|
||||
self.upButton.setEnabled(False)
|
||||
else:
|
||||
self.upButton.setEnabled(True)
|
||||
self.deleteButton.setEnabled(True)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user