From 6baefdadced3cc201e38cfeb6f6007e69080b5b2 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 18 Apr 2011 20:57:58 +0200 Subject: [PATCH] more fixes --- openlp/plugins/songs/forms/songimportform.py | 5 +---- openlp/plugins/songs/lib/olp1import.py | 18 +++--------------- openlp/plugins/songs/lib/olpimport.py | 1 + openlp/plugins/songs/lib/oooimport.py | 2 +- 4 files changed, 6 insertions(+), 20 deletions(-) diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 73fa7c79d..3d3421d8b 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -741,10 +741,7 @@ class SongImportForm(OpenLPWizard): filenames=self.getListOfFiles(self.foilPresenterFileListWidget) ) importer.do_import() - if importer.stop_import_flag: - self.progressLabel.setText(translate('SongsPlugin.SongImportForm', - 'Song import has been cancelled.')) - elif importer.error_log: + if importer.error_log: error_path = importer.write_error_report() self.progressLabel.setTextInteractionFlags( QtCore.Qt.TextSelectableByMouse) diff --git a/openlp/plugins/songs/lib/olp1import.py b/openlp/plugins/songs/lib/olp1import.py index b282a8dd7..7ba933a8f 100644 --- a/openlp/plugins/songs/lib/olp1import.py +++ b/openlp/plugins/songs/lib/olp1import.py @@ -33,7 +33,6 @@ from chardet.universaldetector import UniversalDetector import sqlite from openlp.core.lib import translate -from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import retrieve_windows_encoding from songimport import SongImport @@ -69,9 +68,6 @@ class OpenLP1SongImport(SongImport): return encoding = self.get_encoding() if not encoding: - self.log_error(self.import_source, - translate('SongsPlugin.OpenLP1SongImport', - 'Not a valid openlp.org 1.x song database.')) return # Connect to the database connection = sqlite.connect(self.import_source, mode=0444, @@ -81,11 +77,6 @@ class OpenLP1SongImport(SongImport): cursor.execute(u'SELECT name FROM sqlite_master ' u'WHERE type = \'table\' AND name = \'tracks\'') new_db = len(cursor.fetchall()) > 0 - # Count the number of records we need to import, for the progress bar - cursor.execute(u'-- types int') - cursor.execute(u'SELECT COUNT(songid) FROM songs') - count = cursor.fetchone()[0] - self.import_wizard.progressBar.setMaximum(count) # "cache" our list of authors cursor.execute(u'-- types int, unicode') cursor.execute(u'SELECT authorid, authorname FROM authors') @@ -100,20 +91,17 @@ class OpenLP1SongImport(SongImport): cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS lyrics, ' u'copyrightinfo FROM songs') songs = cursor.fetchall() + self.import_wizard.progressBar.setMaximum(len(songs)) for song in songs: self.set_defaults() if self.stop_import_flag: break song_id = song[0] - title = song[1] + self.title = song[1] lyrics = song[2].replace(u'\r\n', u'\n') - copyright = song[3] - self.import_wizard.incrementProgressBar( - WizardStrings.ImportingType % title) - self.title = title + self.add_copyright(song[3]) verses = lyrics.split(u'\n\n') [self.add_verse(verse.strip()) for verse in verses if verse.strip()] - self.add_copyright(copyright) cursor.execute(u'-- types int') cursor.execute(u'SELECT authorid FROM songauthors ' u'WHERE songid = %s' % song_id) diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index bbfabce3e..f17ac188b 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -36,6 +36,7 @@ from sqlalchemy.orm.exc import UnmappedClassError from openlp.core.lib import translate from openlp.core.lib.db import BaseModel +from openlp.core.ui.wizard import WizardStrings from openlp.plugins.songs.lib import clean_song from openlp.plugins.songs.lib.db import Author, Book, Song, Topic #, MediaFile from songimport import SongImport diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 3abc17a7a..d43541bc7 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -57,7 +57,7 @@ class OooImport(SongImport): def do_import(self): self.start_ooo() - self.import_wizard.progressBar.setMaximum(self.import_source) + self.import_wizard.progressBar.setMaximum(len(self.import_source)) for filename in self.import_source: if self.stop_import_flag: break