forked from openlp/openlp
Edit Cancel updating song by accident
This commit is contained in:
parent
d4668e2ba3
commit
18760262ab
@ -316,13 +316,13 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
|
||||
def onVerseAddButtonClicked(self):
|
||||
self.verse_form.setVerse(u'', self.VerseListWidget.count() + 1, True)
|
||||
self.verse_form.exec_()
|
||||
afterText, verse, subVerse = self.verse_form.getVerse()
|
||||
data = u'%s:%s' %(verse, subVerse)
|
||||
item = QtGui.QListWidgetItem(afterText)
|
||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
|
||||
item.setText(afterText)
|
||||
self.VerseListWidget.addItem(item)
|
||||
if self.verse_form.exec_():
|
||||
afterText, verse, subVerse = self.verse_form.getVerse()
|
||||
data = u'%s:%s' %(verse, subVerse)
|
||||
item = QtGui.QListWidgetItem(afterText)
|
||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
|
||||
item.setText(afterText)
|
||||
self.VerseListWidget.addItem(item)
|
||||
|
||||
def onVerseEditButtonClicked(self):
|
||||
item = self.VerseListWidget.currentItem()
|
||||
@ -331,25 +331,25 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
verseId = unicode((item.data(QtCore.Qt.UserRole)).toString())
|
||||
self.verse_form.setVerse(tempText, \
|
||||
self.VerseListWidget.count(), True, verseId)
|
||||
self.verse_form.exec_()
|
||||
afterText, verse, subVerse = self.verse_form.getVerse()
|
||||
data = u'%s:%s' %(verse, subVerse)
|
||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
|
||||
item.setText(afterText)
|
||||
#number of lines has change so repaint the list moving the data
|
||||
if len(tempText.split(u'\n')) != len(afterText.split(u'\n')):
|
||||
tempList = {}
|
||||
tempId = {}
|
||||
for row in range(0, self.VerseListWidget.count()):
|
||||
tempList[row] = self.VerseListWidget.item(row).text()
|
||||
tempId[row] = self.VerseListWidget.item(row).\
|
||||
data(QtCore.Qt.UserRole)
|
||||
self.VerseListWidget.clear()
|
||||
for row in range (0, len(tempList)):
|
||||
item = QtGui.QListWidgetItem(tempList[row])
|
||||
item.setData(QtCore.Qt.UserRole, tempId[row])
|
||||
self.VerseListWidget.addItem(item)
|
||||
self.VerseListWidget.repaint()
|
||||
if self.verse_form.exec_():
|
||||
afterText, verse, subVerse = self.verse_form.getVerse()
|
||||
data = u'%s:%s' %(verse, subVerse)
|
||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
|
||||
item.setText(afterText)
|
||||
#number of lines has change so repaint the list moving the data
|
||||
if len(tempText.split(u'\n')) != len(afterText.split(u'\n')):
|
||||
tempList = {}
|
||||
tempId = {}
|
||||
for row in range(0, self.VerseListWidget.count()):
|
||||
tempList[row] = self.VerseListWidget.item(row).text()
|
||||
tempId[row] = self.VerseListWidget.item(row).\
|
||||
data(QtCore.Qt.UserRole)
|
||||
self.VerseListWidget.clear()
|
||||
for row in range (0, len(tempList)):
|
||||
item = QtGui.QListWidgetItem(tempList[row])
|
||||
item.setData(QtCore.Qt.UserRole, tempId[row])
|
||||
self.VerseListWidget.addItem(item)
|
||||
self.VerseListWidget.repaint()
|
||||
self.VerseEditButton.setEnabled(False)
|
||||
self.VerseDeleteButton.setEnabled(False)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user