Fix song number/book save and load

bzr-revno: 1061
This commit is contained in:
Jonathan Corwin 2010-09-25 14:03:01 +01:00
commit f7b90c5a76

View File

@ -218,6 +218,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.CCLNumberEdit.setText(self.song.ccli_number) self.CCLNumberEdit.setText(self.song.ccli_number)
else: else:
self.CCLNumberEdit.setText(u'') self.CCLNumberEdit.setText(u'')
if self.song.song_number:
self.songBookNumberEdit.setText(self.song.song_number)
else:
self.songBookNumberEdit.setText(u'')
# lazy xml migration for now # lazy xml migration for now
self.VerseListWidget.clear() self.VerseListWidget.clear()
self.VerseListWidget.setRowCount(0) self.VerseListWidget.setRowCount(0)
@ -604,7 +609,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song = Song() self.song = Song()
item = int(self.SongbookCombo.currentIndex()) item = int(self.SongbookCombo.currentIndex())
text = unicode(self.SongbookCombo.currentText()) text = unicode(self.SongbookCombo.currentText())
if item == 0 and text: if self.SongbookCombo.findText(text, QtCore.Qt.MatchExactly) < 0:
if QtGui.QMessageBox.question(self, if QtGui.QMessageBox.question(self,
translate('SongsPlugin.EditSongForm', 'Add Book'), translate('SongsPlugin.EditSongForm', 'Add Book'),
translate('SongsPlugin.EditSongForm', 'This song book does ' translate('SongsPlugin.EditSongForm', 'This song book does '
@ -613,7 +618,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes: QtGui.QMessageBox.Yes) == QtGui.QMessageBox.Yes:
book = Book.populate(name=text, publisher=u'') book = Book.populate(name=text, publisher=u'')
self.songmanager.save_object(book) self.songmanager.save_object(book)
self.song.book = book
else: else:
return return
if self.saveSong(): if self.saveSong():
@ -634,6 +638,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.song.verse_order = unicode(self.VerseOrderEdit.text()) self.song.verse_order = unicode(self.VerseOrderEdit.text())
self.song.ccli_number = unicode(self.CCLNumberEdit.text()) self.song.ccli_number = unicode(self.CCLNumberEdit.text())
self.song.song_number = unicode(self.songBookNumberEdit.text()) self.song.song_number = unicode(self.songBookNumberEdit.text())
book_name = unicode(self.SongbookCombo.currentText())
if book_name:
self.song.book = self.songmanager.get_object_filtered(Book,
Book.name == book_name)
else:
self.song.book = None
if self._validate_song(): if self._validate_song():
self.processLyrics() self.processLyrics()
self.processTitle() self.processTitle()