openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #14318
[Merge] lp:~orangeshirt/openlp/bibles into lp:openlp
Armin Köhler has proposed merging lp:~orangeshirt/openlp/bibles into lp:openlp.
Requested reviews:
Raoul Snyman (raoul-snyman)
Related bugs:
Bug #822363 in OpenLP: "[i18n] OSIS Bible Book Names are always in English"
https://bugs.launchpad.net/openlp/+bug/822363
For more details, see:
https://code.launchpad.net/~orangeshirt/openlp/bibles/+merge/96437
add possibility to switch the booknames of bibles to Application Language or English
fix bug #822363
Could a native english speaker take a close look at the new English strings. Thanks.
--
https://code.launchpad.net/~orangeshirt/openlp/bibles/+merge/96437
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/__init__.py'
--- openlp/plugins/bibles/lib/__init__.py 2012-02-05 19:20:01 +0000
+++ openlp/plugins/bibles/lib/__init__.py 2012-03-07 19:24:35 +0000
@@ -34,6 +34,7 @@
from PyQt4 import QtCore
from openlp.core.lib import translate
+from openlp.plugins.bibles.lib.db import BiblesResourcesDB
log = logging.getLogger(__name__)
@@ -59,6 +60,122 @@
Square = 3
+class LanguageSelection(object):
+ """
+ An enumeration for bible bookname language.
+ And standard strings for use throughout the bibles plugin.
+ """
+ Bible = 0
+ Application = 1
+ English = 2
+
+
+class BibleStrings(object):
+ """
+ Provide standard strings for objects to use.
+ """
+ __instance__ = None
+
+ def __new__(cls):
+ """
+ Override the default object creation method to return a single instance.
+ """
+ if not cls.__instance__:
+ cls.__instance__ = object.__new__(cls)
+ return cls.__instance__
+
+ def __init__(self):
+ """
+ These strings should need a good reason to be retranslated elsewhere.
+ """
+ self.Booknames = {
+ u'Gen': translate('BiblesPlugin','Genesis'),
+ u'Exod': translate('BiblesPlugin','Exodus'),
+ u'Lev': translate('BiblesPlugin','Leviticus'),
+ u'Num': translate('BiblesPlugin','Numbers'),
+ u'Deut': translate('BiblesPlugin','Deuteronomy'),
+ u'Josh': translate('BiblesPlugin','Joshua'),
+ u'Judg': translate('BiblesPlugin','Judges'),
+ u'Ruth': translate('BiblesPlugin','Ruth'),
+ u'1Sam': translate('BiblesPlugin','1 Samuel'),
+ u'2Sam': translate('BiblesPlugin','2 Samuel'),
+ u'1Kgs': translate('BiblesPlugin','1 Kings'),
+ u'2Kgs': translate('BiblesPlugin','2 Kings'),
+ u'1Chr': translate('BiblesPlugin','1 Chronicles'),
+ u'2Chr': translate('BiblesPlugin','2 Chronicles'),
+ u'Esra': translate('BiblesPlugin','Ezra'),
+ u'Neh': translate('BiblesPlugin','Nehemiah'),
+ u'Esth': translate('BiblesPlugin','Esther'),
+ u'Job': translate('BiblesPlugin','Job'),
+ u'Ps': translate('BiblesPlugin','Psalms'),
+ u'Prov': translate('BiblesPlugin','Proverbs'),
+ u'Eccl': translate('BiblesPlugin','Ecclesiastes'),
+ u'Song': translate('BiblesPlugin','Song of Solomon'),
+ u'Isa': translate('BiblesPlugin','Isaiah'),
+ u'Jer': translate('BiblesPlugin','Jeremiah'),
+ u'Lam': translate('BiblesPlugin','Lamentations'),
+ u'Ezek': translate('BiblesPlugin','Ezekiel'),
+ u'Dan': translate('BiblesPlugin','Daniel'),
+ u'Hos': translate('BiblesPlugin','Hosea'),
+ u'Joel': translate('BiblesPlugin','Joel'),
+ u'Amos': translate('BiblesPlugin','Amos'),
+ u'Obad': translate('BiblesPlugin','Obadiah'),
+ u'Jonah': translate('BiblesPlugin','Jonah'),
+ u'Mic': translate('BiblesPlugin','Micah'),
+ u'Nah': translate('BiblesPlugin','Nahum'),
+ u'Hab': translate('BiblesPlugin','Habakkuk'),
+ u'Zeph': translate('BiblesPlugin','Zephaniah'),
+ u'Hag': translate('BiblesPlugin','Haggai'),
+ u'Zech': translate('BiblesPlugin','Zechariah'),
+ u'Mal': translate('BiblesPlugin','Malachi'),
+ u'Matt': translate('BiblesPlugin','Matthew'),
+ u'Mark': translate('BiblesPlugin','Mark'),
+ u'Luke': translate('BiblesPlugin','Luke'),
+ u'John': translate('BiblesPlugin','John'),
+ u'Acts': translate('BiblesPlugin','Acts'),
+ u'Rom': translate('BiblesPlugin','Romans'),
+ u'1Cor': translate('BiblesPlugin','1 Corinthians'),
+ u'2Cor': translate('BiblesPlugin','2 Corinthians'),
+ u'Gal': translate('BiblesPlugin','Galatians'),
+ u'Eph': translate('BiblesPlugin','Ephesians'),
+ u'Phil': translate('BiblesPlugin','Philippians'),
+ u'Col': translate('BiblesPlugin','Colossians'),
+ u'1Thess': translate('BiblesPlugin','1 Thessalonians'),
+ u'2Thess': translate('BiblesPlugin','2 Thessalonians'),
+ u'1Tim': translate('BiblesPlugin','1 Timothy'),
+ u'2Tim': translate('BiblesPlugin','2 Timothy'),
+ u'Titus': translate('BiblesPlugin','Titus'),
+ u'Phlm': translate('BiblesPlugin','Philemon'),
+ u'Heb': translate('BiblesPlugin','Hebrews'),
+ u'Jas': translate('BiblesPlugin','James'),
+ u'1Pet': translate('BiblesPlugin','1 Peter'),
+ u'2Pet': translate('BiblesPlugin','2 Peter'),
+ u'1John': translate('BiblesPlugin','1 John'),
+ u'2John': translate('BiblesPlugin','2 John'),
+ u'3John': translate('BiblesPlugin','3 John'),
+ u'Jude': translate('BiblesPlugin','Jude'),
+ u'Rev': translate('BiblesPlugin','Revelation'),
+ u'Jdt': translate('BiblesPlugin','Judith'),
+ u'Wis': translate('BiblesPlugin','Wisdom'),
+ u'Tob': translate('BiblesPlugin','Tobit'),
+ u'Sir': translate('BiblesPlugin','Sirach'),
+ u'Bar': translate('BiblesPlugin','Baruch'),
+ u'1Macc': translate('BiblesPlugin','1 Maccabees'),
+ u'2Macc': translate('BiblesPlugin','2 Maccabees'),
+ u'3Macc': translate('BiblesPlugin','3 Maccabees'),
+ u'4Macc': translate('BiblesPlugin','4 Maccabees'),
+ u'AddDan': translate('BiblesPlugin','Rest of Daniel'),
+ u'AddEsth': translate('BiblesPlugin','Rest of Esther'),
+ u'PrMan': translate('BiblesPlugin','Prayer of Manasses'),
+ u'LetJer': translate('BiblesPlugin','Letter of Jeremiah'),
+ u'PrAza': translate('BiblesPlugin','Prayer of Azariah'),
+ u'Sus': translate('BiblesPlugin','Susanna'),
+ u'Bel': translate('BiblesPlugin','Bel'),
+ u'1Esdr': translate('BiblesPlugin','1 Esdras'),
+ u'2Esdr': translate('BiblesPlugin','2 Esdras')
+ }
+
+
def update_reference_separators():
"""
Updates separators and matches for parsing and formating scripture
@@ -139,7 +256,7 @@
update_reference_separators()
return REFERENCE_MATCHES[match_type]
-def parse_reference(reference):
+def parse_reference(reference, bible, language_selection, book_ref_id=False):
"""
This is the next generation über-awesome function that takes a person's
typed in string and converts it to a list of references to be queried from
@@ -147,6 +264,16 @@
``reference``
A string. The Bible reference to parse.
+
+ ``bible``
+ A object. The Bible database object.
+
+ ``language_selection``
+ An int. The language selection the user has choosen in settings
+ section.
+
+ ``book_ref_id``
+ A string. The book reference id.
Returns ``None`` or a reference list.
@@ -232,6 +359,51 @@
if match:
log.debug(u'Matched reference %s' % reference)
book = match.group(u'book')
+ if not book_ref_id:
+ booknames = BibleStrings().Booknames
+ # escape reserved characters
+ book_escaped = book
+ for character in u'\\.^$*+?{}[]()':
+ book_escaped = book_escaped.replace(
+ character, u'\\' + character)
+ regex_book = re.compile(u'\s*%s\s*' % u'\s*'.join(
+ book_escaped.split()), re.UNICODE | re.IGNORECASE)
+ if language_selection == LanguageSelection.Bible:
+ db_book = bible.get_book(book)
+ if db_book:
+ book_ref_id = db_book.book_reference_id
+ elif language_selection == LanguageSelection.Application:
+ book_list = []
+ for key, value in booknames.iteritems():
+ if regex_book.match(unicode(value)):
+ book_list.append(key)
+ books = []
+ if book_list:
+ for value in book_list:
+ item = BiblesResourcesDB.get_book(value)
+ if item:
+ books.append(item)
+ if books:
+ for value in books:
+ if bible.get_book_by_book_ref_id(value[u'id']):
+ book_ref_id = value[u'id']
+ break
+ elif language_selection == LanguageSelection.English:
+ books = BiblesResourcesDB.get_books_like(book)
+ if books:
+ book_list = []
+ for value in books:
+ if regex_book.match(value[u'name']):
+ book_list.append(value)
+ if not book_list:
+ book_list = books
+ for value in book_list:
+ if bible.get_book_by_book_ref_id(value[u'id']):
+ book_ref_id = value[u'id']
+ break
+ else:
+ if not bible.get_book_by_book_ref_id(book_ref_id):
+ book_ref_id = False
ranges = match.group(u'ranges')
range_list = get_reference_match(u'range_separator').split(ranges)
ref_list = []
@@ -277,16 +449,18 @@
if not to_verse:
to_verse = -1
if to_chapter > from_chapter:
- ref_list.append((book, from_chapter, from_verse, -1))
+ ref_list.append((book_ref_id, from_chapter, from_verse, -1))
for i in range(from_chapter + 1, to_chapter):
- ref_list.append((book, i, 1, -1))
- ref_list.append((book, to_chapter, 1, to_verse))
+ ref_list.append((book_ref_id, i, 1, -1))
+ ref_list.append((book_ref_id, to_chapter, 1, to_verse))
elif to_verse >= from_verse or to_verse == -1:
- ref_list.append((book, from_chapter, from_verse, to_verse))
+ ref_list.append((book_ref_id, from_chapter,
+ from_verse, to_verse))
elif from_verse:
- ref_list.append((book, from_chapter, from_verse, from_verse))
+ ref_list.append((book_ref_id, from_chapter,
+ from_verse, from_verse))
else:
- ref_list.append((book, from_chapter, 1, -1))
+ ref_list.append((book_ref_id, from_chapter, 1, -1))
return ref_list
else:
log.debug(u'Invalid reference: %s' % reference)
=== modified file 'openlp/plugins/bibles/lib/biblestab.py'
--- openlp/plugins/bibles/lib/biblestab.py 2012-02-05 19:20:01 +0000
+++ openlp/plugins/bibles/lib/biblestab.py 2012-03-07 19:24:35 +0000
@@ -32,7 +32,7 @@
from openlp.core.lib import Receiver, SettingsTab, translate
from openlp.core.lib.ui import UiStrings, find_and_set_in_combo_box
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
- update_reference_separators, get_reference_separator
+ update_reference_separators, get_reference_separator, LanguageSelection
log = logging.getLogger(__name__)
@@ -140,9 +140,25 @@
self.scriptureReferenceLayout.addWidget(self.endSeparatorLineEdit, 3,
1)
self.leftLayout.addWidget(self.scriptureReferenceGroupBox)
- self.leftLayout.addStretch()
self.rightColumn.setSizePolicy(
QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
+ self.languageSelectionGroupBox = QtGui.QGroupBox(self.rightColumn)
+ self.languageSelectionGroupBox.setObjectName(
+ u'languageSelectionGroupBox')
+ self.languageSelectionLayout = QtGui.QVBoxLayout(
+ self.languageSelectionGroupBox)
+ self.languageSelectionLabel = QtGui.QLabel(
+ self.languageSelectionGroupBox)
+ self.languageSelectionLabel.setObjectName(u'languageSelectionLabel')
+ self.languageSelectionComboBox = QtGui.QComboBox(
+ self.languageSelectionGroupBox)
+ self.languageSelectionComboBox.setObjectName(
+ u'languageSelectionComboBox')
+ self.languageSelectionComboBox.addItems([u'', u'', u''])
+ self.languageSelectionLayout.addWidget(self.languageSelectionLabel)
+ self.languageSelectionLayout.addWidget(self.languageSelectionComboBox)
+ self.rightLayout.addWidget(self.languageSelectionGroupBox)
+ self.leftLayout.addStretch()
self.rightLayout.addStretch()
# Signals and slots
QtCore.QObject.connect(
@@ -198,6 +214,9 @@
self.onEndSeparatorLineEditFinished)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
+ QtCore.QObject.connect(
+ self.languageSelectionComboBox, QtCore.SIGNAL(u'activated(int)'),
+ self.onLanguageSelectionComboBoxChanged)
def retranslateUi(self):
self.verseDisplayGroupBox.setTitle(
@@ -257,6 +276,24 @@
'end marks may be defined.\nThey have to be separated by a '
'vertical bar "|".\nPlease clear this edit line to use the '
'default value.'))
+ self.languageSelectionGroupBox.setTitle(
+ translate('BiblesPlugin.BiblesTab', 'Preferred Bookname Language'))
+ self.languageSelectionLabel.setText(translate('BiblesPlugin.BiblesTab',
+ 'Choose the language in which the book names of the\nbible should '
+ 'be displayed in advanced search or on\nautocompleter in quick '
+ 'search:'))
+ self.languageSelectionComboBox.setItemText(LanguageSelection.Bible,
+ translate('BiblesPlugin.BiblesTab', 'Bible language'))
+ self.languageSelectionComboBox.setItemText(
+ LanguageSelection.Application,
+ translate('BiblesPlugin.BiblesTab', 'Application language'))
+ self.languageSelectionComboBox.setItemText(LanguageSelection.English,
+ translate('BiblesPlugin.BiblesTab', 'English'))
+ self.languageSelectionComboBox.setToolTip(
+ translate('BiblesPlugin.BiblesTab', 'Multiple options:\n '
+ 'Bible language - the language in which the bible book names '
+ 'was imported\n Application language - the language you have '
+ 'choosen for Openlp\n English - use always English booknames'))
def onBibleThemeComboBoxChanged(self):
self.bible_theme = self.bibleThemeComboBox.currentText()
@@ -267,6 +304,9 @@
def onLayoutStyleComboBoxChanged(self):
self.layout_style = self.layoutStyleComboBox.currentIndex()
+ def onLanguageSelectionComboBoxChanged(self):
+ self.language_selection = self.languageSelectionComboBox.currentIndex()
+
def onNewChaptersCheckBoxChanged(self, check_state):
self.show_new_chapters = False
# We have a set value convert to True/False.
@@ -448,6 +488,9 @@
self.endSeparatorLineEdit.setPalette(
self.getGreyTextPalette(False))
self.endSeparatorCheckBox.setChecked(True)
+ self.language_selection = settings.value(
+ u'bookname language', QtCore.QVariant(0)).toInt()[0]
+ self.languageSelectionComboBox.setCurrentIndex(self.language_selection)
settings.endGroup()
def save(self):
@@ -459,6 +502,8 @@
QtCore.QVariant(self.display_style))
settings.setValue(u'verse layout style',
QtCore.QVariant(self.layout_style))
+ settings.setValue(u'bookname language',
+ QtCore.QVariant(self.language_selection))
settings.setValue(u'second bibles', QtCore.QVariant(self.second_bibles))
settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme))
if self.verseSeparatorCheckBox.isChecked():
@@ -482,6 +527,7 @@
else:
settings.remove(u'end separator')
update_reference_separators()
+ Receiver.send_message(u'bibles_load_list')
settings.endGroup()
def updateThemeList(self, theme_list):
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py 2012-01-17 20:37:57 +0000
+++ openlp/plugins/bibles/lib/db.py 2012-03-07 19:24:35 +0000
@@ -435,19 +435,19 @@
else:
return count
- def get_verse_count(self, book_id, chapter):
+ def get_verse_count(self, book_ref_id, chapter):
"""
Return the number of verses in a chapter.
- ``book``
- The book containing the chapter.
+ ``book_ref_id``
+ The book reference id.
``chapter``
The chapter to get the verse count for.
"""
- log.debug(u'BibleDB.get_verse_count("%s", "%s")', book_id, chapter)
+ log.debug(u'BibleDB.get_verse_count("%s", "%s")', book_ref_id, chapter)
count = self.session.query(Verse).join(Book)\
- .filter(Book.book_reference_id==book_id)\
+ .filter(Book.book_reference_id==book_ref_id)\
.filter(Verse.chapter==chapter)\
.count()
if not count:
@@ -596,6 +596,35 @@
return None
@staticmethod
+ def get_books_like(string):
+ """
+ Return the books which include string.
+
+ ``string``
+ The string to search for in the booknames or abbreviations.
+ """
+ log.debug(u'BiblesResourcesDB.get_book_like("%s")', string)
+ if not isinstance(string, unicode):
+ name = unicode(string)
+ books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, '
+ u'abbreviation, chapters FROM book_reference WHERE '
+ u'LOWER(name) LIKE ? OR LOWER(abbreviation) LIKE ?',
+ (u'%'+string.lower()+u'%', u'%'+string.lower()+u'%'))
+ if books:
+ return [
+ {
+ u'id': book[0],
+ u'testament_id': book[1],
+ u'name': unicode(book[2]),
+ u'abbreviation': unicode(book[3]),
+ u'chapters': book[4]
+ }
+ for book in books
+ ]
+ else:
+ return None
+
+ @staticmethod
def get_book_by_id(id):
"""
Return a book by id.
@@ -621,23 +650,23 @@
return None
@staticmethod
- def get_chapter(book_id, chapter):
+ def get_chapter(book_ref_id, chapter):
"""
Return the chapter details for a specific chapter of a book.
- ``book_id``
+ ``book_ref_id``
The id of a book.
``chapter``
The chapter number.
"""
- log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id,
+ log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_ref_id,
chapter)
if not isinstance(chapter, int):
chapter = int(chapter)
chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, '
u'chapter, verse_count FROM chapters WHERE book_reference_id = ?',
- (book_id,))
+ (book_ref_id,))
try:
return {
u'id': chapters[chapter-1][0],
@@ -649,21 +678,21 @@
return None
@staticmethod
- def get_chapter_count(book_id):
+ def get_chapter_count(book_ref_id):
"""
Return the number of chapters in a book.
- ``book_id``
+ ``book_ref_id``
The id of the book.
"""
- log.debug(u'BiblesResourcesDB.get_chapter_count("%s")', book_id)
- details = BiblesResourcesDB.get_book_by_id(book_id)
+ log.debug(u'BiblesResourcesDB.get_chapter_count("%s")', book_ref_id)
+ details = BiblesResourcesDB.get_book_by_id(book_ref_id)
if details:
return details[u'chapters']
return 0
@staticmethod
- def get_verse_count(book_id, chapter):
+ def get_verse_count(book_ref_id, chapter):
"""
Return the number of verses in a chapter.
@@ -673,9 +702,9 @@
``chapter``
The number of the chapter.
"""
- log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_id,
+ log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_ref_id,
chapter)
- details = BiblesResourcesDB.get_chapter(book_id, chapter)
+ details = BiblesResourcesDB.get_chapter(book_ref_id, chapter)
if details:
return details[u'verse_count']
return 0
=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py 2012-01-18 20:20:05 +0000
+++ openlp/plugins/bibles/lib/manager.py 2012-03-07 19:24:35 +0000
@@ -33,7 +33,8 @@
from openlp.core.lib import Receiver, SettingsManager, translate
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.utils import AppLocation, delete_file
-from openlp.plugins.bibles.lib import parse_reference, get_reference_separator
+from openlp.plugins.bibles.lib import parse_reference, \
+ get_reference_separator, LanguageSelection
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
from csvbible import CSVBible
from http import HTTPBible
@@ -227,6 +228,19 @@
for book in self.db_cache[bible].get_books()
]
+ def get_book_by_id(self, bible, id):
+ """
+ Returns a book object by given id.
+
+ ``bible``
+ Unicode. The Bible to get the list of books from.
+
+ ``id``
+ Unicode. The book_reference_id to get the book for.
+ """
+ log.debug(u'BibleManager.get_book_by_id("%s", "%s")', bible, id)
+ return self.db_cache[bible].get_book_by_book_ref_id(id)
+
def get_chapter_count(self, bible, book):
"""
Returns the number of Chapters for a given book.
@@ -252,7 +266,16 @@
book_ref_id = db_book.book_reference_id
return self.db_cache[bible].get_verse_count(book_ref_id, chapter)
- def get_verses(self, bible, versetext, firstbible=False, show_error=True):
+ def get_verse_count_by_book_ref_id(self, bible, book_ref_id, chapter):
+ """
+ Returns all the number of verses for a given
+ book_ref_id and chapterMaxBibleBookVerses.
+ """
+ log.debug(u'BibleManager.get_verse_count_by_book_ref_id("%s", "%s", '
+ u'"%s")', bible, book_ref_id, chapter)
+ return self.db_cache[bible].get_verse_count(book_ref_id, chapter)
+
+ def get_verses(self, bible, versetext, book_ref_id=False, show_error=True):
"""
Parses a scripture reference, fetches the verses from the Bible
specified, and returns a list of ``Verse`` objects.
@@ -270,6 +293,10 @@
- Genesis 1:1-10,15-20
- Genesis 1:1-2:10
- Genesis 1:1-10,2:1-10
+
+ ``book_ref_id``
+ Unicode. The book referece id from the book in versetext.
+ For second bible this is necessary.
"""
log.debug(u'BibleManager.get_verses("%s", "%s")', bible, versetext)
if not bible:
@@ -282,30 +309,12 @@
'Import Wizard to install one or more Bibles.')
})
return None
- reflist = parse_reference(versetext)
+ language_selection = QtCore.QSettings().value(
+ self.settingsSection + u'/bookname language',
+ QtCore.QVariant(0)).toInt()[0]
+ reflist = parse_reference(versetext, self.db_cache[bible],
+ language_selection, book_ref_id)
if reflist:
- new_reflist = []
- for item in reflist:
- if item:
- if firstbible:
- db_book = self.db_cache[firstbible].get_book(item[0])
- db_book = self.db_cache[bible].get_book_by_book_ref_id(
- db_book.book_reference_id)
- else:
- db_book = self.db_cache[bible].get_book(item[0])
- if db_book:
- book_id = db_book.book_reference_id
- log.debug(u'Book name corrected to "%s"', db_book.name)
- new_reflist.append((book_id, item[1], item[2],
- item[3]))
- else:
- log.debug(u'OpenLP failed to find book %s', item[0])
- critical_error_message_box(
- translate('BiblesPlugin', 'No Book Found'),
- translate('BiblesPlugin', 'No matching book '
- 'could be found in this Bible. Check that you have '
- 'spelled the name of the book correctly.'))
- reflist = new_reflist
return self.db_cache[bible].get_verses(reflist, show_error)
else:
if show_error:
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2012-02-16 20:36:35 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2012-03-07 19:24:35 +0000
@@ -38,7 +38,8 @@
find_and_set_in_combo_box, build_icon
from openlp.plugins.bibles.forms import BibleImportForm
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
- VerseReferenceList, get_reference_separator
+ VerseReferenceList, get_reference_separator, LanguageSelection, BibleStrings
+from openlp.plugins.bibles.lib.db import BiblesResourcesDB
log = logging.getLogger(__name__)
@@ -424,20 +425,37 @@
book_data = book_data_temp
self.advancedBookComboBox.clear()
first = True
+ language_selection = QtCore.QSettings().value(
+ self.settingsSection + u'/bookname language',
+ QtCore.QVariant(0)).toInt()[0]
+ booknames = BibleStrings().Booknames
for book in book_data:
row = self.advancedBookComboBox.count()
- self.advancedBookComboBox.addItem(book[u'name'])
+ if language_selection == LanguageSelection.Bible:
+ self.advancedBookComboBox.addItem(book[u'name'])
+ elif language_selection == LanguageSelection.Application:
+ data = BiblesResourcesDB.get_book_by_id(
+ book[u'book_reference_id'])
+ self.advancedBookComboBox.addItem(
+ booknames[data[u'abbreviation']])
+ elif language_selection == LanguageSelection.English:
+ data = BiblesResourcesDB.get_book_by_id(
+ book[u'book_reference_id'])
+ self.advancedBookComboBox.addItem(data[u'name'])
self.advancedBookComboBox.setItemData(
- row, QtCore.QVariant(book[u'chapters']))
+ row, QtCore.QVariant(book[u'book_reference_id']))
if first:
first = False
self.initialiseChapterVerse(bible, book[u'name'],
- book[u'chapters'])
+ book[u'book_reference_id'])
- def initialiseChapterVerse(self, bible, book, chapter_count):
- log.debug(u'initialiseChapterVerse %s, %s', bible, book)
- self.chapter_count = chapter_count
- verse_count = self.plugin.manager.get_verse_count(bible, book, 1)
+ def initialiseChapterVerse(self, bible, book, book_ref_id):
+ log.debug(u'initialiseChapterVerse %s, %s, %s', bible, book,
+ book_ref_id)
+ book = self.plugin.manager.get_book_by_id(bible, book_ref_id)
+ self.chapter_count = self.plugin.manager.get_chapter_count(bible, book)
+ verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible,
+ book_ref_id, 1)
if verse_count == 0:
self.advancedSearchButton.setEnabled(False)
critical_error_message_box(
@@ -456,6 +474,7 @@
completion depends on the bible. It is only updated when we are doing a
reference search, otherwise the auto completion list is removed.
"""
+ log.debug(u'updateAutoCompleter')
# Save the current search type to the configuration.
QtCore.QSettings().setValue(u'%s/last search type' %
self.settingsSection,
@@ -480,7 +499,22 @@
secondbook.book_reference_id:
book_data_temp.append(book)
book_data = book_data_temp
- books = [book.name + u' ' for book in book_data]
+ language_selection = QtCore.QSettings().value(
+ self.settingsSection + u'/bookname language',
+ QtCore.QVariant(0)).toInt()[0]
+ if language_selection == LanguageSelection.Bible:
+ books = [book.name + u' ' for book in book_data]
+ elif language_selection == LanguageSelection.Application:
+ booknames = BibleStrings().Booknames
+ for book in book_data:
+ data = BiblesResourcesDB.get_book_by_id(
+ book.book_reference_id)
+ books.append(data[u'name'] + u' ')
+ elif language_selection == LanguageSelection.English:
+ for book in book_data:
+ data = BiblesResourcesDB.get_book_by_id(
+ book.book_reference_id)
+ books.append(data[u'name'] + u' ')
books.sort(cmp=locale.strcoll)
add_widget_completer(books, self.quickSearchEdit)
@@ -547,29 +581,31 @@
self.initialiseChapterVerse(
unicode(self.advancedVersionComboBox.currentText()),
unicode(self.advancedBookComboBox.currentText()),
- self.advancedBookComboBox.itemData(item).toInt()[0])
+ unicode(self.advancedBookComboBox.itemData(item).toString()))
def onAdvancedFromVerse(self):
chapter_from = int(self.advancedFromChapter.currentText())
chapter_to = int(self.advancedToChapter.currentText())
if chapter_from == chapter_to:
bible = unicode(self.advancedVersionComboBox.currentText())
- book = unicode(self.advancedBookComboBox.currentText())
+ book_ref_id = unicode(self.advancedBookComboBox.itemData(
+ int(self.advancedBookComboBox.currentIndex())).toString())
verse_from = int(self.advancedFromVerse.currentText())
- verse_count = self.plugin.manager.get_verse_count(bible, book,
- chapter_to)
+ verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(
+ bible, book_ref_id, chapter_to)
self.adjustComboBox(verse_from, verse_count,
self.advancedToVerse, True)
def onAdvancedToChapter(self):
bible = unicode(self.advancedVersionComboBox.currentText())
- book = unicode(self.advancedBookComboBox.currentText())
+ book_ref_id = unicode(self.advancedBookComboBox.itemData(
+ int(self.advancedBookComboBox.currentIndex())).toString())
chapter_from = int(self.advancedFromChapter.currentText())
chapter_to = int(self.advancedToChapter.currentText())
verse_from = int(self.advancedFromVerse.currentText())
verse_to = int(self.advancedToVerse.currentText())
- verse_count = self.plugin.manager.get_verse_count(bible, book,
- chapter_to)
+ verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible,
+ book_ref_id, chapter_to)
if chapter_from == chapter_to and verse_from > verse_to:
self.adjustComboBox(verse_from, verse_count, self.advancedToVerse)
else:
@@ -577,11 +613,12 @@
def onAdvancedFromChapter(self):
bible = unicode(self.advancedVersionComboBox.currentText())
- book = unicode(self.advancedBookComboBox.currentText())
+ book_ref_id = unicode(self.advancedBookComboBox.itemData(
+ int(self.advancedBookComboBox.currentIndex())).toString())
chapter_from = int(self.advancedFromChapter.currentText())
chapter_to = int(self.advancedToChapter.currentText())
- verse_count = self.plugin.manager.get_verse_count(bible, book,
- chapter_from)
+ verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible,
+ book_ref_id, chapter_from)
self.adjustComboBox(1, verse_count, self.advancedFromVerse)
if chapter_from > chapter_to:
self.adjustComboBox(1, verse_count, self.advancedToVerse)
@@ -630,6 +667,8 @@
bible = unicode(self.advancedVersionComboBox.currentText())
second_bible = unicode(self.advancedSecondComboBox.currentText())
book = unicode(self.advancedBookComboBox.currentText())
+ book_ref_id = unicode(self.advancedBookComboBox.itemData(
+ int(self.advancedBookComboBox.currentIndex())).toString())
chapter_from = self.advancedFromChapter.currentText()
chapter_to = self.advancedToChapter.currentText()
verse_from = self.advancedFromVerse.currentText()
@@ -640,10 +679,11 @@
range_separator + chapter_to + verse_separator + verse_to
versetext = u'%s %s' % (book, verse_range)
Receiver.send_message(u'cursor_busy')
- self.search_results = self.plugin.manager.get_verses(bible, versetext)
+ self.search_results = self.plugin.manager.get_verses(bible, versetext,
+ book_ref_id)
if second_bible:
self.second_search_results = self.plugin.manager.get_verses(
- second_bible, versetext, bible)
+ second_bible, versetext, book_ref_id)
if not self.advancedLockButton.isChecked():
self.listView.clear()
if self.listView.count() != 0:
@@ -671,7 +711,8 @@
self.search_results = self.plugin.manager.get_verses(bible, text)
if second_bible and self.search_results:
self.second_search_results = self.plugin.manager.get_verses(
- second_bible, text, bible)
+ second_bible, text,
+ self.search_results[0].book.book_reference_id)
else:
# We are doing a 'Text Search'.
Receiver.send_message(u'cursor_busy')
@@ -989,8 +1030,7 @@
Search for some Bible verses (by reference).
"""
bible = unicode(self.quickVersionComboBox.currentText())
- search_results = self.plugin.manager.get_verses(bible, string, False,
- False)
+ search_results = self.plugin.manager.get_verses(bible, string, False)
if search_results:
versetext = u' '.join([verse.text for verse in search_results])
return [[string, versetext]]
Follow ups