openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #15127
[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)
Andreas Preikschat (googol)
Related bugs:
Bug #738697 in OpenLP: "No way of modifying bible metadata or changing permissions that are displayed"
https://bugs.launchpad.net/openlp/+bug/738697
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/101018
add possibility to delete bibles
add possibility to edit bibles metadata (name, copyright, permissions)
bookname in search results and shown on display (e.g. footer) now uses the preferred language
add possibility to choose preferred language for each bible
add possibility to customize book names (for all bibles except webbibles)
--
https://code.launchpad.net/~orangeshirt/openlp/bibles/+merge/101018
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/bibles/forms/__init__.py'
--- openlp/plugins/bibles/forms/__init__.py 2012-04-04 07:26:51 +0000
+++ openlp/plugins/bibles/forms/__init__.py 2012-04-05 18:39:21 +0000
@@ -55,6 +55,7 @@
from languageform import LanguageForm
from bibleimportform import BibleImportForm
from bibleupgradeform import BibleUpgradeForm
+from editbibleform import EditBibleForm
__all__ = [u'BookNameForm', u'LanguageForm', u'BibleImportForm',
- u'BibleUpgradeForm']
+ u'BibleUpgradeForm', u'EditBibleForm']
=== modified file 'openlp/plugins/bibles/forms/bibleupgradeform.py'
--- openlp/plugins/bibles/forms/bibleupgradeform.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/bibles/forms/bibleupgradeform.py 2012-04-05 18:39:21 +0000
@@ -415,7 +415,7 @@
meta_data[meta[u'key']] = meta[u'value']
if not meta[u'key'] == u'Version' and not meta[u'key'] == \
u'dbversion':
- self.newbibles[number].create_meta(meta[u'key'],
+ self.newbibles[number].save_meta(meta[u'key'],
meta[u'value'])
if meta[u'key'] == u'download source':
webbible = True
@@ -455,7 +455,7 @@
meta_data[u'download source'].lower())
if bible and bible[u'language_id']:
language_id = bible[u'language_id']
- self.newbibles[number].create_meta(u'language_id',
+ self.newbibles[number].save_meta(u'language_id',
language_id)
else:
language_id = self.newbibles[number].get_language(name)
@@ -574,7 +574,7 @@
self.progressBar.maximum() - self.progressBar.value())
else:
self.success[number] = True
- self.newbibles[number].create_meta(u'Version', name)
+ self.newbibles[number].save_meta(u'Version', name)
self.incrementProgressBar(unicode(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\n'
=== added file 'openlp/plugins/bibles/forms/editbibledialog.py'
--- openlp/plugins/bibles/forms/editbibledialog.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/bibles/forms/editbibledialog.py 2012-04-05 18:39:21 +0000
@@ -0,0 +1,180 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2012 Raoul Snyman #
+# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
+# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
+# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU General Public License as published by the Free #
+# Software Foundation; version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
+# more details. #
+# #
+# You should have received a copy of the GNU General Public License along #
+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
+###############################################################################
+
+from PyQt4 import QtCore, QtGui
+
+from openlp.core.lib import build_icon, translate
+from openlp.core.lib.ui import create_button_box
+from openlp.plugins.bibles.lib import LanguageSelection, BibleStrings
+from openlp.plugins.bibles.lib.db import BiblesResourcesDB
+
+
+class Ui_EditBibleDialog(object):
+ def setupUi(self, editBibleDialog):
+ editBibleDialog.setObjectName(u'editBibleDialog')
+ editBibleDialog.resize(600, 400)
+ editBibleDialog.setWindowIcon(
+ build_icon(u':/icon/openlp-logo-16x16.png'))
+ editBibleDialog.setModal(True)
+ self.dialogLayout = QtGui.QVBoxLayout(editBibleDialog)
+ self.dialogLayout.setSpacing(8)
+ self.dialogLayout.setContentsMargins(8, 8, 8, 8)
+ self.dialogLayout.setObjectName(u'dialogLayout')
+ self.bibleTabWidget = QtGui.QTabWidget(editBibleDialog)
+ self.bibleTabWidget.setObjectName(u'BibleTabWidget')
+ # Meta tab
+ self.metaTab = QtGui.QWidget()
+ self.metaTab.setObjectName(u'metaTab')
+ self.metaTabLayout = QtGui.QVBoxLayout(self.metaTab)
+ self.metaTabLayout.setObjectName(u'metaTabLayout')
+ self.licenseDetailsGroupBox = QtGui.QGroupBox(self.metaTab)
+ self.licenseDetailsGroupBox.setObjectName(u'licenseDetailsGroupBox')
+ self.licenseDetailsLayout = QtGui.QFormLayout(
+ self.licenseDetailsGroupBox)
+ self.licenseDetailsLayout.setObjectName(u'licenseDetailsLayout')
+ self.versionNameLabel = QtGui.QLabel(self.licenseDetailsGroupBox)
+ self.versionNameLabel.setObjectName(u'versionNameLabel')
+ self.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox)
+ self.versionNameEdit.setObjectName(u'versionNameEdit')
+ self.versionNameLabel.setBuddy(self.versionNameEdit)
+ self.licenseDetailsLayout.addRow(self.versionNameLabel,
+ self.versionNameEdit)
+ self.copyrightLabel = QtGui.QLabel(self.licenseDetailsGroupBox)
+ self.copyrightLabel.setObjectName(u'copyrightLabel')
+ self.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox)
+ self.copyrightEdit.setObjectName(u'copyrightEdit')
+ self.copyrightLabel.setBuddy(self.copyrightEdit)
+ self.licenseDetailsLayout.addRow(self.copyrightLabel,
+ self.copyrightEdit)
+ self.permissionsLabel = QtGui.QLabel(self.licenseDetailsGroupBox)
+ self.permissionsLabel.setObjectName(u'permissionsLabel')
+ self.permissionsEdit = QtGui.QLineEdit(self.licenseDetailsGroupBox)
+ self.permissionsEdit.setObjectName(u'permissionsEdit')
+ self.permissionsLabel.setBuddy(self.permissionsEdit)
+ self.licenseDetailsLayout.addRow(self.permissionsLabel,
+ self.permissionsEdit)
+ self.metaTabLayout.addWidget(self.licenseDetailsGroupBox)
+ self.languageSelectionGroupBox = QtGui.QGroupBox(self.metaTab)
+ 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'', u''])
+ self.languageSelectionLayout.addWidget(self.languageSelectionLabel)
+ self.languageSelectionLayout.addWidget(self.languageSelectionComboBox)
+ self.metaTabLayout.addWidget(self.languageSelectionGroupBox)
+ self.metaTabLayout.addStretch()
+ self.bibleTabWidget.addTab(self.metaTab, u'')
+ # Book name tab
+ self.bookNameTab = QtGui.QWidget()
+ self.bookNameTab.setObjectName(u'bookNameTab')
+ self.bookNameTabLayout = QtGui.QVBoxLayout(self.bookNameTab)
+ self.bookNameTabLayout.setObjectName(u'bookNameTabLayout')
+ self.bookNameNotice = QtGui.QLabel(self.bookNameTab)
+ self.bookNameNotice.setObjectName(u'bookNameNotice')
+ self.bookNameTabLayout.addWidget(self.bookNameNotice)
+ self.scrollArea = QtGui.QScrollArea(self.bookNameTab)
+ self.scrollArea.setWidgetResizable(True)
+ self.scrollArea.setObjectName(u'scrollArea')
+ self.scrollArea.setHorizontalScrollBarPolicy(
+ QtCore.Qt.ScrollBarAlwaysOff)
+ self.bookNameWidget = QtGui.QWidget(self.scrollArea)
+ self.bookNameWidget.setObjectName(u'bookNameWidget')
+ self.bookNameWidgetLayout = QtGui.QFormLayout(self.bookNameWidget)
+ self.bookNameWidgetLayout.setObjectName(u'bookNameWidgetLayout')
+ self.bookNameLabel = {}
+ self.bookNameEdit= {}
+ for book in BiblesResourcesDB.get_books():
+ self.bookNameLabel[book[u'abbreviation']] = QtGui.QLabel(
+ self.bookNameWidget)
+ self.bookNameLabel[book[u'abbreviation']].setObjectName(
+ u'bookNameLabel[%s]' % book[u'abbreviation'])
+ self.bookNameEdit[book[u'abbreviation']] = QtGui.QLineEdit(
+ self.bookNameWidget)
+ self.bookNameEdit[book[u'abbreviation']].setObjectName(
+ u'bookNameEdit[%s]' % book[u'abbreviation'])
+ self.bookNameWidgetLayout.addRow(
+ self.bookNameLabel[book[u'abbreviation']],
+ self.bookNameEdit[book[u'abbreviation']])
+ self.scrollArea.setWidget(self.bookNameWidget)
+ self.bookNameTabLayout.addWidget(self.scrollArea)
+ self.bookNameTabLayout.addStretch()
+ self.bibleTabWidget.addTab(self.bookNameTab, u'')
+ # Last few bits
+ self.dialogLayout.addWidget(self.bibleTabWidget)
+ self.buttonBox = create_button_box(editBibleDialog, u'buttonBox',
+ [u'cancel', u'save'])
+ self.dialogLayout.addWidget(self.buttonBox)
+ self.retranslateUi(editBibleDialog)
+ QtCore.QMetaObject.connectSlotsByName(editBibleDialog)
+
+ def retranslateUi(self, editBibleDialog):
+ self.booknames = BibleStrings().Booknames
+ editBibleDialog.setWindowTitle(
+ translate('BiblesPlugin.EditBibleForm', 'Bible Editor'))
+ # Meta tab
+ self.bibleTabWidget.setTabText(
+ self.bibleTabWidget.indexOf(self.metaTab),
+ translate('SongsPlugin.EditBibleForm', 'Meta Data'))
+ self.licenseDetailsGroupBox.setTitle(
+ translate('BiblesPlugin.EditBibleForm', 'License Details'))
+ self.versionNameLabel.setText(
+ translate('BiblesPlugin.EditBibleForm', 'Version name:'))
+ self.copyrightLabel.setText(
+ translate('BiblesPlugin.EditBibleForm', 'Copyright:'))
+ self.permissionsLabel.setText(
+ translate('BiblesPlugin.EditBibleForm', 'Permissions:'))
+ self.languageSelectionGroupBox.setTitle(translate(
+ 'BiblesPlugin.EditBibleForm', 'Default Bible Language'))
+ self.languageSelectionLabel.setText(
+ translate('BiblesPlugin.EditBibleForm',
+ 'Book name language in search field, search results and on '
+ 'display:'))
+ self.languageSelectionComboBox.setItemText(0,
+ translate('BiblesPlugin.EditBibleForm', 'Global Settings'))
+ self.languageSelectionComboBox.setItemText(LanguageSelection.Bible + 1,
+ translate('BiblesPlugin.EditBibleForm', 'Bible Language'))
+ self.languageSelectionComboBox.setItemText(
+ LanguageSelection.Application + 1,
+ translate('BiblesPlugin.EditBibleForm', 'Application Language'))
+ self.languageSelectionComboBox.setItemText(
+ LanguageSelection.English + 1,
+ translate('BiblesPlugin.EditBibleForm', 'English'))
+ # Book name tab
+ self.bibleTabWidget.setTabText(
+ self.bibleTabWidget.indexOf(self.bookNameTab),
+ translate('SongsPlugin.EditBibleForm', 'Custom Book Names'))
+ for book in BiblesResourcesDB.get_books():
+ self.bookNameLabel[book[u'abbreviation']].setText(
+ u'%s:' % unicode(self.booknames[book[u'abbreviation']]))
=== added file 'openlp/plugins/bibles/forms/editbibleform.py'
--- openlp/plugins/bibles/forms/editbibleform.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/bibles/forms/editbibleform.py 2012-04-05 18:39:21 +0000
@@ -0,0 +1,237 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2012 Raoul Snyman #
+# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
+# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
+# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU General Public License as published by the Free #
+# Software Foundation; version 2 of the License. #
+# #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
+# more details. #
+# #
+# You should have received a copy of the GNU General Public License along #
+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
+###############################################################################
+
+import logging
+import re
+
+from PyQt4 import QtGui
+
+from openlp.core.lib import Receiver, translate
+from openlp.core.lib.ui import UiStrings, critical_error_message_box
+from editbibledialog import Ui_EditBibleDialog
+from openlp.plugins.bibles.lib import BibleStrings
+from openlp.plugins.bibles.lib.db import BiblesResourcesDB
+
+log = logging.getLogger(__name__)
+
+class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
+ """
+ Class to manage the editing of a bible
+ """
+ log.info(u'%s EditBibleForm loaded', __name__)
+
+ def __init__(self, mediaitem, parent, manager):
+ """
+ Constructor
+ """
+ QtGui.QDialog.__init__(self, parent)
+ self.mediaitem = mediaitem
+ self.validate_error = []
+ self.booknames = BibleStrings().Booknames
+ self.setupUi(self)
+ self.manager = manager
+
+ def loadBible(self, bible):
+ """
+ Loads a bible.
+
+ ``bible``
+ The name of the bible.
+ """
+ log.debug(u'Load Bible')
+ self.bible = bible
+ self.versionNameEdit.setText(
+ self.manager.get_meta_data(self.bible, u'Version').value)
+ self.copyrightEdit.setText(
+ 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:
+ self.languageSelectionComboBox.setCurrentIndex(
+ int(self.bookname_language.value) + 1)
+ self.books = {}
+ self.webbible = self.manager.get_meta_data(self.bible,
+ u'download source')
+ if self.webbible:
+ self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
+ 'This is a webbible.\nIt is not possible to customize the Book '
+ 'Names.'))
+ self.scrollArea.hide()
+ else:
+ self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
+ 'To use the customized Book Names, choose the option "Bible '
+ 'language"\nin global settings or explicit for this Bible.'))
+ for book in BiblesResourcesDB.get_books():
+ self.books[book[u'abbreviation']] = self.manager.get_book_by_id(
+ self.bible, book[u'id'])
+ if self.books[book[u'abbreviation']] and not self.webbible:
+ self.bookNameEdit[book[u'abbreviation']].setText(
+ self.books[book[u'abbreviation']].name)
+ else:
+ self.bookNameWidgetLayout.removeWidget(
+ self.bookNameLabel[book[u'abbreviation']])
+ self.bookNameLabel[book[u'abbreviation']].setParent(None)
+ self.bookNameWidgetLayout.removeWidget(
+ self.bookNameEdit[book[u'abbreviation']])
+ self.bookNameEdit[book[u'abbreviation']].setParent(None)
+
+ def reject(self):
+ """
+ Exit Dialog and do not save
+ """
+ log.debug (u'BibleEditForm.reject')
+ self.bible = None
+ QtGui.QDialog.reject(self)
+
+ def accept(self):
+ """
+ Exit Dialog and save data
+ """
+ log.debug(u'BibleEditForm.accept')
+ save = True
+ 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
+ for error in self.validate_error:
+ self.changeBackgroundColor(error)
+ if not self.validateMeta():
+ save = False
+ if not self.webbible and save:
+ custom_names = {}
+ for abbr, book in self.books.iteritems():
+ if book:
+ custom_names[abbr] = unicode(self.bookNameEdit[abbr].text())
+ if book.name != custom_names[abbr]:
+ if not self.validateBook(custom_names[abbr], abbr):
+ save = False
+ break
+ if save:
+ 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)
+ if not self.webbible:
+ for abbr, book in self.books.iteritems():
+ if book:
+ if book.name != custom_names[abbr]:
+ book.name = custom_names[abbr]
+ self.manager.update_book(self.bible, book)
+ self.bible = None
+ Receiver.send_message(u'cursor_normal')
+ QtGui.QDialog.accept(self)
+
+ def validateMeta(self):
+ """
+ Validate the Meta before saving.
+ """
+ if not self.version:
+ self.changeBackgroundColor(self.versionNameEdit, u'red')
+ self.validate_error = [self.versionNameEdit]
+ 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:
+ self.changeBackgroundColor(self.copyrightEdit, u'red')
+ self.validate_error = [self.copyrightEdit]
+ 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 \
+ self.manager.get_meta_data(self.bible, u'Version').value != \
+ self.version:
+ self.changeBackgroundColor(self.versionNameEdit, u'red')
+ self.validate_error = [self.versionNameEdit]
+ self.versionNameEdit.setFocus()
+ critical_error_message_box(
+ translate('BiblesPlugin.BibleEditForm', 'Bible Exists'),
+ translate('BiblesPlugin.BibleEditForm',
+ 'This Bible already exists. Please import '
+ 'a different Bible or first delete the existing one.'))
+ return False
+ return True
+
+ def validateBook(self, new_bookname, abbreviation):
+ """
+ Validate a book.
+ """
+ book_regex = re.compile(u'[\d]*[^\d]+$')
+ if not new_bookname:
+ self.changeBackgroundColor(self.bookNameEdit[abbreviation], u'red')
+ self.validate_error = [self.bookNameEdit[abbreviation]]
+ self.bookNameEdit[abbreviation].setFocus()
+ critical_error_message_box(UiStrings().EmptyField,
+ unicode(translate('BiblesPlugin.BibleEditForm',
+ 'You need to specify a book name for "%s".')) %
+ self.booknames[abbreviation])
+ return False
+ elif not book_regex.match(new_bookname):
+ self.changeBackgroundColor(self.bookNameEdit[abbreviation], u'red')
+ self.validate_error = [self.bookNameEdit[abbreviation]]
+ self.bookNameEdit[abbreviation].setFocus()
+ critical_error_message_box(UiStrings().EmptyField,
+ unicode(translate('BiblesPlugin.BibleEditForm',
+ 'The book name "%s" is not correct.\nDecimal digits only could '
+ 'be used at the beginning and\nmust be followed by one or more '
+ 'non-digit characters')) % new_bookname)
+ return False
+ for abbr, book in self.books.iteritems():
+ if book:
+ if abbr == abbreviation:
+ continue
+ if unicode(self.bookNameEdit[abbr].text()) == new_bookname:
+ self.changeBackgroundColor(self.bookNameEdit[abbreviation],
+ u'red')
+ self.bookNameEdit[abbreviation].setFocus()
+ self.changeBackgroundColor(self.bookNameEdit[abbr], u'red')
+ self.validate_error = [self.bookNameEdit[abbr],
+ self.bookNameEdit[abbreviation]]
+ critical_error_message_box(
+ translate('BiblesPlugin.BibleEditForm',
+ 'Book Name Exists Twice'),
+ unicode(translate('BiblesPlugin.BibleEditForm',
+ 'The Book Name "%s" exists twice. Please change one.'))
+ % new_bookname)
+ return False
+ return True
+
+ def changeBackgroundColor(self, lineedit, color=None):
+ """
+ Change the Background Color of the given LineEdit
+ """
+ pal = QtGui.QPalette(self.palette())
+ if color:
+ pal.setColor(QtGui.QPalette.Base, QtGui.QColor(color))
+ lineedit.setPalette(pal)
=== modified file 'openlp/plugins/bibles/lib/__init__.py'
--- openlp/plugins/bibles/lib/__init__.py 2012-04-04 07:26:51 +0000
+++ openlp/plugins/bibles/lib/__init__.py 2012-04-05 18:39:21 +0000
@@ -386,7 +386,7 @@
if bible.get_book_by_book_ref_id(value[u'id']):
book_ref_id = value[u'id']
break
- elif bible.get_book_by_book_ref_id(book_ref_id):
+ elif 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)
=== modified file 'openlp/plugins/bibles/lib/biblestab.py'
--- openlp/plugins/bibles/lib/biblestab.py 2012-04-02 10:32:52 +0000
+++ openlp/plugins/bibles/lib/biblestab.py 2012-04-05 18:39:21 +0000
@@ -276,10 +276,11 @@
'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',
- 'Default Search Field Language'))
+ self.languageSelectionGroupBox.setTitle(translate(
+ 'BiblesPlugin.BiblesTab', 'Default Bible Language'))
self.languageSelectionLabel.setText(translate('BiblesPlugin.BiblesTab',
- 'Book name language in search field:'))
+ 'Book name language in search field,\nsearch results and on '
+ 'display:'))
self.languageSelectionComboBox.setItemText(LanguageSelection.Bible,
translate('BiblesPlugin.BiblesTab', 'Bible language'))
self.languageSelectionComboBox.setItemText(
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py 2012-03-31 16:24:25 +0000
+++ openlp/plugins/bibles/lib/db.py 2012-04-05 18:39:21 +0000
@@ -182,7 +182,7 @@
The actual Qt wizard form.
"""
self.wizard = wizard
- self.create_meta(u'dbversion', u'2')
+ self.save_meta(u'dbversion', u'2')
return self.name
def create_book(self, name, bk_ref_id, testament=1):
@@ -205,6 +205,16 @@
self.save_object(book)
return book
+ def update_book(self, book):
+ """
+ Update a book in the database.
+
+ ``book``
+ The book object
+ """
+ log.debug(u'BibleDB.update_book("%s")', book.name)
+ return self.save_object(book)
+
def delete_book(self, db_book):
"""
Delete a book from the database.
@@ -271,9 +281,9 @@
self.session.add(verse)
return verse
- def create_meta(self, key, value):
+ def save_meta(self, key, value):
"""
- Utility method to save BibleMeta objects in a Bible database.
+ Utility method to save or update BibleMeta objects in a Bible database.
``key``
The key for this instance.
@@ -284,7 +294,12 @@
if not isinstance(value, unicode):
value = unicode(value)
log.debug(u'BibleDB.save_meta("%s/%s")', key, value)
- self.save_object(BibleMeta.populate(key=key, value=value))
+ meta = self.get_object(BibleMeta, key)
+ if meta:
+ meta.value = value
+ self.save_object(meta)
+ else:
+ self.save_object(BibleMeta.populate(key=key, value=value))
def get_book(self, book):
"""
@@ -471,7 +486,7 @@
return False
language = BiblesResourcesDB.get_language(language)
language_id = language[u'id']
- self.create_meta(u'language_id', language_id)
+ self.save_meta(u'language_id', language_id)
return language_id
def is_old_database(self):
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py 2012-04-03 17:58:42 +0000
+++ openlp/plugins/bibles/lib/http.py 2012-04-05 18:39:21 +0000
@@ -401,16 +401,16 @@
self.wizard.incrementProgressBar(unicode(translate(
'BiblesPlugin.HTTPBible',
'Registering Bible and loading books...')))
- self.create_meta(u'download source', self.download_source)
- self.create_meta(u'download name', self.download_name)
+ self.save_meta(u'download source', self.download_source)
+ self.save_meta(u'download name', self.download_name)
if self.proxy_server:
- self.create_meta(u'proxy server', self.proxy_server)
+ self.save_meta(u'proxy server', self.proxy_server)
if self.proxy_username:
# Store the proxy userid.
- self.create_meta(u'proxy username', self.proxy_username)
+ self.save_meta(u'proxy username', self.proxy_username)
if self.proxy_password:
# Store the proxy password.
- self.create_meta(u'proxy password', self.proxy_password)
+ self.save_meta(u'proxy password', self.proxy_password)
if self.download_source.lower() == u'crosswalk':
handler = CWExtract(self.proxy_server)
elif self.download_source.lower() == u'biblegateway':
@@ -429,7 +429,7 @@
self.download_source.lower())
if bible[u'language_id']:
language_id = bible[u'language_id']
- self.create_meta(u'language_id', language_id)
+ self.save_meta(u'language_id', language_id)
else:
language_id = self.get_language(bible_name)
if not language_id:
=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py 2012-04-05 16:21:29 +0000
+++ openlp/plugins/bibles/lib/manager.py 2012-04-05 18:39:21 +0000
@@ -31,7 +31,6 @@
from PyQt4 import QtCore
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, LanguageSelection
@@ -141,13 +140,14 @@
BibleDB class.
"""
log.debug(u'Reload bibles')
- files = SettingsManager.get_files(self.settingsSection, self.suffix)
- if u'alternative_book_names.sqlite' in files:
- files.remove(u'alternative_book_names.sqlite')
- log.debug(u'Bible Files %s', files)
+ self.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)
self.db_cache = {}
self.old_bible_databases = []
- for filename in files:
+ for filename in self.files:
bible = BibleDB(self.parent, path=self.path, file=filename)
name = bible.get_name()
# Remove corrupted files.
@@ -204,6 +204,22 @@
self.db_cache[name] = importer
return importer
+ def delete_bible(self, name):
+ """
+ Delete a bible completly.
+
+ ``name``
+ The name of the bible.
+ """
+ for filename in self.files:
+ bible = BibleDB(self.parent, path=self.path, file=filename)
+ # Remove the bible files
+ if name == bible.get_name():
+ bible.session.close()
+ if delete_file(os.path.join(self.path, filename)):
+ return True
+ return False
+
def get_bibles(self):
"""
Returns a dict with all available Bibles.
@@ -309,9 +325,13 @@
'Import Wizard to install one or more Bibles.')
})
return None
- language_selection = QtCore.QSettings().value(
- self.settingsSection + u'/bookname language',
- QtCore.QVariant(0)).toInt()[0]
+ language_selection = self.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]
reflist = parse_reference(versetext, self.db_cache[bible],
language_selection, book_ref_id)
if reflist:
@@ -396,15 +416,18 @@
})
return None
- def save_meta_data(self, bible, version, copyright, permissions):
+ def save_meta_data(self, bible, version, copyright, permissions,
+ bookname_language=-1):
"""
Saves the bibles meta data.
"""
- log.debug(u'save_meta data %s,%s, %s,%s',
+ log.debug(u'save_meta data %s, %s, %s, %s',
bible, version, copyright, permissions)
- self.db_cache[bible].create_meta(u'Version', version)
- self.db_cache[bible].create_meta(u'Copyright', copyright)
- self.db_cache[bible].create_meta(u'Permissions', permissions)
+ self.db_cache[bible].save_meta(u'Version', version)
+ self.db_cache[bible].save_meta(u'Copyright', copyright)
+ self.db_cache[bible].save_meta(u'Permissions', permissions)
+ self.db_cache[bible].save_meta(u'Bookname language',
+ bookname_language)
def get_meta_data(self, bible, key):
"""
@@ -412,6 +435,13 @@
"""
log.debug(u'get_meta %s,%s', bible, key)
return self.db_cache[bible].get_object(BibleMeta, key)
+
+ def update_book(self, bible, book):
+ """
+ Update a book of the bible.
+ """
+ log.debug(u'BibleManager.update_book("%s", "%s")', bible, book.name)
+ self.db_cache[bible].update_book(book)
def exists(self, name):
"""
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2012-04-05 15:17:40 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2012-04-05 18:39:21 +0000
@@ -36,9 +36,10 @@
from openlp.core.lib.ui import UiStrings, set_case_insensitive_completer, \
create_horizontal_adjusting_combo_box, critical_error_message_box, \
find_and_set_in_combo_box, build_icon
-from openlp.plugins.bibles.forms import BibleImportForm
+from openlp.plugins.bibles.forms import BibleImportForm, EditBibleForm
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \
- VerseReferenceList, get_reference_separator, LanguageSelection, BibleStrings
+ VerseReferenceList, get_reference_separator, LanguageSelection, \
+ BibleStrings
from openlp.plugins.bibles.lib.db import BiblesResourcesDB
log = logging.getLogger(__name__)
@@ -109,8 +110,8 @@
MediaManagerItem.requiredIcons(self)
self.hasImportIcon = True
self.hasNewIcon = False
- self.hasEditIcon = False
- self.hasDeleteIcon = False
+ self.hasEditIcon = True
+ self.hasDeleteIcon = True
self.addToServiceItem = False
def addSearchTab(self, prefix, name):
@@ -350,10 +351,6 @@
log.debug(u'bible manager initialise')
self.plugin.manager.media = self
self.loadBibles()
- bible = QtCore.QSettings().value(
- self.settingsSection + u'/quick bible', QtCore.QVariant(
- self.quickVersionComboBox.currentText())).toString()
- find_and_set_in_combo_box(self.quickVersionComboBox, bible)
self.quickSearchEdit.setSearchTypes([
(BibleSearch.Reference, u':/bibles/bibles_search_reference.png',
translate('BiblesPlugin.MediaItem', 'Scripture Reference'),
@@ -395,6 +392,10 @@
self.initialiseAdvancedBible(unicode(bible))
elif len(bibles):
self.initialiseAdvancedBible(bibles[0])
+ bible = QtCore.QSettings().value(
+ self.settingsSection + u'/quick bible', QtCore.QVariant(
+ self.quickVersionComboBox.currentText())).toString()
+ find_and_set_in_combo_box(self.quickVersionComboBox, bible)
def reloadBibles(self, process=False):
log.debug(u'Reloading Bibles')
@@ -429,9 +430,14 @@
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]
+ 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]
booknames = BibleStrings().Booknames
for book in book_data:
row = self.advancedBookComboBox.count()
@@ -503,9 +509,14 @@
secondbook.book_reference_id:
book_data_temp.append(book)
book_data = book_data_temp
- language_selection = QtCore.QSettings().value(
- self.settingsSection + u'/bookname language',
- QtCore.QVariant(0)).toInt()[0]
+ 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]
if language_selection == LanguageSelection.Bible:
books = [book.name + u' ' for book in book_data]
elif language_selection == LanguageSelection.Application:
@@ -531,6 +542,34 @@
if self.import_wizard.exec_():
self.reloadBibles()
+ def onEditClick(self):
+ if self.quickTab.isVisible():
+ bible = unicode(self.quickVersionComboBox.currentText())
+ elif self.advancedTab.isVisible():
+ bible = unicode(self.advancedVersionComboBox.currentText())
+ if bible:
+ self.editBibleForm = EditBibleForm(self, self.plugin.formparent,
+ self.plugin.manager)
+ self.editBibleForm.loadBible(bible)
+ if self.editBibleForm.exec_():
+ self.reloadBibles()
+
+ def onDeleteClick(self):
+ if self.quickTab.isVisible():
+ bible = unicode(self.quickVersionComboBox.currentText())
+ elif self.advancedTab.isVisible():
+ bible = unicode(self.advancedVersionComboBox.currentText())
+ if bible:
+ if QtGui.QMessageBox.question(self, UiStrings().ConfirmDelete,
+ unicode(translate('BiblesPlugin.MediaItem',
+ 'Are you sure you want to delete "%s"?')) % bible,
+ QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
+ QtGui.QMessageBox.No),
+ QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
+ return
+ self.plugin.manager.delete_bible(bible)
+ self.reloadBibles()
+
def onSearchTabBarCurrentChanged(self, index):
if index == 0:
self.advancedTab.setVisible(False)
@@ -793,9 +832,28 @@
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]
for count, verse in enumerate(search_results):
+ if language_selection == LanguageSelection.Bible:
+ book = verse.book.name
+ elif language_selection == LanguageSelection.Application:
+ booknames = BibleStrings().Booknames
+ data = BiblesResourcesDB.get_book_by_id(
+ verse.book.book_reference_id)
+ book = unicode(booknames[data[u'abbreviation']])
+ elif language_selection == LanguageSelection.English:
+ data = BiblesResourcesDB.get_book_by_id(
+ verse.book.book_reference_id)
+ book = data[u'name']
data = {
- 'book': QtCore.QVariant(verse.book.name),
+ 'book': QtCore.QVariant(book),
'chapter': QtCore.QVariant(verse.chapter),
'verse': QtCore.QVariant(verse.verse),
'bible': QtCore.QVariant(bible),
@@ -817,12 +875,11 @@
log.exception(u'The second_search_results does not have as '
'many verses as the search_results.')
break
- bible_text = u'%s %d%s%d (%s, %s)' % (verse.book.name,
- verse.chapter, verse_separator, verse.verse, version,
- second_version)
+ bible_text = u'%s %d%s%d (%s, %s)' % (book, verse.chapter,
+ verse_separator, verse.verse, version, second_version)
else:
- bible_text = u'%s %d%s%d (%s)' % (verse.book.name,
- verse.chapter, verse_separator, verse.verse, version)
+ bible_text = u'%s %d%s%d (%s)' % (book, verse.chapter,
+ verse_separator, verse.verse, version)
bible_verse = QtGui.QListWidgetItem(bible_text)
bible_verse.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
items.append(bible_verse)
=== modified file 'openlp/plugins/bibles/lib/osis.py'
--- openlp/plugins/bibles/lib/osis.py 2012-03-01 18:09:47 +0000
+++ openlp/plugins/bibles/lib/osis.py 2012-04-05 18:39:21 +0000
@@ -123,7 +123,7 @@
language_match.group(1))
if language:
language_id = language[u'id']
- self.create_meta(u'language_id', language_id)
+ self.save_meta(u'language_id', language_id)
continue
match = self.verse_regex.search(file_record)
if match:
Follow ups