- 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) QtGui.QWizard.__init__(self, parent)
self.setupUi(self) self.setupUi(self)
self.registerFields() 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.finishButton = self.button(QtGui.QWizard.FinishButton)
self.cancelButton = self.button(QtGui.QWizard.CancelButton) self.cancelButton = self.button(QtGui.QWizard.CancelButton)
self.manager = manager self.manager = manager
@ -102,9 +108,6 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
QtCore.QObject.connect(self.openlp1FileButton, QtCore.QObject.connect(self.openlp1FileButton,
QtCore.SIGNAL(u'clicked()'), QtCore.SIGNAL(u'clicked()'),
self.onOpenlp1FileButtonClicked) self.onOpenlp1FileButtonClicked)
QtCore.QObject.connect(self.cancelButton,
QtCore.SIGNAL(u'clicked(bool)'),
self.onCancelButtonClicked)
QtCore.QObject.connect(self, QtCore.QObject.connect(self,
QtCore.SIGNAL(u'currentIdChanged(int)'), QtCore.SIGNAL(u'currentIdChanged(int)'),
self.onCurrentIdChanged) self.onCurrentIdChanged)
@ -123,7 +126,6 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard):
log.debug('Import canceled by user.') log.debug('Import canceled by user.')
if self.currentId() == 3: if self.currentId() == 3:
Receiver.send_message(u'bibles_stop_import') Receiver.send_message(u'bibles_stop_import')
else:
self.done(QtGui.QDialog.Rejected) self.done(QtGui.QDialog.Rejected)
def validateCurrentPage(self): def validateCurrentPage(self):

View File

@ -279,6 +279,11 @@ class Ui_BibleImportWizard(object):
self.openlp1LocationLayout.addWidget(self.openlp1FileButton) self.openlp1LocationLayout.addWidget(self.openlp1FileButton)
self.openlp1Layout.setLayout(1, QtGui.QFormLayout.FieldRole, self.openlp1Layout.setLayout(1, QtGui.QFormLayout.FieldRole,
self.openlp1LocationLayout) 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.formatWidget.addWidget(self.openlp1Page)
self.selectPageLayout.addWidget(self.formatWidget) self.selectPageLayout.addWidget(self.formatWidget)
bibleImportWizard.addPage(self.selectPage) bibleImportWizard.addPage(self.selectPage)
@ -417,3 +422,8 @@ class Ui_BibleImportWizard(object):
self.importProgressLabel.setText( self.importProgressLabel.setText(
translate('BiblesPlugin.ImportWizardForm', 'Ready.')) translate('BiblesPlugin.ImportWizardForm', 'Ready.'))
self.importProgressBar.setFormat(u'%p%') 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 csvbible import CSVBible
from http import HTTPBible from http import HTTPBible
from openlp1 import OpenLP1Bible
from opensong import OpenSongBible from opensong import OpenSongBible
from osis import OSISBible 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__) log = logging.getLogger(__name__)
@ -57,6 +62,7 @@ class BibleFormat(object):
plus a few helper functions to facilitate generic handling of Bible types plus a few helper functions to facilitate generic handling of Bible types
for importing. for importing.
""" """
_format_availability = {}
Unknown = -1 Unknown = -1
OSIS = 0 OSIS = 0
CSV = 1 CSV = 1
@ -98,6 +104,13 @@ class BibleFormat(object):
BibleFormat.OpenLP1 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): class BibleManager(object):
""" """
@ -339,3 +352,7 @@ class BibleManager(object):
""" """
for bible in self.db_cache: for bible in self.db_cache:
self.db_cache[bible].finalise() 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. # Create all books.
cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
books = cursor.fetchall() books = cursor.fetchall()
self.wizard.importProgressBar.setMaximum(len(books) + 1)
for book in books: for book in books:
if self.stop_import_flag: if self.stop_import_flag:
connection.close() connection.close()

View File

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

View File

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