forked from openlp/openlp
Fix song authors and books
bzr-revno: 958
This commit is contained in:
commit
5b0ca457a1
@ -48,7 +48,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
"""
|
||||
QtGui.QDialog.__init__(self, parent)
|
||||
self.parent = parent
|
||||
#can this be automated?
|
||||
# can this be automated?
|
||||
self.width = 400
|
||||
self.setupUi(self)
|
||||
# Connecting signals and slots
|
||||
@ -171,7 +171,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.loadAuthors()
|
||||
self.loadTopics()
|
||||
self.loadBooks()
|
||||
#it's a new song to preview is not possible
|
||||
# it's a new song to preview is not possible
|
||||
self.previewButton.setVisible(False)
|
||||
|
||||
def loadSong(self, id, preview):
|
||||
@ -221,7 +221,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
self.CCLNumberEdit.setText(self.song.ccli_number)
|
||||
else:
|
||||
self.CCLNumberEdit.setText(u'')
|
||||
#lazy xml migration for now
|
||||
# lazy xml migration for now
|
||||
self.VerseListWidget.clear()
|
||||
self.VerseListWidget.setRowCount(0)
|
||||
self.VerseListWidget.setColumnWidth(0, self.width)
|
||||
@ -263,7 +263,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
topic_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id))
|
||||
self.TopicsListView.addItem(topic_name)
|
||||
self.TitleEditItem.setFocus(QtCore.Qt.OtherFocusReason)
|
||||
#if not preview hide the preview button
|
||||
# if not preview hide the preview button
|
||||
self.previewButton.setVisible(False)
|
||||
if preview:
|
||||
self.previewButton.setVisible(True)
|
||||
@ -288,11 +288,15 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Author'),
|
||||
translate('SongsPlugin.EditSongForm', 'This author does not '
|
||||
'exist, do you want to add them?'),
|
||||
'exist, do you want to add them?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
|
||||
last_name=text.rsplit(u' ', 1)[1], display_name=text)
|
||||
if text.find(u' ') == -1:
|
||||
author = Author.populate(first_name=u'', last_name=u'',
|
||||
display_name=text)
|
||||
else:
|
||||
author = Author.populate(first_name=text.rsplit(u' ', 1)[0],
|
||||
last_name=text.rsplit(u' ', 1)[1], display_name=text)
|
||||
self.songmanager.save_object(author, False)
|
||||
self.song.authors.append(author)
|
||||
author_item = QtGui.QListWidgetItem(
|
||||
@ -324,9 +328,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtGui.QMessageBox.warning(self,
|
||||
translate('SongsPlugin.EditSongForm', 'No Author Selected'),
|
||||
translate('SongsPlugin.EditSongForm', 'You have not selected '
|
||||
'a valid author. Either select an author from the list, '
|
||||
'or type in a new author and click the "Add Author to '
|
||||
'Song" button to add the new author.'),
|
||||
'a valid author. Either select an author from the list, '
|
||||
'or type in a new author and click the "Add Author to '
|
||||
'Song" button to add the new author.'),
|
||||
QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
|
||||
|
||||
def onAuthorsListViewPressed(self):
|
||||
@ -349,7 +353,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Topic'),
|
||||
translate('SongsPlugin.EditSongForm', 'This topic does not '
|
||||
'exist, do you want to add it?'),
|
||||
'exist, do you want to add it?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
topic = Topic.populate(name=text)
|
||||
@ -382,9 +386,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtGui.QMessageBox.warning(self,
|
||||
translate('SongsPlugin.EditSongForm', 'No Topic Selected'),
|
||||
translate('SongsPlugin.EditSongForm', 'You have not selected '
|
||||
'a valid topic. Either select a topic from the list, or '
|
||||
'type in a new topic and click the "Add Topic to Song" '
|
||||
'button to add the new topic.'),
|
||||
'a valid topic. Either select a topic from the list, or '
|
||||
'type in a new topic and click the "Add Topic to Song" '
|
||||
'button to add the new topic.'),
|
||||
QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok)
|
||||
|
||||
def onTopicListViewPressed(self):
|
||||
@ -408,7 +412,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
|
||||
def onThemeComboChanged(self, item):
|
||||
if item == 0:
|
||||
#None means no Theme
|
||||
# None means no Theme
|
||||
self.song.theme_name = None
|
||||
else:
|
||||
them_name = unicode(self.ThemeSelectionComboItem.itemText(item))
|
||||
@ -445,7 +449,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
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
|
||||
# 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 = {}
|
||||
@ -484,7 +488,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
for count, parts in enumerate(match.split(u']---\n')):
|
||||
if len(parts) > 1:
|
||||
if count == 0:
|
||||
#make sure the tag is correctly cased
|
||||
# make sure the tag is correctly cased
|
||||
variant = u'%s%s' % \
|
||||
(parts[0:1].upper(), parts[1:].lower())
|
||||
else:
|
||||
@ -521,7 +525,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
translate('SongsPlugin.EditSongForm',
|
||||
'You need to type in a song title.'))
|
||||
'You need to type in a song title.'))
|
||||
return False
|
||||
if self.VerseListWidget.rowCount() == 0:
|
||||
self.SongTabWidget.setCurrentIndex(0)
|
||||
@ -529,7 +533,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
translate('SongsPlugin.EditSongForm',
|
||||
'You need to type in at least one verse.'))
|
||||
'You need to type in at least one verse.'))
|
||||
return False
|
||||
if self.AuthorsListView.count() == 0:
|
||||
self.SongTabWidget.setCurrentIndex(1)
|
||||
@ -537,8 +541,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
answer = QtGui.QMessageBox.warning(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Warning'),
|
||||
translate('SongsPlugin.EditSongForm',
|
||||
'You have not added any authors for this song. Do you '
|
||||
'want to add an author now?'),
|
||||
'You have not added any authors for this song. Do you '
|
||||
'want to add an author now?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
|
||||
if answer == QtGui.QMessageBox.Yes:
|
||||
return False
|
||||
@ -569,9 +573,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Error'),
|
||||
unicode(translate('SongsPlugin.EditSongForm',
|
||||
'The verse order is invalid. There is no verse '
|
||||
'corresponding to %s. Valid entries are %s.')) % \
|
||||
(order_names[count], valid))
|
||||
'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:
|
||||
@ -580,10 +584,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
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].replace(u':', u' '),
|
||||
'You have not used %s anywhere in the verse '
|
||||
'order. Are you sure you want to save the song '
|
||||
'like this?')) % verse_names[count].replace(u':', u' '),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
|
||||
if answer == QtGui.QMessageBox.No:
|
||||
return False
|
||||
@ -624,10 +627,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
|
||||
if QtGui.QMessageBox.question(self,
|
||||
translate('SongsPlugin.EditSongForm', 'Add Book'),
|
||||
translate('SongsPlugin.EditSongForm', 'This song book does '
|
||||
'not exist, do you want to add it?'),
|
||||
'not exist, do you want to add it?'),
|
||||
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No,
|
||||
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
|
||||
book = Book.populate(name=text)
|
||||
book = Book.populate(name=text, publisher=u'')
|
||||
self.songmanager.save_object(book)
|
||||
self.song.book = book
|
||||
self.loadBooks()
|
||||
|
@ -350,6 +350,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
|
||||
book_id = self._getCurrentItemId(self.BooksListWidget)
|
||||
if book_id != -1:
|
||||
book = self.songmanager.get_object(Book, book_id)
|
||||
if book.publisher is None:
|
||||
book.publisher = u''
|
||||
self.bookform.NameEdit.setText(book.name)
|
||||
self.bookform.PublisherEdit.setText(book.publisher)
|
||||
# Save the book's name and publisher for the case that they have to
|
||||
|
Loading…
Reference in New Issue
Block a user