Fix up merge issues

This commit is contained in:
Tim Bentley 2013-05-19 08:35:07 +01:00
commit 945a99ea24
50 changed files with 649 additions and 1142 deletions

View File

@ -155,7 +155,7 @@ def build_icon(icon):
``icon``
The icon to build. This can be a QIcon, a resource string in the form ``:/resource/file.png``, or a file
location like ``/path/to/file.png``.
location like ``/path/to/file.png``. However, the **recommended** way is to specify a resource string.
"""
button_icon = QtGui.QIcon()
if isinstance(icon, QtGui.QIcon):

View File

@ -426,7 +426,7 @@ class MediaManagerItem(QtGui.QWidget):
"""
raise NotImplementedError(u'MediaManagerItem.on_delete_click needs to be defined by the plugin')
def onFocus(self):
def on_focus(self):
"""
Run when a tab in the media manager gains focus. This gives the media
item a chance to focus any elements it wants to.

View File

@ -107,7 +107,6 @@ class UiStrings(object):
self.NFSp = translate('OpenLP.Ui', 'No Files Selected', 'Plural')
self.NISs = translate('OpenLP.Ui', 'No Item Selected', 'Singular')
self.NISp = translate('OpenLP.Ui', 'No Items Selected', 'Plural')
self.OLPV1 = translate('OpenLP.Ui', 'openlp.org 1.x')
self.OLPV2 = translate('OpenLP.Ui', 'OpenLP 2')
self.OLPV2x = translate('OpenLP.Ui', 'OpenLP 2.1')
self.OpenLPStart = translate('OpenLP.Ui', 'OpenLP is already running. Do you wish to continue?')

View File

@ -59,11 +59,6 @@ try:
ENCHANT_VERSION = enchant.__version__
except ImportError:
ENCHANT_VERSION = u'-'
try:
import sqlite
SQLITE_VERSION = sqlite.version
except ImportError:
SQLITE_VERSION = u'-'
try:
import mako
MAKO_VERSION = mako.__version__
@ -154,7 +149,6 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog):
u'lxml: %s\n' % etree.__version__ + \
u'Chardet: %s\n' % CHARDET_VERSION + \
u'PyEnchant: %s\n' % ENCHANT_VERSION + \
u'PySQLite: %s\n' % SQLITE_VERSION + \
u'Mako: %s\n' % MAKO_VERSION + \
u'CherryPy: %s\n' % CHERRYPY_VERSION + \
u'pyICU: %s\n' % ICU_VERSION + \

View File

@ -39,39 +39,39 @@ class Ui_FirstTimeLanguageDialog(object):
"""
The UI widgets of the language selection dialog.
"""
def setupUi(self, languageDialog):
def setupUi(self, language_dialog):
"""
Set up the UI.
"""
languageDialog.setObjectName(u'languageDialog')
languageDialog.resize(300, 50)
self.dialogLayout = QtGui.QVBoxLayout(languageDialog)
self.dialogLayout.setContentsMargins(8, 8, 8, 8)
self.dialogLayout.setSpacing(8)
self.dialogLayout.setObjectName(u'dialog_layout')
self.infoLabel = QtGui.QLabel(languageDialog)
self.infoLabel.setObjectName(u'infoLabel')
self.dialogLayout.addWidget(self.infoLabel)
self.languageLayout = QtGui.QHBoxLayout()
self.languageLayout.setObjectName(u'languageLayout')
self.languageLabel = QtGui.QLabel(languageDialog)
self.languageLabel.setObjectName(u'languageLabel')
self.languageLayout.addWidget(self.languageLabel)
self.languageComboBox = QtGui.QComboBox(languageDialog)
self.languageComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
self.languageComboBox.setObjectName("languageComboBox")
self.languageLayout.addWidget(self.languageComboBox)
self.dialogLayout.addLayout(self.languageLayout)
self.button_box = create_button_box(languageDialog, u'button_box', [u'cancel', u'ok'])
self.dialogLayout.addWidget(self.button_box)
self.retranslateUi(languageDialog)
language_dialog.setObjectName(u'language_dialog')
language_dialog.resize(300, 50)
self.dialog_layout = QtGui.QVBoxLayout(language_dialog)
self.dialog_layout.setContentsMargins(8, 8, 8, 8)
self.dialog_layout.setSpacing(8)
self.dialog_layout.setObjectName(u'dialog_layout')
self.info_label = QtGui.QLabel(language_dialog)
self.info_label.setObjectName(u'info_label')
self.dialog_layout.addWidget(self.info_label)
self.language_layout = QtGui.QHBoxLayout()
self.language_layout.setObjectName(u'language_layout')
self.language_label = QtGui.QLabel(language_dialog)
self.language_label.setObjectName(u'language_label')
self.language_layout.addWidget(self.language_label)
self.language_combo_box = QtGui.QComboBox(language_dialog)
self.language_combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
self.language_combo_box.setObjectName("language_combo_box")
self.language_layout.addWidget(self.language_combo_box)
self.dialog_layout.addLayout(self.language_layout)
self.button_box = create_button_box(language_dialog, u'button_box', [u'cancel', u'ok'])
self.dialog_layout.addWidget(self.button_box)
self.retranslateUi(language_dialog)
self.setMaximumHeight(self.sizeHint().height())
def retranslateUi(self, languageDialog):
def retranslateUi(self, language_dialog):
"""
Translate the UI on the fly.
"""
self.setWindowTitle(translate('OpenLP.FirstTimeLanguageForm', 'Select Translation'))
self.infoLabel.setText(
self.info_label.setText(
translate('OpenLP.FirstTimeLanguageForm', 'Choose the translation you\'d like to use in OpenLP.'))
self.languageLabel.setText(translate('OpenLP.FirstTimeLanguageForm', 'Translation:'))
self.language_label.setText(translate('OpenLP.FirstTimeLanguageForm', 'Translation:'))

View File

@ -47,8 +47,8 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog):
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
self.qmList = LanguageManager.get_qm_list()
self.languageComboBox.addItem(u'Autodetect')
self.languageComboBox.addItems(sorted(self.qmList.keys()))
self.language_combo_box.addItem(u'Autodetect')
self.language_combo_box.addItems(sorted(self.qmList.keys()))
def exec_(self):
"""
@ -61,12 +61,12 @@ class FirstTimeLanguageForm(QtGui.QDialog, Ui_FirstTimeLanguageDialog):
Run when the dialog is OKed.
"""
# It's the first row so must be Automatic
if self.languageComboBox.currentIndex() == 0:
if self.language_combo_box.currentIndex() == 0:
LanguageManager.auto_language = True
LanguageManager.set_language(False, False)
else:
LanguageManager.auto_language = False
action = create_action(None, self.languageComboBox.currentText())
action = create_action(None, self.language_combo_box.currentText())
LanguageManager.set_language(action, False)
return QtGui.QDialog.accept(self)

View File

@ -559,7 +559,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
"""
widget = self.media_tool_box.widget(index)
if widget:
widget.onFocus()
widget.on_focus()
def version_notice(self, version):
"""

View File

@ -295,8 +295,8 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
Sets up the service manager, toolbars, list view, et al.
"""
QtGui.QWidget.__init__(self, parent)
self.active = build_icon(QtGui.QImage(u':/media/auto-start_active.png'))
self.inactive = build_icon(QtGui.QImage(u':/media/auto-start_inactive.png'))
self.active = build_icon(u':/media/auto-start_active.png')
self.inactive = build_icon(u':/media/auto-start_inactive.png')
Registry().register(u'service_manager', self)
self.service_items = []
self.suffixes = []
@ -1383,7 +1383,7 @@ class ServiceManager(QtGui.QWidget, ServiceManagerDialog):
item = self.find_service_item()[0]
if self.service_items[item][u'service_item'].is_capable(ItemCapabilities.CanEdit):
new_item = Registry().get(self.service_items[item][u'service_item'].name). \
onRemoteEdit(self.service_items[item][u'service_item'].edit_id)
on_remote_edit(self.service_items[item][u'service_item'].edit_id)
if new_item:
self.add_service_item(new_item, replace=True)

View File

@ -1233,7 +1233,7 @@ class SlideController(DisplayController):
From the preview display requires the service Item to be editied
"""
self.song_edit = True
new_item = Registry().get(self.service_item.name).onRemoteEdit(self.service_item.edit_id, True)
new_item = Registry().get(self.service_item.name).on_remote_edit(self.service_item.edit_id, True)
if new_item:
self.add_service_item(new_item)

View File

@ -58,8 +58,6 @@ class WizardStrings(object):
ImportingType = translate('OpenLP.Ui', 'Importing "%s"...')
ImportSelect = translate('OpenLP.Ui', 'Select Import Source')
ImportSelectLong = translate('OpenLP.Ui', 'Select the import format and the location to import from.')
NoSqlite = translate('OpenLP.Ui', 'The openlp.org 1.x importer has been disabled due to a missing Python module. '
'If you want to use this importer, you will need to install the "python-sqlite" module.')
OpenTypeFile = translate('OpenLP.Ui', 'Open %s File')
OpenTypeFolder = translate('OpenLP.Ui', 'Open %s Folder')
PercentSymbolFormat = translate('OpenLP.Ui', '%p%')

View File

@ -27,6 +27,5 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`alerts` module provides the Alerts plugin for producing impromptu
on-screen announcements during a service.
The :mod:`alerts` module provides the Alerts plugin for producing impromptu on-screen announcements during a service.
"""

View File

@ -115,13 +115,13 @@ HTML = """
"""
__default_settings__ = {
u'alerts/font face': QtGui.QFont().family(),
u'alerts/font size': 40,
u'alerts/db type': u'sqlite',
u'alerts/location': AlertLocation.Bottom,
u'alerts/background color': u'#660000',
u'alerts/font color': u'#ffffff',
u'alerts/timeout': 5
u'alerts/font face': QtGui.QFont().family(),
u'alerts/font size': 40,
u'alerts/db type': u'sqlite',
u'alerts/location': AlertLocation.Bottom,
u'alerts/background color': u'#660000',
u'alerts/font color': u'#ffffff',
u'alerts/timeout': 5
}
@ -139,12 +139,10 @@ class AlertsPlugin(Plugin):
def add_tools_menu_item(self, tools_menu):
"""
Give the alerts plugin the opportunity to add items to the
**Tools** menu.
Give the alerts plugin the opportunity to add items to the **Tools** menu.
``tools_menu``
The actual **Tools** menu item, so that your actions can
use it as their parent.
The actual **Tools** menu item, so that your actions can use it as their parent.
"""
log.info(u'add tools menu')
self.tools_alert_item = create_action(tools_menu, u'toolsAlertItem',

View File

@ -27,20 +27,16 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
Forms in OpenLP are made up of two classes. One class holds all the graphical
elements, like buttons and lists, and the other class holds all the functional
code, like slots and loading and saving.
Forms in OpenLP are made up of two classes. One class holds all the graphical elements, like buttons and lists, and the
other class holds all the functional code, like slots and loading and saving.
The first class, commonly known as the **Dialog** class, is typically named
``Ui_<name>Dialog``. It is a slightly modified version of the class that the
``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be
converting most strings from "" to u'' and using OpenLP's ``translate()``
function for translating strings.
The first class, commonly known as the **Dialog** class, is typically named ``Ui_<name>Dialog``. It is a slightly
modified version of the class that the ``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be
converting most strings from "" to u'' and using OpenLP's ``translate()`` function for translating strings.
The second class, commonly known as the **Form** class, is typically named
``<name>Form``. This class is the one which is instantiated and used. It uses
dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class
mentioned above, like so::
The second class, commonly known as the **Form** class, is typically named ``<name>Form``. This class is the one which
is instantiated and used. It uses dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class mentioned
above, like so::
class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog):
@ -48,9 +44,8 @@ mentioned above, like so::
QtGui.QDialog.__init__(self, parent)
self.setupUi(self)
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping
them separate from the functionality, so that it is easier to recreate the GUI
from the .ui files later if necessary.
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality,
so that it is easier to recreate the GUI from the .ui files later if necessary.
"""
from alertform import AlertForm

View File

@ -71,13 +71,13 @@ class Ui_AlertDialog(object):
self.save_button.setObjectName(u'save_button')
self.manage_button_layout.addWidget(self.save_button)
self.delete_button = create_button(alert_dialog, u'delete_button', role=u'delete', enabled=False,
click=alert_dialog.onDeleteButtonClicked)
click=alert_dialog.on_delete_button_clicked)
self.manage_button_layout.addWidget(self.delete_button)
self.manage_button_layout.addStretch()
self.alert_dialog_layout.addLayout(self.manage_button_layout, 1, 1)
displayIcon = build_icon(u':/general/general_live.png')
self.display_button = create_button(alert_dialog, u'display_button', icon=displayIcon, enabled=False)
self.display_close_button = create_button(alert_dialog, u'display_close_button', icon=displayIcon,
display_icon = build_icon(u':/general/general_live.png')
self.display_button = create_button(alert_dialog, u'display_button', icon=display_icon, enabled=False)
self.display_close_button = create_button(alert_dialog, u'display_close_button', icon=display_icon,
enabled=False)
self.button_box = create_button_box(alert_dialog, u'button_box', [u'close'],
[self.display_button, self.display_close_button])

View File

@ -93,7 +93,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
if self.trigger_alert(self.alert_text_edit.text()):
self.close()
def onDeleteButtonClicked(self):
def on_delete_button_clicked(self):
"""
Deletes the selected item.
"""
@ -160,8 +160,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
def on_single_click(self):
"""
List item has been single clicked to add it to the edit field so it can
be changed.
List item has been single clicked to add it to the edit field so it can be changed.
"""
item = self.alert_list_widget.selectedIndexes()[0]
bitem = self.alert_list_widget.item(item.row())
@ -186,7 +185,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
translate('AlertsPlugin.AlertForm', 'No Parameter Found'),
translate('AlertsPlugin.AlertForm', 'You have not entered a parameter to be replaced.\n'
'Do you want to continue anyway?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
self.parameter_edit.setFocus()
return False
# The ParameterEdit field is not empty, but we have not found '<>'
@ -195,7 +194,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
translate('AlertsPlugin.AlertForm', 'No Placeholder Found'),
translate('AlertsPlugin.AlertForm', 'The alert text does not contain \'<>\'.\n'
'Do you want to continue anyway?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.No | QtGui.QMessageBox.Yes)) == QtGui.QMessageBox.No:
self.parameter_edit.setFocus()
return False
text = text.replace(u'<>', self.parameter_edit.text())
@ -204,8 +203,8 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog):
def on_current_row_changed(self, row):
"""
Called when the *alert_list_widget*'s current row has been changed. This
enables or disables buttons which require an item to act on.
Called when the *alert_list_widget*'s current row has been changed. This enables or disables buttons which
require an item to act on.
``row``
The row (int). If there is no current row, the value is -1.

View File

@ -27,8 +27,8 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`~openlp.plugins.alerts.lib.alertsmanager` module contains the part of
the plugin which manages storing and displaying of alerts.
The :mod:`~openlp.plugins.alerts.lib.alertsmanager` module contains the part of the plugin which manages storing and
displaying of alerts.
"""
import logging
@ -58,15 +58,14 @@ class AlertsManager(QtCore.QObject):
def alert_text(self, message):
"""
Called via a alerts_text event. Message is single element array
containing text
Called via a alerts_text event. Message is single element array containing text.
"""
if message:
self.display_alert(message[0])
def display_alert(self, text=u''):
"""
Called from the Alert Tab to display an alert
Called from the Alert Tab to display an alert.
``text``
display text
@ -83,7 +82,7 @@ class AlertsManager(QtCore.QObject):
def generate_alert(self):
"""
Format and request the Alert and start the timer
Format and request the Alert and start the timer.
"""
log.debug(u'Generate Alert called')
if not self.alert_list:
@ -97,8 +96,7 @@ class AlertsManager(QtCore.QObject):
def timerEvent(self, event):
"""
Time has finished so if our time then request the next Alert
if there is one and reset the timer.
Time has finished so if our time then request the next Alert if there is one and reset the timer.
``event``
the QT event that has been triggered.

View File

@ -27,8 +27,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`db` module provides the database and schema that is the backend for
the Alerts plugin
The :mod:`db` module provides the database and schema that is the backend for the Alerts plugin.
"""
from sqlalchemy import Column, Table, types
@ -36,12 +35,14 @@ from sqlalchemy.orm import mapper
from openlp.core.lib.db import BaseModel, init_db
class AlertItem(BaseModel):
"""
AlertItem model
"""
pass
def init_schema(url):
"""
Setup the alerts database connection and initialise the database schema

View File

@ -27,6 +27,5 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`bibles` module provides the Bible plugin to enable OpenLP to display
scripture.
The :mod:`bibles` module provides the Bible plugin to enable OpenLP to display scripture.
"""

View File

@ -43,25 +43,25 @@ log = logging.getLogger(__name__)
__default_settings__ = {
u'bibles/db type': u'sqlite',
u'bibles/last search type': BibleSearch.Reference,
u'bibles/verse layout style': LayoutStyle.VersePerSlide,
u'bibles/book name language': LanguageSelection.Bible,
u'bibles/display brackets': DisplayStyle.NoBrackets,
u'bibles/display new chapter': False,
u'bibles/second bibles': True,
u'bibles/advanced bible': u'',
u'bibles/quick bible': u'',
u'bibles/proxy name': u'',
u'bibles/proxy address': u'',
u'bibles/proxy username': u'',
u'bibles/proxy password': u'',
u'bibles/bible theme': u'',
u'bibles/verse separator': u'',
u'bibles/range separator': u'',
u'bibles/list separator': u'',
u'bibles/end separator': u'',
u'bibles/last directory import': u''
u'bibles/db type': u'sqlite',
u'bibles/last search type': BibleSearch.Reference,
u'bibles/verse layout style': LayoutStyle.VersePerSlide,
u'bibles/book name language': LanguageSelection.Bible,
u'bibles/display brackets': DisplayStyle.NoBrackets,
u'bibles/display new chapter': False,
u'bibles/second bibles': True,
u'bibles/advanced bible': u'',
u'bibles/quick bible': u'',
u'bibles/proxy name': u'',
u'bibles/proxy address': u'',
u'bibles/proxy username': u'',
u'bibles/proxy password': u'',
u'bibles/bible theme': u'',
u'bibles/verse separator': u'',
u'bibles/range separator': u'',
u'bibles/list separator': u'',
u'bibles/end separator': u'',
u'bibles/last directory import': u''
}
@ -124,18 +124,15 @@ class BiblePlugin(Plugin):
def add_export_menu_Item(self, export_menu):
self.export_bible_item = create_action(export_menu, u'exportBibleItem',
text=translate('BiblesPlugin', '&Bible'),
visible=False)
text=translate('BiblesPlugin', '&Bible'), visible=False)
export_menu.addAction(self.export_bible_item)
def add_tools_menu_item(self, tools_menu):
"""
Give the bible plugin the opportunity to add items to the
**Tools** menu.
Give the bible plugin the opportunity to add items to the **Tools** menu.
``tools_menu``
The actual **Tools** menu item, so that your actions can
use it as their parent.
The actual **Tools** menu item, so that your actions can use it as their parent.
"""
log.debug(u'add tools menu')
self.tools_upgrade_item = create_action(tools_menu, u'toolsUpgradeItem',
@ -166,25 +163,23 @@ class BiblePlugin(Plugin):
def uses_theme(self, theme):
"""
Called to find out if the bible plugin is currently using a theme.
Returns ``True`` if the theme is being used, otherwise returns
``False``.
Called to find out if the bible plugin is currently using a theme. Returns ``True`` if the theme is being used,
otherwise returns ``False``.
"""
return unicode(self.settings_tab.bible_theme) == theme
def rename_theme(self, oldTheme, newTheme):
def rename_theme(self, old_theme, new_theme):
"""
Rename the theme the bible plugin is using making the plugin use the
new name.
``oldTheme``
The name of the theme the plugin should stop using. Unused for
this particular plugin.
``old_theme``
The name of the theme the plugin should stop using. Unused for this particular plugin.
``newTheme``
``new_theme``
The new name the plugin should now use.
"""
self.settings_tab.bible_theme = newTheme
self.settings_tab.bible_theme = new_theme
self.settings_tab.save()
def set_plugin_text_strings(self):

View File

@ -28,30 +28,25 @@
###############################################################################
"""
Forms in OpenLP are made up of two classes. One class holds all the graphical
elements, like buttons and lists, and the other class holds all the functional
code, like slots and loading and saving.
Forms in OpenLP are made up of two classes. One class holds all the graphical elements, like buttons and lists, and the
other class holds all the functional code, like slots and loading and saving.
The first class, commonly known as the **Dialog** class, is typically named
``Ui_<name>Dialog``. It is a slightly modified version of the class that the
``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be
converting most strings from "" to u'' and using OpenLP's ``translate()``
function for translating strings.
The first class, commonly known as the **Dialog** class, is typically named ``Ui_<name>Dialog``. It is a slightly
modified version of the class that the ``pyuic4`` command produces from Qt4's .ui file. Typical modifications will be
converting most strings from "" to u'' and using OpenLP's ``translate()`` function for translating strings.
The second class, commonly known as the **Form** class, is typically named
``<name>Form``. This class is the one which is instantiated and used. It uses
dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class
mentioned above, like so::
The second class, commonly known as the **Form** class, is typically named ``<name>Form``. This class is the one which
is instantiated and used. It uses dual inheritance to inherit from (usually) QtGui.QDialog and the Ui class mentioned
above, like so::
class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
def __init__(self, parent, manager, bibleplugin):
def __init__(self, parent, manager, bible_plugin):
QtGui.QWizard.__init__(self, parent)
self.setupUi(self)
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping
them separate from the functionality, so that it is easier to recreate the GUI
from the .ui files later if necessary.
This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality,
so that it is easier to recreate the GUI from the .ui files later if necessary.
"""
from booknameform import BookNameForm
from languageform import LanguageForm
@ -59,5 +54,4 @@ from bibleimportform import BibleImportForm
from bibleupgradeform import BibleUpgradeForm
from editbibleform import EditBibleForm
__all__ = [u'BookNameForm', u'LanguageForm', u'BibleImportForm',
u'BibleUpgradeForm', u'EditBibleForm']
__all__ = [u'BookNameForm', u'LanguageForm', u'BibleImportForm', u'BibleUpgradeForm', u'EditBibleForm']

View File

@ -58,12 +58,12 @@ class WebDownload(object):
class BibleImportForm(OpenLPWizard):
"""
This is the Bible Import Wizard, which allows easy importing of Bibles
into OpenLP from other formats like OSIS, CSV and OpenSong.
This is the Bible Import Wizard, which allows easy importing of Bibles into OpenLP from other formats like OSIS,
CSV and OpenSong.
"""
log.info(u'BibleImportForm loaded')
def __init__(self, parent, manager, bibleplugin):
def __init__(self, parent, manager, bible_plugin):
"""
Instantiate the wizard, and run any extra setup we need to.
@ -73,12 +73,12 @@ class BibleImportForm(OpenLPWizard):
``manager``
The Bible manager.
``bibleplugin``
``bible_plugin``
The Bible plugin.
"""
self.manager = manager
self.web_bible_list = {}
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleImportWizard', u':/wizards/wizard_importbible.bmp')
OpenLPWizard.__init__(self, parent, bible_plugin, u'bibleImportWizard', u':/wizards/wizard_importbible.bmp')
def setupUi(self, image):
"""
@ -94,19 +94,11 @@ class BibleImportForm(OpenLPWizard):
button.
"""
self.selectStack.setCurrentIndex(index)
next_button = self.button(QtGui.QWizard.NextButton)
next_button.setEnabled(BibleFormat.get_availability(index))
def custom_init(self):
"""
Perform any custom initialisation for bible importing.
"""
if BibleFormat.get_availability(BibleFormat.OpenLP1):
self.openlp1DisabledLabel.hide()
else:
self.openlp1FileLabel.hide()
self.openlp1FileEdit.hide()
self.openlp1BrowseButton.hide()
self.manager.set_process_dialog(self)
self.loadWebBibles()
self.restart()
@ -121,7 +113,6 @@ class BibleImportForm(OpenLPWizard):
self.csvBooksButton.clicked.connect(self.onCsvBooksBrowseButtonClicked)
self.csvVersesButton.clicked.connect(self.onCsvVersesBrowseButtonClicked)
self.openSongBrowseButton.clicked.connect(self.onOpenSongBrowseButtonClicked)
self.openlp1BrowseButton.clicked.connect(self.onOpenlp1BrowseButtonClicked)
def add_custom_pages(self):
"""
@ -137,7 +128,7 @@ class BibleImportForm(OpenLPWizard):
self.formatLabel = QtGui.QLabel(self.selectPage)
self.formatLabel.setObjectName(u'FormatLabel')
self.formatComboBox = QtGui.QComboBox(self.selectPage)
self.formatComboBox.addItems([u'', u'', u'', u'', u''])
self.formatComboBox.addItems([u'', u'', u'', u''])
self.formatComboBox.setObjectName(u'FormatComboBox')
self.formatLayout.addRow(self.formatLabel, self.formatComboBox)
self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
@ -259,29 +250,6 @@ class BibleImportForm(OpenLPWizard):
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.webPasswordEdit)
self.webTabWidget.addTab(self.webProxyTab, u'')
self.selectStack.addWidget(self.webTabWidget)
self.openlp1Widget = QtGui.QWidget(self.selectPage)
self.openlp1Widget.setObjectName(u'Openlp1Widget')
self.openlp1Layout = QtGui.QFormLayout(self.openlp1Widget)
self.openlp1Layout.setMargin(0)
self.openlp1Layout.setObjectName(u'Openlp1Layout')
self.openlp1FileLabel = QtGui.QLabel(self.openlp1Widget)
self.openlp1FileLabel.setObjectName(u'Openlp1FileLabel')
self.openlp1FileLayout = QtGui.QHBoxLayout()
self.openlp1FileLayout.setObjectName(u'Openlp1FileLayout')
self.openlp1FileEdit = QtGui.QLineEdit(self.openlp1Widget)
self.openlp1FileEdit.setObjectName(u'Openlp1FileEdit')
self.openlp1FileLayout.addWidget(self.openlp1FileEdit)
self.openlp1BrowseButton = QtGui.QToolButton(self.openlp1Widget)
self.openlp1BrowseButton.setIcon(self.open_icon)
self.openlp1BrowseButton.setObjectName(u'Openlp1BrowseButton')
self.openlp1FileLayout.addWidget(self.openlp1BrowseButton)
self.openlp1Layout.addRow(self.openlp1FileLabel, self.openlp1FileLayout)
self.openlp1DisabledLabel = QtGui.QLabel(self.openlp1Widget)
self.openlp1DisabledLabel.setWordWrap(True)
self.openlp1DisabledLabel.setObjectName(u'Openlp1DisabledLabel')
self.openlp1Layout.addRow(self.openlp1DisabledLabel)
self.openlp1Layout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer)
self.selectStack.addWidget(self.openlp1Widget)
self.selectPageLayout.addLayout(self.selectStack)
self.addPage(self.selectPage)
# License Page
@ -330,8 +298,6 @@ class BibleImportForm(OpenLPWizard):
self.formatComboBox.setItemText(BibleFormat.OpenSong, WizardStrings.OS)
self.formatComboBox.setItemText(BibleFormat.WebDownload,
translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
self.formatComboBox.setItemText(BibleFormat.OpenLP1, UiStrings().OLPV1)
self.openlp1FileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
self.osisFileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
self.csvBooksLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Books file:'))
self.csvVersesLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Verses file:'))
@ -364,14 +330,12 @@ class BibleImportForm(OpenLPWizard):
'Please wait while your Bible is imported.'))
self.progress_label.setText(WizardStrings.Ready)
self.progress_bar.setFormat(u'%p%')
self.openlp1DisabledLabel.setText(WizardStrings.NoSqlite)
# Align all QFormLayouts towards each other.
labelWidth = max(self.formatLabel.minimumSizeHint().width(),
self.osisFileLabel.minimumSizeHint().width(),
self.csvBooksLabel.minimumSizeHint().width(),
self.csvVersesLabel.minimumSizeHint().width(),
self.openSongFileLabel.minimumSizeHint().width(),
self.openlp1FileLabel.minimumSizeHint().width())
self.openSongFileLabel.minimumSizeHint().width())
self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
def validateCurrentPage(self):
@ -406,11 +370,6 @@ class BibleImportForm(OpenLPWizard):
elif self.field(u'source_format') == BibleFormat.WebDownload:
self.versionNameEdit.setText(self.webTranslationComboBox.currentText())
return True
elif self.field(u'source_format') == BibleFormat.OpenLP1:
if not self.field(u'openlp1_location'):
critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % UiStrings().OLPV1)
self.openlp1FileEdit.setFocus()
return False
return True
elif self.currentPage() == self.licenseDetailsPage:
license_version = self.field(u'license_version')
@ -484,13 +443,6 @@ class BibleImportForm(OpenLPWizard):
"""
self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit, u'last directory import')
def onOpenlp1BrowseButtonClicked(self):
"""
Show the file open dialog for the openlp.org 1.x file.
"""
self.get_file_name(WizardStrings.OpenTypeFile % UiStrings().OLPV1, self.openlp1FileEdit, u'last directory import',
u'%s (*.bible)' % translate('BiblesPlugin.ImportWizardForm', 'openlp.org 1.x Bible Files'))
def register_fields(self):
"""
Register the bible import wizard fields.
@ -505,7 +457,6 @@ class BibleImportForm(OpenLPWizard):
self.selectPage.registerField(u'proxy_server', self.webServerEdit)
self.selectPage.registerField(u'proxy_username', self.webUserEdit)
self.selectPage.registerField(u'proxy_password', self.webPasswordEdit)
self.selectPage.registerField(u'openlp1_location', self.openlp1FileEdit)
self.licenseDetailsPage.registerField(u'license_version', self.versionNameEdit)
self.licenseDetailsPage.registerField(u'license_copyright', self.copyrightEdit)
self.licenseDetailsPage.registerField(u'license_permissions', self.permissionsEdit)
@ -529,7 +480,6 @@ class BibleImportForm(OpenLPWizard):
self.setField(u'proxy_server', settings.value(u'proxy address'))
self.setField(u'proxy_username', settings.value(u'proxy username'))
self.setField(u'proxy_password', settings.value(u'proxy password'))
self.setField(u'openlp1_location', '')
self.setField(u'license_version', self.versionNameEdit.text())
self.setField(u'license_copyright', self.copyrightEdit.text())
self.setField(u'license_permissions', self.permissionsEdit.text())
@ -615,12 +565,6 @@ class BibleImportForm(OpenLPWizard):
proxy_username=self.field(u'proxy_username'),
proxy_password=self.field(u'proxy_password')
)
elif bible_type == BibleFormat.OpenLP1:
# Import an openlp.org 1.x bible.
importer = self.manager.import_bible(BibleFormat.OpenLP1,
name=license_version,
filename=self.field(u'openlp1_location')
)
if importer.do_import(license_version):
self.manager.save_meta_data(license_version, license_version,
license_copyright, license_permissions)

View File

@ -48,8 +48,8 @@ log = logging.getLogger(__name__)
class BibleUpgradeForm(OpenLPWizard):
"""
This is the Bible Upgrade Wizard, which allows easy importing of Bibles
into OpenLP from older OpenLP2 database versions.
This is the Bible Upgrade Wizard, which allows easy importing of Bibles into OpenLP from older OpenLP2 database
versions.
"""
log.info(u'BibleUpgradeForm loaded')
@ -63,7 +63,7 @@ class BibleUpgradeForm(OpenLPWizard):
``manager``
The Bible manager.
``bibleplugin``
``bible_plugin``
The Bible plugin.
"""
self.manager = manager
@ -74,7 +74,7 @@ class BibleUpgradeForm(OpenLPWizard):
self.temp_dir = os.path.join(unicode(gettempdir(), get_filesystem_encoding()), u'openlp')
self.files = self.manager.old_bible_databases
self.success = {}
self.newbibles = {}
self.new_bibles = {}
OpenLPWizard.__init__(self, parent, bible_plugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp')
def setupUi(self, image):
@ -159,41 +159,41 @@ class BibleUpgradeForm(OpenLPWizard):
Add the bible import specific wizard pages.
"""
# Backup Page
self.backupPage = QtGui.QWizardPage()
self.backupPage.setObjectName(u'BackupPage')
self.backupLayout = QtGui.QVBoxLayout(self.backupPage)
self.backup_page = QtGui.QWizardPage()
self.backup_page.setObjectName(u'BackupPage')
self.backupLayout = QtGui.QVBoxLayout(self.backup_page)
self.backupLayout.setObjectName(u'BackupLayout')
self.backupInfoLabel = QtGui.QLabel(self.backupPage)
self.backupInfoLabel = QtGui.QLabel(self.backup_page)
self.backupInfoLabel.setOpenExternalLinks(True)
self.backupInfoLabel.setTextFormat(QtCore.Qt.RichText)
self.backupInfoLabel.setWordWrap(True)
self.backupInfoLabel.setObjectName(u'backupInfoLabel')
self.backupLayout.addWidget(self.backupInfoLabel)
self.selectLabel = QtGui.QLabel(self.backupPage)
self.selectLabel = QtGui.QLabel(self.backup_page)
self.selectLabel.setObjectName(u'select_label')
self.backupLayout.addWidget(self.selectLabel)
self.formLayout = QtGui.QFormLayout()
self.formLayout.setMargin(0)
self.formLayout.setObjectName(u'FormLayout')
self.backupDirectoryLabel = QtGui.QLabel(self.backupPage)
self.backupDirectoryLabel = QtGui.QLabel(self.backup_page)
self.backupDirectoryLabel.setObjectName(u'backupDirectoryLabel')
self.backupDirectoryLayout = QtGui.QHBoxLayout()
self.backupDirectoryLayout.setObjectName(u'BackupDirectoryLayout')
self.backupDirectoryEdit = QtGui.QLineEdit(self.backupPage)
self.backupDirectoryEdit = QtGui.QLineEdit(self.backup_page)
self.backupDirectoryEdit.setObjectName(u'BackupFolderEdit')
self.backupDirectoryLayout.addWidget(self.backupDirectoryEdit)
self.backupBrowseButton = QtGui.QToolButton(self.backupPage)
self.backupBrowseButton = QtGui.QToolButton(self.backup_page)
self.backupBrowseButton.setIcon(self.open_icon)
self.backupBrowseButton.setObjectName(u'BackupBrowseButton')
self.backupDirectoryLayout.addWidget(self.backupBrowseButton)
self.formLayout.addRow(self.backupDirectoryLabel, self.backupDirectoryLayout)
self.backupLayout.addLayout(self.formLayout)
self.noBackupCheckBox = QtGui.QCheckBox(self.backupPage)
self.noBackupCheckBox = QtGui.QCheckBox(self.backup_page)
self.noBackupCheckBox.setObjectName('NoBackupCheckBox')
self.backupLayout.addWidget(self.noBackupCheckBox)
self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
self.backupLayout.addItem(self.spacer)
self.addPage(self.backupPage)
self.addPage(self.backup_page)
# Select Page
self.selectPage = QtGui.QWizardPage()
self.selectPage.setObjectName(u'SelectPage')
@ -247,8 +247,8 @@ class BibleUpgradeForm(OpenLPWizard):
self.information_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
'This wizard will help you to upgrade your existing Bibles from a prior version of OpenLP 2. '
'Click the next button below to start the upgrade process.'))
self.backupPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Backup Directory'))
self.backupPage.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm',
self.backup_page.setTitle(translate('BiblesPlugin.UpgradeWizardForm', 'Select Backup Directory'))
self.backup_page.setSubTitle(translate('BiblesPlugin.UpgradeWizardForm',
'Please select a backup directory for your Bibles'))
self.backupInfoLabel.setText(translate('BiblesPlugin.UpgradeWizardForm',
'Previous releases of OpenLP 2.0 are unable to use upgraded Bibles.'
@ -277,7 +277,7 @@ class BibleUpgradeForm(OpenLPWizard):
"""
if self.currentPage() == self.welcome_page:
return True
elif self.currentPage() == self.backupPage:
elif self.currentPage() == self.backup_page:
if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked:
backup_path = self.backupDirectoryEdit.text()
if not backup_path:
@ -316,7 +316,7 @@ class BibleUpgradeForm(OpenLPWizard):
settings.beginGroup(self.plugin.settings_section)
self.stop_import_flag = False
self.success.clear()
self.newbibles.clear()
self.new_bibles.clear()
self.clearScrollArea()
self.files = self.manager.old_bible_databases
self.addScrollArea()
@ -372,8 +372,8 @@ class BibleUpgradeForm(OpenLPWizard):
name = filename[1]
self.progress_label.setText(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nUpgrading ...') % (number + 1, max_bibles, name))
self.newbibles[number] = BibleDB(self.media_item, path=self.path, name=name, file=filename[0])
self.newbibles[number].register(self.plugin.upgrade_wizard)
self.new_bibles[number] = BibleDB(self.media_item, path=self.path, name=name, file=filename[0])
self.new_bibles[number].register(self.plugin.upgrade_wizard)
metadata = old_bible.get_metadata()
web_bible = False
meta_data = {}
@ -387,7 +387,7 @@ class BibleUpgradeForm(OpenLPWizard):
# Copy the metadata
meta_data[meta[u'key']] = meta[u'value']
if meta[u'key'] != u'name' and meta[u'key'] != u'dbversion':
self.newbibles[number].save_meta(meta[u'key'], meta[u'value'])
self.new_bibles[number].save_meta(meta[u'key'], meta[u'value'])
if meta[u'key'] == u'download_source':
web_bible = True
self.includeWebBible = True
@ -403,8 +403,8 @@ class BibleUpgradeForm(OpenLPWizard):
if not books:
log.error(u'Upgrading books from %s - download name: "%s" failed' % (
meta_data[u'download_source'], meta_data[u'download_name']))
self.newbibles[number].session.close()
del self.newbibles[number]
self.new_bibles[number].session.close()
del self.new_bibles[number]
critical_error_message_box(
translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'),
translate('BiblesPlugin.UpgradeWizardForm',
@ -419,14 +419,14 @@ class BibleUpgradeForm(OpenLPWizard):
meta_data[u'download_source'].lower())
if bible and bible[u'language_id']:
language_id = bible[u'language_id']
self.newbibles[number].save_meta(u'language_id',
self.new_bibles[number].save_meta(u'language_id',
language_id)
else:
language_id = self.newbibles[number].get_language(name)
language_id = self.new_bibles[number].get_language(name)
if not language_id:
log.warn(u'Upgrading from "%s" failed' % filename[0])
self.newbibles[number].session.close()
del self.newbibles[number]
self.new_bibles[number].session.close()
del self.new_bibles[number]
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
self.progress_bar.maximum() - self.progress_bar.value())
@ -439,17 +439,17 @@ class BibleUpgradeForm(OpenLPWizard):
break
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') % (number + 1, max_bibles, name, book))
book_ref_id = self.newbibles[number].\
book_ref_id = self.new_bibles[number].\
get_book_ref_id_by_name(book, len(books), language_id)
if not book_ref_id:
log.warn(u'Upgrading books from %s - download name: "%s" aborted by user' % (
meta_data[u'download_source'], meta_data[u'download_name']))
self.newbibles[number].session.close()
del self.newbibles[number]
self.new_bibles[number].session.close()
del self.new_bibles[number]
self.success[number] = False
break
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
db_book = self.newbibles[number].create_book(book,
db_book = self.new_bibles[number].create_book(book,
book_ref_id, book_details[u'testament_id'])
# Try to import already downloaded verses.
oldbook = old_bible.get_book(book)
@ -462,19 +462,19 @@ class BibleUpgradeForm(OpenLPWizard):
if self.stop_import_flag:
self.success[number] = False
break
self.newbibles[number].create_verse(db_book.id,
self.new_bibles[number].create_verse(db_book.id,
int(verse[u'chapter']),
int(verse[u'verse']), unicode(verse[u'text']))
self.application.process_events()
self.newbibles[number].session.commit()
self.new_bibles[number].session.commit()
else:
language_id = self.newbibles[number].get_object(BibleMeta, u'language_id')
language_id = self.new_bibles[number].get_object(BibleMeta, u'language_id')
if not language_id:
language_id = self.newbibles[number].get_language(name)
language_id = self.new_bibles[number].get_language(name)
if not language_id:
log.warn(u'Upgrading books from "%s" failed' % name)
self.newbibles[number].session.close()
del self.newbibles[number]
self.new_bibles[number].session.close()
del self.new_bibles[number]
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
self.progress_bar.maximum() - self.progress_bar.value())
@ -489,41 +489,41 @@ class BibleUpgradeForm(OpenLPWizard):
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nUpgrading %s ...') %
(number + 1, max_bibles, name, book[u'name']))
book_ref_id = self.newbibles[number].get_book_ref_id_by_name(book[u'name'], len(books), language_id)
book_ref_id = self.new_bibles[number].get_book_ref_id_by_name(book[u'name'], len(books), language_id)
if not book_ref_id:
log.warn(u'Upgrading books from %s " failed - aborted by user' % name)
self.newbibles[number].session.close()
del self.newbibles[number]
self.new_bibles[number].session.close()
del self.new_bibles[number]
self.success[number] = False
break
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
db_book = self.newbibles[number].create_book(book[u'name'],
db_book = self.new_bibles[number].create_book(book[u'name'],
book_ref_id, book_details[u'testament_id'])
verses = old_bible.get_verses(book[u'id'])
if not verses:
log.warn(u'No verses found to import for book "%s"', book[u'name'])
self.newbibles[number].delete_book(db_book)
self.new_bibles[number].delete_book(db_book)
continue
for verse in verses:
if self.stop_import_flag:
self.success[number] = False
break
self.newbibles[number].create_verse(db_book.id,
self.new_bibles[number].create_verse(db_book.id,
int(verse[u'chapter']),
int(verse[u'verse']), unicode(verse[u'text']))
self.application.process_events()
self.newbibles[number].session.commit()
self.new_bibles[number].session.commit()
if not self.success.get(number, True):
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nFailed') % (number + 1, max_bibles, name),
self.progress_bar.maximum() - self.progress_bar.value())
else:
self.success[number] = True
self.newbibles[number].save_meta(u'name', name)
self.new_bibles[number].save_meta(u'name', name)
self.increment_progress_bar(translate('BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\nComplete') % (number + 1, max_bibles, name))
if number in self.newbibles:
self.newbibles[number].session.close()
if number in self.new_bibles:
self.new_bibles[number].session.close()
# Close the last bible's connection if possible.
if old_bible is not None:
old_bible.close_connection()

View File

@ -33,66 +33,66 @@ from openlp.core.lib import translate
from openlp.core.lib.ui import create_button_box
class Ui_BookNameDialog(object):
def setupUi(self, bookNameDialog):
bookNameDialog.setObjectName(u'bookNameDialog')
bookNameDialog.resize(400, 271)
self.bookNameLayout = QtGui.QVBoxLayout(bookNameDialog)
self.bookNameLayout.setSpacing(8)
self.bookNameLayout.setMargin(8)
self.bookNameLayout.setObjectName(u'bookNameLayout')
self.infoLabel = QtGui.QLabel(bookNameDialog)
self.infoLabel.setWordWrap(True)
self.infoLabel.setObjectName(u'infoLabel')
self.bookNameLayout.addWidget(self.infoLabel)
self.correspondingLayout = QtGui.QGridLayout()
self.correspondingLayout.setColumnStretch(1, 1)
self.correspondingLayout.setSpacing(8)
self.correspondingLayout.setObjectName(u'correspondingLayout')
self.currentLabel = QtGui.QLabel(bookNameDialog)
def setupUi(self, book_name_dialog):
book_name_dialog.setObjectName(u'book_name_dialog')
book_name_dialog.resize(400, 271)
self.book_name_layout = QtGui.QVBoxLayout(book_name_dialog)
self.book_name_layout.setSpacing(8)
self.book_name_layout.setMargin(8)
self.book_name_layout.setObjectName(u'book_name_layout')
self.info_label = QtGui.QLabel(book_name_dialog)
self.info_label.setWordWrap(True)
self.info_label.setObjectName(u'info_label')
self.book_name_layout.addWidget(self.info_label)
self.corresponding_layout = QtGui.QGridLayout()
self.corresponding_layout.setColumnStretch(1, 1)
self.corresponding_layout.setSpacing(8)
self.corresponding_layout.setObjectName(u'corresponding_layout')
self.currentLabel = QtGui.QLabel(book_name_dialog)
self.currentLabel.setObjectName(u'currentLabel')
self.correspondingLayout.addWidget(self.currentLabel, 0, 0, 1, 1)
self.currentBookLabel = QtGui.QLabel(bookNameDialog)
self.currentBookLabel.setObjectName(u'currentBookLabel')
self.correspondingLayout.addWidget(self.currentBookLabel, 0, 1, 1, 1)
self.correspondingLabel = QtGui.QLabel(bookNameDialog)
self.corresponding_layout.addWidget(self.currentLabel, 0, 0, 1, 1)
self.current_book_label = QtGui.QLabel(book_name_dialog)
self.current_book_label.setObjectName(u'current_book_label')
self.corresponding_layout.addWidget(self.current_book_label, 0, 1, 1, 1)
self.correspondingLabel = QtGui.QLabel(book_name_dialog)
self.correspondingLabel.setObjectName(u'correspondingLabel')
self.correspondingLayout.addWidget(self.correspondingLabel, 1, 0, 1, 1)
self.correspondingComboBox = QtGui.QComboBox(bookNameDialog)
self.correspondingComboBox.setObjectName(u'correspondingComboBox')
self.correspondingLayout.addWidget(self.correspondingComboBox, 1, 1, 1, 1)
self.bookNameLayout.addLayout(self.correspondingLayout)
self.optionsGroupBox = QtGui.QGroupBox(bookNameDialog)
self.optionsGroupBox.setObjectName(u'optionsGroupBox')
self.optionsLayout = QtGui.QVBoxLayout(self.optionsGroupBox)
self.optionsLayout.setSpacing(8)
self.optionsLayout.setMargin(8)
self.optionsLayout.setObjectName(u'optionsLayout')
self.oldTestamentCheckBox = QtGui.QCheckBox(self.optionsGroupBox)
self.oldTestamentCheckBox.setObjectName(u'oldTestamentCheckBox')
self.oldTestamentCheckBox.setCheckState(QtCore.Qt.Checked)
self.optionsLayout.addWidget(self.oldTestamentCheckBox)
self.newTestamentCheckBox = QtGui.QCheckBox(self.optionsGroupBox)
self.newTestamentCheckBox.setObjectName(u'newTestamentCheckBox')
self.newTestamentCheckBox.setCheckState(QtCore.Qt.Checked)
self.optionsLayout.addWidget(self.newTestamentCheckBox)
self.apocryphaCheckBox = QtGui.QCheckBox(self.optionsGroupBox)
self.apocryphaCheckBox.setObjectName(u'apocryphaCheckBox')
self.apocryphaCheckBox.setCheckState(QtCore.Qt.Checked)
self.optionsLayout.addWidget(self.apocryphaCheckBox)
self.bookNameLayout.addWidget(self.optionsGroupBox)
self.button_box = create_button_box(bookNameDialog, u'button_box', [u'cancel', u'ok'])
self.bookNameLayout.addWidget(self.button_box)
self.corresponding_layout.addWidget(self.correspondingLabel, 1, 0, 1, 1)
self.corresponding_combo_box = QtGui.QComboBox(book_name_dialog)
self.corresponding_combo_box.setObjectName(u'corresponding_combo_box')
self.corresponding_layout.addWidget(self.corresponding_combo_box, 1, 1, 1, 1)
self.book_name_layout.addLayout(self.corresponding_layout)
self.options_group_box = QtGui.QGroupBox(book_name_dialog)
self.options_group_box.setObjectName(u'options_group_box')
self.options_layout = QtGui.QVBoxLayout(self.options_group_box)
self.options_layout.setSpacing(8)
self.options_layout.setMargin(8)
self.options_layout.setObjectName(u'options_layout')
self.old_testament_check_box = QtGui.QCheckBox(self.options_group_box)
self.old_testament_check_box.setObjectName(u'old_testament_check_box')
self.old_testament_check_box.setCheckState(QtCore.Qt.Checked)
self.options_layout.addWidget(self.old_testament_check_box)
self.new_testament_check_box = QtGui.QCheckBox(self.options_group_box)
self.new_testament_check_box.setObjectName(u'new_testament_check_box')
self.new_testament_check_box.setCheckState(QtCore.Qt.Checked)
self.options_layout.addWidget(self.new_testament_check_box)
self.apocrypha_check_box = QtGui.QCheckBox(self.options_group_box)
self.apocrypha_check_box.setObjectName(u'apocrypha_check_box')
self.apocrypha_check_box.setCheckState(QtCore.Qt.Checked)
self.options_layout.addWidget(self.apocrypha_check_box)
self.book_name_layout.addWidget(self.options_group_box)
self.button_box = create_button_box(book_name_dialog, u'button_box', [u'cancel', u'ok'])
self.book_name_layout.addWidget(self.button_box)
self.retranslateUi(bookNameDialog)
self.retranslateUi(book_name_dialog)
def retranslateUi(self, bookNameDialog):
bookNameDialog.setWindowTitle(translate('BiblesPlugin.BookNameDialog', 'Select Book Name'))
self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog',
def retranslateUi(self, book_name_dialog):
book_name_dialog.setWindowTitle(translate('BiblesPlugin.BookNameDialog', 'Select Book Name'))
self.info_label.setText(translate('BiblesPlugin.BookNameDialog',
'The following book name cannot be matched up internally. '
'Please select the corresponding name from the list.'))
self.currentLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Current name:'))
self.correspondingLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Corresponding name:'))
self.optionsGroupBox.setTitle(translate('BiblesPlugin.BookNameDialog', 'Show Books From'))
self.oldTestamentCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'Old Testament'))
self.newTestamentCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'New Testament'))
self.apocryphaCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'Apocrypha'))
self.options_group_box.setTitle(translate('BiblesPlugin.BookNameDialog', 'Show Books From'))
self.old_testament_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'Old Testament'))
self.new_testament_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'New Testament'))
self.apocrypha_check_box.setText(translate('BiblesPlugin.BookNameDialog', 'Apocrypha'))

View File

@ -66,61 +66,61 @@ class BookNameForm(QDialog, Ui_BookNameDialog):
"""
Set up the signals used in the booknameform.
"""
self.oldTestamentCheckBox.stateChanged.connect(self.onCheckBoxIndexChanged)
self.newTestamentCheckBox.stateChanged.connect(self.onCheckBoxIndexChanged)
self.apocryphaCheckBox.stateChanged.connect(self.onCheckBoxIndexChanged)
self.old_testament_check_box.stateChanged.connect(self.onCheckBoxIndexChanged)
self.new_testament_check_box.stateChanged.connect(self.onCheckBoxIndexChanged)
self.apocrypha_check_box.stateChanged.connect(self.onCheckBoxIndexChanged)
def onCheckBoxIndexChanged(self, index):
"""
Reload Combobox if CheckBox state has changed
"""
self.reloadComboBox()
self.reload_combo_box()
def reloadComboBox(self):
def reload_combo_box(self):
"""
Reload the Combobox items
"""
self.correspondingComboBox.clear()
self.corresponding_combo_box.clear()
items = BiblesResourcesDB.get_books()
for item in items:
addBook = True
add_book = True
for book in self.books:
if book.book_reference_id == item[u'id']:
addBook = False
add_book = False
break
if self.oldTestamentCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 1:
addBook = False
elif self.newTestamentCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 2:
addBook = False
elif self.apocryphaCheckBox.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 3:
addBook = False
if addBook:
self.correspondingComboBox.addItem(self.book_names[item[u'abbreviation']])
if self.old_testament_check_box.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 1:
add_book = False
elif self.new_testament_check_box.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 2:
add_book = False
elif self.apocrypha_check_box.checkState() == QtCore.Qt.Unchecked and item[u'testament_id'] == 3:
add_book = False
if add_book:
self.corresponding_combo_box.addItem(self.book_names[item[u'abbreviation']])
def exec_(self, name, books, maxbooks):
def exec_(self, name, books, max_books):
self.books = books
log.debug(maxbooks)
if maxbooks <= 27:
self.oldTestamentCheckBox.setCheckState(QtCore.Qt.Unchecked)
self.apocryphaCheckBox.setCheckState(QtCore.Qt.Unchecked)
elif maxbooks <= 66:
self.apocryphaCheckBox.setCheckState(QtCore.Qt.Unchecked)
self.reloadComboBox()
self.currentBookLabel.setText(unicode(name))
self.correspondingComboBox.setFocus()
log.debug(max_books)
if max_books <= 27:
self.old_testament_check_box.setCheckState(QtCore.Qt.Unchecked)
self.apocrypha_check_box.setCheckState(QtCore.Qt.Unchecked)
elif max_books <= 66:
self.apocrypha_check_box.setCheckState(QtCore.Qt.Unchecked)
self.reload_combo_box()
self.current_book_label.setText(unicode(name))
self.corresponding_combo_box.setFocus()
return QDialog.exec_(self)
def accept(self):
if self.correspondingComboBox.currentText() == u'':
if not self.corresponding_combo_box.currentText():
critical_error_message_box(message=translate('BiblesPlugin.BookNameForm', 'You need to select a book.'))
self.correspondingComboBox.setFocus()
self.corresponding_combo_box.setFocus()
return False
else:
cor_book = self.correspondingComboBox.currentText()
cor_book = self.corresponding_combo_box.currentText()
for character in u'\\.^$*+?{}[]()':
cor_book = cor_book.replace(character, u'\\' + character)
books = filter(lambda key:
re.match(cor_book, unicode(self.book_names[key]), re.UNICODE), self.book_names.keys())
books = filter(
lambda key: re.match(cor_book, unicode(self.book_names[key]), re.UNICODE), self.book_names.keys())
books = filter(None, map(BiblesResourcesDB.get_book, books))
if books:
self.book_id = books[0][u'id']

View File

@ -36,118 +36,118 @@ from openlp.plugins.bibles.lib.db import BiblesResourcesDB
class Ui_EditBibleDialog(object):
def setupUi(self, editBibleDialog):
editBibleDialog.setObjectName(u'editBibleDialog')
editBibleDialog.resize(520, 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'dialog_layout')
self.bibleTabWidget = QtGui.QTabWidget(editBibleDialog)
self.bibleTabWidget.setObjectName(u'BibleTabWidget')
def setupUi(self, edit_bible_dialog):
edit_bible_dialog.setObjectName(u'edit_bible_dialog')
edit_bible_dialog.resize(520, 400)
edit_bible_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo-16x16.png'))
edit_bible_dialog.setModal(True)
self.dialog_layout = QtGui.QVBoxLayout(edit_bible_dialog)
self.dialog_layout.setSpacing(8)
self.dialog_layout.setContentsMargins(8, 8, 8, 8)
self.dialog_layout.setObjectName(u'dialog_layout')
self.bible_tab_widget = QtGui.QTabWidget(edit_bible_dialog)
self.bible_tab_widget.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'copyright_edit')
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'')
self.meta_tab = QtGui.QWidget()
self.meta_tab.setObjectName(u'meta_tab')
self.meta_tab_layout = QtGui.QVBoxLayout(self.meta_tab)
self.meta_tab_layout.setObjectName(u'meta_tab_layout')
self.license_details_group_box = QtGui.QGroupBox(self.meta_tab)
self.license_details_group_box.setObjectName(u'license_details_group_box')
self.license_details_layout = QtGui.QFormLayout(self.license_details_group_box)
self.license_details_layout.setObjectName(u'license_details_layout')
self.version_name_label = QtGui.QLabel(self.license_details_group_box)
self.version_name_label.setObjectName(u'version_name_label')
self.version_name_edit = QtGui.QLineEdit(self.license_details_group_box)
self.version_name_edit.setObjectName(u'version_name_edit')
self.version_name_label.setBuddy(self.version_name_edit)
self.license_details_layout.addRow(self.version_name_label, self.version_name_edit)
self.copyright_label = QtGui.QLabel(self.license_details_group_box)
self.copyright_label.setObjectName(u'copyright_label')
self.copyright_edit = QtGui.QLineEdit(self.license_details_group_box)
self.copyright_edit.setObjectName(u'copyright_edit')
self.copyright_label.setBuddy(self.copyright_edit)
self.license_details_layout.addRow(self.copyright_label, self.copyright_edit)
self.permissions_label = QtGui.QLabel(self.license_details_group_box)
self.permissions_label.setObjectName(u'permissions_label')
self.permissions_edit = QtGui.QLineEdit(self.license_details_group_box)
self.permissions_edit.setObjectName(u'permissions_edit')
self.permissions_label.setBuddy(self.permissions_edit)
self.license_details_layout.addRow(self.permissions_label, self.permissions_edit)
self.meta_tab_layout.addWidget(self.license_details_group_box)
self.language_selection_group_box = QtGui.QGroupBox(self.meta_tab)
self.language_selection_group_box.setObjectName(u'language_selection_group_box')
self.language_selection_layout = QtGui.QVBoxLayout(self.language_selection_group_box)
self.language_selection_label = QtGui.QLabel(self.language_selection_group_box)
self.language_selection_label.setObjectName(u'language_selection_label')
self.language_selection_combo_box = QtGui.QComboBox(self.language_selection_group_box)
self.language_selection_combo_box.setObjectName(u'language_selection_combo_box')
self.language_selection_combo_box.addItems([u'', u'', u'', u''])
self.language_selection_layout.addWidget(self.language_selection_label)
self.language_selection_layout.addWidget(self.language_selection_combo_box)
self.meta_tab_layout.addWidget(self.language_selection_group_box)
self.meta_tab_layout.addStretch()
self.bible_tab_widget.addTab(self.meta_tab, 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.bookNameNotice.setWordWrap(True)
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= {}
self.book_name_tab = QtGui.QWidget()
self.book_name_tab.setObjectName(u'book_name_tab')
self.book_name_tab_layout = QtGui.QVBoxLayout(self.book_name_tab)
self.book_name_tab_layout.setObjectName(u'book_name_tab_layout')
self.book_name_notice = QtGui.QLabel(self.book_name_tab)
self.book_name_notice.setObjectName(u'book_name_notice')
self.book_name_notice.setWordWrap(True)
self.book_name_tab_layout.addWidget(self.book_name_notice)
self.scroll_area = QtGui.QScrollArea(self.book_name_tab)
self.scroll_area.setWidgetResizable(True)
self.scroll_area.setObjectName(u'scroll_area')
self.scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
self.book_name_widget = QtGui.QWidget(self.scroll_area)
self.book_name_widget.setObjectName(u'book_name_widget')
self.book_name_widget_layout = QtGui.QFormLayout(self.book_name_widget)
self.book_name_widget_layout.setObjectName(u'book_name_widget_layout')
self.book_name_label = {}
self.book_name_edit= {}
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'')
self.book_name_label[book[u'abbreviation']] = QtGui.QLabel(self.book_name_widget)
self.book_name_label[book[u'abbreviation']].setObjectName(u'book_name_label[%s]' % book[u'abbreviation'])
self.book_name_edit[book[u'abbreviation']] = QtGui.QLineEdit(self.book_name_widget)
self.book_name_edit[book[u'abbreviation']].setObjectName(u'book_name_edit[%s]' % book[u'abbreviation'])
self.book_name_widget_layout.addRow(
self.book_name_label[book[u'abbreviation']],
self.book_name_edit[book[u'abbreviation']])
self.scroll_area.setWidget(self.book_name_widget)
self.book_name_tab_layout.addWidget(self.scroll_area)
self.book_name_tab_layout.addStretch()
self.bible_tab_widget.addTab(self.book_name_tab, u'')
# Last few bits
self.dialogLayout.addWidget(self.bibleTabWidget)
self.button_box = create_button_box(editBibleDialog, u'button_box', [u'cancel', u'save'])
self.dialogLayout.addWidget(self.button_box)
self.retranslateUi(editBibleDialog)
QtCore.QMetaObject.connectSlotsByName(editBibleDialog)
self.dialog_layout.addWidget(self.bible_tab_widget)
self.button_box = create_button_box(edit_bible_dialog, u'button_box', [u'cancel', u'save'])
self.dialog_layout.addWidget(self.button_box)
self.retranslateUi(edit_bible_dialog)
QtCore.QMetaObject.connectSlotsByName(edit_bible_dialog)
def retranslateUi(self, editBibleDialog):
def retranslateUi(self, edit_bible_dialog):
self.book_names = BibleStrings().BookNames
editBibleDialog.setWindowTitle(translate('BiblesPlugin.EditBibleForm', 'Bible Editor'))
edit_bible_dialog.setWindowTitle(translate('BiblesPlugin.EditBibleForm', 'Bible Editor'))
# Meta tab
self.bibleTabWidget.setTabText( self.bibleTabWidget.indexOf(self.metaTab),
self.bible_tab_widget.setTabText( self.bible_tab_widget.indexOf(self.meta_tab),
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',
self.license_details_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'License Details'))
self.version_name_label.setText(translate('BiblesPlugin.EditBibleForm', 'Version name:'))
self.copyright_label.setText(translate('BiblesPlugin.EditBibleForm', 'Copyright:'))
self.permissions_label.setText(translate('BiblesPlugin.EditBibleForm', 'Permissions:'))
self.language_selection_group_box.setTitle(translate('BiblesPlugin.EditBibleForm', 'Default Bible Language'))
self.language_selection_label.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,
self.language_selection_combo_box.setItemText(0, translate('BiblesPlugin.EditBibleForm', 'Global Settings'))
self.language_selection_combo_box.setItemText(LanguageSelection.Bible + 1,
translate('BiblesPlugin.EditBibleForm', 'Bible Language'))
self.languageSelectionComboBox.setItemText(LanguageSelection.Application + 1,
self.language_selection_combo_box.setItemText(LanguageSelection.Application + 1,
translate('BiblesPlugin.EditBibleForm', 'Application Language'))
self.languageSelectionComboBox.setItemText(LanguageSelection.English + 1,
self.language_selection_combo_box.setItemText(LanguageSelection.English + 1,
translate('BiblesPlugin.EditBibleForm', 'English'))
# Book name tab
self.bibleTabWidget.setTabText(self.bibleTabWidget.indexOf(self.bookNameTab),
self.bible_tab_widget.setTabText(self.bible_tab_widget.indexOf(self.book_name_tab),
translate('SongsPlugin.EditBibleForm', 'Custom Book Names'))
for book in BiblesResourcesDB.get_books():
self.bookNameLabel[book[u'abbreviation']].setText(u'%s:' % unicode(self.book_names[book[u'abbreviation']]))
self.book_name_label[book[u'abbreviation']].setText(u'%s:' % unicode(self.book_names[book[u'abbreviation']]))

View File

@ -65,33 +65,33 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
"""
log.debug(u'Load Bible')
self.bible = bible
self.versionNameEdit.setText(self.manager.get_meta_data(self.bible, u'name').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.version_name_edit.setText(self.manager.get_meta_data(self.bible, u'name').value)
self.copyright_edit.setText(self.manager.get_meta_data(self.bible, u'copyright').value)
self.permissions_edit.setText(self.manager.get_meta_data(self.bible, u'permissions').value)
book_name_language = self.manager.get_meta_data(self.bible, u'book_name_language')
if book_name_language and book_name_language.value != u'None':
self.languageSelectionComboBox.setCurrentIndex(int(book_name_language.value) + 1)
self.language_selection_combo_box.setCurrentIndex(int(book_name_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',
self.book_name_notice.setText(translate('BiblesPlugin.EditBibleForm',
'This is a Web Download Bible.\nIt is not possible to customize the Book Names.'))
self.scrollArea.hide()
self.scroll_area.hide()
else:
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
self.book_name_notice.setText(translate('BiblesPlugin.EditBibleForm',
'To use the customized book names, "Bible language" must be selected on the Meta Data tab or, '
'if "Global settings" is selected, on the Bible page in Configure OpenLP.'))
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)
self.book_name_edit[book[u'abbreviation']].setText(self.books[book[u'abbreviation']].name)
else:
# It is necessary to remove the Widget otherwise there still
# exists the vertical spacing in QFormLayout
self.bookNameWidgetLayout.removeWidget(self.bookNameLabel[book[u'abbreviation']])
self.bookNameLabel[book[u'abbreviation']].hide()
self.bookNameWidgetLayout.removeWidget(self.bookNameEdit[book[u'abbreviation']])
self.bookNameEdit[book[u'abbreviation']].hide()
self.book_name_widget_layout.removeWidget(self.book_name_label[book[u'abbreviation']])
self.book_name_label[book[u'abbreviation']].hide()
self.book_name_widget_layout.removeWidget(self.book_name_edit[book[u'abbreviation']])
self.book_name_edit[book[u'abbreviation']].hide()
def reject(self):
"""
@ -106,10 +106,10 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
Exit Dialog and save data
"""
log.debug(u'BibleEditForm.accept')
version = self.versionNameEdit.text()
copyright = self.copyrightEdit.text()
permissions = self.permissionsEdit.text()
book_name_language = self.languageSelectionComboBox.currentIndex() - 1
version = self.version_name_edit.text()
copyright = self.copyright_edit.text()
permissions = self.permissions_edit.text()
book_name_language = self.language_selection_combo_box.currentIndex() - 1
if book_name_language == -1:
book_name_language = None
if not self.validateMeta(version, copyright):
@ -118,7 +118,7 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
custom_names = {}
for abbr, book in self.books.iteritems():
if book:
custom_names[abbr] = self.bookNameEdit[abbr].text()
custom_names[abbr] = self.book_name_edit[abbr].text()
if book.name != custom_names[abbr]:
if not self.validateBook(custom_names[abbr], abbr):
return
@ -139,19 +139,19 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
Validate the Meta before saving.
"""
if not name:
self.versionNameEdit.setFocus()
self.version_name_edit.setFocus()
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm', 'You need to specify a version name for your Bible.'))
return False
elif not copyright:
self.copyrightEdit.setFocus()
self.copyright_edit.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(name) and self.manager.get_meta_data(self.bible, u'name').value != \
name:
self.versionNameEdit.setFocus()
self.version_name_edit.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.'))
@ -164,13 +164,13 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
"""
book_regex = re.compile(u'[\d]*[^\d]+$')
if not new_book_name:
self.bookNameEdit[abbreviation].setFocus()
self.book_name_edit[abbreviation].setFocus()
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') %
self.book_names[abbreviation])
return False
elif not book_regex.match(new_book_name):
self.bookNameEdit[abbreviation].setFocus()
self.book_name_edit[abbreviation].setFocus()
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm',
'The book name "%s" is not correct.\nNumbers can only be used at the beginning and must\nbe '
@ -180,8 +180,8 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog):
if book:
if abbr == abbreviation:
continue
if self.bookNameEdit[abbr].text() == new_book_name:
self.bookNameEdit[abbreviation].setFocus()
if self.book_name_edit[abbr].text() == new_book_name:
self.book_name_edit[abbreviation].setFocus()
critical_error_message_box(
translate('BiblesPlugin.BibleEditForm', 'Duplicate Book Name'),
translate('BiblesPlugin.BibleEditForm', 'The Book Name "%s" has been entered more than once.')

View File

@ -33,44 +33,44 @@ from openlp.core.lib import translate
from openlp.core.lib.ui import create_button_box
class Ui_LanguageDialog(object):
def setupUi(self, languageDialog):
languageDialog.setObjectName(u'languageDialog')
languageDialog.resize(400, 165)
self.languageLayout = QtGui.QVBoxLayout(languageDialog)
self.languageLayout.setSpacing(8)
self.languageLayout.setMargin(8)
self.languageLayout.setObjectName(u'languageLayout')
self.bibleLabel = QtGui.QLabel(languageDialog)
self.bibleLabel.setObjectName(u'bibleLabel')
self.languageLayout.addWidget(self.bibleLabel)
self.infoLabel = QtGui.QLabel(languageDialog)
self.infoLabel.setWordWrap(True)
self.infoLabel.setObjectName(u'infoLabel')
self.languageLayout.addWidget(self.infoLabel)
self.languageHBoxLayout = QtGui.QHBoxLayout()
self.languageHBoxLayout.setSpacing(8)
self.languageHBoxLayout.setObjectName(u'languageHBoxLayout')
self.languageLabel = QtGui.QLabel(languageDialog)
self.languageLabel.setObjectName(u'languageLabel')
self.languageHBoxLayout.addWidget(self.languageLabel)
self.languageComboBox = QtGui.QComboBox(languageDialog)
def setupUi(self, language_dialog):
language_dialog.setObjectName(u'language_dialog')
language_dialog.resize(400, 165)
self.language_layout = QtGui.QVBoxLayout(language_dialog)
self.language_layout.setSpacing(8)
self.language_layout.setMargin(8)
self.language_layout.setObjectName(u'language_layout')
self.bible_label = QtGui.QLabel(language_dialog)
self.bible_label.setObjectName(u'bible_label')
self.language_layout.addWidget(self.bible_label)
self.info_label = QtGui.QLabel(language_dialog)
self.info_label.setWordWrap(True)
self.info_label.setObjectName(u'info_label')
self.language_layout.addWidget(self.info_label)
self.language_h_box_layout = QtGui.QHBoxLayout()
self.language_h_box_layout.setSpacing(8)
self.language_h_box_layout.setObjectName(u'language_h_box_layout')
self.language_label = QtGui.QLabel(language_dialog)
self.language_label.setObjectName(u'language_label')
self.language_h_box_layout.addWidget(self.language_label)
self.language_combo_box = QtGui.QComboBox(language_dialog)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.languageComboBox.sizePolicy().hasHeightForWidth())
self.languageComboBox.setSizePolicy(sizePolicy)
self.languageComboBox.setObjectName(u'languageComboBox')
self.languageHBoxLayout.addWidget(self.languageComboBox)
self.languageLayout.addLayout(self.languageHBoxLayout)
self.button_box = create_button_box(languageDialog, u'button_box', [u'cancel', u'ok'])
self.languageLayout.addWidget(self.button_box)
sizePolicy.setHeightForWidth(self.language_combo_box.sizePolicy().hasHeightForWidth())
self.language_combo_box.setSizePolicy(sizePolicy)
self.language_combo_box.setObjectName(u'language_combo_box')
self.language_h_box_layout.addWidget(self.language_combo_box)
self.language_layout.addLayout(self.language_h_box_layout)
self.button_box = create_button_box(language_dialog, u'button_box', [u'cancel', u'ok'])
self.language_layout.addWidget(self.button_box)
self.retranslateUi(languageDialog)
self.retranslateUi(language_dialog)
def retranslateUi(self, languageDialog):
languageDialog.setWindowTitle(translate('BiblesPlugin.LanguageDialog', 'Select Language'))
self.bibleLabel.setText(translate('BiblesPlugin.LanguageDialog', ''))
self.infoLabel.setText(translate('BiblesPlugin.LanguageDialog',
def retranslateUi(self, language_dialog):
language_dialog.setWindowTitle(translate('BiblesPlugin.LanguageDialog', 'Select Language'))
self.bible_label.setText(translate('BiblesPlugin.LanguageDialog', ''))
self.info_label.setText(translate('BiblesPlugin.LanguageDialog',
'OpenLP is unable to determine the language of this translation of the Bible. Please select the language '
'from the list below.'))
self.languageLabel.setText(translate('BiblesPlugin.LanguageDialog', 'Language:'))
self.language_label.setText(translate('BiblesPlugin.LanguageDialog', 'Language:'))

View File

@ -40,8 +40,10 @@ from openlp.plugins.bibles.forms.languagedialog import \
Ui_LanguageDialog
from openlp.plugins.bibles.lib.db import BiblesResourcesDB
log = logging.getLogger(__name__)
class LanguageForm(QDialog, Ui_LanguageDialog):
"""
Class to manage a dialog which ask the user for a language.
@ -56,19 +58,17 @@ class LanguageForm(QDialog, Ui_LanguageDialog):
self.setupUi(self)
def exec_(self, bible_name):
self.languageComboBox.addItem(u'')
self.language_combo_box.addItem(u'')
if bible_name:
self.bibleLabel.setText(unicode(bible_name))
self.bible_label.setText(unicode(bible_name))
items = BiblesResourcesDB.get_languages()
self.languageComboBox.addItems([item[u'name'] for item in items])
self.language_combo_box.addItems([item[u'name'] for item in items])
return QDialog.exec_(self)
def accept(self):
if not self.languageComboBox.currentText():
critical_error_message_box(
message=translate('BiblesPlugin.LanguageForm',
'You need to choose a language.'))
self.languageComboBox.setFocus()
if not self.language_combo_box.currentText():
critical_error_message_box(message=translate('BiblesPlugin.LanguageForm', 'You need to choose a language.'))
self.language_combo_box.setFocus()
return False
else:
return QDialog.accept(self)

View File

@ -38,9 +38,11 @@ from openlp.core.lib import Settings, translate
log = logging.getLogger(__name__)
REFERENCE_MATCHES = {}
REFERENCE_SEPARATORS = {}
class LayoutStyle(object):
"""
An enumeration for bible screen layout styles.
@ -62,8 +64,7 @@ class DisplayStyle(object):
class LanguageSelection(object):
"""
An enumeration for bible bookname language.
And standard strings for use throughout the bibles plugin.
An enumeration for bible bookname language. And standard strings for use throughout the bibles plugin.
"""
Bible = 0
Application = 1
@ -178,8 +179,7 @@ class BibleStrings(object):
def update_reference_separators():
"""
Updates separators and matches for parsing and formating scripture
references.
Updates separators and matches for parsing and formating scripture references.
"""
default_separators = translate('BiblesPlugin',
':|v|V|verse|verses;;-|to;;,|and;;end Double-semicolon delimited separators for parsing references. '
@ -245,9 +245,8 @@ def get_reference_match(match_type):
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
the Bible database files.
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 the Bible database files.
``reference``
A string. The Bible reference to parse.
@ -256,16 +255,14 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
A object. The Bible database object.
``language_selection``
An int. The language selection the user has choosen in settings
section.
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.
The reference list is a list of tuples, with each tuple structured like
this::
The reference list is a list of tuples, with each tuple structured like this::
(book, chapter, from_verse, to_verse)
@ -275,8 +272,7 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
**Reference string details:**
Each reference starts with the book name and a chapter number. These are
both mandatory.
Each reference starts with the book name and a chapter number. These are both mandatory.
* ``John 3`` refers to Gospel of John chapter 3
@ -289,38 +285,31 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
* ``John 3:16`` refers to John chapter 3 verse 16
* ``John 3:16-4:3`` refers to John chapter 3 verse 16 to chapter 4 verse 3
After a verse reference all further single values are treat as verse in
the last selected chapter.
After a verse reference all further single values are treat as verse in the last selected chapter.
* ``John 3:16-18`` refers to John chapter 3 verses 16 to 18
After a list separator it is possible to refer to additional verses. They
are build analog to the first ones. This way it is possible to define each
number of verse references. It is not possible to refer to verses in
additional books.
After a list separator it is possible to refer to additional verses. They are build analog to the first ones. This
way it is possible to define each number of verse references. It is not possible to refer to verses in additional
books.
* ``John 3:16,18`` refers to John chapter 3 verses 16 and 18
* ``John 3:16-18,20`` refers to John chapter 3 verses 16 to 18 and 20
* ``John 3:16-18,4:1`` refers to John chapter 3 verses 16 to 18 and
chapter 4 verse 1
* ``John 3:16-18,4:1`` refers to John chapter 3 verses 16 to 18 and chapter 4 verse 1
If there is a range separator without further verse declaration the last
refered chapter is addressed until the end.
If there is a range separator without further verse declaration the last refered chapter is addressed until the end.
``range_regex`` is a regular expression which matches for verse range
declarations:
``range_regex`` is a regular expression which matches for verse range declarations:
``(?:(?P<from_chapter>[0-9]+)%(sep_v)s)?``
It starts with a optional chapter reference ``from_chapter`` followed by
a verse separator.
It starts with a optional chapter reference ``from_chapter`` followed by a verse separator.
``(?P<from_verse>[0-9]+)``
The verse reference ``from_verse`` is manditory
``(?P<range_to>%(sep_r)s(?:`` ... ``|%(sep_e)s)?)?``
A ``range_to`` declaration is optional. It starts with a range separator
and contains optional a chapter and verse declaration or a end
separator.
A ``range_to`` declaration is optional. It starts with a range separator and contains optional a chapter and
verse declaration or a end separator.
``(?:(?P<to_chapter>[0-9]+)%(sep_v)s)?``
The ``to_chapter`` reference with separator is equivalent to group 1.
@ -328,17 +317,15 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False):
``(?P<to_verse>[0-9]+)``
The ``to_verse`` reference is equivalent to group 2.
The full reference is matched against get_reference_match(u'full'). This
regular expression looks like this:
The full reference is matched against get_reference_match(u'full'). This regular expression looks like this:
``^\s*(?!\s)(?P<book>[\d]*[^\d]+)(?<!\s)\s*``
The ``book`` group starts with the first non-whitespace character. There
are optional leading digits followed by non-digits. The group ends
before the whitspace in front of the next digit.
The ``book`` group starts with the first non-whitespace character. There are optional leading digits followed by
non-digits. The group ends before the whitspace in front of the next digit.
``(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$``
The second group contains all ``ranges``. This can be multiple
declarations of range_regex separated by a list separator.
The second group contains all ``ranges``. This can be multiple declarations of range_regex separated by a list
separator.
"""
log.debug(u'parse_reference("%s")', reference)

View File

@ -27,8 +27,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`cvsbible` modules provides a facility to import bibles from a set of
CSV files.
The :mod:`cvsbible` modules provides a facility to import bibles from a set of CSV files.
The module expects two mandatory files containing the books and the verses.
@ -55,8 +54,7 @@ There are two acceptable formats of the verses file. They are:
or
"Genesis",1,2,"And the earth was without form, and void; and...."
All CSV files are expected to use a comma (',') as the delimiter and double
quotes ('"') as the quote symbol.
All CSV files are expected to use a comma (',') as the delimiter and double quotes ('"') as the quote symbol.
"""
import logging
import chardet
@ -65,8 +63,10 @@ import csv
from openlp.core.lib import translate
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
log = logging.getLogger(__name__)
class CSVBible(BibleDB):
"""
This class provides a specialisation for importing of CSV Bibles.
@ -75,9 +75,8 @@ class CSVBible(BibleDB):
def __init__(self, parent, **kwargs):
"""
Loads a Bible from a set of CSV files.
This class assumes the files contain all the information and
a clean bible is being loaded.
Loads a Bible from a set of CSV files. This class assumes the files contain all the information and a clean
bible is being loaded.
"""
log.info(self.__class__.__name__)
BibleDB.__init__(self, parent, **kwargs)

View File

@ -511,7 +511,7 @@ class BibleDB(QtCore.QObject, Manager):
language = None
language_form = LanguageForm(self.wizard)
if language_form.exec_(bible_name):
language = unicode(language_form.languageComboBox.currentText())
language = unicode(language_form.language_combo_box.currentText())
if not language:
return False
language = BiblesResourcesDB.get_language(language)

View File

@ -27,8 +27,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`http` module enables OpenLP to retrieve scripture from bible
websites.
The :mod:`http` module enables OpenLP to retrieve scripture from bible websites.
"""
import logging
import re

View File

@ -38,28 +38,21 @@ from csvbible import CSVBible
from http import HTTPBible
from opensong import OpenSongBible
from osis import OSISBible
# Imports that might fail.
try:
from openlp1 import OpenLP1Bible
HAS_OPENLP1 = True
except ImportError:
HAS_OPENLP1 = False
log = logging.getLogger(__name__)
class BibleFormat(object):
"""
This is a special enumeration class that holds the various types of Bibles,
plus a few helper functions to facilitate generic handling of Bible types
for importing.
This is a special enumeration class that holds the various types of Bibles.
"""
_format_availability = {}
Unknown = -1
OSIS = 0
CSV = 1
OpenSong = 2
WebDownload = 3
OpenLP1 = 4
@staticmethod
def get_class(format):
@ -77,8 +70,6 @@ class BibleFormat(object):
return OpenSongBible
elif format == BibleFormat.WebDownload:
return HTTPBible
elif format == BibleFormat.OpenLP1:
return OpenLP1Bible
else:
return None
@ -92,17 +83,8 @@ class BibleFormat(object):
BibleFormat.CSV,
BibleFormat.OpenSong,
BibleFormat.WebDownload,
BibleFormat.OpenLP1
]
@staticmethod
def set_availability(format, available):
BibleFormat._format_availability[format] = available
@staticmethod
def get_availability(format):
return BibleFormat._format_availability.get(format, True)
class BibleManager(object):
"""
@ -463,6 +445,5 @@ class BibleManager(object):
main_window = property(_get_main_window)
BibleFormat.set_availability(BibleFormat.OpenLP1, HAS_OPENLP1)
__all__ = [u'BibleFormat']

View File

@ -61,8 +61,8 @@ class BibleMediaItem(MediaManagerItem):
def __init__(self, parent, plugin):
self.icon_path = u'songs/song'
self.lockIcon = build_icon(u':/bibles/bibles_search_lock.png')
self.unlockIcon = build_icon(u':/bibles/bibles_search_unlock.png')
self.lock_icon = build_icon(u':/bibles/bibles_search_lock.png')
self.unlock_icon = build_icon(u':/bibles/bibles_search_unlock.png')
MediaManagerItem.__init__(self, parent, plugin)
# Place to store the search results for both bibles.
self.settings = self.plugin.settings_tab
@ -73,7 +73,7 @@ class BibleMediaItem(MediaManagerItem):
self.check_search_result()
Registry().register_function(u'bibles_load_list', self.reload_bibles)
def __checkSecondBible(self, bible, second_bible):
def __check_second_bible(self, bible, second_bible):
"""
Check if the first item is a second bible item or not.
"""
@ -84,7 +84,7 @@ class BibleMediaItem(MediaManagerItem):
self.displayResults(bible, second_bible)
return
else:
item_second_bible = self._decodeQtObject(bitem, 'second_bible')
item_second_bible = self._decode_qt_object(bitem, 'second_bible')
if item_second_bible and second_bible or not item_second_bible and not second_bible:
self.displayResults(bible, second_bible)
elif critical_error_message_box(
@ -95,7 +95,7 @@ class BibleMediaItem(MediaManagerItem):
self.list_view.clear()
self.displayResults(bible, second_bible)
def _decodeQtObject(self, bitem, key):
def _decode_qt_object(self, bitem, key):
reference = bitem.data(QtCore.Qt.UserRole)
obj = reference[unicode(key)]
return unicode(obj).strip()
@ -159,7 +159,7 @@ class BibleMediaItem(MediaManagerItem):
search_button_layout.setObjectName(prefix + u'search_button_layout')
search_button_layout.addStretch()
lockButton = QtGui.QToolButton(tab)
lockButton.setIcon(self.unlockIcon)
lockButton.setIcon(self.unlock_icon)
lockButton.setCheckable(True)
lockButton.setObjectName(prefix + u'LockButton')
search_button_layout.addWidget(lockButton)
@ -250,7 +250,7 @@ class BibleMediaItem(MediaManagerItem):
self.quickSearchEdit.returnPressed.connect(self.onQuickSearchButton)
self.searchTabBar.currentChanged.connect(self.onSearchTabBarCurrentChanged)
def onFocus(self):
def on_focus(self):
if self.quickTab.isVisible():
self.quickSearchEdit.setFocus()
else:
@ -509,9 +509,9 @@ class BibleMediaItem(MediaManagerItem):
def onLockButtonToggled(self, checked):
if checked:
self.sender().setIcon(self.lockIcon)
self.sender().setIcon(self.lock_icon)
else:
self.sender().setIcon(self.unlockIcon)
self.sender().setIcon(self.unlock_icon)
def onQuickStyleComboBoxChanged(self):
self.settings.layout_style = self.quickStyleComboBox.currentIndex()
@ -633,7 +633,7 @@ class BibleMediaItem(MediaManagerItem):
if not self.advancedLockButton.isChecked():
self.list_view.clear()
if self.list_view.count() != 0:
self.__checkSecondBible(bible, second_bible)
self.__check_second_bible(bible, second_bible)
elif self.search_results:
self.displayResults(bible, second_bible)
self.advancedSearchButton.setEnabled(True)
@ -689,7 +689,7 @@ class BibleMediaItem(MediaManagerItem):
if not self.quickLockButton.isChecked():
self.list_view.clear()
if self.list_view.count() != 0 and self.search_results:
self.__checkSecondBible(bible, second_bible)
self.__check_second_bible(bible, second_bible)
elif self.search_results:
self.displayResults(bible, second_bible)
self.quickSearchButton.setEnabled(True)
@ -787,19 +787,19 @@ class BibleMediaItem(MediaManagerItem):
raw_title = []
verses = VerseReferenceList()
for bitem in items:
book = self._decodeQtObject(bitem, 'book')
chapter = int(self._decodeQtObject(bitem, 'chapter'))
verse = int(self._decodeQtObject(bitem, 'verse'))
bible = self._decodeQtObject(bitem, 'bible')
version = self._decodeQtObject(bitem, 'version')
copyright = self._decodeQtObject(bitem, 'copyright')
permissions = self._decodeQtObject(bitem, 'permissions')
text = self._decodeQtObject(bitem, 'text')
second_bible = self._decodeQtObject(bitem, 'second_bible')
second_version = self._decodeQtObject(bitem, 'second_version')
second_copyright = self._decodeQtObject(bitem, 'second_copyright')
second_permissions = self._decodeQtObject(bitem, 'second_permissions')
second_text = self._decodeQtObject(bitem, 'second_text')
book = self._decode_qt_object(bitem, 'book')
chapter = int(self._decode_qt_object(bitem, 'chapter'))
verse = int(self._decode_qt_object(bitem, 'verse'))
bible = self._decode_qt_object(bitem, 'bible')
version = self._decode_qt_object(bitem, 'version')
copyright = self._decode_qt_object(bitem, 'copyright')
permissions = self._decode_qt_object(bitem, 'permissions')
text = self._decode_qt_object(bitem, 'text')
second_bible = self._decode_qt_object(bitem, 'second_bible')
second_version = self._decode_qt_object(bitem, 'second_version')
second_copyright = self._decode_qt_object(bitem, 'second_copyright')
second_permissions = self._decode_qt_object(bitem, 'second_permissions')
second_text = self._decode_qt_object(bitem, 'second_text')
verses.add(book, chapter, verse, version, copyright, permissions)
verse_text = self.formatVerse(old_chapter, chapter, verse)
if second_bible:
@ -867,13 +867,13 @@ class BibleMediaItem(MediaManagerItem):
"""
verse_separator = get_reference_separator(u'sep_v_display')
range_separator = get_reference_separator(u'sep_r_display')
old_chapter = self._decodeQtObject(old_bitem, 'chapter')
old_verse = self._decodeQtObject(old_bitem, 'verse')
start_book = self._decodeQtObject(start_bitem, 'book')
start_chapter = self._decodeQtObject(start_bitem, 'chapter')
start_verse = self._decodeQtObject(start_bitem, 'verse')
start_bible = self._decodeQtObject(start_bitem, 'bible')
start_second_bible = self._decodeQtObject(start_bitem, 'second_bible')
old_chapter = self._decode_qt_object(old_bitem, 'chapter')
old_verse = self._decode_qt_object(old_bitem, 'verse')
start_book = self._decode_qt_object(start_bitem, 'book')
start_chapter = self._decode_qt_object(start_bitem, 'chapter')
start_verse = self._decode_qt_object(start_bitem, 'verse')
start_bible = self._decode_qt_object(start_bitem, 'bible')
start_second_bible = self._decode_qt_object(start_bitem, 'second_bible')
if start_second_bible:
bibles = u'%s, %s' % (start_bible, start_second_bible)
else:
@ -901,16 +901,16 @@ class BibleMediaItem(MediaManagerItem):
The item we were previously dealing with.
"""
# Get all the necessary meta data.
book = self._decodeQtObject(bitem, 'book')
chapter = int(self._decodeQtObject(bitem, 'chapter'))
verse = int(self._decodeQtObject(bitem, 'verse'))
bible = self._decodeQtObject(bitem, 'bible')
second_bible = self._decodeQtObject(bitem, 'second_bible')
old_book = self._decodeQtObject(old_bitem, 'book')
old_chapter = int(self._decodeQtObject(old_bitem, 'chapter'))
old_verse = int(self._decodeQtObject(old_bitem, 'verse'))
old_bible = self._decodeQtObject(old_bitem, 'bible')
old_second_bible = self._decodeQtObject(old_bitem, 'second_bible')
book = self._decode_qt_object(bitem, 'book')
chapter = int(self._decode_qt_object(bitem, 'chapter'))
verse = int(self._decode_qt_object(bitem, 'verse'))
bible = self._decode_qt_object(bitem, 'bible')
second_bible = self._decode_qt_object(bitem, 'second_bible')
old_book = self._decode_qt_object(old_bitem, 'book')
old_chapter = int(self._decode_qt_object(old_bitem, 'chapter'))
old_verse = int(self._decode_qt_object(old_bitem, 'verse'))
old_bible = self._decode_qt_object(old_bitem, 'bible')
old_second_bible = self._decode_qt_object(old_bitem, 'second_bible')
if old_bible != bible or old_second_bible != second_bible or old_book != book:
# The bible, second bible or book has changed.
return True

View File

@ -1,113 +0,0 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2013 Raoul Snyman #
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# 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 sqlite
import sys
from openlp.core.ui.wizard import WizardStrings
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
log = logging.getLogger(__name__)
class OpenLP1Bible(BibleDB):
"""
This class provides the OpenLPv1 bible importer.
"""
def __init__(self, parent, **kwargs):
"""
Constructor.
"""
log.debug(self.__class__.__name__)
BibleDB.__init__(self, parent, **kwargs)
self.filename = kwargs[u'filename']
def do_import(self, bible_name=None):
"""
Imports an openlp.org v1 bible.
"""
connection = None
cursor = None
try:
connection = sqlite.connect(self.filename.encode(sys.getfilesystemencoding()))
cursor = connection.cursor()
except sqlite.DatabaseError:
log.exception(u'File "%s" is encrypted or not a sqlite database, '
'therefore not an openlp.org 1.x database either' % self.filename)
# Please add an user error here!
# This file is not an openlp.org 1.x bible database.
return False
#Create the bible language
language_id = self.get_language(bible_name)
if not language_id:
log.exception(u'Importing books from "%s" failed' % self.filename)
return False
# Create all books.
try:
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
except sqlite.DatabaseError as error:
log.exception(u'DatabaseError: %s' % error)
# Please add an user error here!
# This file is not an openlp.org 1.x bible database.
return False
books = cursor.fetchall()
self.wizard.progress_bar.setMaximum(len(books) + 1)
for book in books:
if self.stop_import_flag:
connection.close()
return False
book_id = int(book[0])
testament_id = int(book[1])
name = unicode(book[2], u'cp1252')
abbreviation = unicode(book[3], u'cp1252')
book_ref_id = self.get_book_ref_id_by_name(name, len(books),
language_id)
if not book_ref_id:
log.exception(u'Importing books from "%s" failed' % self.filename)
return False
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
db_book = self.create_book(name, book_ref_id, book_details[u'testament_id'])
# Update the progess bar.
self.wizard.increment_progress_bar(WizardStrings.ImportingType % name)
# Import the verses for this book.
cursor.execute(u'SELECT chapter, verse, text || \'\' AS text FROM '
'verse WHERE book_id=%s' % book_id)
verses = cursor.fetchall()
for verse in verses:
if self.stop_import_flag:
connection.close()
return False
chapter = int(verse[0])
verse_number = int(verse[1])
text = unicode(verse[2], u'cp1252')
self.create_verse(db_book.id, chapter, verse_number, text)
self.application.process_events()
self.session.commit()
connection.close()
return True

View File

@ -34,16 +34,18 @@ from openlp.core.lib import translate
from openlp.core.lib.ui import critical_error_message_box
from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
log = logging.getLogger(__name__)
class OpenSongBible(BibleDB):
"""
OpenSong Bible format importer class.
"""
def __init__(self, parent, **kwargs):
"""
Constructor to create and set up an instance of the OpenSongBible
class. This class is used to import Bibles from OpenSong's XML format.
Constructor to create and set up an instance of the OpenSongBible class. This class is used to import Bibles
from OpenSong's XML format.
"""
log.debug(self.__class__.__name__)
BibleDB.__init__(self, parent, **kwargs)
@ -75,9 +77,8 @@ class OpenSongBible(BibleDB):
file = None
success = True
try:
# NOTE: We don't need to do any of the normal encoding detection
# here, because lxml does it's own encoding detection, and the two
# mechanisms together interfere with each other.
# NOTE: We don't need to do any of the normal encoding detection here, because lxml does it's own encoding
# detection, and the two mechanisms together interfere with each other.
file = open(self.filename, u'r')
opensong = objectify.parse(file)
bible = opensong.getroot()
@ -116,16 +117,11 @@ class OpenSongBible(BibleDB):
if len(verse_parts) > 1:
number = int(verse_parts[0])
except TypeError:
log.warn(u'Illegal verse number: %s',
unicode(verse.attrib[u'n']))
log.warn(u'Illegal verse number: %s', unicode(verse.attrib[u'n']))
verse_number = number
else:
verse_number += 1
self.create_verse(
db_book.id,
chapter_number,
verse_number,
self.get_text(verse))
self.create_verse(db_book.id, chapter_number, verse_number, self.get_text(verse))
self.wizard.increment_progress_bar(translate('BiblesPlugin.Opensong', 'Importing %s %s...',
'Importing <book name> <chapter>...')) % (db_book.name, chapter_number)
self.session.commit()

View File

@ -39,9 +39,11 @@ from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
log = logging.getLogger(__name__)
def replacement(match):
return match.group(2).upper()
class OSISBible(BibleDB):
"""
`OSIS <http://www.bibletechnologies.net/>`_ Bible format importer class.
@ -53,8 +55,7 @@ class OSISBible(BibleDB):
BibleDB.__init__(self, parent, **kwargs)
self.filename = kwargs[u'filename']
self.language_regex = re.compile(r'<language.*>(.*?)</language>')
self.verse_regex = re.compile(
r'<verse osisID="([a-zA-Z0-9 ]*).([0-9]*).([0-9]*)">(.*?)</verse>')
self.verse_regex = re.compile(r'<verse osisID="([a-zA-Z0-9 ]*).([0-9]*).([0-9]*)">(.*?)</verse>')
self.note_regex = re.compile(r'<note(.*?)>(.*?)</note>')
self.title_regex = re.compile(r'<title(.*?)>(.*?)</title>')
self.milestone_regex = re.compile(r'<milestone(.*?)/>')
@ -68,8 +69,7 @@ class OSISBible(BibleDB):
self.q1_regex = re.compile(r'<q(.*?)level="1"(.*?)>')
self.q2_regex = re.compile(r'<q(.*?)level="2"(.*?)>')
self.trans_regex = re.compile(r'<transChange(.*?)>(.*?)</transChange>')
self.divine_name_regex = re.compile(
r'<divineName(.*?)>(.*?)</divineName>')
self.divine_name_regex = re.compile(r'<divineName(.*?)>(.*?)</divineName>')
self.spaces_regex = re.compile(r'([ ]{2,})')
filepath = os.path.join(
AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', u'resources', u'osisbooks.csv')
@ -158,10 +158,8 @@ class OSISBible(BibleDB):
self.wizard.increment_progress_bar(translate('BiblesPlugin.OsisImport', 'Importing %s %s...',
'Importing <book name> <chapter>...') % (book_details[u'name'], chapter))
last_chapter = chapter
# All of this rigmarol below is because the mod2osis
# tool from the Sword library embeds XML in the OSIS
# but neglects to enclose the verse text (with XML) in
# <[CDATA[ ]]> tags.
# All of this rigmarol below is because the mod2osis tool from the Sword library embeds XML in the
# OSIS but neglects to enclose the verse text (with XML) in <[CDATA[ ]]> tags.
verse_text = self.note_regex.sub(u'', verse_text)
verse_text = self.title_regex.sub(u'', verse_text)
verse_text = self.milestone_regex.sub(u'', verse_text)

View File

@ -27,8 +27,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
"""
The :mod:`upgrade` module provides a way for the database and schema that is the
backend for the Bibles plugin
The :mod:`upgrade` module provides a way for the database and schema that is the backend for the Bibles plugin.
"""
import logging

View File

@ -29,8 +29,8 @@
class VerseReferenceList(object):
"""
The VerseReferenceList class encapsulates a list of verse references, but
maintains the order in which they were added.
The VerseReferenceList class encapsulates a list of verse references, but maintains the order in which they were
added.
"""
def __init__(self):

View File

@ -64,14 +64,14 @@ class CustomMediaItem(MediaManagerItem):
self.has_search = True
# Holds information about whether the edit is remotely triggered and
# which Custom is required.
self.remoteCustom = -1
self.remote_custom = -1
self.manager = plugin.manager
def add_end_header_bar(self):
self.toolbar.addSeparator()
self.add_search_to_toolbar()
# Signals and slots
QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL(u'cleared()'), self.on_clear_text_button_click)
QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL(u'searchTypeChanged(int)'),
self.on_search_text_button_clicked)
Registry().register_function(u'custom_load_list', self.load_list)
@ -120,14 +120,13 @@ class CustomMediaItem(MediaManagerItem):
def on_new_click(self):
self.edit_custom_form.load_custom(0)
self.edit_custom_form.exec_()
self.onClearTextButtonClick()
self.on_clear_text_button_click()
self.on_selection_change()
def onRemoteEdit(self, custom_id, preview=False):
def on_remote_edit(self, custom_id, preview=False):
"""
Called by ServiceManager or SlideController by event passing
the custom Id in the payload along with an indicator to say which
type of display is required.
Called by ServiceManager or SlideController by event passing the custom Id in the payload along with an
indicator to say which type of display is required.
"""
custom_id = int(custom_id)
valid = self.manager.get_object(CustomSlide, custom_id)
@ -135,12 +134,12 @@ class CustomMediaItem(MediaManagerItem):
self.edit_custom_form.load_custom(custom_id, preview)
if self.edit_custom_form.exec_() == QtGui.QDialog.Accepted:
self.remote_triggered = True
self.remoteCustom = custom_id
self.remote_custom = custom_id
self.auto_select_id = -1
self.on_search_text_button_clicked()
item = self.build_service_item(remote=True)
self.remote_triggered = None
self.remoteCustom = 1
self.remote_custom = 1
if item:
return item
return None
@ -164,22 +163,21 @@ class CustomMediaItem(MediaManagerItem):
if check_item_selected(self.list_view, UiStrings().SelectDelete):
items = self.list_view.selectedIndexes()
if QtGui.QMessageBox.question(self,
UiStrings().ConfirmDelete,
translate('CustomPlugin.MediaItem',
'Are you sure you want to delete the %n selected custom slide(s)?', '',
QtCore.QCoreApplication.CodecForTr, len(items)),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
UiStrings().ConfirmDelete,
translate('CustomPlugin.MediaItem',
'Are you sure you want to delete the %n selected custom slide(s)?', '',
QtCore.QCoreApplication.CodecForTr, len(items)),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
return
row_list = [item.row() for item in self.list_view.selectedIndexes()]
row_list.sort(reverse=True)
id_list = [(item.data(QtCore.Qt.UserRole))
for item in self.list_view.selectedIndexes()]
id_list = [(item.data(QtCore.Qt.UserRole)) for item in self.list_view.selectedIndexes()]
for id in id_list:
self.plugin.manager.delete_object(CustomSlide, id)
self.on_search_text_button_clicked()
def onFocus(self):
def on_focus(self):
self.search_text_edit.setFocus()
def generate_slide_data(self, service_item, item=None, xmlVersion=False,
@ -187,20 +185,20 @@ class CustomMediaItem(MediaManagerItem):
"""
Generate the slide data. Needs to be implemented by the plugin.
"""
item_id = self._get_id_of_item_to_generate(item, self.remoteCustom)
item_id = self._get_id_of_item_to_generate(item, self.remote_custom)
service_item.add_capability(ItemCapabilities.CanEdit)
service_item.add_capability(ItemCapabilities.CanPreview)
service_item.add_capability(ItemCapabilities.CanLoop)
service_item.add_capability(ItemCapabilities.CanSoftBreak)
service_item.add_capability(ItemCapabilities.OnLoadUpdate)
customSlide = self.plugin.manager.get_object(CustomSlide, item_id)
title = customSlide.title
credit = customSlide.credits
custom_slide = self.plugin.manager.get_object(CustomSlide, item_id)
title = custom_slide.title
credit = custom_slide.credits
service_item.edit_id = item_id
theme = customSlide.theme_name
theme = custom_slide.theme_name
if theme:
service_item.theme = theme
custom_xml = CustomXMLParser(customSlide.text)
custom_xml = CustomXMLParser(custom_slide.text)
verse_list = custom_xml.get_verses()
raw_slides = [verse[1] for verse in verse_list]
service_item.title = title
@ -234,15 +232,14 @@ class CustomMediaItem(MediaManagerItem):
def on_search_text_edit_changed(self, text):
"""
If search as type enabled invoke the search on each key press.
If the Title is being searched do not start until 2 characters
have been entered.
If search as type enabled invoke the search on each key press. If the Title is being searched do not start until
2 characters have been entered.
"""
search_length = 2
if len(text) > search_length:
self.on_search_text_button_clicked()
elif not text:
self.onClearTextButtonClick()
self.on_clear_text_button_click()
def service_load(self, item):
"""
@ -286,7 +283,7 @@ class CustomMediaItem(MediaManagerItem):
self.plugin.manager.save_object(custom)
self.on_search_text_button_clicked()
def onClearTextButtonClick(self):
def on_clear_text_button_click(self):
"""
Clear the search text.
"""

View File

@ -44,10 +44,10 @@ log = logging.getLogger(__name__)
CLAPPERBOARD = u':/media/slidecontroller_multimedia.png'
VIDEO_ICON = build_icon(QtGui.QImage(u':/media/media_video.png'))
AUDIO_ICON = build_icon(QtGui.QImage(u':/media/media_audio.png'))
DVD_ICON = build_icon(QtGui.QImage(u':/media/media_video.png'))
ERROR_ICON = build_icon(QtGui.QImage(u':/general/general_delete.png'))
VIDEO_ICON = build_icon(u':/media/media_video.png')
AUDIO_ICON = build_icon(u':/media/media_audio.png')
DVD_ICON = build_icon(u':/media/media_video.png')
ERROR_ICON = build_icon(u':/general/general_delete.png')
class MediaMediaItem(MediaManagerItem):

View File

@ -147,7 +147,7 @@ window.OpenLP = {
},
pollServer: function () {
$.getJSON(
"/stage/api/poll",
"/stage/poll",
function (data, status) {
var prevItem = OpenLP.currentItem;
OpenLP.currentSlide = data.results.slide;

View File

@ -26,7 +26,7 @@
window.OpenLP = {
loadService: function (event) {
$.getJSON(
"/stage/api/service/list",
"/stage/service/list",
function (data, status) {
OpenLP.nextSong = "";
$("#notes").html("");
@ -46,7 +46,7 @@ window.OpenLP = {
},
loadSlides: function (event) {
$.getJSON(
"/stage/api/controller/live/text",
"/stage/controller/live/text",
function (data, status) {
OpenLP.currentSlides = data.results.slides;
OpenLP.currentSlide = 0;
@ -137,7 +137,7 @@ window.OpenLP = {
},
pollServer: function () {
$.getJSON(
"/stage/api/poll",
"/stage/poll",
function (data, status) {
OpenLP.updateClock(data);
if (OpenLP.currentItem != data.results.item ||

View File

@ -267,11 +267,11 @@ class HttpRouter(object):
(u'^/(stage)$', self.serve_file),
(r'^/files/(.*)$', self.serve_file),
(r'^/api/poll$', self.poll),
(r'^/stage/api/poll$', self.poll),
(r'^/stage/poll$', self.poll),
(r'^/api/controller/(live|preview)/(.*)$', self.controller),
(r'^/stage/api/controller/(live|preview)/(.*)$', self.controller),
(r'^/stage/controller/(live|preview)/(.*)$', self.controller),
(r'^/api/service/(.*)$', self.service),
(r'^/stage/api/service/(.*)$', self.service),
(r'^/stage/service/(.*)$', self.service),
(r'^/api/display/(hide|show|blank|theme|desktop)$', self.display),
(r'^/api/alert$', self.alert),
(r'^/api/plugin/(search)$', self.plugin_info),

View File

@ -714,7 +714,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
text = self.song_book_combo_box.currentText()
if item == 0 and text:
temp_song_book = text
self.media_item.songMaintenanceForm.exec_(True)
self.media_item.song_maintenance_form.exec_(True)
self.load_authors()
self.load_books()
self.load_topics()

View File

@ -50,13 +50,11 @@ from sundayplusimport import SundayPlusImport
from foilpresenterimport import FoilPresenterImport
from zionworximport import ZionWorxImport
# Imports that might fail
log = logging.getLogger(__name__)
try:
from olp1import import OpenLP1SongImport
HAS_OPENLP1 = True
except ImportError:
log.exception('Error importing %s', 'OpenLP1SongImport')
HAS_OPENLP1 = False
try:
from sofimport import SofImport
HAS_SOF = True
@ -144,23 +142,22 @@ class SongFormat(object):
Unknown = -1
OpenLyrics = 0
OpenLP2 = 1
OpenLP1 = 2
Generic = 3
CCLI = 4
DreamBeam = 5
EasySlides = 6
EasyWorship = 7
FoilPresenter = 8
MediaShout = 9
OpenSong = 10
PowerSong = 11
SongBeamer = 12
SongPro = 13
SongShowPlus = 14
SongsOfFellowship = 15
SundayPlus = 16
WordsOfWorship = 17
ZionWorx = 18
Generic = 2
CCLI = 3
DreamBeam = 4
EasySlides = 5
EasyWorship = 6
FoilPresenter = 7
MediaShout = 8
OpenSong = 9
PowerSong = 10
SongBeamer = 11
SongPro = 12
SongShowPlus = 13
SongsOfFellowship = 14
SundayPlus = 15
WordsOfWorship = 16
ZionWorx = 17
# Set optional attribute defaults
__defaults__ = {
@ -191,14 +188,6 @@ class SongFormat(object):
u'selectMode': SongFormatSelect.SingleFile,
u'filter': u'%s (*.sqlite)' % (translate('SongsPlugin.ImportWizardForm', 'OpenLP 2.0 Databases'))
},
OpenLP1: {
u'name': UiStrings().OLPV1,
u'prefix': u'openLP1',
u'canDisable': True,
u'selectMode': SongFormatSelect.SingleFile,
u'filter': u'%s (*.olp)' % translate('SongsPlugin.ImportWizardForm', 'openlp.org v1.x Databases'),
u'disabledLabelText': WizardStrings.NoSqlite
},
Generic: {
u'name': translate('SongsPlugin.ImportWizardForm', 'Generic Document/Presentation'),
u'prefix': u'generic',
@ -332,7 +321,6 @@ class SongFormat(object):
return [
SongFormat.OpenLyrics,
SongFormat.OpenLP2,
SongFormat.OpenLP1,
SongFormat.Generic,
SongFormat.CCLI,
SongFormat.DreamBeam,
@ -387,9 +375,7 @@ class SongFormat(object):
"""
SongFormat.__attributes__[format][attribute] = value
SongFormat.set(SongFormat.OpenLP1, u'availability', HAS_OPENLP1)
if HAS_OPENLP1:
SongFormat.set(SongFormat.OpenLP1, u'class', OpenLP1SongImport)
SongFormat.set(SongFormat.SongsOfFellowship, u'availability', HAS_SOF)
if HAS_SOF:
SongFormat.set(SongFormat.SongsOfFellowship, u'class', SofImport)

View File

@ -73,23 +73,20 @@ class SongMediaItem(MediaManagerItem):
self.icon_path = u'songs/song'
MediaManagerItem.__init__(self, parent, plugin)
self.single_service_item = False
# Holds information about whether the edit is remotely triggered and
# which Song is required.
self.remoteSong = -1
self.editItem = None
# Holds information about whether the edit is remotely triggered and which Song is required.
self.remote_song = -1
self.edit_item = None
self.quick_preview_allowed = True
self.has_search = True
def _updateBackgroundAudio(self, song, item):
def _update_background_audio(self, song, item):
song.media_files = []
for i, bga in enumerate(item.background_audio):
dest_file = os.path.join(
AppLocation.get_section_data_path(self.plugin.name), u'audio', str(song.id), os.path.split(bga)[1])
check_directory_exists(os.path.split(dest_file)[0])
shutil.copyfile(os.path.join(AppLocation.get_section_data_path(u'servicemanager'), bga),
dest_file)
song.media_files.append(MediaFile.populate(
weight=i, file_name=dest_file))
shutil.copyfile(os.path.join(AppLocation.get_section_data_path(u'servicemanager'), bga), dest_file)
song.media_files.append(MediaFile.populate(weight=i, file_name=dest_file))
self.plugin.manager.save_object(song, True)
def add_end_header_bar(self):
@ -97,12 +94,12 @@ class SongMediaItem(MediaManagerItem):
## Song Maintenance Button ##
self.maintenanceAction = self.toolbar.add_toolbar_action('maintenanceAction',
icon=':/songs/song_maintenance.png',
triggers=self.onSongMaintenanceClick)
triggers=self.on_song_maintenance_click)
self.add_search_to_toolbar()
# Signals and slots
Registry().register_function(u'songs_load_list', self.on_song_list_load)
Registry().register_function(u'songs_preview', self.on_preview_click)
QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL(u'cleared()'), self.onClearTextButtonClick)
QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL(u'cleared()'), self.on_clear_text_button_click)
QtCore.QObject.connect(self.search_text_edit, QtCore.SIGNAL(u'searchTypeChanged(int)'),
self.on_search_text_button_clicked)
@ -110,17 +107,17 @@ class SongMediaItem(MediaManagerItem):
create_widget_action(self.list_view, separator=True)
create_widget_action(self.list_view,
text=translate('OpenLP.MediaManagerItem', '&Clone'), icon=u':/general/general_clone.png',
triggers=self.onCloneClick)
triggers=self.on_clone_click)
def onFocus(self):
def on_focus(self):
self.search_text_edit.setFocus()
def config_update(self):
"""
IS triggered when the songs config is updated
Is triggered when the songs config is updated
"""
log.debug(u'config_updated')
self.searchAsYouType = Settings().value(self.settings_section + u'/search as type')
self.search_as_you_type = Settings().value(self.settings_section + u'/search as type')
self.updateServiceOnEdit = Settings().value(self.settings_section + u'/update service on edit')
self.addSongFromService = Settings().value(self.settings_section + u'/add song from service',)
@ -166,23 +163,23 @@ class SongMediaItem(MediaManagerItem):
search_type = self.search_text_edit.current_search_type()
if search_type == SongSearch.Entire:
log.debug(u'Entire Song Search')
search_results = self.searchEntire(search_keywords)
self.displayResultsSong(search_results)
search_results = self.search_entire(search_keywords)
self.display_results_song(search_results)
elif search_type == SongSearch.Titles:
log.debug(u'Titles Search')
search_results = self.plugin.manager.get_all_objects(Song,
Song.search_title.like(u'%' + clean_string(search_keywords) + u'%'))
self.displayResultsSong(search_results)
self.display_results_song(search_results)
elif search_type == SongSearch.Lyrics:
log.debug(u'Lyrics Search')
search_results = self.plugin.manager.get_all_objects(Song,
Song.search_lyrics.like(u'%' + clean_string(search_keywords) + u'%'))
self.displayResultsSong(search_results)
self.display_results_song(search_results)
elif search_type == SongSearch.Authors:
log.debug(u'Authors Search')
search_results = self.plugin.manager.get_all_objects(Author,
Author.display_name.like(u'%' + search_keywords + u'%'), Author.display_name.asc())
self.displayResultsAuthor(search_results)
self.display_results_author(search_results)
elif search_type == SongSearch.Books:
log.debug(u'Books Search')
search_results = self.plugin.manager.get_all_objects(Book,
@ -193,15 +190,15 @@ class SongMediaItem(MediaManagerItem):
search_results = self.plugin.manager.get_all_objects(Book,
Book.name.like(u'%' + search_keywords[0] + u'%'), Book.name.asc())
song_number = re.sub(r'[^0-9]', u'', search_keywords[2])
self.displayResultsBook(search_results, song_number)
self.display_results_book(search_results, song_number)
elif search_type == SongSearch.Themes:
log.debug(u'Theme Search')
search_results = self.plugin.manager.get_all_objects(Song,
Song.theme_name.like(u'%' + search_keywords + u'%'))
self.displayResultsSong(search_results)
self.display_results_song(search_results)
self.check_search_result()
def searchEntire(self, search_keywords):
def search_entire(self, search_keywords):
return self.plugin.manager.get_all_objects(Song,
or_(Song.search_title.like(u'%' + clean_string(search_keywords) + u'%'),
Song.search_lyrics.like(u'%' + clean_string(search_keywords) + u'%'),
@ -213,17 +210,16 @@ class SongMediaItem(MediaManagerItem):
of songs
"""
log.debug(u'on_song_list_load - start')
# Called to redisplay the song list screen edit from a search
# or from the exit of the Song edit dialog. If remote editing is active
# Trigger it and clean up so it will not update again.
# Push edits to the service manager to update items
if self.editItem and self.updateServiceOnEdit and not self.remote_triggered:
item = self.build_service_item(self.editItem)
# Called to redisplay the song list screen edit from a search or from the exit of the Song edit dialog. If
# remote editing is active Trigger it and clean up so it will not update again. Push edits to the service
# manager to update items
if self.edit_item and self.updateServiceOnEdit and not self.remote_triggered:
item = self.build_service_item(self.edit_item)
self.service_manager.replace_service_item(item)
self.on_search_text_button_clicked()
log.debug(u'on_song_list_load - finished')
def displayResultsSong(self, searchresults):
def display_results_song(self, searchresults):
log.debug(u'display results Song')
self.save_auto_select_id()
self.list_view.clear()
@ -243,7 +239,7 @@ class SongMediaItem(MediaManagerItem):
self.list_view.setCurrentItem(song_name)
self.auto_select_id = -1
def displayResultsAuthor(self, searchresults):
def display_results_author(self, searchresults):
log.debug(u'display results Author')
self.list_view.clear()
for author in searchresults:
@ -256,7 +252,7 @@ class SongMediaItem(MediaManagerItem):
song_name.setData(QtCore.Qt.UserRole, song.id)
self.list_view.addItem(song_name)
def displayResultsBook(self, searchresults, song_number=False):
def display_results_book(self, searchresults, song_number=False):
log.debug(u'display results Book')
self.list_view.clear()
for book in searchresults:
@ -273,7 +269,7 @@ class SongMediaItem(MediaManagerItem):
song_name.setData(QtCore.Qt.UserRole, song.id)
self.list_view.addItem(song_name)
def onClearTextButtonClick(self):
def on_clear_text_button_click(self):
"""
Clear the search text.
"""
@ -282,11 +278,10 @@ class SongMediaItem(MediaManagerItem):
def on_search_text_edit_changed(self, text):
"""
If search as type enabled invoke the search on each key press.
If the Lyrics are being searched do not start till 7 characters
have been entered.
If search as type enabled invoke the search on each key press. If the Lyrics are being searched do not start
till 7 characters have been entered.
"""
if self.searchAsYouType:
if self.search_as_you_type:
search_length = 1
if self.search_text_edit.current_search_type() == SongSearch.Entire:
search_length = 4
@ -295,7 +290,7 @@ class SongMediaItem(MediaManagerItem):
if len(text) > search_length:
self.on_search_text_button_clicked()
elif not text:
self.onClearTextButtonClick()
self.on_clear_text_button_click()
def on_import_click(self):
if not hasattr(self, u'import_wizard'):
@ -311,33 +306,32 @@ class SongMediaItem(MediaManagerItem):
def on_new_click(self):
log.debug(u'on_new_click')
self.editSongForm.new_song()
self.editSongForm.exec_()
self.onClearTextButtonClick()
self.edit_song_form.new_song()
self.edit_song_form.exec_()
self.on_clear_text_button_click()
self.on_selection_change()
self.auto_select_id = -1
def onSongMaintenanceClick(self):
self.songMaintenanceForm.exec_()
def on_song_maintenance_click(self):
self.song_maintenance_form.exec_()
def onRemoteEdit(self, song_id, preview=False):
def on_remote_edit(self, song_id, preview=False):
"""
Called by ServiceManager or SlideController by event passing
the Song Id in the payload along with an indicator to say which
type of display is required.
Called by ServiceManager or SlideController by event passing the Song Id in the payload along with an indicator
to say which type of display is required.
"""
log.debug(u'onRemoteEdit for song %s' % song_id)
log.debug(u'on_remote_edit for song %s' % song_id)
song_id = int(song_id)
valid = self.plugin.manager.get_object(Song, song_id)
if valid:
self.editSongForm.load_song(song_id, preview)
if self.editSongForm.exec_() == QtGui.QDialog.Accepted:
self.edit_song_form.load_song(song_id, preview)
if self.edit_song_form.exec_() == QtGui.QDialog.Accepted:
self.auto_select_id = -1
self.on_song_list_load()
self.remoteSong = song_id
self.remote_song = song_id
self.remote_triggered = True
item = self.build_service_item(remote=True)
self.remoteSong = -1
self.remote_song = -1
self.remote_triggered = None
if item:
return item
@ -349,13 +343,13 @@ class SongMediaItem(MediaManagerItem):
"""
log.debug(u'on_edit_click')
if check_item_selected(self.list_view, UiStrings().SelectEdit):
self.editItem = self.list_view.currentItem()
item_id = self.editItem.data(QtCore.Qt.UserRole)
self.editSongForm.load_song(item_id, False)
self.editSongForm.exec_()
self.edit_item = self.list_view.currentItem()
item_id = self.edit_item.data(QtCore.Qt.UserRole)
self.edit_song_form.load_song(item_id, False)
self.edit_song_form.exec_()
self.auto_select_id = -1
self.on_song_list_load()
self.editItem = None
self.edit_item = None
def on_delete_click(self):
"""
@ -364,11 +358,11 @@ class SongMediaItem(MediaManagerItem):
if check_item_selected(self.list_view, UiStrings().SelectDelete):
items = self.list_view.selectedIndexes()
if QtGui.QMessageBox.question(self,
UiStrings().ConfirmDelete,
translate('SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '',
QtCore.QCoreApplication.CodecForTr, len(items)),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
UiStrings().ConfirmDelete,
translate('SongsPlugin.MediaItem', 'Are you sure you want to delete the %n selected song(s)?', '',
QtCore.QCoreApplication.CodecForTr, len(items)),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No),
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
return
self.application.set_busy_cursor()
self.main_window.display_progress_bar(len(items))
@ -392,14 +386,14 @@ class SongMediaItem(MediaManagerItem):
self.application.set_normal_cursor()
self.on_search_text_button_clicked()
def onCloneClick(self):
def on_clone_click(self):
"""
Clone a Song
"""
log.debug(u'onCloneClick')
log.debug(u'on_clone_click')
if check_item_selected(self.list_view, UiStrings().SelectEdit):
self.editItem = self.list_view.currentItem()
item_id = self.editItem.data(QtCore.Qt.UserRole)
self.edit_item = self.list_view.currentItem()
item_id = self.edit_item.data(QtCore.Qt.UserRole)
old_song = self.plugin.manager.get_object(Song, item_id)
song_xml = self.openLyrics.song_to_xml(old_song)
new_song = self.openLyrics.xml_to_song(song_xml)
@ -413,8 +407,8 @@ class SongMediaItem(MediaManagerItem):
"""
Generate the slide data. Needs to be implemented by the plugin.
"""
log.debug(u'generate_slide_data: %s, %s, %s' % (service_item, item, self.remoteSong))
item_id = self._get_id_of_item_to_generate(item, self.remoteSong)
log.debug(u'generate_slide_data: %s, %s, %s' % (service_item, item, self.remote_song))
item_id = self._get_id_of_item_to_generate(item, self.remote_song)
service_item.add_capability(ItemCapabilities.CanEdit)
service_item.add_capability(ItemCapabilities.CanPreview)
service_item.add_capability(ItemCapabilities.CanLoop)
@ -432,8 +426,8 @@ class SongMediaItem(MediaManagerItem):
verse_tags_translated = True
if not song.verse_order.strip():
for verse in verse_list:
# We cannot use from_loose_input() here, because database
# is supposed to contain English lowercase singlechar tags.
# We cannot use from_loose_input() here, because database is supposed to contain English lowercase
# singlechar tags.
verse_tag = verse[0][u'type']
verse_index = None
if len(verse_tag) > 1:
@ -506,9 +500,8 @@ class SongMediaItem(MediaManagerItem):
if self.plugin.status != PluginStatus.Active or not item.data_string:
return
if item.data_string[u'title'].find(u'@') == -1:
# This file seems to be an old one (prior to 1.9.5), which means,
# that the search title (data_string[u'title']) is probably wrong.
# We add "@" to search title and hope that we do not add any
# FIXME: This file seems to be an old one (prior to 1.9.5), which means, that the search title
# (data_string[u'title']) is probably wrong. We add "@" to search title and hope that we do not add any
# duplicate. This should work for songs without alternate title.
search_results = self.plugin.manager.get_all_objects(Song,
Song.search_title == (re.compile(r'\W+', re.UNICODE).sub(u' ',
@ -534,20 +527,20 @@ class SongMediaItem(MediaManagerItem):
break
# If there's any backing tracks, copy them over.
if item.background_audio:
self._updateBackgroundAudio(song, item)
self._update_background_audio(song, item)
if add_song and self.addSongFromService:
song = self.openLyrics.xml_to_song(item.xml_version)
# If there's any backing tracks, copy them over.
if item.background_audio:
self._updateBackgroundAudio(song, item)
edit_id = song.id
self._update_background_audio(song, item)
editId = song.id
self.on_search_text_button_clicked()
elif add_song and not self.addSongFromService:
# Make sure we temporary import formatting tags.
song = self.openLyrics.xml_to_song(item.xml_version, True)
# If there's any backing tracks, copy them over.
if item.background_audio:
self._updateBackgroundAudio(song, item)
self._update_background_audio(song, item)
edit_id = song.id
# Update service with correct song id and return it to caller.
item.edit_id = edit_id
@ -558,5 +551,5 @@ class SongMediaItem(MediaManagerItem):
"""
Search for some songs
"""
search_results = self.searchEntire(string)
search_results = self.search_entire(string)
return [[song.id, song.title] for song in search_results]

View File

@ -1,227 +0,0 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2013 Raoul Snyman #
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
# --------------------------------------------------------------------------- #
# 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 #
###############################################################################
"""
The :mod:`olp1import` module provides the functionality for importing
openlp.org 1.x song databases into the current installation database.
"""
import logging
from chardet.universaldetector import UniversalDetector
import sqlite
import sys
import os
from openlp.core.lib import Registry, translate
from openlp.plugins.songs.lib import retrieve_windows_encoding
from songimport import SongImport
log = logging.getLogger(__name__)
class OpenLP1SongImport(SongImport):
"""
The :class:`OpenLP1SongImport` class provides OpenLP with the ability to
import song databases from installations of openlp.org 1.x.
"""
lastEncoding = u'windows-1252'
def __init__(self, manager, **kwargs):
"""
Initialise the import.
``manager``
The song manager for the running OpenLP installation.
``filename``
The database providing the data to import.
"""
SongImport.__init__(self, manager, **kwargs)
def doImport(self):
"""
Run the import for an openlp.org 1.x song database.
"""
if not self.import_source.endswith(u'.olp'):
self.logError(self.import_source,
translate('SongsPlugin.OpenLP1SongImport', 'Not a valid openlp.org 1.x song database.'))
return
encoding = self.getEncoding()
if not encoding:
return
# Connect to the database.
connection = sqlite.connect(self.import_source, mode=0444, encoding=(encoding, 'replace'))
cursor = connection.cursor()
# Determine if the db supports linking audio to songs.
cursor.execute(u'SELECT name FROM sqlite_master '
u'WHERE type = \'table\' AND name = \'tracks\'')
db_has_tracks = len(cursor.fetchall()) > 0
# Determine if the db contains theme information.
cursor.execute(u'SELECT name FROM sqlite_master '
u'WHERE type = \'table\' AND name = \'settings\'')
db_has_themes = len(cursor.fetchall()) > 0
# "cache" our list of authors.
cursor.execute(u'-- types int, unicode')
cursor.execute(u'SELECT authorid, authorname FROM authors')
authors = cursor.fetchall()
if db_has_tracks:
# "cache" our list of tracks.
cursor.execute(u'-- types int, unicode')
cursor.execute(u'SELECT trackid, fulltrackname FROM tracks')
tracks = cursor.fetchall()
if db_has_themes:
# "cache" our list of themes.
themes = {}
cursor.execute(u'-- types int, unicode')
cursor.execute(u'SELECT settingsid, settingsname FROM settings')
for theme_id, theme_name in cursor.fetchall():
if theme_name in self.theme_manager.get_themes():
themes[theme_id] = theme_name
# Import the songs.
cursor.execute(u'-- types int, unicode, unicode, unicode')
cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS ' \
u'lyrics, copyrightinfo FROM songs')
songs = cursor.fetchall()
self.import_wizard.progress_bar.setMaximum(len(songs))
for song in songs:
self.setDefaults()
if self.stop_import_flag:
break
song_id = song[0]
self.title = song[1]
lyrics = song[2].replace(u'\r\n', u'\n')
self.addCopyright(song[3])
if db_has_themes:
cursor.execute(u'-- types int')
cursor.execute(
u'SELECT settingsid FROM songs WHERE songid = %s' % song_id)
theme_id = cursor.fetchone()[0]
self.themeName = themes.get(theme_id, u'')
verses = lyrics.split(u'\n\n')
for verse in verses:
if verse.strip():
self.addVerse(verse.strip())
cursor.execute(u'-- types int')
cursor.execute(u'SELECT authorid FROM songauthors '
u'WHERE songid = %s' % song_id)
author_ids = cursor.fetchall()
for author_id in author_ids:
if self.stop_import_flag:
break
for author in authors:
if author[0] == author_id[0]:
self.parse_author(author[1])
break
if self.stop_import_flag:
break
if db_has_tracks:
cursor.execute(u'-- types int, int')
cursor.execute(u'SELECT trackid, listindex '
u'FROM songtracks '
u'WHERE songid = %s ORDER BY listindex' % song_id)
track_ids = cursor.fetchall()
for track_id, listindex in track_ids:
if self.stop_import_flag:
break
for track in tracks:
if track[0] == track_id:
media_file = self.expandMediaFile(track[1])
self.addMediaFile(media_file, listindex)
break
if self.stop_import_flag:
break
if not self.finish():
self.logError(self.import_source)
def getEncoding(self):
"""
Detect character encoding of an openlp.org 1.x song database.
"""
# Connect to the database.
connection = sqlite.connect(self.import_source.encode(
sys.getfilesystemencoding()), mode=0444)
cursor = connection.cursor()
detector = UniversalDetector()
# Detect charset by authors.
cursor.execute(u'SELECT authorname FROM authors')
authors = cursor.fetchall()
for author in authors:
detector.feed(author[0])
if detector.done:
detector.close()
return detector.result[u'encoding']
# Detect charset by songs.
cursor.execute(u'SELECT songtitle, copyrightinfo, '
u'lyrics || \'\' AS lyrics FROM songs')
songs = cursor.fetchall()
for index in [0, 1, 2]:
for song in songs:
detector.feed(song[index])
if detector.done:
detector.close()
return detector.result[u'encoding']
# Detect charset by songs.
cursor.execute(u'SELECT name FROM sqlite_master '
u'WHERE type = \'table\' AND name = \'tracks\'')
if cursor.fetchall():
cursor.execute(u'SELECT fulltrackname FROM tracks')
tracks = cursor.fetchall()
for track in tracks:
detector.feed(track[0])
if detector.done:
detector.close()
return detector.result[u'encoding']
detector.close()
return retrieve_windows_encoding(detector.result[u'encoding'])
def expandMediaFile(self, filename):
"""
When you're on Windows, this function expands the file name to include
the path to OpenLP's application data directory. If you are not on
Windows, it returns the original file name.
``filename``
The filename to expand.
"""
if sys.platform != u'win32' and not os.environ.get(u'ALLUSERSPROFILE') and not os.environ.get(u'APPDATA'):
return filename
common_app_data = os.path.join(os.environ[u'ALLUSERSPROFILE'],
os.path.split(os.environ[u'APPDATA'])[1])
if not common_app_data:
return filename
return os.path.join(common_app_data, u'openlp.org', 'Audio', filename)
def _get_theme_manager(self):
"""
Adds the theme manager to the class dynamically
"""
if not hasattr(self, u'_theme_manager'):
self._theme_manager = Registry().get(u'theme_manager')
return self._theme_manager
theme_manager = property(_get_theme_manager)

View File

@ -89,7 +89,6 @@ MODULES = [
OPTIONAL_MODULES = [
('sqlite', ' (SQLite 2 support)'),
('MySQLdb', ' (MySQL support)'),
('psycopg2', ' (PostgreSQL support)'),
('nose', ' (testing framework)'),

View File

@ -24,7 +24,7 @@ class TestMediaItem(TestCase):
"""
Registry.create()
Registry().register(u'service_list', MagicMock())
Registry().register(u'main_window', MagicMock())
with patch('openlp.core.lib.mediamanageritem.MediaManagerItem.__init__'), \
patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__'):
self.media_item = SongMediaItem(MagicMock(), MagicMock())