started to rework bibles (dual/single verses)

This commit is contained in:
Andreas Preikschat 2010-09-11 21:36:47 +02:00
parent 66a22f7711
commit 6654a7993a
2 changed files with 69 additions and 65 deletions

View File

@ -173,8 +173,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'Empty Version Name'), 'Empty Version Name'),
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'You need to specify a version name for your ' 'You need to specify a version name for your Bible.'))
'Bible.'))
self.VersionNameEdit.setFocus() self.VersionNameEdit.setFocus()
return False return False
elif license_copyright == u'': elif license_copyright == u'':
@ -183,14 +182,12 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
'Empty Copyright'), 'Empty Copyright'),
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'You need to set a copyright for your Bible! ' 'You need to set a copyright for your Bible! '
'Bibles in the Public Domain need to be marked as ' 'Bibles in the Public Domain need to be marked as such.'))
'such.'))
self.CopyrightEdit.setFocus() self.CopyrightEdit.setFocus()
return False return False
elif self.manager.exists(license_version): elif self.manager.exists(license_version):
QtGui.QMessageBox.critical(self, QtGui.QMessageBox.critical(self,
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'),
'Bible Exists'),
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',
'This Bible already exists! Please import ' 'This Bible already exists! Please import '
'a different Bible or first delete the existing one.')) 'a different Bible or first delete the existing one.'))
@ -434,14 +431,12 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
unicode(self.field(u'proxy_username').toString()), unicode(self.field(u'proxy_username').toString()),
proxy_password=unicode(self.field(u'proxy_password').toString()) proxy_password=unicode(self.field(u'proxy_password').toString())
) )
success = importer.do_import() if importer.do_import():
if success:
self.manager.save_meta_data(license_version, license_version, self.manager.save_meta_data(license_version, license_version,
license_copyright, license_permission) license_copyright, license_permission)
self.manager.reload_bibles() self.manager.reload_bibles()
self.ImportProgressLabel.setText( self.ImportProgressLabel.setText(
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm', 'Finished import.'))
'Finished import.'))
else: else:
self.ImportProgressLabel.setText( self.ImportProgressLabel.setText(
translate('BiblesPlugin.ImportWizardForm', translate('BiblesPlugin.ImportWizardForm',

View File

@ -245,6 +245,10 @@ 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)
@ -438,8 +442,21 @@ 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:
self.AdvancedSecondBibleComboBox.setEnabled(False)
else:
self.AdvancedSecondBibleComboBox.setEnabled(True)
if self.AdvancedSecondBibleComboBox.findText(u'') != -1:
self.AdvancedSecondBibleComboBox.removeItem(0)
self.displayResults(bible, dual_bible) self.displayResults(bible, dual_bible)
def onClearAdvancedSearchComboBox(self):
self.listView.clear()
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
self.AdvancedSecondBibleComboBox.setEnabled(True)
if self.AdvancedSecondBibleComboBox.findText(u'') == -1:
self.AdvancedSecondBibleComboBox.insertItem(0, u'')
def onAdvancedFromChapter(self): def onAdvancedFromChapter(self):
bible = unicode(self.AdvancedVersionComboBox.currentText()) bible = unicode(self.AdvancedVersionComboBox.currentText())
book = unicode(self.AdvancedBookComboBox.currentText()) book = unicode(self.AdvancedBookComboBox.currentText())
@ -455,15 +472,28 @@ class BibleMediaItem(MediaManagerItem):
bible = unicode(self.QuickVersionComboBox.currentText()) bible = unicode(self.QuickVersionComboBox.currentText())
dual_bible = unicode(self.QuickSecondBibleComboBox.currentText()) dual_bible = unicode(self.QuickSecondBibleComboBox.currentText())
text = unicode(self.QuickSearchEdit.text()) text = unicode(self.QuickSearchEdit.text())
if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.listView.clear()
self.search_results = self.parent.manager.get_verses(bible, text) self.search_results = self.parent.manager.get_verses(bible, text)
if dual_bible: if dual_bible:
self.dual_search_results = self.parent.manager.get_verses( self.dual_search_results = self.parent.manager.get_verses(
dual_bible, text) dual_bible, text)
if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.listView.clear()
elif not dual_bible:
self.QuickSecondBibleComboBox.setEnabled(False)
else:
self.QuickSecondBibleComboBox.setEnabled(True)
if self.QuickSecondBibleComboBox.findText(u'') != -1:
self.QuickSecondBibleComboBox.removeItem(0)
if self.search_results: if self.search_results:
self.displayResults(bible, dual_bible) self.displayResults(bible, dual_bible)
def onClearQuickSearchComboBox(self):
self.listView.clear()
if self.ClearQuickSearchComboBox.currentIndex() == 0:
self.QuickSecondBibleComboBox.setEnabled(True)
if self.QuickSecondBibleComboBox.findText(u'') == -1:
self.QuickSecondBibleComboBox.insertItem(0, u'')
def generateSlideData(self, service_item, item=None): def generateSlideData(self, service_item, item=None):
""" """
Generates and formats the slides for the service item as well as the Generates and formats the slides for the service item as well as the
@ -473,20 +503,10 @@ class BibleMediaItem(MediaManagerItem):
items = self.listView.selectedIndexes() items = self.listView.selectedIndexes()
if len(items) == 0: if len(items) == 0:
return False return False
has_dual_bible = False
bible_text = u'' bible_text = u''
old_chapter = u'' old_chapter = u''
raw_footer = [] raw_footer = []
raw_slides = [] raw_slides = []
for item in items:
bitem = self.listView.item(item.row())
reference = bitem.data(QtCore.Qt.UserRole)
if isinstance(reference, QtCore.QVariant):
reference = reference.toPyObject()
dual_bible = self._decodeQtObject(reference, 'dual_bible')
if dual_bible:
has_dual_bible = True
break
# 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())
@ -514,26 +534,15 @@ class BibleMediaItem(MediaManagerItem):
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:
raw_footer.append(footer) raw_footer.append(footer)
if has_dual_bible:
if dual_bible: if dual_bible:
footer = u'%s (%s %s %s)' % (book, dual_version, footer = u'%s (%s %s %s)' % (book, dual_version,
dual_copyright, dual_permission) dual_copyright, dual_permission)
if footer not in raw_footer: if footer not in raw_footer:
raw_footer.append(footer) raw_footer.append(footer)
# If there is an old bible_text we have to add it.
if bible_text:
raw_slides.append(bible_text)
bible_text = u''
bible_text = u'%s %s\n\n%s %s' % (verse_text, text, bible_text = u'%s %s\n\n%s %s' % (verse_text, text,
verse_text, dual_text) verse_text, dual_text)
raw_slides.append(bible_text) raw_slides.append(bible_text)
bible_text = u'' bible_text = u''
elif self.parent.settings_tab.layout_style == 0:
bible_text = u'%s %s' % (verse_text, text)
raw_slides.append(bible_text)
bible_text = u''
else:
bible_text = u'%s %s %s\n' % (bible_text, verse_text, text)
# If we are 'Verse Per Slide' then create a new slide. # If we are 'Verse Per Slide' then create a new slide.
elif self.parent.settings_tab.layout_style == 0: elif self.parent.settings_tab.layout_style == 0:
bible_text = u'%s %s' % (verse_text, text) bible_text = u'%s %s' % (verse_text, text)
@ -551,19 +560,19 @@ class BibleMediaItem(MediaManagerItem):
raw_slides.append(bible_text) raw_slides.append(bible_text)
bible_text = u'' bible_text = u''
# Service Item: Capabilities # Service Item: Capabilities
if self.parent.settings_tab.layout_style == 2 and not has_dual_bible: if self.parent.settings_tab.layout_style == 2 and not dual_bible:
# split the line but do not replace line breaks in renderer # split the line but do not replace line breaks in renderer
service_item.add_capability(ItemCapabilities.NoLineBreaks) service_item.add_capability(ItemCapabilities.NoLineBreaks)
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.add_capability(ItemCapabilities.AllowsAdditions) #service_item.add_capability(ItemCapabilities.AllowsAdditions)
# Service Item: Title # Service Item: Title
if not service_item.title: if not service_item.title:
if dual_bible: if dual_bible:
service_item.title = u'%s (%s, %s) %s' % (book, version, service_item.title = u'%s %s (%s, %s)' % (book, version,
dual_version, verse_text) verse_text, dual_version)
else: else:
service_item.title = u'%s (%s) %s' % (book, version, verse_text) service_item.title = u'%s %s (%s)' % (book, verse_text, version)
elif service_item.title.find( elif service_item.title.find(
translate('BiblesPlugin.MediaItem', 'etc')) == -1: translate('BiblesPlugin.MediaItem', 'etc')) == -1:
service_item.title = u'%s, %s' % (service_item.title, service_item.title = u'%s, %s' % (service_item.title,