changed behaviour if the user cancel the import so that after a traceback it is possible to cancel the dialog

This commit is contained in:
Armin Köhler 2011-06-05 14:40:26 +02:00
parent 52bab3e415
commit 346bf24267
1 changed files with 15 additions and 11 deletions

View File

@ -116,6 +116,8 @@ class BibleUpgradeForm(OpenLPWizard):
self.stop_import_flag = True
if not self.currentPage() == self.progressPage:
self.done(QtGui.QDialog.Rejected)
else:
self.postWizard()
def onCurrentIdChanged(self, pageId):
"""
@ -132,9 +134,7 @@ class BibleUpgradeForm(OpenLPWizard):
"""
Some cleanup while finishing
"""
for number, filename in enumerate(self.files):
if number in self.success and self.success[number] == True:
delete_file(os.path.join(self.path, filename[0]))
self.mediaItem.reloadBibles()
def onBackupBrowseButtonClicked(self):
"""
@ -537,7 +537,7 @@ class BibleUpgradeForm(OpenLPWizard):
"""
Perform the actual upgrade.
"""
include_webbible = False
self.include_webbible = False
proxy_server = None
if self.maxBibles == 0:
self.progressLabel.setText(
@ -591,7 +591,7 @@ class BibleUpgradeForm(OpenLPWizard):
meta[u'value'])
if meta[u'key'] == u'download source':
webbible = True
include_webbible = True
self.include_webbible = True
if meta.has_key(u'proxy server'):
proxy_server = meta[u'proxy server']
if webbible:
@ -607,8 +607,7 @@ class BibleUpgradeForm(OpenLPWizard):
u'name: "%s" failed' % (
meta_data[u'download source'],
meta_data[u'download name']))
delete_database(self.path,
clean_filename(name))
delete_database(self.path, clean_filename(name))
del self.newbibles[number]
critical_error_message_box(
translate('BiblesPlugin.UpgradeWizardForm',
@ -635,8 +634,7 @@ class BibleUpgradeForm(OpenLPWizard):
language_id = self.newbibles[number].get_language(name)
if not language_id:
log.warn(u'Upgrading from "%s" failed' % filename[0])
delete_database(self.path,
clean_filename(name))
delete_database(self.path, clean_filename(name))
del self.newbibles[number]
self.incrementProgressBar(unicode(translate(
'BiblesPlugin.UpgradeWizardForm',
@ -743,6 +741,7 @@ class BibleUpgradeForm(OpenLPWizard):
self.newbibles[number].session.commit()
if not bible_failed:
self.newbibles[number].create_meta(u'Version', name)
delete_file(os.path.join(self.path, filename[0]))
self.incrementProgressBar(unicode(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\n'
@ -757,7 +756,11 @@ class BibleUpgradeForm(OpenLPWizard):
self.progressBar.maximum() - self.progressBar.value())
delete_database(self.path, clean_filename(name))
number += 1
self.mediaItem.reloadBibles()
def postWizard(self):
"""
Clean up the UI after the import has finished.
"""
successful_import = 0
failed_import = 0
for number, filename in enumerate(self.files):
@ -772,7 +775,7 @@ class BibleUpgradeForm(OpenLPWizard):
else:
failed_import_text = u''
if successful_import > 0:
if include_webbible:
if self.include_webbible:
self.progressLabel.setText(unicode(
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading '
'Bible(s): %s successful%s\nPlease note, that verses from '
@ -788,3 +791,4 @@ class BibleUpgradeForm(OpenLPWizard):
self.progressLabel.setText(
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade '
'failed.'))
OpenLPWizard.postWizard(self)