- fixed progress bar (bible openlp1 import)

- fixed Bug #688647 (mostly copy&paste)
- fixed "reject" method (the import would not stop, if currentId() == 2/3)
- some songbeamer import tweaks

bzr-revno: 1142
Fixes: https://launchpad.net/bugs/688647
This commit is contained in:
Andreas Preikschat 2010-12-12 09:06:24 +00:00 committed by Tim Bentley
commit 77f4adbef0
7 changed files with 48 additions and 12 deletions

View File

@ -77,6 +77,12 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
QtGui.QWizard.__init__(self, parent)
self.setupUi(self)
self.registerFields()
if not BibleFormat.get_availability(BibleFormat.OpenLP1):
self.openlp1Page.setVisible(False)
self.openlp1LocationLabel.setVisible(False)
self.openlp1LocationEdit.setVisible(False)
self.openlp1FileButton.setVisible(False)
self.openlp1DisabledLabel.setVisible(True)
self.finishButton = self.button(QtGui.QWizard.FinishButton)
self.cancelButton = self.button(QtGui.QWizard.CancelButton)
self.manager = manager
@ -102,9 +108,6 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
QtCore.QObject.connect(self.openlp1FileButton,
QtCore.SIGNAL(u'clicked()'),
self.onOpenlp1FileButtonClicked)
QtCore.QObject.connect(self.cancelButton,
QtCore.SIGNAL(u'clicked(bool)'),
self.onCancelButtonClicked)
QtCore.QObject.connect(self,
QtCore.SIGNAL(u'currentIdChanged(int)'),
self.onCurrentIdChanged)
@ -123,8 +126,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
log.debug('Import canceled by user.')
if self.currentId() == 3:
Receiver.send_message(u'bibles_stop_import')
else:
self.done(QtGui.QDialog.Rejected)
self.done(QtGui.QDialog.Rejected)
def validateCurrentPage(self):
"""

View File

@ -279,6 +279,11 @@ class Ui_BibleImportWizard(object):
self.openlp1LocationLayout.addWidget(self.openlp1FileButton)
self.openlp1Layout.setLayout(1, QtGui.QFormLayout.FieldRole,
self.openlp1LocationLayout)
self.openlp1DisabledLabel = QtGui.QLabel(self.openlp1Page)
self.openlp1DisabledLabel.setObjectName(u'openlp1DisabledLabel')
self.openlp1DisabledLabel.setVisible(False)
self.openlp1DisabledLabel.setWordWrap(True)
self.openlp1Layout.addWidget(self.openlp1DisabledLabel)
self.formatWidget.addWidget(self.openlp1Page)
self.selectPageLayout.addWidget(self.formatWidget)
bibleImportWizard.addPage(self.selectPage)
@ -417,3 +422,8 @@ class Ui_BibleImportWizard(object):
self.importProgressLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Ready.'))
self.importProgressBar.setFormat(u'%p%')
self.openlp1DisabledLabel.setText(
translate('BiblesPlugin.ImportWizardForm', '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.'))

View File

@ -35,9 +35,14 @@ from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
from csvbible import CSVBible
from http import HTTPBible
from openlp1 import OpenLP1Bible
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__)
@ -57,6 +62,7 @@ class BibleFormat(object):
plus a few helper functions to facilitate generic handling of Bible types
for importing.
"""
_format_availability = {}
Unknown = -1
OSIS = 0
CSV = 1
@ -98,6 +104,13 @@ class BibleFormat(object):
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):
"""
@ -339,3 +352,7 @@ class BibleManager(object):
"""
for bible in self.db_cache:
self.db_cache[bible].finalise()
BibleFormat.set_availability(BibleFormat.OpenLP1, has_openlp1)
__all__ = [u'BibleFormat']

View File

@ -62,6 +62,7 @@ class OpenLP1Bible(BibleDB):
# Create all books.
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
books = cursor.fetchall()
self.wizard.importProgressBar.setMaximum(len(books) + 1)
for book in books:
if self.stop_import_flag:
connection.close()

View File

@ -136,8 +136,7 @@ class SongImportForm(QtGui.QWizard, Ui_SongImportWizard):
log.debug('Import canceled by user.')
if self.currentId() == 2:
Receiver.send_message(u'songs_stop_import')
else:
self.done(QtGui.QDialog.Rejected)
self.done(QtGui.QDialog.Rejected)
def validateCurrentPage(self):
"""

View File

@ -350,7 +350,7 @@ class Ui_SongImportWizard(object):
else:
setattr(self, prefix + u'Layout', importLayout)
self.formatComboBox.addItem(u'')
def disablableWidget(self, page, prefix, obj_prefix):
layout = QtGui.QVBoxLayout(page)
layout.setMargin(0)

View File

@ -32,6 +32,7 @@ import os
import chardet
import codecs
from openlp.core.lib import translate
from openlp.plugins.songs.lib.songimport import SongImport
log = logging.getLogger(__name__)
@ -54,7 +55,8 @@ class SongBeamerTypes(object):
u'Pre-Bridge': u'O',
u'Pre-Coda': u'O',
u'Unbekannt': u'O',
u'Unknown': u'O'
u'Unknown': u'O',
u'Unbenannt': u'O'
}
@ -100,6 +102,7 @@ class SongBeamerImport(SongImport):
detect_file.close()
infile = codecs.open(file, u'r', details['encoding'])
self.songData = infile.readlines()
infile.close()
else:
return False
for line in self.songData:
@ -127,8 +130,9 @@ class SongBeamerImport(SongImport):
self.replace_html_tags()
self.add_verse(self.current_verse, self.current_verse_type)
self.finish()
self.import_wizard.incrementProgressBar(
"Importing %s" % (self.file_name))
self.import_wizard.incrementProgressBar(u'%s %s...' %
(translate('SongsPlugin.SongBeamerImport', 'Importing'),
self.file_name))
return True
def replace_html_tags(self):
@ -263,6 +267,9 @@ class SongBeamerImport(SongImport):
pass
elif tag_val[0] == u'#Version':
pass
elif tag_val[0] == u'#VerseOrder':
# TODO: add the verse order.
pass
def check_verse_marks(self, line):
"""