forked from openlp/openlp
add Bible Name to LanguageDialog
renamed "Importing" to "Upgrading" and "Choose" to "Select" fixed traceback while textsearch removed unnecessary code
This commit is contained in:
parent
e8cdba44be
commit
175d6cebb2
@ -80,8 +80,7 @@ class BiblePlugin(Plugin):
|
||||
"""
|
||||
Perform tasks on application starup
|
||||
"""
|
||||
if not len(self.manager.db_cache) and \
|
||||
len(self.manager.old_bible_databases):
|
||||
if len(self.manager.old_bible_databases):
|
||||
if QtGui.QMessageBox.information(self.formparent,
|
||||
translate('OpenLP', 'Information'), translate('OpenLP',
|
||||
'Bible format has changed.\nYou have to upgrade your '
|
||||
@ -114,7 +113,7 @@ class BiblePlugin(Plugin):
|
||||
The actual **Tools** menu item, so that your actions can
|
||||
use it as their parent.
|
||||
"""
|
||||
log.info(u'add tools menu')
|
||||
log.debug(u'add tools menu')
|
||||
self.toolsUpgradeItem = QtGui.QAction(tools_menu)
|
||||
self.toolsUpgradeItem.setObjectName(u'toolsUpgradeItem')
|
||||
self.toolsUpgradeItem.setText(
|
||||
|
@ -31,7 +31,6 @@ import csv
|
||||
import logging
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
|
@ -305,7 +305,8 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.versionInfoLabel[number].setText(
|
||||
translate('BiblesPlugin.UpgradeWizardForm', 'This '
|
||||
'Bible still exists. Please change the name or uncheck it.'))
|
||||
self.progressPage.setTitle(WizardStrings.Importing)
|
||||
self.progressPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading'))
|
||||
self.progressPage.setSubTitle(
|
||||
translate('BiblesPlugin.UpgradeWizardForm',
|
||||
'Please wait while your Bibles are upgraded.'))
|
||||
@ -459,7 +460,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
continue
|
||||
self.progressLabel.setText(unicode(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\nImporting ...')) %
|
||||
'Upgrading Bible %s of %s: "%s"\nUpgrading ...')) %
|
||||
(number + 1, self.maxBibles, name))
|
||||
if os.path.exists(os.path.join(self.path, filename)):
|
||||
name = unicode(self.versionNameEdit[biblenumber].text())
|
||||
@ -489,7 +490,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
handler = BSExtract(proxy_server)
|
||||
books = handler.get_books_from_http(meta_data[u'download name'])
|
||||
if not books:
|
||||
log.exception(u'Importing books from %s - download '\
|
||||
log.exception(u'Upgrading books from %s - download '\
|
||||
u'name: "%s" failed' % (
|
||||
meta_data[u'download source'],
|
||||
meta_data[u'download name']))
|
||||
@ -518,7 +519,7 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.newbibles[number].create_meta(u'language_id',
|
||||
language_id)
|
||||
else:
|
||||
language_id = self.newbibles[number].get_language()
|
||||
language_id = self.newbibles[number].get_language(name)
|
||||
if not language_id:
|
||||
log.exception(u'Upgrading from "%s" '\
|
||||
'failed' % filename)
|
||||
@ -539,12 +540,12 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\n'
|
||||
'Importing %s ...')) %
|
||||
'Upgrading %s ...')) %
|
||||
(number+1, self.maxBibles, name, book))
|
||||
book_ref_id = self.newbibles[number].\
|
||||
get_book_ref_id_by_name(book, len(books), language_id)
|
||||
if not book_ref_id:
|
||||
log.exception(u'Importing books from %s - download '\
|
||||
log.exception(u'Upgrading books from %s - download '\
|
||||
u'name: "%s" aborted by user' % (
|
||||
meta_data[u'download source'],
|
||||
meta_data[u'download name']))
|
||||
@ -560,9 +561,9 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
language_id = self.newbibles[number].get_object(BibleMeta,
|
||||
u'language_id')
|
||||
if not language_id:
|
||||
language_id = self.newbibles[number].get_language()
|
||||
language_id = self.newbibles[number].get_language(name)
|
||||
if not language_id:
|
||||
log.exception(u'Importing books from "%s" '\
|
||||
log.exception(u'Upgrading books from "%s" '\
|
||||
'failed' % name)
|
||||
delete_database(self.path,
|
||||
clean_filename(self.newbibles[number].get_name()))
|
||||
@ -582,13 +583,13 @@ class BibleUpgradeForm(OpenLPWizard):
|
||||
self.incrementProgressBar(unicode(translate(
|
||||
'BiblesPlugin.UpgradeWizardForm',
|
||||
'Upgrading Bible %s of %s: "%s"\n'
|
||||
'Importing %s ...')) %
|
||||
'Upgrading %s ...')) %
|
||||
(number+1, self.maxBibles, name, book[u'name']))
|
||||
book_ref_id = self.newbibles[number].\
|
||||
get_book_ref_id_by_name(book[u'name'], len(books),
|
||||
language_id)
|
||||
if not book_ref_id:
|
||||
log.exception(u'Importing books from %s " '\
|
||||
log.exception(u'Upgrading books from %s " '\
|
||||
'failed - aborted by user' % name)
|
||||
delete_database(self.path,
|
||||
clean_filename(self.newbibles[number].get_name()))
|
||||
|
@ -100,12 +100,12 @@ class Ui_BookNameDialog(object):
|
||||
|
||||
def retranslateUi(self, bookNameDialog):
|
||||
bookNameDialog.setWindowTitle(
|
||||
translate('BiblesPlugin.BookNameDialog', 'Choose Book'))
|
||||
translate('BiblesPlugin.BookNameDialog', 'Select Book'))
|
||||
self.headlineLabel.setText(
|
||||
translate('BiblesPlugin.BookNameDialog', 'Choose Book:'))
|
||||
translate('BiblesPlugin.BookNameDialog', 'Select Book:'))
|
||||
self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog',
|
||||
'The following books cannot be clearly attributed. \n'
|
||||
'Please choose which book it is.'))
|
||||
'Please select which book it is.'))
|
||||
self.requestLabel.setText(translate('BiblesPlugin.BookNameDialog',
|
||||
'Book:'))
|
||||
self.infoLabelTestaments.setText(translate(
|
||||
|
@ -116,7 +116,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
|
||||
if self.requestComboBox.currentText() == u'':
|
||||
critical_error_message_box(
|
||||
message=translate('BiblesPlugin.BookNameForm',
|
||||
'You need to choose a book.'))
|
||||
'You need to select a book.'))
|
||||
self.requestComboBox.setFocus()
|
||||
return False
|
||||
else:
|
||||
|
@ -85,10 +85,10 @@ class Ui_LanguageDialog(object):
|
||||
|
||||
def retranslateUi(self, languageDialog):
|
||||
languageDialog.setWindowTitle(
|
||||
translate('BiblesPlugin.LanguageDialog', 'Choose Language'))
|
||||
translate('BiblesPlugin.LanguageDialog', 'Select Language'))
|
||||
self.headlineLabel.setText(
|
||||
translate('BiblesPlugin.LanguageDialog', 'Choose Language:'))
|
||||
translate('BiblesPlugin.LanguageDialog', 'Select Language:'))
|
||||
self.infoLabel.setText(translate('BiblesPlugin.LanguageDialog',
|
||||
'Please choose the Bible\'s language'))
|
||||
'Please select the Bible\'s language'))
|
||||
self.requestLabel.setText(translate('BiblesPlugin.languageDialog',
|
||||
'Language:'))
|
||||
|
@ -52,8 +52,13 @@ class LanguageForm(QDialog, Ui_LanguageDialog):
|
||||
QDialog.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
|
||||
def exec_(self):
|
||||
def exec_(self, bible_name):
|
||||
self.requestComboBox.addItem(u'')
|
||||
if bible_name:
|
||||
self.infoLabel.setText(unicode(translate(
|
||||
'BiblesPlugin.LanguageDialog',
|
||||
'Please select the language for Bible:\n"%s"')) %
|
||||
bible_name)
|
||||
items = BiblesResourcesDB.get_languages()
|
||||
for item in items:
|
||||
self.requestComboBox.addItem(item[u'name'])
|
||||
@ -63,7 +68,7 @@ class LanguageForm(QDialog, Ui_LanguageDialog):
|
||||
if self.requestComboBox.currentText() == u'':
|
||||
critical_error_message_box(
|
||||
message=translate('BiblesPlugin.LanguageForm',
|
||||
'You need to choose a language.'))
|
||||
'You need to select a language.'))
|
||||
self.requestComboBox.setFocus()
|
||||
return False
|
||||
else:
|
||||
|
@ -396,7 +396,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
.all()
|
||||
verse_list.extend(verses)
|
||||
else:
|
||||
log.debug(u'OpenLP failed to find book %s', book)
|
||||
log.debug(u'OpenLP failed to find book with id "%s"', book_id)
|
||||
if show_error:
|
||||
critical_error_message_box(
|
||||
translate('BiblesPlugin', 'No Book Found'),
|
||||
@ -466,10 +466,10 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
else:
|
||||
return count
|
||||
|
||||
def get_language(self):
|
||||
def get_language(self, bible_name=None):
|
||||
"""
|
||||
If no language is given it calls a dialog window where the user could
|
||||
choose the bible language.
|
||||
select the bible language.
|
||||
Return the language id of a bible.
|
||||
|
||||
``book``
|
||||
@ -479,7 +479,7 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
from openlp.plugins.bibles.forms import LanguageForm
|
||||
language = None
|
||||
language_form = LanguageForm(self.wizard)
|
||||
if language_form.exec_():
|
||||
if language_form.exec_(bible_name):
|
||||
language = unicode(language_form.requestComboBox.currentText())
|
||||
if not language:
|
||||
return False
|
||||
@ -488,9 +488,10 @@ class BibleDB(QtCore.QObject, Manager):
|
||||
self.create_meta(u'language_id', language_id)
|
||||
return language_id
|
||||
|
||||
def find_old_database(self):
|
||||
def is_old_database(self):
|
||||
"""
|
||||
Returns true if it is an old bible database.
|
||||
Returns ``True`` if it is a bible database, which has been created
|
||||
prior to 1.9.6.
|
||||
"""
|
||||
try:
|
||||
columns = self.session.query(Book).all()
|
||||
|
@ -154,7 +154,7 @@ class BibleManager(object):
|
||||
delete_file(os.path.join(self.path, filename))
|
||||
continue
|
||||
# Find old database versions
|
||||
if bible.find_old_database():
|
||||
if bible.is_old_database():
|
||||
self.old_bible_databases.append(filename)
|
||||
continue
|
||||
log.debug(u'Bible Name: "%s"', name)
|
||||
|
Loading…
Reference in New Issue
Block a user