Match method and overridden method arguments and cleanups

This commit is contained in:
Jon Tibble 2010-05-26 00:47:26 +01:00
parent f0c03ad2cb
commit e195f0ffb7
3 changed files with 32 additions and 25 deletions

View File

@ -418,12 +418,13 @@ class HTTPBible(BibleDB):
Receiver.send_message(u'bibles_nobook') Receiver.send_message(u'bibles_nobook')
return [] return []
db_book = self.create_book(book_details[u'name'], db_book = self.create_book(book_details[u'name'],
book_details[u'abbreviation'], book_details[u'testament_id']) book_details[u'abbreviation'],
book_details[u'testament_id'])
book = db_book.name book = db_book.name
if BibleDB.get_verse_count(self, book, reference[1]) == 0: if BibleDB.get_verse_count(self, book, reference[1]) == 0:
Receiver.send_message(u'bibles_showprogress') Receiver.send_message(u'bibles_showprogress')
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
search_results = self.get_chapter(self.name, book, reference[1]) search_results = self.get_chapter(book, reference[1])
if search_results and search_results.has_verselist(): if search_results and search_results.has_verselist():
## We have found a book of the bible lets check to see ## We have found a book of the bible lets check to see
## if it was there. By reusing the returned book name ## if it was there. By reusing the returned book name
@ -433,18 +434,19 @@ class HTTPBible(BibleDB):
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
# check to see if book/chapter exists # check to see if book/chapter exists
db_book = self.get_book(bookname) db_book = self.get_book(bookname)
self.create_chapter(db_book.id, search_results.get_chapter(), self.create_chapter(db_book.id,
search_results.get_chapter(),
search_results.get_verselist()) search_results.get_verselist())
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
Receiver.send_message(u'bibles_hideprogress') Receiver.send_message(u'bibles_hideprogress')
Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'openlp_process_events')
return BibleDB.get_verses(self, reference_list) return BibleDB.get_verses(self, reference_list)
def get_chapter(self, version, book, chapter): def get_chapter(self, book, chapter):
""" """
Receive the request and call the relevant handler methods Receive the request and call the relevant handler methods
""" """
log.debug(u'get_chapter %s, %s, %s', version, book, chapter) log.debug(u'get_chapter %s, %s', book, chapter)
log.debug(u'source = %s', self.download_source) log.debug(u'source = %s', self.download_source)
try: try:
if self.download_source.lower() == u'crosswalk': if self.download_source.lower() == u'crosswalk':

View File

@ -129,39 +129,41 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
self.authorform.setAutoDisplayName(True) self.authorform.setAutoDisplayName(True)
if self.authorform.exec_(): if self.authorform.exec_():
author = Author.populate( author = Author.populate(
first_name=unicode(self.authorform.FirstNameEdit.text(), u'utf-8'), first_name=unicode(
last_name=unicode(self.authorform.LastNameEdit.text(), u'utf-8'), self.authorform.FirstNameEdit.text(), u'utf-8'),
display_name=unicode(self.authorform.DisplayEdit.text(), u'utf-8')) last_name=unicode(
self.authorform.LastNameEdit.text(), u'utf-8'),
display_name=unicode(
self.authorform.DisplayEdit.text(), u'utf-8'))
if self.songmanager.save_author(author): if self.songmanager.save_author(author):
self.resetAuthors() self.resetAuthors()
else: else:
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(
self, self.trUtf8('Error'), self, self.trUtf8('Error'),
self.trUtf8('Couldn\'t add your author.'), self.trUtf8('Couldn\'t add your author.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
def onTopicAddButtonClick(self): def onTopicAddButtonClick(self):
if self.topicform.exec_(): if self.topicform.exec_():
topic = Topic.populate(name=unicode(self.topicform.NameEdit.text(), u'utf-8')) topic = Topic.populate(
name=unicode(self.topicform.NameEdit.text(), u'utf-8'))
if self.songmanager.save_topic(topic): if self.songmanager.save_topic(topic):
self.resetTopics() self.resetTopics()
else: else:
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(
self, self.trUtf8('Error'), self, self.trUtf8('Error'),
self.trUtf8('Couldn\'t add your topic.'), self.trUtf8('Couldn\'t add your topic.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
def onBookAddButtonClick(self): def onBookAddButtonClick(self):
if self.bookform.exec_(): if self.bookform.exec_():
book = Book.populate(name=unicode(self.bookform.NameEdit.text(), u'utf-8'), book = Book.populate(
name=unicode(self.bookform.NameEdit.text(), u'utf-8'),
publisher=unicode(self.bookform.PublisherEdit.text(), u'utf-8')) publisher=unicode(self.bookform.PublisherEdit.text(), u'utf-8'))
if self.songmanager.save_book(book): if self.songmanager.save_book(book):
self.resetBooks() self.resetBooks()
else: else:
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(
self, self.trUtf8('Error'), self, self.trUtf8('Error'),
self.trUtf8('Couldn\'t add your book.'), self.trUtf8('Couldn\'t add your book.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
def onAuthorEditButtonClick(self): def onAuthorEditButtonClick(self):
author_id = self._getCurrentItemId(self.AuthorsListWidget) author_id = self._getCurrentItemId(self.AuthorsListWidget)
@ -172,16 +174,18 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog):
self.authorform.LastNameEdit.setText(author.last_name) self.authorform.LastNameEdit.setText(author.last_name)
self.authorform.DisplayEdit.setText(author.display_name) self.authorform.DisplayEdit.setText(author.display_name)
if self.authorform.exec_(False): if self.authorform.exec_(False):
author.first_name = unicode(self.authorform.FirstNameEdit.text(), u'utf-8') author.first_name = unicode(
author.last_name = unicode(self.authorform.LastNameEdit.text(), u'utf-8') self.authorform.FirstNameEdit.text(), u'utf-8')
author.display_name = unicode(self.authorform.DisplayEdit.text(), u'utf-8') author.last_name = unicode(
self.authorform.LastNameEdit.text(), u'utf-8')
author.display_name = unicode(
self.authorform.DisplayEdit.text(), u'utf-8')
if self.songmanager.save_author(author): if self.songmanager.save_author(author):
self.resetAuthors() self.resetAuthors()
else: else:
QtGui.QMessageBox.critical( QtGui.QMessageBox.critical(
self, self.trUtf8('Error'), self, self.trUtf8('Error'),
self.trUtf8('Couldn\'t save your author.'), self.trUtf8('Couldn\'t save your author.'))
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
def onTopicEditButtonClick(self): def onTopicEditButtonClick(self):
topic_id = self._getCurrentItemId(self.TopicsListWidget) topic_id = self._getCurrentItemId(self.TopicsListWidget)

View File

@ -270,7 +270,7 @@ class SongMediaItem(MediaManagerItem):
self.edit_song_form.loadSong(fields[1], (fields[0] == u'P')) self.edit_song_form.loadSong(fields[1], (fields[0] == u'P'))
self.edit_song_form.exec_() self.edit_song_form.exec_()
def onEditClick(self, preview=False): def onEditClick(self):
item = self.ListView.currentItem() item = self.ListView.currentItem()
if item: if item:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
@ -283,7 +283,8 @@ class SongMediaItem(MediaManagerItem):
if len(items) == 1: if len(items) == 1:
del_message = self.trUtf8('Delete song?') del_message = self.trUtf8('Delete song?')
else: else:
del_message = unicode(self.trUtf8('Delete %d songs?')) % len(items) del_message = unicode(
self.trUtf8('Delete %d songs?')) % len(items)
ans = QtGui.QMessageBox.question(self, ans = QtGui.QMessageBox.question(self,
self.trUtf8('Delete Confirmation'), del_message, self.trUtf8('Delete Confirmation'), del_message,
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok| QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok|
@ -323,7 +324,8 @@ class SongMediaItem(MediaManagerItem):
#no verse list or only 1 space (in error) #no verse list or only 1 space (in error)
if not song.verse_order or not song.verse_order.strip(): if not song.verse_order or not song.verse_order.strip():
for verse in verseList: for verse in verseList:
verseTag = u'%s:%s' % (verse[0][u'type'], verse[0][u'label']) verseTag = u'%s:%s' % (
verse[0][u'type'], verse[0][u'label'])
service_item.add_from_text(\ service_item.add_from_text(\
verse[1][:30], unicode(verse[1]), verseTag) verse[1][:30], unicode(verse[1]), verseTag)
else: else:
@ -372,4 +374,3 @@ class SongMediaItem(MediaManagerItem):
] ]
return True return True