forked from openlp/openlp
tweaked 'Reorder Service Item' dialog
This commit is contained in:
parent
166867544e
commit
88166c22a6
@ -25,6 +25,7 @@
|
|||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
from serviceitemeditdialog import Ui_ServiceItemEditDialog
|
from serviceitemeditdialog import Ui_ServiceItemEditDialog
|
||||||
|
|
||||||
class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
||||||
@ -39,16 +40,18 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
|||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.itemList = []
|
self.itemList = []
|
||||||
# enable drop
|
# enable drop
|
||||||
QtCore.QObject.connect(self.upButton, QtCore.SIGNAL(u'clicked()'),
|
QtCore.QObject.connect(self.upButton,
|
||||||
self.onItemUp)
|
QtCore.SIGNAL(u'clicked()'), self.onItemUp)
|
||||||
QtCore.QObject.connect(self.downButton, QtCore.SIGNAL(u'clicked()'),
|
QtCore.QObject.connect(self.downButton,
|
||||||
self.onItemDown)
|
QtCore.SIGNAL(u'clicked()'), self.onItemDown)
|
||||||
QtCore.QObject.connect(self.deleteButton, QtCore.SIGNAL(u'clicked()'),
|
QtCore.QObject.connect(self.deleteButton,
|
||||||
self.onItemDelete)
|
QtCore.SIGNAL(u'clicked()'), self.onItemDelete)
|
||||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'),
|
QtCore.QObject.connect(self.buttonBox,
|
||||||
self.accept)
|
QtCore.SIGNAL(u'accepted()'), self.accept)
|
||||||
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'),
|
QtCore.QObject.connect(self.buttonBox,
|
||||||
self.reject)
|
QtCore.SIGNAL(u'rejected()'), self.reject)
|
||||||
|
QtCore.QObject.connect(self.listWidget,
|
||||||
|
QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
|
||||||
|
|
||||||
def setServiceItem(self, item):
|
def setServiceItem(self, item):
|
||||||
self.item = item
|
self.item = item
|
||||||
@ -58,6 +61,7 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
|||||||
for frame in self.item._raw_frames:
|
for frame in self.item._raw_frames:
|
||||||
self.itemList.append(frame)
|
self.itemList.append(frame)
|
||||||
self.loadData()
|
self.loadData()
|
||||||
|
self.listWidget.setCurrentItem(self.listWidget.currentItem())
|
||||||
|
|
||||||
def getServiceItem(self):
|
def getServiceItem(self):
|
||||||
if self.data:
|
if self.data:
|
||||||
@ -69,25 +73,21 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
|||||||
return self.item
|
return self.item
|
||||||
|
|
||||||
def loadData(self):
|
def loadData(self):
|
||||||
|
"""
|
||||||
|
Loads the image list.
|
||||||
|
"""
|
||||||
self.listWidget.clear()
|
self.listWidget.clear()
|
||||||
for frame in self.itemList:
|
for frame in self.itemList:
|
||||||
item_name = QtGui.QListWidgetItem(frame[u'title'])
|
item_name = QtGui.QListWidgetItem(frame[u'title'])
|
||||||
self.listWidget.addItem(item_name)
|
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):
|
def onItemDelete(self):
|
||||||
"""
|
"""
|
||||||
Delete the selected row
|
Delete the current row.
|
||||||
"""
|
"""
|
||||||
items = self.listWidget.selectedItems()
|
item = self.listWidget.currentItem()
|
||||||
for item in items:
|
if not item:
|
||||||
|
return
|
||||||
row = self.listWidget.row(item)
|
row = self.listWidget.row(item)
|
||||||
self.itemList.remove(self.itemList[row])
|
self.itemList.remove(self.itemList[row])
|
||||||
self.loadData()
|
self.loadData()
|
||||||
@ -98,12 +98,12 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
|||||||
|
|
||||||
def onItemUp(self):
|
def onItemUp(self):
|
||||||
"""
|
"""
|
||||||
Move the selected row up in the list
|
Move the current row up in the list.
|
||||||
"""
|
"""
|
||||||
items = self.listWidget.selectedItems()
|
item = self.listWidget.currentItem()
|
||||||
for item in items:
|
if not item:
|
||||||
|
return
|
||||||
row = self.listWidget.row(item)
|
row = self.listWidget.row(item)
|
||||||
if row > 0:
|
|
||||||
temp = self.itemList[row]
|
temp = self.itemList[row]
|
||||||
self.itemList.remove(self.itemList[row])
|
self.itemList.remove(self.itemList[row])
|
||||||
self.itemList.insert(row - 1, temp)
|
self.itemList.insert(row - 1, temp)
|
||||||
@ -112,14 +112,39 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog):
|
|||||||
|
|
||||||
def onItemDown(self):
|
def onItemDown(self):
|
||||||
"""
|
"""
|
||||||
Move the selected row down in the list
|
Move the current row down in the list
|
||||||
"""
|
"""
|
||||||
items = self.listWidget.selectedItems()
|
item = self.listWidget.currentItem()
|
||||||
for item in items:
|
if not item:
|
||||||
|
return
|
||||||
row = self.listWidget.row(item)
|
row = self.listWidget.row(item)
|
||||||
if row < len(self.itemList) and row is not -1:
|
|
||||||
temp = self.itemList[row]
|
temp = self.itemList[row]
|
||||||
self.itemList.remove(self.itemList[row])
|
self.itemList.remove(self.itemList[row])
|
||||||
self.itemList.insert(row + 1, temp)
|
self.itemList.insert(row + 1, temp)
|
||||||
self.loadData()
|
self.loadData()
|
||||||
self.listWidget.setCurrentRow(row + 1)
|
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