forked from openlp/openlp
removed code and added a dialog
This commit is contained in:
parent
17b4335ee4
commit
137fb7417e
@ -239,10 +239,6 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromVerse)
|
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromVerse)
|
||||||
QtCore.QObject.connect(self.AdvancedToChapter,
|
QtCore.QObject.connect(self.AdvancedToChapter,
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedToChapter)
|
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedToChapter)
|
||||||
QtCore.QObject.connect(self.ClearAdvancedSearchComboBox,
|
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onClearAdvancedSearchComboBox)
|
|
||||||
QtCore.QObject.connect(self.ClearQuickSearchComboBox,
|
|
||||||
QtCore.SIGNAL(u'activated(int)'), self.onClearQuickSearchComboBox)
|
|
||||||
# Buttons
|
# Buttons
|
||||||
QtCore.QObject.connect(self.AdvancedSearchButton,
|
QtCore.QObject.connect(self.AdvancedSearchButton,
|
||||||
QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton)
|
QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton)
|
||||||
@ -436,29 +432,23 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
dual_bible, versetext)
|
dual_bible, versetext)
|
||||||
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
|
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
|
||||||
self.listView.clear()
|
self.listView.clear()
|
||||||
elif not dual_bible:
|
if self.listView.count() != 0:
|
||||||
self.AdvancedSecondBibleComboBox.setEnabled(False)
|
bitem = self.listView.item(0)
|
||||||
|
item_dual_bible = self._decodeQtObject(bitem, 'dual_bible')
|
||||||
|
if item_dual_bible and dual_bible or not item_dual_bible and \
|
||||||
|
not dual_bible:
|
||||||
|
self.displayResults(bible, dual_bible)
|
||||||
|
elif QtGui.QMessageBox.critical(self,
|
||||||
|
translate('BiblePlugin.MediaItem', 'Error'),
|
||||||
|
translate('BiblePlugin.MediaItem', 'You cannot combine single '
|
||||||
|
'and dual bible verses. Do you want to delete your search '
|
||||||
|
'results and start a new search?'),
|
||||||
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
|
||||||
|
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
|
||||||
|
self.listView.clear()
|
||||||
|
self.displayResults(bible, dual_bible)
|
||||||
else:
|
else:
|
||||||
self.AdvancedSecondBibleComboBox.setEnabled(True)
|
self.displayResults(bible, dual_bible)
|
||||||
if self.AdvancedSecondBibleComboBox.findText(u'') != -1:
|
|
||||||
self.AdvancedSecondBibleComboBox.removeItem(0)
|
|
||||||
self.displayResults(bible, dual_bible)
|
|
||||||
|
|
||||||
def onClearAdvancedSearchComboBox(self):
|
|
||||||
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
|
|
||||||
self.AdvancedSecondBibleComboBox.setEnabled(True)
|
|
||||||
if self.AdvancedSecondBibleComboBox.findText(u'') == -1:
|
|
||||||
self.AdvancedSecondBibleComboBox.insertItem(0, u'')
|
|
||||||
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())
|
||||||
@ -481,31 +471,24 @@ 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()
|
||||||
elif not dual_bible:
|
if self.listView.count() != 0:
|
||||||
self.QuickSecondBibleComboBox.setEnabled(False)
|
bitem = self.listView.item(0)
|
||||||
|
item_dual_bible = self._decodeQtObject(bitem, 'dual_bible')
|
||||||
|
if item_dual_bible and dual_bible or not item_dual_bible and \
|
||||||
|
not dual_bible:
|
||||||
|
self.displayResults(bible, dual_bible)
|
||||||
|
elif QtGui.QMessageBox.critical(self,
|
||||||
|
translate('BiblePlugin.MediaItem', 'Error'),
|
||||||
|
translate('BiblePlugin.MediaItem', 'You cannot combine single '
|
||||||
|
'and dual bible verses. Do you want to delete your search '
|
||||||
|
'resutls and start a new search?'),
|
||||||
|
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No |
|
||||||
|
QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.Yes:
|
||||||
|
self.listView.clear()
|
||||||
|
self.displayResults(bible, dual_bible)
|
||||||
else:
|
else:
|
||||||
self.QuickSecondBibleComboBox.setEnabled(True)
|
|
||||||
if self.QuickSecondBibleComboBox.findText(u'') != -1:
|
|
||||||
self.QuickSecondBibleComboBox.removeItem(0)
|
|
||||||
if self.search_results:
|
|
||||||
self.displayResults(bible, dual_bible)
|
self.displayResults(bible, dual_bible)
|
||||||
|
|
||||||
def onClearQuickSearchComboBox(self):
|
|
||||||
if self.ClearQuickSearchComboBox.currentIndex() == 0:
|
|
||||||
self.QuickSecondBibleComboBox.setEnabled(True)
|
|
||||||
if self.QuickSecondBibleComboBox.findText(u'') == -1:
|
|
||||||
self.QuickSecondBibleComboBox.insertItem(0, u'')
|
|
||||||
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, bitem, key):
|
def _decodeQtObject(self, bitem, key):
|
||||||
reference = bitem.data(QtCore.Qt.UserRole)
|
reference = bitem.data(QtCore.Qt.UserRole)
|
||||||
if isinstance(reference, QtCore.QVariant):
|
if isinstance(reference, QtCore.QVariant):
|
||||||
@ -529,7 +512,7 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
raw_footer = []
|
raw_footer = []
|
||||||
raw_slides = []
|
raw_slides = []
|
||||||
raw_title = []
|
raw_title = []
|
||||||
first = True
|
first_item = 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:
|
||||||
bitem = self.listView.item(item.row())
|
bitem = self.listView.item(item.row())
|
||||||
@ -570,9 +553,9 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
# We have to be 'Continuous'.
|
# We have to be 'Continuous'.
|
||||||
else:
|
else:
|
||||||
bible_text = u'%s %s %s\n' % (bible_text, verse_text, text)
|
bible_text = u'%s %s %s\n' % (bible_text, verse_text, text)
|
||||||
if first:
|
if first_item:
|
||||||
start_item = item
|
start_item = item
|
||||||
first = False
|
first_item = False
|
||||||
elif self.checkTitle(item, old_item):
|
elif self.checkTitle(item, old_item):
|
||||||
raw_title.append(self.formatTitle(start_item, old_item))
|
raw_title.append(self.formatTitle(start_item, old_item))
|
||||||
start_item = item
|
start_item = item
|
||||||
@ -590,10 +573,8 @@ class BibleMediaItem(MediaManagerItem):
|
|||||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||||
# Service Item: Title
|
# Service Item: Title
|
||||||
first = True
|
|
||||||
for title in raw_title:
|
for title in raw_title:
|
||||||
if first:
|
if not service_item.title:
|
||||||
first = False
|
|
||||||
service_item.title = title
|
service_item.title = title
|
||||||
else:
|
else:
|
||||||
service_item.title += u', ' + title
|
service_item.title += u', ' + title
|
||||||
@ -756,50 +737,52 @@ 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()
|
||||||
for count, verse in enumerate(self.search_results):
|
if self.search_results:
|
||||||
if dual_bible:
|
for count, verse in enumerate(self.search_results):
|
||||||
vdict = {
|
if dual_bible:
|
||||||
'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(dual_bible),
|
'text': QtCore.QVariant(verse.text),
|
||||||
'dual_version': QtCore.QVariant(dual_version.value),
|
'dual_bible': QtCore.QVariant(dual_bible),
|
||||||
'dual_copyright': QtCore.QVariant(dual_copyright.value),
|
'dual_version': QtCore.QVariant(dual_version.value),
|
||||||
'dual_permission': QtCore.QVariant(dual_permission.value),
|
'dual_copyright': QtCore.QVariant(dual_copyright.value),
|
||||||
'dual_text': QtCore.QVariant(
|
'dual_permission': QtCore.QVariant(
|
||||||
self.dual_search_results[count].text)
|
dual_permission.value),
|
||||||
}
|
'dual_text': QtCore.QVariant(
|
||||||
bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name,
|
self.dual_search_results[count].text)
|
||||||
verse.chapter, verse.verse, version.value,
|
}
|
||||||
dual_version.value)
|
bible_text = u' %s %d:%d (%s, %s)' % (verse.book.name,
|
||||||
else:
|
verse.chapter, verse.verse, version.value,
|
||||||
vdict = {
|
dual_version.value)
|
||||||
'book': QtCore.QVariant(verse.book.name),
|
else:
|
||||||
'chapter': QtCore.QVariant(verse.chapter),
|
vdict = {
|
||||||
'verse': QtCore.QVariant(verse.verse),
|
'book': QtCore.QVariant(verse.book.name),
|
||||||
'bible': QtCore.QVariant(bible),
|
'chapter': QtCore.QVariant(verse.chapter),
|
||||||
'version': QtCore.QVariant(version.value),
|
'verse': QtCore.QVariant(verse.verse),
|
||||||
'copyright': QtCore.QVariant(copyright.value),
|
'bible': QtCore.QVariant(bible),
|
||||||
'permission': QtCore.QVariant(permission.value),
|
'version': QtCore.QVariant(version.value),
|
||||||
'text': QtCore.QVariant(verse.text),
|
'copyright': QtCore.QVariant(copyright.value),
|
||||||
'dual_bible': QtCore.QVariant(u''),
|
'permission': QtCore.QVariant(permission.value),
|
||||||
'dual_version': QtCore.QVariant(u''),
|
'text': QtCore.QVariant(verse.text),
|
||||||
'dual_copyright': QtCore.QVariant(u''),
|
'dual_bible': QtCore.QVariant(u''),
|
||||||
'dual_permission': QtCore.QVariant(u''),
|
'dual_version': QtCore.QVariant(u''),
|
||||||
'dual_text': QtCore.QVariant(u'')
|
'dual_copyright': QtCore.QVariant(u''),
|
||||||
}
|
'dual_permission': QtCore.QVariant(u''),
|
||||||
bible_text = u' %s %d:%d (%s)' % (verse.book.name,
|
'dual_text': QtCore.QVariant(u'')
|
||||||
verse.chapter, verse.verse, version.value)
|
}
|
||||||
bible_verse = QtGui.QListWidgetItem(bible_text)
|
bible_text = u' %s %d:%d (%s)' % (verse.book.name,
|
||||||
bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(vdict))
|
verse.chapter, verse.verse, version.value)
|
||||||
self.listView.addItem(bible_verse)
|
bible_verse = QtGui.QListWidgetItem(bible_text)
|
||||||
row = self.listView.setCurrentRow(count + start_count)
|
bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(vdict))
|
||||||
if row:
|
self.listView.addItem(bible_verse)
|
||||||
row.setSelected(True)
|
row = self.listView.setCurrentRow(count + start_count)
|
||||||
self.search_results = {}
|
if row:
|
||||||
self.dual_search_results = {}
|
row.setSelected(True)
|
||||||
|
self.search_results = {}
|
||||||
|
self.dual_search_results = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user