forked from openlp/openlp
Head r1902
This commit is contained in:
commit
fd8af8691e
@ -21,3 +21,4 @@ openlp/core/resources.py.old
|
|||||||
*.qm
|
*.qm
|
||||||
resources/windows/warnOpenLP.txt
|
resources/windows/warnOpenLP.txt
|
||||||
openlp.cfg
|
openlp.cfg
|
||||||
|
.idea
|
||||||
|
@ -280,8 +280,15 @@ class Ui_EditSongDialog(object):
|
|||||||
self.songTabWidget.addTab(self.audioTab, u'')
|
self.songTabWidget.addTab(self.audioTab, u'')
|
||||||
# Last few bits
|
# Last few bits
|
||||||
self.dialogLayout.addWidget(self.songTabWidget)
|
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.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)
|
self.retranslateUi(editSongDialog)
|
||||||
QtCore.QMetaObject.connectSlotsByName(editSongDialog)
|
QtCore.QMetaObject.connectSlotsByName(editSongDialog)
|
||||||
|
|
||||||
@ -349,14 +356,19 @@ class Ui_EditSongDialog(object):
|
|||||||
translate('SongsPlugin.EditSongForm', '&Remove'))
|
translate('SongsPlugin.EditSongForm', '&Remove'))
|
||||||
self.audioRemoveAllButton.setText(
|
self.audioRemoveAllButton.setText(
|
||||||
translate('SongsPlugin.EditSongForm', 'Remove &All'))
|
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):
|
def editSongDialogComboBox(parent, name):
|
||||||
"""
|
"""
|
||||||
Utility method to generate a standard combo box for this dialog.
|
Utility method to generate a standard combo box for this dialog.
|
||||||
"""
|
"""
|
||||||
comboBox = QtGui.QComboBox(parent)
|
comboBox = QtGui.QComboBox(parent)
|
||||||
comboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength)
|
comboBox.setSizeAdjustPolicy(
|
||||||
comboBox.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
QtGui.QComboBox.AdjustToMinimumContentsLength)
|
||||||
|
comboBox.setSizePolicy(
|
||||||
|
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
|
||||||
comboBox.setEditable(True)
|
comboBox.setEditable(True)
|
||||||
comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
|
comboBox.setInsertPolicy(QtGui.QComboBox.NoInsert)
|
||||||
comboBox.setObjectName(name)
|
comboBox.setObjectName(name)
|
||||||
|
@ -92,6 +92,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
QtCore.QObject.connect(self.verseListWidget,
|
QtCore.QObject.connect(self.verseListWidget,
|
||||||
QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'),
|
QtCore.SIGNAL(u'itemClicked(QTableWidgetItem*)'),
|
||||||
self.onVerseListViewPressed)
|
self.onVerseListViewPressed)
|
||||||
|
QtCore.QObject.connect(self.verseOrderEdit,
|
||||||
|
QtCore.SIGNAL(u'textChanged(QString)'),
|
||||||
|
self.onVerseOrderTextChanged)
|
||||||
QtCore.QObject.connect(self.themeAddButton,
|
QtCore.QObject.connect(self.themeAddButton,
|
||||||
QtCore.SIGNAL(u'clicked()'),
|
QtCore.SIGNAL(u'clicked()'),
|
||||||
self.mediaitem.plugin.renderer.themeManager.onAddTheme)
|
self.mediaitem.plugin.renderer.themeManager.onAddTheme)
|
||||||
@ -574,7 +577,76 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
self.verseEditButton.setEnabled(False)
|
self.verseEditButton.setEnabled(False)
|
||||||
self.verseDeleteButton.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.
|
Check the validity of the song.
|
||||||
"""
|
"""
|
||||||
@ -604,56 +676,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
'You need to have an author for this song.'))
|
'You need to have an author for this song.'))
|
||||||
return False
|
return False
|
||||||
if self.verseOrderEdit.text():
|
if self.verseOrderEdit.text():
|
||||||
order = []
|
result = self.__validateVerseList(self.verseOrderEdit.text(),
|
||||||
order_names = unicode(self.verseOrderEdit.text()).split()
|
self.verseListWidget.rowCount())
|
||||||
for item in order_names:
|
if not result:
|
||||||
if len(item) == 1:
|
return False
|
||||||
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
|
|
||||||
item = int(self.songBookComboBox.currentIndex())
|
item = int(self.songBookComboBox.currentIndex())
|
||||||
text = unicode(self.songBookComboBox.currentText())
|
text = unicode(self.songBookComboBox.currentText())
|
||||||
if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0:
|
if self.songBookComboBox.findText(text, QtCore.Qt.MatchExactly) < 0:
|
||||||
@ -790,7 +816,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
|||||||
"""
|
"""
|
||||||
log.debug(u'SongEditForm.accept')
|
log.debug(u'SongEditForm.accept')
|
||||||
self.clearCaches()
|
self.clearCaches()
|
||||||
if self._validate_song():
|
if self.__validateSong():
|
||||||
self.saveSong()
|
self.saveSong()
|
||||||
self.song = None
|
self.song = None
|
||||||
QtGui.QDialog.accept(self)
|
QtGui.QDialog.accept(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user