openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #14531
[Merge] lp:~raoul-snyman/openlp/bug-716405 into lp:openlp
Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/bug-716405 into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Jonathan Corwin (j-corwin)
Related bugs:
Bug #716405 in OpenLP: "RFE using verses and the warning dialog they are not used."
https://bugs.launchpad.net/openlp/+bug/716405
For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/bug-716405/+merge/96939
Added a label on the edit dialog to show when you have an incomplete verse order.
--
https://code.launchpad.net/~raoul-snyman/openlp/bug-716405/+merge/96939
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file '.bzrignore'
--- .bzrignore 2011-07-23 22:39:37 +0000
+++ .bzrignore 2012-03-11 21:46:28 +0000
@@ -21,3 +21,4 @@
*.qm
resources/windows/warnOpenLP.txt
openlp.cfg
+.idea
=== modified file 'openlp/plugins/songs/forms/editsongdialog.py'
--- openlp/plugins/songs/forms/editsongdialog.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/songs/forms/editsongdialog.py 2012-03-11 21:46:28 +0000
@@ -280,8 +280,15 @@
self.songTabWidget.addTab(self.audioTab, u'')
# Last few bits
self.dialogLayout.addWidget(self.songTabWidget)
+ self.bottomLayout = QtGui.QHBoxLayout()
+ self.bottomLayout.setObjectName(u'bottomLayout')
+ self.warningLabel = QtGui.QLabel(editSongDialog)
+ self.warningLabel.setObjectName(u'warningLabel')
+ self.warningLabel.setVisible(False)
+ self.bottomLayout.addWidget(self.warningLabel)
self.buttonBox = create_accept_reject_button_box(editSongDialog)
- self.dialogLayout.addWidget(self.buttonBox)
+ self.bottomLayout.addWidget(self.buttonBox)
+ self.dialogLayout.addLayout(self.bottomLayout)
self.retranslateUi(editSongDialog)
QtCore.QMetaObject.connectSlotsByName(editSongDialog)
@@ -349,14 +356,19 @@
translate('SongsPlugin.EditSongForm', '&Remove'))
self.audioRemoveAllButton.setText(
translate('SongsPlugin.EditSongForm', 'Remove &All'))
+ self.warningLabel.setText(
+ translate('SongsPlugin.EditSongForm', '<strong>Warning:</strong>'
+ ' Not all of the verses are in use.'))
def editSongDialogComboBox(parent, name):
"""
Utility method to generate a standard combo box for this dialog.
"""
comboBox = QtGui.QComboBox(parent)
- comboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
- comboBox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
+ comboBox.setSizeAdjustPolicy(
+ QtGui.QComboBox.AdjustToMinimumContentsLength)
+ comboBox.setSizePolicy(
+ QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
comboBox.setEditable(True)
comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
comboBox.setObjectName(name)
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py 2012-02-16 20:36:35 +0000
+++ openlp/plugins/songs/forms/editsongform.py 2012-03-11 21:46:28 +0000
@@ -92,6 +92,9 @@
QtCore.QObject.connect(self.verseListWidget,
QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'),
self.onVerseListViewPressed)
+ QtCore.QObject.connect(self.verseOrderEdit,
+ QtCore.SIGNAL(u'textChanged(QString)'),
+ self.onVerseOrderTextChanged)
QtCore.QObject.connect(self.themeAddButton,
QtCore.SIGNAL(u'clicked()'),
self.mediaitem.plugin.renderer.themeManager.onAddTheme)
@@ -574,7 +577,76 @@
self.verseEditButton.setEnabled(False)
self.verseDeleteButton.setEnabled(False)
- def _validate_song(self):
+ def onVerseOrderTextChanged(self, text):
+ verses = []
+ verse_names = []
+ order = self.__extractVerseOrder(text)
+ for index in range(0, self.verseListWidget.rowCount()):
+ verse = self.verseListWidget.item(index, 0)
+ verse = unicode(verse.data(QtCore.Qt.UserRole).toString())
+ if verse not in verse_names:
+ verses.append(verse)
+ verse_names.append(u'%s%s' % (
+ VerseType.translated_tag(verse[0]), verse[1:]))
+ verses_not_used = []
+ for count, verse in enumerate(verses):
+ if not verse in order:
+ verses_not_used.append(verse)
+ self.warningLabel.setVisible(len(verses_not_used) > 0)
+
+ def __extractVerseOrder(self, verse_order):
+ order = []
+ order_names = unicode(verse_order).split()
+ for item in order_names:
+ if len(item) == 1:
+ verse_index = VerseType.from_translated_tag(item, None)
+ if verse_index is not None:
+ order.append(VerseType.Tags[verse_index] + u'1')
+ else:
+ # it matches no verses anyway
+ order.append(u'')
+ else:
+ verse_index = VerseType.from_translated_tag(item[0], None)
+ if verse_index is None:
+ # it matches no verses anyway
+ order.append(u'')
+ else:
+ verse_tag = VerseType.Tags[verse_index]
+ verse_num = item[1:].lower()
+ order.append(verse_tag + verse_num)
+ return order
+
+ def __validateVerseList(self, verse_order, verse_count):
+ verses = []
+ invalid_verses = []
+ verse_names = []
+ order_names = unicode(verse_order).split()
+ order = self.__extractVerseOrder(verse_order)
+ for index in range(0, verse_count):
+ verse = self.verseListWidget.item(index, 0)
+ verse = unicode(verse.data(QtCore.Qt.UserRole).toString())
+ if verse not in verse_names:
+ verses.append(verse)
+ verse_names.append(u'%s%s' % (
+ VerseType.translated_tag(verse[0]), verse[1:]))
+ for count, item in enumerate(order):
+ if item not in verses:
+ invalid_verses.append(order_names[count])
+ if invalid_verses:
+ valid = create_separated_list(verse_names)
+ if len(invalid_verses) > 1:
+ critical_error_message_box(message=unicode(translate(
+ 'SongsPlugin.EditSongForm', 'The verse order is invalid. '
+ 'There are no verses corresponding to %s. Valid entries '
+ 'are %s.')) % (u', '.join(invalid_verses), valid))
+ else:
+ critical_error_message_box(message=unicode(translate(
+ 'SongsPlugin.EditSongForm', 'The verse order is invalid. '
+ 'There is no verse corresponding to %s. Valid entries '
+ 'are %s.')) % (invalid_verses[0], valid))
+ return len(invalid_verses) == 0
+
+ def __validateSong(self):
"""
Check the validity of the song.
"""
@@ -604,56 +676,10 @@
'You need to have an author for this song.'))
return False
if self.verseOrderEdit.text():
- order = []
- order_names = unicode(self.verseOrderEdit.text()).split()
- for item in order_names:
- if len(item) == 1:
- verse_index = VerseType.from_translated_tag(item, None)
- if verse_index is not None:
- order.append(VerseType.Tags[verse_index] + u'1')
- else:
- # it matches no verses anyway
- order.append(u'')
- else:
- verse_index = VerseType.from_translated_tag(item[0], None)
- if verse_index is None:
- # it matches no verses anyway
- order.append(u'')
- else:
- verse_tag = VerseType.Tags[verse_index]
- verse_num = item[1:].lower()
- order.append(verse_tag + verse_num)
- verses = []
- verse_names = []
- for index in range(0, self.verseListWidget.rowCount()):
- verse = self.verseListWidget.item(index, 0)
- verse = unicode(verse.data(QtCore.Qt.UserRole).toString())
- if verse not in verse_names:
- verses.append(verse)
- verse_names.append(u'%s%s' % (
- VerseType.translated_tag(verse[0]), verse[1:]))
- for count, item in enumerate(order):
- if item not in verses:
- valid = create_separated_list(verse_names)
- critical_error_message_box(
- message=unicode(translate('SongsPlugin.EditSongForm',
- 'The verse order is invalid. There is no verse '
- 'corresponding to %s. Valid entries are %s.')) % \
- (order_names[count], valid))
- return False
- for count, verse in enumerate(verses):
- if verse not in order:
- self.songTabWidget.setCurrentIndex(0)
- self.verseOrderEdit.setFocus()
- answer = QtGui.QMessageBox.warning(self,
- translate('SongsPlugin.EditSongForm', 'Warning'),
- unicode(translate('SongsPlugin.EditSongForm',
- 'You have not used %s anywhere in the verse '
- 'order. Are you sure you want to save the song '
- 'like this?')) % verse_names[count],
- QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
- if answer == QtGui.QMessageBox.No:
- return False
+ result = self.__validateVerseList(self.verseOrderEdit.text(),
+ self.verseListWidget.rowCount())
+ if not result:
+ return False
item = int(self.songBookComboBox.currentIndex())
text = unicode(self.songBookComboBox.currentText())
if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0:
@@ -790,7 +816,7 @@
"""
log.debug(u'SongEditForm.accept')
self.clearCaches()
- if self._validate_song():
+ if self.__validateSong():
self.saveSong()
self.song = None
QtGui.QDialog.accept(self)
Follow ups