2009-12-15 19:37:56 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2013-01-01 16:33:41 +00:00
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
2009-12-15 19:37:56 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
2012-12-29 20:56:56 +00:00
|
|
|
# Copyright (c) 2008-2013 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
|
2012-06-22 14:14:53 +00:00
|
|
|
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
2012-11-11 21:16:14 +00:00
|
|
|
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
2012-10-21 13:16:22 +00:00
|
|
|
# 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, #
|
2012-12-01 07:57:54 +00:00
|
|
|
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
2009-12-15 19:37:56 +00:00
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# 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 #
|
|
|
|
###############################################################################
|
2011-01-13 17:55:29 +00:00
|
|
|
"""
|
|
|
|
The bible import functions for OpenLP
|
|
|
|
"""
|
2009-12-15 19:37:56 +00:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
from PyQt4 import QtCore, QtGui
|
|
|
|
|
2013-02-05 08:05:28 +00:00
|
|
|
from openlp.core.lib import Settings, UiStrings, translate
|
2010-06-18 01:26:01 +00:00
|
|
|
from openlp.core.lib.db import delete_database
|
2013-01-11 00:19:11 +00:00
|
|
|
from openlp.core.lib.ui import critical_error_message_box
|
2011-02-12 02:43:13 +00:00
|
|
|
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
|
2013-04-05 17:41:01 +00:00
|
|
|
from openlp.core.utils import AppLocation, get_locale_key
|
2009-12-21 20:58:00 +00:00
|
|
|
from openlp.plugins.bibles.lib.manager import BibleFormat
|
2011-05-03 17:09:30 +00:00
|
|
|
from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename
|
2009-12-15 19:37:56 +00:00
|
|
|
|
2010-02-27 15:31:23 +00:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2010-03-24 21:00:43 +00:00
|
|
|
class WebDownload(object):
|
2011-01-13 17:55:29 +00:00
|
|
|
"""
|
|
|
|
Provides an enumeration for the web bible types available to OpenLP.
|
|
|
|
"""
|
2009-12-18 22:31:28 +00:00
|
|
|
Unknown = -1
|
|
|
|
Crosswalk = 0
|
|
|
|
BibleGateway = 1
|
2010-12-11 23:54:07 +00:00
|
|
|
Bibleserver = 2
|
2009-12-18 22:31:28 +00:00
|
|
|
|
2011-02-18 03:15:09 +00:00
|
|
|
Names = [u'Crosswalk', u'BibleGateway', u'Bibleserver']
|
2009-12-18 22:31:28 +00:00
|
|
|
|
|
|
|
|
2011-01-13 17:55:29 +00:00
|
|
|
class BibleImportForm(OpenLPWizard):
|
2009-12-15 19:37:56 +00:00
|
|
|
"""
|
|
|
|
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')
|
|
|
|
|
2010-04-27 16:27:57 +00:00
|
|
|
def __init__(self, parent, manager, bibleplugin):
|
2010-03-21 22:16:43 +00:00
|
|
|
"""
|
|
|
|
Instantiate the wizard, and run any extra setup we need to.
|
|
|
|
|
|
|
|
``parent``
|
|
|
|
The QWidget-derived parent of the wizard.
|
|
|
|
|
|
|
|
``manager``
|
|
|
|
The Bible manager.
|
|
|
|
|
|
|
|
``bibleplugin``
|
|
|
|
The Bible plugin.
|
|
|
|
"""
|
2011-01-13 17:55:29 +00:00
|
|
|
self.manager = manager
|
|
|
|
self.web_bible_list = {}
|
2013-01-01 16:33:41 +00:00
|
|
|
OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleImportWizard', u':/wizards/wizard_importbible.bmp')
|
2011-01-13 17:55:29 +00:00
|
|
|
|
|
|
|
def setupUi(self, image):
|
|
|
|
"""
|
|
|
|
Set up the UI for the bible wizard.
|
|
|
|
"""
|
|
|
|
OpenLPWizard.setupUi(self, image)
|
2013-03-07 11:15:10 +00:00
|
|
|
self.formatComboBox.currentIndexChanged.connect(self.onCurrentIndexChanged)
|
2011-04-11 15:01:42 +00:00
|
|
|
|
|
|
|
def onCurrentIndexChanged(self, index):
|
|
|
|
"""
|
|
|
|
Called when the format combo box's index changed. We have to check if
|
|
|
|
the import is available and accordingly to disable or enable the next
|
|
|
|
button.
|
|
|
|
"""
|
|
|
|
self.selectStack.setCurrentIndex(index)
|
2011-01-13 17:55:29 +00:00
|
|
|
|
2013-03-14 22:22:18 +00:00
|
|
|
def custom_init(self):
|
2011-01-13 17:55:29 +00:00
|
|
|
"""
|
|
|
|
Perform any custom initialisation for bible importing.
|
|
|
|
"""
|
2010-02-04 17:38:21 +00:00
|
|
|
self.manager.set_process_dialog(self)
|
2009-12-16 02:22:16 +00:00
|
|
|
self.loadWebBibles()
|
2010-12-27 15:31:53 +00:00
|
|
|
self.restart()
|
|
|
|
self.selectStack.setCurrentIndex(0)
|
2011-01-13 17:55:29 +00:00
|
|
|
|
2013-03-14 22:22:18 +00:00
|
|
|
def custom_signals(self):
|
2011-01-13 17:55:29 +00:00
|
|
|
"""
|
|
|
|
Set up the signals used in the bible importer.
|
|
|
|
"""
|
2013-03-07 11:01:06 +00:00
|
|
|
self.webSourceComboBox.currentIndexChanged.connect(self.onWebSourceComboBoxIndexChanged)
|
|
|
|
self.osisBrowseButton.clicked.connect(self.onOsisBrowseButtonClicked)
|
|
|
|
self.csvBooksButton.clicked.connect(self.onCsvBooksBrowseButtonClicked)
|
|
|
|
self.csvVersesButton.clicked.connect(self.onCsvVersesBrowseButtonClicked)
|
|
|
|
self.openSongBrowseButton.clicked.connect(self.onOpenSongBrowseButtonClicked)
|
2009-12-15 19:37:56 +00:00
|
|
|
|
2013-03-14 22:22:18 +00:00
|
|
|
def add_custom_pages(self):
|
2010-03-21 22:16:43 +00:00
|
|
|
"""
|
2011-01-13 17:55:29 +00:00
|
|
|
Add the bible import specific wizard pages.
|
2010-03-21 22:16:43 +00:00
|
|
|
"""
|
2011-01-13 17:55:29 +00:00
|
|
|
# Select Page
|
|
|
|
self.selectPage = QtGui.QWizardPage()
|
|
|
|
self.selectPage.setObjectName(u'SelectPage')
|
|
|
|
self.selectPageLayout = QtGui.QVBoxLayout(self.selectPage)
|
|
|
|
self.selectPageLayout.setObjectName(u'SelectPageLayout')
|
|
|
|
self.formatLayout = QtGui.QFormLayout()
|
|
|
|
self.formatLayout.setObjectName(u'FormatLayout')
|
|
|
|
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.setObjectName(u'FormatComboBox')
|
|
|
|
self.formatLayout.addRow(self.formatLabel, self.formatComboBox)
|
2013-01-01 16:33:41 +00:00
|
|
|
self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum)
|
2011-02-03 20:12:06 +00:00
|
|
|
self.formatLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.selectPageLayout.addLayout(self.formatLayout)
|
|
|
|
self.selectStack = QtGui.QStackedLayout()
|
|
|
|
self.selectStack.setObjectName(u'SelectStack')
|
|
|
|
self.osisWidget = QtGui.QWidget(self.selectPage)
|
|
|
|
self.osisWidget.setObjectName(u'OsisWidget')
|
|
|
|
self.osisLayout = QtGui.QFormLayout(self.osisWidget)
|
|
|
|
self.osisLayout.setMargin(0)
|
|
|
|
self.osisLayout.setObjectName(u'OsisLayout')
|
|
|
|
self.osisFileLabel = QtGui.QLabel(self.osisWidget)
|
|
|
|
self.osisFileLabel.setObjectName(u'OsisFileLabel')
|
|
|
|
self.osisFileLayout = QtGui.QHBoxLayout()
|
|
|
|
self.osisFileLayout.setObjectName(u'OsisFileLayout')
|
|
|
|
self.osisFileEdit = QtGui.QLineEdit(self.osisWidget)
|
|
|
|
self.osisFileEdit.setObjectName(u'OsisFileEdit')
|
|
|
|
self.osisFileLayout.addWidget(self.osisFileEdit)
|
|
|
|
self.osisBrowseButton = QtGui.QToolButton(self.osisWidget)
|
2013-03-07 08:05:43 +00:00
|
|
|
self.osisBrowseButton.setIcon(self.open_icon)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.osisBrowseButton.setObjectName(u'OsisBrowseButton')
|
|
|
|
self.osisFileLayout.addWidget(self.osisBrowseButton)
|
|
|
|
self.osisLayout.addRow(self.osisFileLabel, self.osisFileLayout)
|
2011-02-03 20:12:06 +00:00
|
|
|
self.osisLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.selectStack.addWidget(self.osisWidget)
|
|
|
|
self.csvWidget = QtGui.QWidget(self.selectPage)
|
|
|
|
self.csvWidget.setObjectName(u'CsvWidget')
|
|
|
|
self.csvLayout = QtGui.QFormLayout(self.csvWidget)
|
|
|
|
self.csvLayout.setMargin(0)
|
|
|
|
self.csvLayout.setObjectName(u'CsvLayout')
|
|
|
|
self.csvBooksLabel = QtGui.QLabel(self.csvWidget)
|
|
|
|
self.csvBooksLabel.setObjectName(u'CsvBooksLabel')
|
|
|
|
self.csvBooksLayout = QtGui.QHBoxLayout()
|
|
|
|
self.csvBooksLayout.setObjectName(u'CsvBooksLayout')
|
|
|
|
self.csvBooksEdit = QtGui.QLineEdit(self.csvWidget)
|
|
|
|
self.csvBooksEdit.setObjectName(u'CsvBooksEdit')
|
|
|
|
self.csvBooksLayout.addWidget(self.csvBooksEdit)
|
|
|
|
self.csvBooksButton = QtGui.QToolButton(self.csvWidget)
|
2013-03-07 08:05:43 +00:00
|
|
|
self.csvBooksButton.setIcon(self.open_icon)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.csvBooksButton.setObjectName(u'CsvBooksButton')
|
|
|
|
self.csvBooksLayout.addWidget(self.csvBooksButton)
|
|
|
|
self.csvLayout.addRow(self.csvBooksLabel, self.csvBooksLayout)
|
|
|
|
self.csvVersesLabel = QtGui.QLabel(self.csvWidget)
|
|
|
|
self.csvVersesLabel.setObjectName(u'CsvVersesLabel')
|
|
|
|
self.csvVersesLayout = QtGui.QHBoxLayout()
|
|
|
|
self.csvVersesLayout.setObjectName(u'CsvVersesLayout')
|
|
|
|
self.csvVersesEdit = QtGui.QLineEdit(self.csvWidget)
|
|
|
|
self.csvVersesEdit.setObjectName(u'CsvVersesEdit')
|
|
|
|
self.csvVersesLayout.addWidget(self.csvVersesEdit)
|
|
|
|
self.csvVersesButton = QtGui.QToolButton(self.csvWidget)
|
2013-03-07 08:05:43 +00:00
|
|
|
self.csvVersesButton.setIcon(self.open_icon)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.csvVersesButton.setObjectName(u'CsvVersesButton')
|
|
|
|
self.csvVersesLayout.addWidget(self.csvVersesButton)
|
|
|
|
self.csvLayout.addRow(self.csvVersesLabel, self.csvVersesLayout)
|
2011-02-03 20:12:06 +00:00
|
|
|
self.csvLayout.setItem(3, QtGui.QFormLayout.LabelRole, self.spacer)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.selectStack.addWidget(self.csvWidget)
|
|
|
|
self.openSongWidget = QtGui.QWidget(self.selectPage)
|
|
|
|
self.openSongWidget.setObjectName(u'OpenSongWidget')
|
|
|
|
self.openSongLayout = QtGui.QFormLayout(self.openSongWidget)
|
|
|
|
self.openSongLayout.setMargin(0)
|
|
|
|
self.openSongLayout.setObjectName(u'OpenSongLayout')
|
|
|
|
self.openSongFileLabel = QtGui.QLabel(self.openSongWidget)
|
|
|
|
self.openSongFileLabel.setObjectName(u'OpenSongFileLabel')
|
|
|
|
self.openSongFileLayout = QtGui.QHBoxLayout()
|
|
|
|
self.openSongFileLayout.setObjectName(u'OpenSongFileLayout')
|
|
|
|
self.openSongFileEdit = QtGui.QLineEdit(self.openSongWidget)
|
|
|
|
self.openSongFileEdit.setObjectName(u'OpenSongFileEdit')
|
|
|
|
self.openSongFileLayout.addWidget(self.openSongFileEdit)
|
|
|
|
self.openSongBrowseButton = QtGui.QToolButton(self.openSongWidget)
|
2013-03-07 08:05:43 +00:00
|
|
|
self.openSongBrowseButton.setIcon(self.open_icon)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.openSongBrowseButton.setObjectName(u'OpenSongBrowseButton')
|
|
|
|
self.openSongFileLayout.addWidget(self.openSongBrowseButton)
|
2013-01-01 16:33:41 +00:00
|
|
|
self.openSongLayout.addRow(self.openSongFileLabel, self.openSongFileLayout)
|
2011-02-03 20:12:06 +00:00
|
|
|
self.openSongLayout.setItem(1, QtGui.QFormLayout.LabelRole, self.spacer)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.selectStack.addWidget(self.openSongWidget)
|
|
|
|
self.webTabWidget = QtGui.QTabWidget(self.selectPage)
|
|
|
|
self.webTabWidget.setObjectName(u'WebTabWidget')
|
|
|
|
self.webBibleTab = QtGui.QWidget()
|
|
|
|
self.webBibleTab.setObjectName(u'WebBibleTab')
|
|
|
|
self.webBibleLayout = QtGui.QFormLayout(self.webBibleTab)
|
|
|
|
self.webBibleLayout.setObjectName(u'WebBibleLayout')
|
|
|
|
self.webSourceLabel = QtGui.QLabel(self.webBibleTab)
|
|
|
|
self.webSourceLabel.setObjectName(u'WebSourceLabel')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webBibleLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.webSourceLabel)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webSourceComboBox = QtGui.QComboBox(self.webBibleTab)
|
|
|
|
self.webSourceComboBox.setObjectName(u'WebSourceComboBox')
|
|
|
|
self.webSourceComboBox.addItems([u'', u'', u''])
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webBibleLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.webSourceComboBox)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webTranslationLabel = QtGui.QLabel(self.webBibleTab)
|
|
|
|
self.webTranslationLabel.setObjectName(u'webTranslationLabel')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webBibleLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.webTranslationLabel)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webTranslationComboBox = QtGui.QComboBox(self.webBibleTab)
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webTranslationComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webTranslationComboBox.setObjectName(u'WebTranslationComboBox')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webBibleLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.webTranslationComboBox)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webTabWidget.addTab(self.webBibleTab, u'')
|
|
|
|
self.webProxyTab = QtGui.QWidget()
|
|
|
|
self.webProxyTab.setObjectName(u'WebProxyTab')
|
|
|
|
self.webProxyLayout = QtGui.QFormLayout(self.webProxyTab)
|
|
|
|
self.webProxyLayout.setObjectName(u'WebProxyLayout')
|
|
|
|
self.webServerLabel = QtGui.QLabel(self.webProxyTab)
|
|
|
|
self.webServerLabel.setObjectName(u'WebServerLabel')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webProxyLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.webServerLabel)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webServerEdit = QtGui.QLineEdit(self.webProxyTab)
|
|
|
|
self.webServerEdit.setObjectName(u'WebServerEdit')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webProxyLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.webServerEdit)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webUserLabel = QtGui.QLabel(self.webProxyTab)
|
|
|
|
self.webUserLabel.setObjectName(u'WebUserLabel')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webProxyLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.webUserLabel)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webUserEdit = QtGui.QLineEdit(self.webProxyTab)
|
|
|
|
self.webUserEdit.setObjectName(u'WebUserEdit')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webProxyLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.webUserEdit)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webPasswordLabel = QtGui.QLabel(self.webProxyTab)
|
|
|
|
self.webPasswordLabel.setObjectName(u'WebPasswordLabel')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.LabelRole, self.webPasswordLabel)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webPasswordEdit = QtGui.QLineEdit(self.webProxyTab)
|
|
|
|
self.webPasswordEdit.setObjectName(u'WebPasswordEdit')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webProxyLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.webPasswordEdit)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.webTabWidget.addTab(self.webProxyTab, u'')
|
|
|
|
self.selectStack.addWidget(self.webTabWidget)
|
|
|
|
self.selectPageLayout.addLayout(self.selectStack)
|
|
|
|
self.addPage(self.selectPage)
|
|
|
|
# License Page
|
|
|
|
self.licenseDetailsPage = QtGui.QWizardPage()
|
|
|
|
self.licenseDetailsPage.setObjectName(u'LicenseDetailsPage')
|
|
|
|
self.licenseDetailsLayout = QtGui.QFormLayout(self.licenseDetailsPage)
|
|
|
|
self.licenseDetailsLayout.setObjectName(u'LicenseDetailsLayout')
|
|
|
|
self.versionNameLabel = QtGui.QLabel(self.licenseDetailsPage)
|
|
|
|
self.versionNameLabel.setObjectName(u'VersionNameLabel')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.versionNameLabel)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.versionNameEdit = QtGui.QLineEdit(self.licenseDetailsPage)
|
|
|
|
self.versionNameEdit.setObjectName(u'VersionNameEdit')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.licenseDetailsLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.versionNameEdit)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.copyrightLabel = QtGui.QLabel(self.licenseDetailsPage)
|
|
|
|
self.copyrightLabel.setObjectName(u'CopyrightLabel')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.copyrightLabel)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.copyrightEdit = QtGui.QLineEdit(self.licenseDetailsPage)
|
|
|
|
self.copyrightEdit.setObjectName(u'CopyrightEdit')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.licenseDetailsLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.copyrightEdit)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.permissionsLabel = QtGui.QLabel(self.licenseDetailsPage)
|
|
|
|
self.permissionsLabel.setObjectName(u'PermissionsLabel')
|
|
|
|
self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.LabelRole,
|
|
|
|
self.permissionsLabel)
|
|
|
|
self.permissionsEdit = QtGui.QLineEdit(self.licenseDetailsPage)
|
|
|
|
self.permissionsEdit.setObjectName(u'PermissionsEdit')
|
2013-01-01 16:33:41 +00:00
|
|
|
self.licenseDetailsLayout.setWidget(2, QtGui.QFormLayout.FieldRole, self.permissionsEdit)
|
2011-01-13 17:55:29 +00:00
|
|
|
self.addPage(self.licenseDetailsPage)
|
|
|
|
|
|
|
|
def retranslateUi(self):
|
2010-12-08 23:40:28 +00:00
|
|
|
"""
|
2011-01-13 17:55:29 +00:00
|
|
|
Allow for localisation of the bible import wizard.
|
2010-12-08 23:40:28 +00:00
|
|
|
"""
|
2013-01-01 16:33:41 +00:00
|
|
|
self.setWindowTitle(translate('BiblesPlugin.ImportWizardForm', 'Bible Import Wizard'))
|
2013-03-07 08:05:43 +00:00
|
|
|
self.title_label.setText(WizardStrings.HeaderStyle %
|
2011-02-16 03:06:34 +00:00
|
|
|
translate('OpenLP.Ui', 'Welcome to the Bible Import Wizard'))
|
2013-03-07 08:05:43 +00:00
|
|
|
self.information_label.setText(
|
2011-02-16 03:06:34 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm',
|
|
|
|
'This wizard will help you to import Bibles from a variety of '
|
|
|
|
'formats. Click the next button below to start the process by '
|
|
|
|
'selecting a format to import from.'))
|
2011-02-12 02:43:13 +00:00
|
|
|
self.selectPage.setTitle(WizardStrings.ImportSelect)
|
|
|
|
self.selectPage.setSubTitle(WizardStrings.ImportSelectLong)
|
|
|
|
self.formatLabel.setText(WizardStrings.FormatLabel)
|
2011-02-13 01:09:04 +00:00
|
|
|
self.formatComboBox.setItemText(BibleFormat.OSIS, WizardStrings.OSIS)
|
|
|
|
self.formatComboBox.setItemText(BibleFormat.CSV, WizardStrings.CSV)
|
|
|
|
self.formatComboBox.setItemText(BibleFormat.OpenSong, WizardStrings.OS)
|
|
|
|
self.formatComboBox.setItemText(BibleFormat.WebDownload,
|
2011-01-13 17:55:29 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'Web Download'))
|
2013-01-01 16:33:41 +00:00
|
|
|
self.osisFileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
|
|
|
|
self.csvBooksLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Books file:'))
|
|
|
|
self.csvVersesLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Verses file:'))
|
|
|
|
self.openSongFileLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible file:'))
|
|
|
|
self.webSourceLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Location:'))
|
2011-02-18 03:15:09 +00:00
|
|
|
self.webSourceComboBox.setItemText(WebDownload.Crosswalk,
|
2011-01-13 17:55:29 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'Crosswalk'))
|
2011-02-18 03:15:09 +00:00
|
|
|
self.webSourceComboBox.setItemText(WebDownload.BibleGateway,
|
2011-01-13 17:55:29 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'BibleGateway'))
|
2011-02-18 03:15:09 +00:00
|
|
|
self.webSourceComboBox.setItemText(WebDownload.Bibleserver,
|
2011-01-13 17:55:29 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'Bibleserver'))
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webTranslationLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Bible:'))
|
|
|
|
self.webTabWidget.setTabText(self.webTabWidget.indexOf(self.webBibleTab),
|
2011-01-13 17:55:29 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'Download Options'))
|
2013-01-01 16:33:41 +00:00
|
|
|
self.webServerLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Server:'))
|
|
|
|
self.webUserLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Username:'))
|
|
|
|
self.webPasswordLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Password:'))
|
|
|
|
self.webTabWidget.setTabText(self.webTabWidget.indexOf(self.webProxyTab),
|
2011-01-13 17:55:29 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm',
|
|
|
|
'Proxy Server (Optional)'))
|
|
|
|
self.licenseDetailsPage.setTitle(
|
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'License Details'))
|
2013-01-01 16:33:41 +00:00
|
|
|
self.licenseDetailsPage.setSubTitle(translate('BiblesPlugin.ImportWizardForm',
|
2011-01-13 17:55:29 +00:00
|
|
|
'Set up the Bible\'s license details.'))
|
2013-01-01 16:33:41 +00:00
|
|
|
self.versionNameLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Version name:'))
|
|
|
|
self.copyrightLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Copyright:'))
|
|
|
|
self.permissionsLabel.setText(translate('BiblesPlugin.ImportWizardForm', 'Permissions:'))
|
2013-03-07 08:05:43 +00:00
|
|
|
self.progress_page.setTitle(WizardStrings.Importing)
|
|
|
|
self.progress_page.setSubTitle(translate('BiblesPlugin.ImportWizardForm',
|
2011-01-13 17:55:29 +00:00
|
|
|
'Please wait while your Bible is imported.'))
|
2013-03-07 08:05:43 +00:00
|
|
|
self.progress_label.setText(WizardStrings.Ready)
|
|
|
|
self.progress_bar.setFormat(u'%p%')
|
2011-01-13 17:55:29 +00:00
|
|
|
# Align all QFormLayouts towards each other.
|
|
|
|
labelWidth = max(self.formatLabel.minimumSizeHint().width(),
|
|
|
|
self.osisFileLabel.minimumSizeHint().width(),
|
|
|
|
self.csvBooksLabel.minimumSizeHint().width(),
|
|
|
|
self.csvVersesLabel.minimumSizeHint().width(),
|
2013-04-15 21:31:04 +00:00
|
|
|
self.openSongFileLabel.minimumSizeHint().width())
|
2013-01-01 16:33:41 +00:00
|
|
|
self.spacer.changeSize(labelWidth, 0, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
|
2010-12-08 23:40:28 +00:00
|
|
|
|
2009-12-15 19:37:56 +00:00
|
|
|
def validateCurrentPage(self):
|
2010-03-21 22:16:43 +00:00
|
|
|
"""
|
|
|
|
Validate the current page before moving on to the next page.
|
|
|
|
"""
|
2013-03-07 08:05:43 +00:00
|
|
|
if self.currentPage() == self.welcome_page:
|
2009-12-15 19:37:56 +00:00
|
|
|
return True
|
2010-12-27 15:31:53 +00:00
|
|
|
elif self.currentPage() == self.selectPage:
|
2012-05-19 09:13:32 +00:00
|
|
|
if self.field(u'source_format') == BibleFormat.OSIS:
|
2012-05-19 15:10:05 +00:00
|
|
|
if not self.field(u'osis_location'):
|
2013-01-01 16:33:41 +00:00
|
|
|
critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OSIS)
|
2010-12-27 15:31:53 +00:00
|
|
|
self.osisFileEdit.setFocus()
|
2009-12-15 19:37:56 +00:00
|
|
|
return False
|
2012-05-19 09:13:32 +00:00
|
|
|
elif self.field(u'source_format') == BibleFormat.CSV:
|
2012-05-19 15:10:05 +00:00
|
|
|
if not self.field(u'csv_booksfile'):
|
2013-01-01 16:33:41 +00:00
|
|
|
critical_error_message_box(UiStrings().NFSs, translate('BiblesPlugin.ImportWizardForm',
|
|
|
|
'You need to specify a file with books of the Bible to use in the import.'))
|
2010-12-27 15:31:53 +00:00
|
|
|
self.csvBooksEdit.setFocus()
|
2009-12-15 19:37:56 +00:00
|
|
|
return False
|
2012-05-19 15:10:05 +00:00
|
|
|
elif not self.field(u'csv_versefile'):
|
2011-04-15 21:43:59 +00:00
|
|
|
critical_error_message_box(UiStrings().NFSs,
|
2010-06-21 18:28:36 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm',
|
2013-01-01 16:33:41 +00:00
|
|
|
'You need to specify a file of Bible verses to import.'))
|
2010-12-27 15:31:53 +00:00
|
|
|
self.csvVersesEdit.setFocus()
|
2009-12-15 19:37:56 +00:00
|
|
|
return False
|
2013-01-01 16:33:41 +00:00
|
|
|
elif self.field(u'source_format') == BibleFormat.OpenSong:
|
2012-05-19 15:10:05 +00:00
|
|
|
if not self.field(u'opensong_file'):
|
2013-01-01 16:33:41 +00:00
|
|
|
critical_error_message_box(UiStrings().NFSs, WizardStrings.YouSpecifyFile % WizardStrings.OS)
|
2010-12-08 17:18:12 +00:00
|
|
|
self.openSongFileEdit.setFocus()
|
2009-12-15 19:37:56 +00:00
|
|
|
return False
|
2013-01-01 16:33:41 +00:00
|
|
|
elif self.field(u'source_format') == BibleFormat.WebDownload:
|
|
|
|
self.versionNameEdit.setText(self.webTranslationComboBox.currentText())
|
2011-10-03 12:32:45 +00:00
|
|
|
return True
|
2009-12-15 19:37:56 +00:00
|
|
|
return True
|
2010-12-27 15:31:53 +00:00
|
|
|
elif self.currentPage() == self.licenseDetailsPage:
|
2012-05-19 15:10:05 +00:00
|
|
|
license_version = self.field(u'license_version')
|
|
|
|
license_copyright = self.field(u'license_copyright')
|
2011-05-25 14:18:03 +00:00
|
|
|
path = AppLocation.get_section_data_path(u'bibles')
|
2010-11-09 16:56:16 +00:00
|
|
|
if not license_version:
|
2011-04-15 21:43:59 +00:00
|
|
|
critical_error_message_box(UiStrings().EmptyField,
|
2013-01-01 16:33:41 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'You need to specify a version name for your Bible.'))
|
2010-12-08 17:18:12 +00:00
|
|
|
self.versionNameEdit.setFocus()
|
2009-12-16 20:52:44 +00:00
|
|
|
return False
|
2010-11-09 16:56:16 +00:00
|
|
|
elif not license_copyright:
|
2011-04-15 21:43:59 +00:00
|
|
|
critical_error_message_box(UiStrings().EmptyField,
|
2013-01-01 16:33:41 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'You need to set a copyright for your Bible. '
|
|
|
|
'Bibles in the Public Domain need to be marked as such.'))
|
2010-12-08 17:18:12 +00:00
|
|
|
self.copyrightEdit.setFocus()
|
2009-12-16 20:52:44 +00:00
|
|
|
return False
|
2010-03-21 22:16:43 +00:00
|
|
|
elif self.manager.exists(license_version):
|
2013-01-01 16:33:41 +00:00
|
|
|
critical_error_message_box(translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'),
|
2010-06-21 18:28:36 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm',
|
2013-01-01 16:33:41 +00:00
|
|
|
'This Bible already exists. Please import a different Bible or first delete the existing one.'))
|
2010-12-08 17:18:12 +00:00
|
|
|
self.versionNameEdit.setFocus()
|
2009-12-30 17:29:08 +00:00
|
|
|
return False
|
2011-05-03 17:09:30 +00:00
|
|
|
elif os.path.exists(os.path.join(path, clean_filename(
|
2011-04-20 09:00:29 +00:00
|
|
|
license_version))):
|
|
|
|
critical_error_message_box(
|
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'),
|
2013-01-01 16:33:41 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'This Bible already exists. Please import '
|
|
|
|
'a different Bible or first delete the existing one.'))
|
2011-04-20 09:00:29 +00:00
|
|
|
self.versionNameEdit.setFocus()
|
|
|
|
return False
|
2009-12-18 22:31:28 +00:00
|
|
|
return True
|
2013-03-07 08:05:43 +00:00
|
|
|
if self.currentPage() == self.progress_page:
|
2009-12-18 22:31:28 +00:00
|
|
|
return True
|
2009-12-15 19:37:56 +00:00
|
|
|
|
2011-01-13 17:55:29 +00:00
|
|
|
def onWebSourceComboBoxIndexChanged(self, index):
|
2010-03-21 22:16:43 +00:00
|
|
|
"""
|
|
|
|
Setup the list of Bibles when you select a different source on the web
|
|
|
|
download page.
|
|
|
|
|
|
|
|
``index``
|
|
|
|
The index of the combo box.
|
|
|
|
"""
|
2010-12-24 00:44:41 +00:00
|
|
|
self.webTranslationComboBox.clear()
|
2010-12-11 23:54:07 +00:00
|
|
|
bibles = self.web_bible_list[index].keys()
|
2013-04-05 17:41:01 +00:00
|
|
|
bibles.sort(key=get_locale_key)
|
2010-12-27 15:31:53 +00:00
|
|
|
self.webTranslationComboBox.addItems(bibles)
|
2009-12-16 02:22:16 +00:00
|
|
|
|
2010-12-27 15:31:53 +00:00
|
|
|
def onOsisBrowseButtonClicked(self):
|
2010-03-21 22:16:43 +00:00
|
|
|
"""
|
|
|
|
Show the file open dialog for the OSIS file.
|
|
|
|
"""
|
2013-03-07 08:05:43 +00:00
|
|
|
self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit, u'last directory import')
|
2011-04-14 20:33:02 +00:00
|
|
|
|
2011-01-27 16:45:23 +00:00
|
|
|
def onCsvBooksBrowseButtonClicked(self):
|
2010-03-21 22:16:43 +00:00
|
|
|
"""
|
|
|
|
Show the file open dialog for the books CSV file.
|
|
|
|
"""
|
2013-03-07 08:05:43 +00:00
|
|
|
self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvBooksEdit, u'last directory import',
|
2013-01-18 20:35:30 +00:00
|
|
|
u'%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
|
2009-12-16 20:52:44 +00:00
|
|
|
|
2010-12-27 15:31:53 +00:00
|
|
|
def onCsvVersesBrowseButtonClicked(self):
|
2010-03-21 22:16:43 +00:00
|
|
|
"""
|
|
|
|
Show the file open dialog for the verses CSV file.
|
|
|
|
"""
|
2013-03-07 08:05:43 +00:00
|
|
|
self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvVersesEdit, u'last directory import',
|
2013-01-18 20:35:30 +00:00
|
|
|
u'%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File'))
|
2009-12-16 20:52:44 +00:00
|
|
|
|
|
|
|
def onOpenSongBrowseButtonClicked(self):
|
2010-03-21 22:16:43 +00:00
|
|
|
"""
|
|
|
|
Show the file open dialog for the OpenSong file.
|
|
|
|
"""
|
2013-03-07 08:05:43 +00:00
|
|
|
self.get_file_name(WizardStrings.OpenTypeFile % WizardStrings.OS, self.openSongFileEdit, u'last directory import')
|
2009-12-16 20:52:44 +00:00
|
|
|
|
2013-03-07 11:42:56 +00:00
|
|
|
def register_fields(self):
|
2011-01-13 17:55:29 +00:00
|
|
|
"""
|
|
|
|
Register the bible import wizard fields.
|
|
|
|
"""
|
2010-12-09 16:53:48 +00:00
|
|
|
self.selectPage.registerField(u'source_format', self.formatComboBox)
|
2010-12-24 00:44:41 +00:00
|
|
|
self.selectPage.registerField(u'osis_location', self.osisFileEdit)
|
|
|
|
self.selectPage.registerField(u'csv_booksfile', self.csvBooksEdit)
|
|
|
|
self.selectPage.registerField(u'csv_versefile', self.csvVersesEdit)
|
2010-12-09 16:53:48 +00:00
|
|
|
self.selectPage.registerField(u'opensong_file', self.openSongFileEdit)
|
2010-12-24 00:44:41 +00:00
|
|
|
self.selectPage.registerField(u'web_location', self.webSourceComboBox)
|
2013-01-01 16:33:41 +00:00
|
|
|
self.selectPage.registerField(u'web_biblename', self.webTranslationComboBox)
|
2010-12-24 00:44:41 +00:00
|
|
|
self.selectPage.registerField(u'proxy_server', self.webServerEdit)
|
|
|
|
self.selectPage.registerField(u'proxy_username', self.webUserEdit)
|
|
|
|
self.selectPage.registerField(u'proxy_password', self.webPasswordEdit)
|
2013-01-01 16:33:41 +00:00
|
|
|
self.licenseDetailsPage.registerField(u'license_version', self.versionNameEdit)
|
|
|
|
self.licenseDetailsPage.registerField(u'license_copyright', self.copyrightEdit)
|
|
|
|
self.licenseDetailsPage.registerField(u'license_permissions', self.permissionsEdit)
|
2009-12-16 02:22:16 +00:00
|
|
|
|
|
|
|
def setDefaults(self):
|
2011-01-13 17:55:29 +00:00
|
|
|
"""
|
|
|
|
Set default values for the wizard pages.
|
|
|
|
"""
|
2012-05-17 15:13:09 +00:00
|
|
|
settings = Settings()
|
2013-03-19 19:43:22 +00:00
|
|
|
settings.beginGroup(self.plugin.settings_section)
|
2010-09-21 18:12:46 +00:00
|
|
|
self.restart()
|
2013-03-07 08:05:43 +00:00
|
|
|
self.finish_button.setVisible(False)
|
|
|
|
self.cancel_button.setVisible(True)
|
2012-05-17 15:13:09 +00:00
|
|
|
self.setField(u'source_format', 0)
|
|
|
|
self.setField(u'osis_location', '')
|
|
|
|
self.setField(u'csv_booksfile', '')
|
|
|
|
self.setField(u'csv_versefile', '')
|
|
|
|
self.setField(u'opensong_file', '')
|
|
|
|
self.setField(u'web_location', WebDownload.Crosswalk)
|
2013-01-01 16:33:41 +00:00
|
|
|
self.setField(u'web_biblename', self.webTranslationComboBox.currentIndex())
|
2013-01-10 23:07:48 +00:00
|
|
|
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'))
|
2012-05-17 15:13:09 +00:00
|
|
|
self.setField(u'license_version', self.versionNameEdit.text())
|
|
|
|
self.setField(u'license_copyright', self.copyrightEdit.text())
|
|
|
|
self.setField(u'license_permissions', self.permissionsEdit.text())
|
2011-01-13 17:55:29 +00:00
|
|
|
self.onWebSourceComboBoxIndexChanged(WebDownload.Crosswalk)
|
2010-04-28 14:17:42 +00:00
|
|
|
settings.endGroup()
|
2009-12-16 02:22:16 +00:00
|
|
|
|
|
|
|
def loadWebBibles(self):
|
2009-12-16 20:52:44 +00:00
|
|
|
"""
|
2011-01-13 17:55:29 +00:00
|
|
|
Load the lists of Crosswalk, BibleGateway and Bibleserver bibles.
|
2009-12-16 20:52:44 +00:00
|
|
|
"""
|
2011-01-13 17:55:29 +00:00
|
|
|
# Load Crosswalk Bibles.
|
2011-03-12 10:23:42 +00:00
|
|
|
self.loadBibleResource(WebDownload.Crosswalk)
|
2010-12-17 22:10:29 +00:00
|
|
|
# Load BibleGateway Bibles.
|
2011-03-12 10:23:42 +00:00
|
|
|
self.loadBibleResource(WebDownload.BibleGateway)
|
2010-12-17 22:10:29 +00:00
|
|
|
# Load and Bibleserver Bibles.
|
2011-03-12 10:23:42 +00:00
|
|
|
self.loadBibleResource(WebDownload.Bibleserver)
|
2011-01-13 17:55:29 +00:00
|
|
|
|
2011-03-12 10:23:42 +00:00
|
|
|
def loadBibleResource(self, download_type):
|
2011-01-13 17:55:29 +00:00
|
|
|
"""
|
2011-03-12 10:23:42 +00:00
|
|
|
Loads a web bible from bible_resources.sqlite.
|
2011-01-13 17:55:29 +00:00
|
|
|
|
|
|
|
``download_type``
|
2011-03-12 10:23:42 +00:00
|
|
|
The WebDownload type e.g. bibleserver.
|
2011-01-13 17:55:29 +00:00
|
|
|
"""
|
|
|
|
self.web_bible_list[download_type] = {}
|
2013-01-01 16:33:41 +00:00
|
|
|
bibles = BiblesResourcesDB.get_webbibles(WebDownload.Names[download_type])
|
2011-03-12 10:23:42 +00:00
|
|
|
for bible in bibles:
|
2011-05-03 20:34:39 +00:00
|
|
|
version = bible[u'name']
|
2011-03-12 10:23:42 +00:00
|
|
|
name = bible[u'abbreviation']
|
2011-05-03 20:34:39 +00:00
|
|
|
self.web_bible_list[download_type][version] = name.strip()
|
2010-12-11 23:54:07 +00:00
|
|
|
|
2011-01-13 17:55:29 +00:00
|
|
|
def preWizard(self):
|
2010-12-06 19:30:04 +00:00
|
|
|
"""
|
|
|
|
Prepare the UI for the import.
|
|
|
|
"""
|
2013-03-07 08:05:43 +00:00
|
|
|
OpenLPWizard.pre_wizard(self)
|
2012-05-19 09:13:32 +00:00
|
|
|
bible_type = self.field(u'source_format')
|
2010-11-09 16:56:16 +00:00
|
|
|
if bible_type == BibleFormat.WebDownload:
|
2013-03-07 08:05:43 +00:00
|
|
|
self.progress_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Registering Bible...'))
|
2010-11-09 16:56:16 +00:00
|
|
|
else:
|
2013-03-07 08:05:43 +00:00
|
|
|
self.progress_label.setText(WizardStrings.StartingImport)
|
2013-02-03 19:23:12 +00:00
|
|
|
self.application.process_events()
|
2009-12-18 22:31:28 +00:00
|
|
|
|
2011-01-13 17:55:29 +00:00
|
|
|
def performWizard(self):
|
2010-12-06 19:30:04 +00:00
|
|
|
"""
|
|
|
|
Perform the actual import.
|
|
|
|
"""
|
2012-05-19 09:13:32 +00:00
|
|
|
bible_type = self.field(u'source_format')
|
2012-05-19 15:10:05 +00:00
|
|
|
license_version = self.field(u'license_version')
|
|
|
|
license_copyright = self.field(u'license_copyright')
|
|
|
|
license_permissions = self.field(u'license_permissions')
|
2010-03-19 22:08:06 +00:00
|
|
|
importer = None
|
2009-12-18 22:31:28 +00:00
|
|
|
if bible_type == BibleFormat.OSIS:
|
2010-11-12 21:34:06 +00:00
|
|
|
# Import an OSIS bible.
|
2010-03-19 22:08:06 +00:00
|
|
|
importer = self.manager.import_bible(BibleFormat.OSIS,
|
2010-03-21 22:16:43 +00:00
|
|
|
name=license_version,
|
2012-05-19 15:10:05 +00:00
|
|
|
filename=self.field(u'osis_location')
|
2009-12-18 22:31:28 +00:00
|
|
|
)
|
|
|
|
elif bible_type == BibleFormat.CSV:
|
2010-11-12 21:34:06 +00:00
|
|
|
# Import a CSV bible.
|
2011-04-01 17:54:12 +00:00
|
|
|
importer = self.manager.import_bible(BibleFormat.CSV,
|
2011-10-03 12:32:45 +00:00
|
|
|
name=license_version,
|
2012-05-19 15:10:05 +00:00
|
|
|
booksfile=self.field(u'csv_booksfile'),
|
|
|
|
versefile=self.field(u'csv_versefile')
|
2009-12-18 22:31:28 +00:00
|
|
|
)
|
|
|
|
elif bible_type == BibleFormat.OpenSong:
|
2010-11-12 21:34:06 +00:00
|
|
|
# Import an OpenSong bible.
|
2010-03-19 22:08:06 +00:00
|
|
|
importer = self.manager.import_bible(BibleFormat.OpenSong,
|
2010-03-21 22:16:43 +00:00
|
|
|
name=license_version,
|
2012-05-19 15:10:05 +00:00
|
|
|
filename=self.field(u'opensong_file')
|
2009-12-18 22:31:28 +00:00
|
|
|
)
|
|
|
|
elif bible_type == BibleFormat.WebDownload:
|
2010-11-12 21:34:06 +00:00
|
|
|
# Import a bible from the web.
|
2013-03-07 08:05:43 +00:00
|
|
|
self.progress_bar.setMaximum(1)
|
2012-05-19 09:13:32 +00:00
|
|
|
download_location = self.field(u'web_location')
|
2012-05-17 18:57:01 +00:00
|
|
|
bible_version = self.webTranslationComboBox.currentText()
|
2011-02-18 03:15:09 +00:00
|
|
|
bible = self.web_bible_list[download_location][bible_version]
|
2010-03-21 22:16:43 +00:00
|
|
|
importer = self.manager.import_bible(
|
2011-01-27 16:45:23 +00:00
|
|
|
BibleFormat.WebDownload, name=license_version,
|
2011-02-18 03:15:09 +00:00
|
|
|
download_source=WebDownload.Names[download_location],
|
2010-03-21 20:33:57 +00:00
|
|
|
download_name=bible,
|
2012-05-19 15:10:05 +00:00
|
|
|
proxy_server=self.field(u'proxy_server'),
|
|
|
|
proxy_username=self.field(u'proxy_username'),
|
|
|
|
proxy_password=self.field(u'proxy_password')
|
2009-12-18 22:31:28 +00:00
|
|
|
)
|
2011-05-26 19:13:11 +00:00
|
|
|
if importer.do_import(license_version):
|
2010-03-21 22:16:43 +00:00
|
|
|
self.manager.save_meta_data(license_version, license_version,
|
2010-10-06 14:57:38 +00:00
|
|
|
license_copyright, license_permissions)
|
2010-02-04 17:38:21 +00:00
|
|
|
self.manager.reload_bibles()
|
2010-11-09 16:56:16 +00:00
|
|
|
if bible_type == BibleFormat.WebDownload:
|
2013-03-07 08:05:43 +00:00
|
|
|
self.progress_label.setText(
|
2013-01-01 16:33:41 +00:00
|
|
|
translate('BiblesPlugin.ImportWizardForm', 'Registered Bible. Please note, that verses will be '
|
|
|
|
'downloaded on\ndemand and thus an internet connection is required.'))
|
2010-11-09 16:56:16 +00:00
|
|
|
else:
|
2013-03-07 08:05:43 +00:00
|
|
|
self.progress_label.setText(WizardStrings.FinishedImport)
|
2009-12-18 22:31:28 +00:00
|
|
|
else:
|
2013-03-07 08:05:43 +00:00
|
|
|
self.progress_label.setText(translate('BiblesPlugin.ImportWizardForm', 'Your Bible import failed.'))
|
2011-02-25 06:24:35 +00:00
|
|
|
del self.manager.db_cache[importer.name]
|
2013-03-19 19:43:22 +00:00
|
|
|
delete_database(self.plugin.settings_section, importer.file)
|