forked from openlp/openlp
fixes
This commit is contained in:
parent
5f16ddc73c
commit
665c27c785
@ -69,11 +69,11 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
||||
self.manager.get_meta_data(self.bible, u'Copyright').value)
|
||||
self.permissionsEdit.setText(
|
||||
self.manager.get_meta_data(self.bible, u'Permissions').value)
|
||||
self.bookname_language = self.manager.get_meta_data(
|
||||
self.bible, u'Bookname language')
|
||||
if self.bookname_language:
|
||||
bookname_language = self.manager.get_meta_data(self.bible,
|
||||
u'Bookname language')
|
||||
if bookname_language and bookname_language.value != u'None':
|
||||
self.languageSelectionComboBox.setCurrentIndex(
|
||||
int(self.bookname_language.value) + 1)
|
||||
int(bookname_language.value) + 1)
|
||||
self.books = {}
|
||||
self.webbible = self.manager.get_meta_data(self.bible,
|
||||
u'download source')
|
||||
@ -116,12 +116,13 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
||||
Exit Dialog and save data
|
||||
"""
|
||||
log.debug(u'BibleEditForm.accept')
|
||||
self.version = unicode(self.versionNameEdit.text())
|
||||
self.copyright = unicode(self.copyrightEdit.text())
|
||||
self.permissions = unicode(self.permissionsEdit.text())
|
||||
self.bookname_language = \
|
||||
self.languageSelectionComboBox.currentIndex() - 1
|
||||
if not self.validateMeta():
|
||||
version = unicode(self.versionNameEdit.text())
|
||||
copyright = unicode(self.copyrightEdit.text())
|
||||
permissions = unicode(self.permissionsEdit.text())
|
||||
bookname_language = self.languageSelectionComboBox.currentIndex() - 1
|
||||
if bookname_language == -1:
|
||||
bookname_language = None
|
||||
if not self.validateMeta(version, copyright):
|
||||
return
|
||||
if not self.webbible:
|
||||
custom_names = {}
|
||||
@ -133,8 +134,8 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
||||
return
|
||||
Receiver.send_message(u'openlp_process_events')
|
||||
Receiver.send_message(u'cursor_busy')
|
||||
self.manager.save_meta_data(self.bible, self.version,
|
||||
self.copyright, self.permissions, self.bookname_language)
|
||||
self.manager.save_meta_data(self.bible, version, copyright, permissions,
|
||||
bookname_language)
|
||||
if not self.webbible:
|
||||
for abbr, book in self.books.iteritems():
|
||||
if book:
|
||||
@ -145,26 +146,26 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
|
||||
Receiver.send_message(u'cursor_normal')
|
||||
QtGui.QDialog.accept(self)
|
||||
|
||||
def validateMeta(self):
|
||||
def validateMeta(self, version, copyright):
|
||||
"""
|
||||
Validate the Meta before saving.
|
||||
"""
|
||||
if not self.version:
|
||||
if not version:
|
||||
self.versionNameEdit.setFocus()
|
||||
critical_error_message_box(UiStrings().EmptyField,
|
||||
translate('BiblesPlugin.BibleEditForm',
|
||||
'You need to specify a version name for your Bible.'))
|
||||
return False
|
||||
elif not self.copyright:
|
||||
elif not copyright:
|
||||
self.copyrightEdit.setFocus()
|
||||
critical_error_message_box(UiStrings().EmptyField,
|
||||
translate('BiblesPlugin.BibleEditForm',
|
||||
'You need to set a copyright for your Bible. '
|
||||
'Bibles in the Public Domain need to be marked as such.'))
|
||||
return False
|
||||
elif self.manager.exists(self.version) and \
|
||||
elif self.manager.exists(version) and \
|
||||
self.manager.get_meta_data(self.bible, u'Version').value != \
|
||||
self.version:
|
||||
version:
|
||||
self.versionNameEdit.setFocus()
|
||||
critical_error_message_box(
|
||||
translate('BiblesPlugin.BibleEditForm', 'Bible Exists'),
|
||||
|
@ -140,14 +140,14 @@ class BibleManager(object):
|
||||
BibleDB class.
|
||||
"""
|
||||
log.debug(u'Reload bibles')
|
||||
self.files = SettingsManager.get_files(self.settingsSection,
|
||||
files = SettingsManager.get_files(self.settingsSection,
|
||||
self.suffix)
|
||||
if u'alternative_book_names.sqlite' in self.files:
|
||||
self.files.remove(u'alternative_book_names.sqlite')
|
||||
log.debug(u'Bible Files %s', self.files)
|
||||
if u'alternative_book_names.sqlite' in files:
|
||||
files.remove(u'alternative_book_names.sqlite')
|
||||
log.debug(u'Bible Files %s', files)
|
||||
self.db_cache = {}
|
||||
self.old_bible_databases = []
|
||||
for filename in self.files:
|
||||
for filename in files:
|
||||
bible = BibleDB(self.parent, path=self.path, file=filename)
|
||||
name = bible.get_name()
|
||||
# Remove corrupted files.
|
||||
@ -211,7 +211,12 @@ class BibleManager(object):
|
||||
``name``
|
||||
The name of the bible.
|
||||
"""
|
||||
for filename in self.files:
|
||||
log.debug(u'BibleManager.delete_bible("%s")', name)
|
||||
files = SettingsManager.get_files(self.settingsSection,
|
||||
self.suffix)
|
||||
if u'alternative_book_names.sqlite' in files:
|
||||
files.remove(u'alternative_book_names.sqlite')
|
||||
for filename in files:
|
||||
bible = BibleDB(self.parent, path=self.path, file=filename)
|
||||
# Remove the bible files
|
||||
if name == bible.get_name():
|
||||
@ -364,6 +369,22 @@ class BibleManager(object):
|
||||
})
|
||||
return None
|
||||
|
||||
def get_language_selection(self, bible):
|
||||
"""
|
||||
Returns the language selection of a bible.
|
||||
|
||||
``bible``
|
||||
Unicode. The Bible to get the language selection from.
|
||||
"""
|
||||
log.debug(u'BibleManager.get_language_selection("%s")', bible)
|
||||
language_selection = self.get_meta_data(bible, u'Bookname language')
|
||||
if language_selection and language_selection.value != u'None':
|
||||
return int(language_selection.value)
|
||||
if language_selection is None or language_selection.value == u'None':
|
||||
return QtCore.QSettings().value(
|
||||
self.settingsSection + u'/bookname language',
|
||||
QtCore.QVariant(0)).toInt()[0]
|
||||
|
||||
def verse_search(self, bible, second_bible, text):
|
||||
"""
|
||||
Does a verse search for the given bible and text.
|
||||
@ -417,7 +438,7 @@ class BibleManager(object):
|
||||
return None
|
||||
|
||||
def save_meta_data(self, bible, version, copyright, permissions,
|
||||
bookname_language=-1):
|
||||
bookname_language=None):
|
||||
"""
|
||||
Saves the bibles meta data.
|
||||
"""
|
||||
|
@ -432,14 +432,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
book_data = book_data_temp
|
||||
self.advancedBookComboBox.clear()
|
||||
first = True
|
||||
language_selection = self.plugin.manager.get_meta_data(
|
||||
bible, u'Bookname language')
|
||||
if language_selection:
|
||||
language_selection = int(language_selection.value)
|
||||
if language_selection is None or language_selection == -1:
|
||||
language_selection = QtCore.QSettings().value(
|
||||
self.settingsSection + u'/bookname language',
|
||||
QtCore.QVariant(0)).toInt()[0]
|
||||
language_selection = self.plugin.manager.get_language_selection(bible)
|
||||
booknames = BibleStrings().Booknames
|
||||
for book in book_data:
|
||||
row = self.advancedBookComboBox.count()
|
||||
@ -511,14 +504,8 @@ class BibleMediaItem(MediaManagerItem):
|
||||
secondbook.book_reference_id:
|
||||
book_data_temp.append(book)
|
||||
book_data = book_data_temp
|
||||
language_selection = self.plugin.manager.get_meta_data(
|
||||
bible, u'Bookname language')
|
||||
if language_selection:
|
||||
language_selection = int(language_selection.value)
|
||||
if language_selection is None or language_selection == -1:
|
||||
language_selection = QtCore.QSettings().value(
|
||||
self.settingsSection + u'/bookname language',
|
||||
QtCore.QVariant(0)).toInt()[0]
|
||||
language_selection = self.plugin.manager.get_language_selection(
|
||||
bible)
|
||||
if language_selection == LanguageSelection.Bible:
|
||||
books = [book.name + u' ' for book in book_data]
|
||||
elif language_selection == LanguageSelection.Application:
|
||||
@ -834,14 +821,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
second_permissions = self.plugin.manager.get_meta_data(
|
||||
second_bible, u'Permissions').value
|
||||
items = []
|
||||
language_selection = self.plugin.manager.get_meta_data(
|
||||
bible, u'Bookname language')
|
||||
if language_selection:
|
||||
language_selection = int(language_selection.value)
|
||||
if language_selection is None or language_selection == -1:
|
||||
language_selection = QtCore.QSettings().value(
|
||||
self.settingsSection + u'/bookname language',
|
||||
QtCore.QVariant(0)).toInt()[0]
|
||||
language_selection = self.plugin.manager.get_language_selection(bible)
|
||||
for count, verse in enumerate(search_results):
|
||||
if language_selection == LanguageSelection.Bible:
|
||||
book = verse.book.name
|
||||
|
Loading…
Reference in New Issue
Block a user