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