changed combobox behaviour

This commit is contained in:
Andreas Preikschat 2010-09-18 23:29:41 +02:00
parent bfc3543d39
commit 02b46f051c

View File

@ -445,11 +445,21 @@ class BibleMediaItem(MediaManagerItem):
self.displayResults(bible, dual_bible) self.displayResults(bible, dual_bible)
def onClearAdvancedSearchComboBox(self): def onClearAdvancedSearchComboBox(self):
self.listView.clear()
if self.ClearAdvancedSearchComboBox.currentIndex() == 0: if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
self.AdvancedSecondBibleComboBox.setEnabled(True) self.AdvancedSecondBibleComboBox.setEnabled(True)
if self.AdvancedSecondBibleComboBox.findText(u'') == -1: if self.AdvancedSecondBibleComboBox.findText(u'') == -1:
self.AdvancedSecondBibleComboBox.insertItem(0, u'') self.AdvancedSecondBibleComboBox.insertItem(0, u'')
self.listView.clear()
else:
if self.listView.count() != 0:
bitem = self.listView.item(0)
dual_bible = self._decodeQtObject(bitem, 'dual_bible')
if self.AdvancedSecondBibleComboBox.findText(u'') != -1 and \
dual_bible:
self.AdvancedSecondBibleComboBox.removeItem(0)
else:
self.AdvancedSecondBibleComboBox.setCurrentIndex(0)
self.AdvancedSecondBibleComboBox.setEnabled(False)
def onAdvancedFromChapter(self): def onAdvancedFromChapter(self):
bible = unicode(self.AdvancedVersionComboBox.currentText()) bible = unicode(self.AdvancedVersionComboBox.currentText())
@ -482,14 +492,23 @@ class BibleMediaItem(MediaManagerItem):
self.displayResults(bible, dual_bible) self.displayResults(bible, dual_bible)
def onClearQuickSearchComboBox(self): def onClearQuickSearchComboBox(self):
self.listView.clear()
if self.ClearQuickSearchComboBox.currentIndex() == 0: if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.QuickSecondBibleComboBox.setEnabled(True) self.QuickSecondBibleComboBox.setEnabled(True)
if self.QuickSecondBibleComboBox.findText(u'') == -1: if self.QuickSecondBibleComboBox.findText(u'') == -1:
self.QuickSecondBibleComboBox.insertItem(0, u'') self.QuickSecondBibleComboBox.insertItem(0, u'')
self.listView.clear()
else:
if self.listView.count() != 0:
bitem = self.listView.item(0)
dual_bible = self._decodeQtObject(bitem, 'dual_bible')
if self.QuickSecondBibleComboBox.findText(u'') != -1 and \
dual_bible:
self.QuickSecondBibleComboBox.removeItem(0)
else:
self.QuickSecondBibleComboBox.setCurrentIndex(0)
self.QuickSecondBibleComboBox.setEnabled(False)
def _decodeQtObject(self, item, key): def _decodeQtObject(self, bitem, key):
bitem = self.listView.item(item.row())
reference = bitem.data(QtCore.Qt.UserRole) reference = bitem.data(QtCore.Qt.UserRole)
if isinstance(reference, QtCore.QVariant): if isinstance(reference, QtCore.QVariant):
reference = reference.toPyObject() reference = reference.toPyObject()
@ -515,19 +534,20 @@ class BibleMediaItem(MediaManagerItem):
first = True first = True
# Let's loop through the main lot, and assemble our verses. # Let's loop through the main lot, and assemble our verses.
for item in items: for item in items:
book = self._decodeQtObject(item, 'book') bitem = self.listView.item(item.row())
chapter = int(self._decodeQtObject(item, 'chapter')) book = self._decodeQtObject(bitem, 'book')
verse = int(self._decodeQtObject(item, 'verse')) chapter = int(self._decodeQtObject(bitem, 'chapter'))
bible = self._decodeQtObject(item, 'bible') verse = int(self._decodeQtObject(bitem, 'verse'))
version = self._decodeQtObject(item, 'version') bible = self._decodeQtObject(bitem, 'bible')
copyright = self._decodeQtObject(item, 'copyright') version = self._decodeQtObject(bitem, 'version')
permission = self._decodeQtObject(item, 'permission') copyright = self._decodeQtObject(bitem, 'copyright')
text = self._decodeQtObject(item, 'text') permission = self._decodeQtObject(bitem, 'permission')
dual_bible = self._decodeQtObject(item, 'dual_bible') text = self._decodeQtObject(bitem, 'text')
dual_version = self._decodeQtObject(item, 'dual_version') dual_bible = self._decodeQtObject(bitem, 'dual_bible')
dual_copyright = self._decodeQtObject(item, 'dual_copyright') dual_version = self._decodeQtObject(bitem, 'dual_version')
dual_permission = self._decodeQtObject(item, 'dual_permission') dual_copyright = self._decodeQtObject(bitem, 'dual_copyright')
dual_text = self._decodeQtObject(item, 'dual_text') dual_permission = self._decodeQtObject(bitem, 'dual_permission')
dual_text = self._decodeQtObject(bitem, 'dual_text')
verse_text = self.formatVerse(old_chapter, chapter, verse) verse_text = self.formatVerse(old_chapter, chapter, verse)
footer = u'%s (%s %s %s)' % (book, version, copyright, permission) footer = u'%s (%s %s %s)' % (book, version, copyright, permission)
if footer not in raw_footer: if footer not in raw_footer:
@ -599,13 +619,15 @@ class BibleMediaItem(MediaManagerItem):
we are at the end of a verse range. E. g. if we want to add we are at the end of a verse range. E. g. if we want to add
Genesis 1:1-6 as well as Daniel 2:14. Genesis 1:1-6 as well as Daniel 2:14.
""" """
old_chapter = int(self._decodeQtObject(old_item, 'chapter')) old_bitem = self.listView.item(old_item.row())
old_verse = int(self._decodeQtObject(old_item, 'verse')) old_chapter = int(self._decodeQtObject(old_bitem, 'chapter'))
start_book = self._decodeQtObject(start_item, 'book') old_verse = int(self._decodeQtObject(old_bitem, 'verse'))
start_chapter = int(self._decodeQtObject(start_item, 'chapter')) start_bitem = self.listView.item(start_item.row())
start_verse = int(self._decodeQtObject(start_item, 'verse')) start_book = self._decodeQtObject(start_bitem, 'book')
start_bible = self._decodeQtObject(start_item, 'bible') start_chapter = int(self._decodeQtObject(start_bitem, 'chapter'))
start_dual_bible = self._decodeQtObject(start_item, 'dual_bible') start_verse = int(self._decodeQtObject(start_bitem, 'verse'))
start_bible = self._decodeQtObject(start_bitem, 'bible')
start_dual_bible = self._decodeQtObject(start_bitem, 'dual_bible')
if start_dual_bible: if start_dual_bible:
if start_verse == old_verse and start_chapter == old_chapter: if start_verse == old_verse and start_chapter == old_chapter:
title = u'%s %s:%s (%s, %s)' % (start_book, start_chapter, title = u'%s %s:%s (%s, %s)' % (start_book, start_chapter,
@ -635,16 +657,18 @@ class BibleMediaItem(MediaManagerItem):
the case, we return True, else False. E. g. if we added Genesis 1:1-6, the case, we return True, else False. E. g. if we added Genesis 1:1-6,
but the next verse is Daniel 2:14. but the next verse is Daniel 2:14.
""" """
book = self._decodeQtObject(item, 'book') bitem = self.listView.item(item.row())
chapter = int(self._decodeQtObject(item, 'chapter')) book = self._decodeQtObject(bitem, 'book')
verse = int(self._decodeQtObject(item, 'verse')) chapter = int(self._decodeQtObject(bitem, 'chapter'))
bible = self._decodeQtObject(item, 'bible') verse = int(self._decodeQtObject(bitem, 'verse'))
dual_bible = self._decodeQtObject(item, 'dual_bible') bible = self._decodeQtObject(bitem, 'bible')
old_book = self._decodeQtObject(old_item, 'book') dual_bible = self._decodeQtObject(bitem, 'dual_bible')
old_chapter = int(self._decodeQtObject(old_item, 'chapter')) old_bitem = self.listView.item(old_item.row())
old_verse = int(self._decodeQtObject(old_item, 'verse')) old_book = self._decodeQtObject(old_bitem, 'book')
old_bible = self._decodeQtObject(old_item, 'bible') old_chapter = int(self._decodeQtObject(old_bitem, 'chapter'))
old_dual_bible = self._decodeQtObject(old_item, 'dual_bible') old_verse = int(self._decodeQtObject(old_bitem, 'verse'))
old_bible = self._decodeQtObject(old_bitem, 'bible')
old_dual_bible = self._decodeQtObject(old_bitem, 'dual_bible')
if old_bible != bible or old_dual_bible != dual_bible or \ if old_bible != bible or old_dual_bible != dual_bible or \
old_book != book: old_book != book:
return True return True