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