-disable search buttons while searching, -clean ups

This commit is contained in:
Andreas Preikschat 2010-10-01 15:50:29 +02:00
parent 74752da694
commit e17f6c7c9e
4 changed files with 35 additions and 25 deletions

View File

@ -75,7 +75,7 @@ def parse_reference(reference):
7 None|[0-9]+|end None or the end of the second verse range.
The reference list is a list of tuples, with each tuple structured like
this::
this:
(book, chapter, start_verse, end_verse)
``reference``

View File

@ -281,23 +281,23 @@ class BibleDB(QtCore.QObject, Manager):
def create_meta(self, key, value):
"""
Utility method to save BibleMeta objects in a Bible database
Utility method to save BibleMeta objects in a Bible database.
``key``
The key for this instance
The key for this instance.
``value``
The value for this instance
The value for this instance.
"""
log.debug(u'save_meta %s/%s', key, value)
self.save_object(BibleMeta.populate(key=key, value=value))
def get_book(self, book):
"""
Return a book object from the database
Return a book object from the database.
``book``
The name of the book to return
The name of the book to return.
"""
log.debug(u'BibleDb.get_book("%s")', book)
db_book = self.get_object_filtered(Book, Book.name.like(book + u'%'))
@ -320,14 +320,14 @@ class BibleDB(QtCore.QObject, Manager):
``reference_list``
This is the list of references the media manager item wants. It is
a list of tuples, with the following format::
a list of tuples, with the following format:
(book, chapter, start_verse, end_verse)
Therefore, when you are looking for multiple items, simply break
them up into references like this, bundle them into a list. This
function then runs through the list, and returns an amalgamated
list of ``Verse`` objects. For example::
list of ``Verse`` objects. For example:
[(u'Genesis', 1, 1, 1), (u'Genesis', 2, 2, 3)]
"""
@ -387,10 +387,10 @@ class BibleDB(QtCore.QObject, Manager):
def get_chapter_count(self, book):
"""
Return the number of chapters in a book
Return the number of chapters in a book.
``book``
The book to get the chapter count for
The book to get the chapter count for.
"""
log.debug(u'BibleDB.get_chapter_count("%s")', book)
count = self.session.query(Verse.chapter).join(Book)\
@ -403,13 +403,13 @@ class BibleDB(QtCore.QObject, Manager):
def get_verse_count(self, book, chapter):
"""
Return the number of verses in a chapter
Return the number of verses in a chapter.
``book``
The book containing the chapter
The book containing the chapter.
``chapter``
The chapter to get the verse count for
The chapter to get the verse count for.
"""
log.debug(u'BibleDB.get_verse_count("%s", %s)', book, chapter)
count = self.session.query(Verse).join(Book)\
@ -423,7 +423,7 @@ class BibleDB(QtCore.QObject, Manager):
def dump_bible(self):
"""
Utility debugging method to dump the contents of a bible
Utility debugging method to dump the contents of a bible.
"""
log.debug(u'.........Dumping Bible Database')
log.debug('...............................Books ')

View File

@ -137,7 +137,7 @@ class BibleManager(object):
name = bible.get_name()
log.debug(u'Bible Name: "%s"', name)
self.db_cache[name] = bible
# look to see if lazy load bible exists and get create getter.
# Look to see if lazy load bible exists and get create getter.
source = self.db_cache[name].get_object(BibleMeta,
u'download source')
if source:
@ -204,7 +204,7 @@ class BibleManager(object):
def get_chapter_count(self, bible, book):
"""
Returns the number of Chapters for a given book
Returns the number of Chapters for a given book.
"""
log.debug(u'get_book_chapter_count %s', book)
return self.db_cache[bible].get_chapter_count(book)
@ -212,7 +212,7 @@ class BibleManager(object):
def get_verse_count(self, bible, book, chapter):
"""
Returns all the number of verses for a given
book and chapterMaxBibleBookVerses
book and chapterMaxBibleBookVerses.
"""
log.debug(u'BibleManager.get_verse_count("%s", "%s", %s)',
bible, book, chapter)
@ -279,7 +279,7 @@ class BibleManager(object):
def save_meta_data(self, bible, version, copyright, permissions):
"""
Saves the bibles meta data
Saves the bibles meta data.
"""
log.debug(u'save_meta data %s,%s, %s,%s',
bible, version, copyright, permissions)
@ -289,14 +289,14 @@ class BibleManager(object):
def get_meta_data(self, bible, key):
"""
Returns the meta data for a given key
Returns the meta data for a given key.
"""
log.debug(u'get_meta %s,%s', bible, key)
return self.db_cache[bible].get_object(BibleMeta, key)
def exists(self, name):
"""
Check cache to see if new bible
Check cache to see if new bible.
"""
if not isinstance(name, unicode):
name = unicode(name)

View File

@ -497,6 +497,7 @@ class BibleMediaItem(MediaManagerItem):
def onAdvancedSearchButton(self):
log.debug(u'Advanced Search Button pressed')
self.AdvancedSearchButton.setEnabled(False)
bible = unicode(self.AdvancedVersionComboBox.currentText())
dual_bible = unicode(self.AdvancedSecondBibleComboBox.currentText())
book = unicode(self.AdvancedBookComboBox.currentText())
@ -529,9 +530,11 @@ class BibleMediaItem(MediaManagerItem):
self.displayResults(bible, dual_bible)
else:
self.displayResults(bible, dual_bible)
self.AdvancedSearchButton.setEnabled(True)
def onQuickSearchButton(self):
log.debug(u'Quick Search Button pressed')
self.QuickSearchButton.setEnabled(False)
bible = unicode(self.QuickVersionComboBox.currentText())
dual_bible = unicode(self.QuickSecondBibleComboBox.currentText())
text = unicode(self.QuickSearchEdit.text())
@ -543,11 +546,17 @@ class BibleMediaItem(MediaManagerItem):
else: # Text Search
self.search_results = self.parent.manager.verse_search(bible, text)
if dual_bible:
for count, verse in enumerate(self.search_results):
text = u'%s %s:%s' % (verse.book.name, verse.chapter,
verse.verse)
self.dual_search_results[count] = self.parent.manager.\
get_verses(dual_bible, text)[0]
text = []
for verse in self.search_results:
text.append((verse.book.name, verse.chapter, verse.verse,
verse.verse))
self.dual_search_results = self.parent.manager.get_verses(
dual_bible, text)
# for count, verse in enumerate(self.search_results):
# text = u'%s %s:%s' % (verse.book.name, verse.chapter,
# verse.verse)
# self.dual_search_results[count] = self.parent.manager.\
# get_verses(dual_bible, text)[0]
if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.listView.clear()
if self.listView.count() != 0 and self.search_results:
@ -567,6 +576,7 @@ class BibleMediaItem(MediaManagerItem):
self.displayResults(bible, dual_bible)
elif self.search_results:
self.displayResults(bible, dual_bible)
self.QuickSearchButton.setEnabled(True)
def displayResults(self, bible, dual_bible=u''):
"""