forked from openlp/openlp
started to rework bibles (dual/single verses)
This commit is contained in:
parent
66a22f7711
commit
6654a7993a
@ -126,29 +126,29 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
if self.field(u'osis_location').toString() == u'':
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Invalid Bible Location'),
|
||||
'Invalid Bible Location'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'You need to specify a file to import your '
|
||||
'Bible from.'))
|
||||
'You need to specify a file to import your '
|
||||
'Bible from.'))
|
||||
self.OSISLocationEdit.setFocus()
|
||||
return False
|
||||
elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV:
|
||||
if self.field(u'csv_booksfile').toString() == u'':
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Invalid Books File'),
|
||||
'Invalid Books File'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'You need to specify a file with books of '
|
||||
'the Bible to use in the import.'))
|
||||
'You need to specify a file with books of '
|
||||
'the Bible to use in the import.'))
|
||||
self.BooksLocationEdit.setFocus()
|
||||
return False
|
||||
elif self.field(u'csv_versefile').toString() == u'':
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Invalid Verse File'),
|
||||
'Invalid Verse File'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'You need to specify a file of Bible '
|
||||
'verses to import.'))
|
||||
'You need to specify a file of Bible '
|
||||
'verses to import.'))
|
||||
self.CsvVerseLocationEdit.setFocus()
|
||||
return False
|
||||
elif self.field(u'source_format').toInt()[0] == \
|
||||
@ -156,10 +156,10 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
if self.field(u'opensong_file').toString() == u'':
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Invalid OpenSong Bible'),
|
||||
'Invalid OpenSong Bible'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'You need to specify an OpenSong Bible '
|
||||
'file to import.'))
|
||||
'You need to specify an OpenSong Bible '
|
||||
'file to import.'))
|
||||
self.OpenSongFileEdit.setFocus()
|
||||
return False
|
||||
return True
|
||||
@ -171,29 +171,26 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
if license_version == u'':
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Empty Version Name'),
|
||||
'Empty Version Name'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'You need to specify a version name for your '
|
||||
'Bible.'))
|
||||
'You need to specify a version name for your Bible.'))
|
||||
self.VersionNameEdit.setFocus()
|
||||
return False
|
||||
elif license_copyright == u'':
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Empty Copyright'),
|
||||
'Empty Copyright'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'You need to set a copyright for your Bible! '
|
||||
'Bibles in the Public Domain need to be marked as '
|
||||
'such.'))
|
||||
'You need to set a copyright for your Bible! '
|
||||
'Bibles in the Public Domain need to be marked as such.'))
|
||||
self.CopyrightEdit.setFocus()
|
||||
return False
|
||||
elif self.manager.exists(license_version):
|
||||
QtGui.QMessageBox.critical(self,
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Bible Exists'),
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'This Bible already exists! Please import '
|
||||
'a different Bible or first delete the existing one.'))
|
||||
'This Bible already exists! Please import '
|
||||
'a different Bible or first delete the existing one.'))
|
||||
self.VersionNameEdit.setFocus()
|
||||
return False
|
||||
return True
|
||||
@ -434,18 +431,16 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
unicode(self.field(u'proxy_username').toString()),
|
||||
proxy_password=unicode(self.field(u'proxy_password').toString())
|
||||
)
|
||||
success = importer.do_import()
|
||||
if success:
|
||||
if importer.do_import():
|
||||
self.manager.save_meta_data(license_version, license_version,
|
||||
license_copyright, license_permission)
|
||||
self.manager.reload_bibles()
|
||||
self.ImportProgressLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Finished import.'))
|
||||
translate('BiblesPlugin.ImportWizardForm', 'Finished import.'))
|
||||
else:
|
||||
self.ImportProgressLabel.setText(
|
||||
translate('BiblesPlugin.ImportWizardForm',
|
||||
'Your Bible import failed.'))
|
||||
'Your Bible import failed.'))
|
||||
delete_database(self.bibleplugin.settingsSection, importer.file)
|
||||
|
||||
def postImport(self):
|
||||
|
@ -245,6 +245,10 @@ class BibleMediaItem(MediaManagerItem):
|
||||
QtCore.SIGNAL(u'activated(int)'), self.onAdvancedFromVerse)
|
||||
QtCore.QObject.connect(self.AdvancedToChapter,
|
||||
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
|
||||
QtCore.QObject.connect(self.AdvancedSearchButton,
|
||||
QtCore.SIGNAL(u'pressed()'), self.onAdvancedSearchButton)
|
||||
@ -438,8 +442,21 @@ class BibleMediaItem(MediaManagerItem):
|
||||
dual_bible, versetext)
|
||||
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
|
||||
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)
|
||||
|
||||
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):
|
||||
bible = unicode(self.AdvancedVersionComboBox.currentText())
|
||||
book = unicode(self.AdvancedBookComboBox.currentText())
|
||||
@ -455,15 +472,28 @@ class BibleMediaItem(MediaManagerItem):
|
||||
bible = unicode(self.QuickVersionComboBox.currentText())
|
||||
dual_bible = unicode(self.QuickSecondBibleComboBox.currentText())
|
||||
text = unicode(self.QuickSearchEdit.text())
|
||||
if self.ClearQuickSearchComboBox.currentIndex() == 0:
|
||||
self.listView.clear()
|
||||
self.search_results = self.parent.manager.get_verses(bible, text)
|
||||
if dual_bible:
|
||||
self.dual_search_results = self.parent.manager.get_verses(
|
||||
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:
|
||||
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):
|
||||
"""
|
||||
Generates and formats the slides for the service item as well as the
|
||||
@ -473,20 +503,10 @@ class BibleMediaItem(MediaManagerItem):
|
||||
items = self.listView.selectedIndexes()
|
||||
if len(items) == 0:
|
||||
return False
|
||||
has_dual_bible = False
|
||||
bible_text = u''
|
||||
old_chapter = u''
|
||||
raw_footer = []
|
||||
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.
|
||||
for item in items:
|
||||
bitem = self.listView.item(item.row())
|
||||
@ -514,26 +534,15 @@ class BibleMediaItem(MediaManagerItem):
|
||||
footer = u'%s (%s %s %s)' % (book, version, copyright, permission)
|
||||
if footer not in raw_footer:
|
||||
raw_footer.append(footer)
|
||||
if has_dual_bible:
|
||||
if dual_bible:
|
||||
footer = u'%s (%s %s %s)' % (book, dual_version,
|
||||
dual_copyright, dual_permission)
|
||||
if footer not in raw_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,
|
||||
verse_text, dual_text)
|
||||
raw_slides.append(bible_text)
|
||||
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 dual_bible:
|
||||
footer = u'%s (%s %s %s)' % (book, dual_version,
|
||||
dual_copyright, dual_permission)
|
||||
if footer not in raw_footer:
|
||||
raw_footer.append(footer)
|
||||
bible_text = u'%s %s\n\n%s %s' % (verse_text, text,
|
||||
verse_text, dual_text)
|
||||
raw_slides.append(bible_text)
|
||||
bible_text = u''
|
||||
# If we are 'Verse Per Slide' then create a new slide.
|
||||
elif self.parent.settings_tab.layout_style == 0:
|
||||
bible_text = u'%s %s' % (verse_text, text)
|
||||
@ -551,19 +560,19 @@ class BibleMediaItem(MediaManagerItem):
|
||||
raw_slides.append(bible_text)
|
||||
bible_text = u''
|
||||
# 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
|
||||
service_item.add_capability(ItemCapabilities.NoLineBreaks)
|
||||
service_item.add_capability(ItemCapabilities.AllowsPreview)
|
||||
service_item.add_capability(ItemCapabilities.AllowsLoop)
|
||||
service_item.add_capability(ItemCapabilities.AllowsAdditions)
|
||||
#service_item.add_capability(ItemCapabilities.AllowsAdditions)
|
||||
# Service Item: Title
|
||||
if not service_item.title:
|
||||
if dual_bible:
|
||||
service_item.title = u'%s (%s, %s) %s' % (book, version,
|
||||
dual_version, verse_text)
|
||||
service_item.title = u'%s %s (%s, %s)' % (book, version,
|
||||
verse_text, dual_version)
|
||||
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(
|
||||
translate('BiblesPlugin.MediaItem', 'etc')) == -1:
|
||||
service_item.title = u'%s, %s' % (service_item.title,
|
||||
|
Loading…
Reference in New Issue
Block a user