This commit is contained in:
Andreas Preikschat 2010-09-20 20:55:14 +02:00
parent 137fb7417e
commit 8b6e90ab44

View File

@ -471,7 +471,7 @@ class BibleMediaItem(MediaManagerItem):
dual_bible, text) dual_bible, text)
if self.ClearQuickSearchComboBox.currentIndex() == 0: if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.listView.clear() self.listView.clear()
if self.listView.count() != 0: if self.listView.count() != 0 and self.search_results:
bitem = self.listView.item(0) bitem = self.listView.item(0)
item_dual_bible = self._decodeQtObject(bitem, 'dual_bible') item_dual_bible = self._decodeQtObject(bitem, 'dual_bible')
if item_dual_bible and dual_bible or not item_dual_bible and \ if item_dual_bible and dual_bible or not item_dual_bible and \
@ -486,7 +486,7 @@ class BibleMediaItem(MediaManagerItem):
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes: QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
self.listView.clear() self.listView.clear()
self.displayResults(bible, dual_bible) self.displayResults(bible, dual_bible)
else: elif self.search_results:
self.displayResults(bible, dual_bible) self.displayResults(bible, dual_bible)
def _decodeQtObject(self, bitem, key): def _decodeQtObject(self, bitem, key):
@ -737,52 +737,50 @@ class BibleMediaItem(MediaManagerItem):
dual_permission = u'' dual_permission = u''
# We count the number of rows which are maybe already present. # We count the number of rows which are maybe already present.
start_count = self.listView.count() start_count = self.listView.count()
if self.search_results: for count, verse in enumerate(self.search_results):
for count, verse in enumerate(self.search_results): if dual_bible:
if dual_bible: vdict = {
vdict = { 'book': QtCore.QVariant(verse.book.name),
'book': QtCore.QVariant(verse.book.name), 'chapter': QtCore.QVariant(verse.chapter),
'chapter': QtCore.QVariant(verse.chapter), 'verse': QtCore.QVariant(verse.verse),
'verse': QtCore.QVariant(verse.verse), 'bible': QtCore.QVariant(bible),
'bible': QtCore.QVariant(bible), 'version': QtCore.QVariant(version.value),
'version': QtCore.QVariant(version.value), 'copyright': QtCore.QVariant(copyright.value),
'copyright': QtCore.QVariant(copyright.value), 'permission': QtCore.QVariant(permission.value),
'permission': QtCore.QVariant(permission.value), 'text': QtCore.QVariant(verse.text),
'text': QtCore.QVariant(verse.text), 'dual_bible': QtCore.QVariant(dual_bible),
'dual_bible': QtCore.QVariant(dual_bible), 'dual_version': QtCore.QVariant(dual_version.value),
'dual_version': QtCore.QVariant(dual_version.value), 'dual_copyright': QtCore.QVariant(dual_copyright.value),
'dual_copyright': QtCore.QVariant(dual_copyright.value), 'dual_permission': QtCore.QVariant(dual_permission.value),
'dual_permission': QtCore.QVariant( 'dual_text': QtCore.QVariant(
dual_permission.value), self.dual_search_results[count].text)
'dual_text': QtCore.QVariant( }
self.dual_search_results[count].text) bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name,
} verse.chapter, verse.verse, version.value,
bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name, dual_version.value)
verse.chapter, verse.verse, version.value, else:
dual_version.value) vdict = {
else: 'book': QtCore.QVariant(verse.book.name),
vdict = { 'chapter': QtCore.QVariant(verse.chapter),
'book': QtCore.QVariant(verse.book.name), 'verse': QtCore.QVariant(verse.verse),
'chapter': QtCore.QVariant(verse.chapter), 'bible': QtCore.QVariant(bible),
'verse': QtCore.QVariant(verse.verse), 'version': QtCore.QVariant(version.value),
'bible': QtCore.QVariant(bible), 'copyright': QtCore.QVariant(copyright.value),
'version': QtCore.QVariant(version.value), 'permission': QtCore.QVariant(permission.value),
'copyright': QtCore.QVariant(copyright.value), 'text': QtCore.QVariant(verse.text),
'permission': QtCore.QVariant(permission.value), 'dual_bible': QtCore.QVariant(u''),
'text': QtCore.QVariant(verse.text), 'dual_version': QtCore.QVariant(u''),
'dual_bible': QtCore.QVariant(u''), 'dual_copyright': QtCore.QVariant(u''),
'dual_version': QtCore.QVariant(u''), 'dual_permission': QtCore.QVariant(u''),
'dual_copyright': QtCore.QVariant(u''), 'dual_text': QtCore.QVariant(u'')
'dual_permission': QtCore.QVariant(u''), }
'dual_text': QtCore.QVariant(u'') bible_text = u' %s %d:%d (%s)' % (verse.book.name,
} verse.chapter, verse.verse, version.value)
bible_text = u' %s %d:%d (%s)' % (verse.book.name, bible_verse = QtGui.QListWidgetItem(bible_text)
verse.chapter, verse.verse, version.value) bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(vdict))
bible_verse = QtGui.QListWidgetItem(bible_text) self.listView.addItem(bible_verse)
bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(vdict)) row = self.listView.setCurrentRow(count + start_count)
self.listView.addItem(bible_verse) if row:
row = self.listView.setCurrentRow(count + start_count) row.setSelected(True)
if row: self.search_results = {}
row.setSelected(True) self.dual_search_results = {}
self.search_results = {}
self.dual_search_results = {}