forked from openlp/openlp
idea to improve song import feedback
This commit is contained in:
parent
237cabfeff
commit
a13cf49940
@ -132,6 +132,7 @@ class OpenLPWizard(QtGui.QWizard):
|
||||
self.progressLayout.addWidget(self.progressLabel)
|
||||
self.progressBar = QtGui.QProgressBar(self.progressPage)
|
||||
self.progressBar.setObjectName(u'progressBar')
|
||||
self.progressLabel.setWordWrap(True)
|
||||
self.progressLayout.addWidget(self.progressBar)
|
||||
self.addPage(self.progressPage)
|
||||
|
||||
|
@ -740,12 +740,15 @@ class SongImportForm(OpenLPWizard):
|
||||
importer = self.plugin.importSongs(SongFormat.FoilPresenter,
|
||||
filenames=self.getListOfFiles(self.foilPresenterFileListWidget)
|
||||
)
|
||||
if importer.do_import():
|
||||
self.progressLabel.setText(WizardStrings.FinishedImport)
|
||||
else:
|
||||
self.progressLabel.setText(
|
||||
message = importer.do_import()
|
||||
if isinstance(message, bool) and not message:
|
||||
self.progressLabel.setText(self.progressLabel.setText(
|
||||
translate('SongsPlugin.SongImportForm',
|
||||
'Your song import failed.'))
|
||||
'Your song import failed.')))
|
||||
elif not isinstance(message, bool) and message:
|
||||
self.progressLabel.setText(message)
|
||||
else:
|
||||
self.progressLabel.setText(WizardStrings.FinishedImport)
|
||||
|
||||
def addFileSelectItem(self, prefix, obj_prefix=None, can_disable=False,
|
||||
single_select=False):
|
||||
|
@ -93,7 +93,6 @@ class CCLIFileImport(SongImport):
|
||||
song_count += 1
|
||||
if self.stop_import_flag:
|
||||
return False
|
||||
return True
|
||||
|
||||
def do_import_usr_file(self, textList):
|
||||
"""
|
||||
|
@ -75,7 +75,6 @@ class EasiSlidesImport(SongImport):
|
||||
return False
|
||||
elif self.commit:
|
||||
self.finish()
|
||||
return True
|
||||
|
||||
def _parse_song(self, song):
|
||||
self._success = True
|
||||
|
@ -273,7 +273,8 @@ class EasyWorshipSongImport(SongImport):
|
||||
self.import_wizard.incrementProgressBar(u'')
|
||||
db_file.close()
|
||||
self.memo_file.close()
|
||||
return success
|
||||
if not success:
|
||||
return False
|
||||
|
||||
def find_field(self, field_name):
|
||||
return [i for i, x in enumerate(self.field_descs) \
|
||||
|
@ -131,7 +131,6 @@ class FoilPresenterImport(SongImport):
|
||||
log.debug(u'File could not be imported: %s' % file_path)
|
||||
except etree.XMLSyntaxError:
|
||||
log.exception(u'XML syntax error in file %s' % file_path)
|
||||
return True
|
||||
|
||||
|
||||
class FoilPresenter(object):
|
||||
@ -235,7 +234,6 @@ class FoilPresenter(object):
|
||||
self._process_topics(foilpresenterfolie, song)
|
||||
clean_song(self.manager, song)
|
||||
self.manager.save_object(song)
|
||||
return song.id
|
||||
|
||||
def _child(self, element):
|
||||
"""
|
||||
|
@ -32,6 +32,7 @@ import logging
|
||||
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
|
||||
@ -62,7 +63,9 @@ class OpenLP1SongImport(SongImport):
|
||||
Run the import for an openlp.org 1.x song database.
|
||||
"""
|
||||
if not self.import_source.endswith(u'.olp'):
|
||||
return False
|
||||
return translate('SongsPlugin.OpenLP1SongImport', 'The file you '
|
||||
'were trying to import is not a valid openlp.org 1.x song '
|
||||
'database.')
|
||||
encoding = self.get_encoding()
|
||||
if not encoding:
|
||||
return False
|
||||
|
@ -100,6 +100,9 @@ class OpenLPSongImport(SongImport):
|
||||
"""
|
||||
Run the import for an OpenLP version 2 song database.
|
||||
"""
|
||||
if not self.import_source.endswith(u'.sqlite'):
|
||||
return translate('SongsPlugin.OpenLPSongImport', 'The file you were'
|
||||
' trying to import is not a valid OpenLP 2.0 song database.')
|
||||
engine = create_engine(self.import_source)
|
||||
source_meta = MetaData()
|
||||
source_meta.reflect(engine)
|
||||
@ -217,4 +220,3 @@ class OpenLPSongImport(SongImport):
|
||||
if self.stop_import_flag:
|
||||
return False
|
||||
engine.dispose()
|
||||
return True
|
||||
|
@ -56,13 +56,11 @@ class OooImport(SongImport):
|
||||
self.process_started = False
|
||||
|
||||
def do_import(self):
|
||||
self.stop_import_flag = False
|
||||
self.import_wizard.progressBar.setMaximum(0)
|
||||
self.start_ooo()
|
||||
self.import_wizard.progressBar.setMaximum(self.import_source)
|
||||
for filename in self.import_source:
|
||||
if self.stop_import_flag:
|
||||
self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
|
||||
return
|
||||
return False
|
||||
filename = unicode(filename)
|
||||
if os.path.isfile(filename):
|
||||
self.open_ooo_file(filename)
|
||||
@ -70,9 +68,6 @@ class OooImport(SongImport):
|
||||
self.process_ooo_document()
|
||||
self.close_ooo_file()
|
||||
self.close_ooo()
|
||||
self.import_wizard.progressBar.setMaximum(1)
|
||||
self.import_wizard.incrementProgressBar(u'', 1)
|
||||
return True
|
||||
|
||||
def process_ooo_document(self):
|
||||
"""
|
||||
|
@ -71,4 +71,3 @@ class OpenLyricsImport(SongImport):
|
||||
log.debug(u'File could not be imported: %s' % file_path)
|
||||
except etree.XMLSyntaxError:
|
||||
log.exception(u'XML syntax error in file %s' % file_path)
|
||||
return True
|
||||
|
@ -163,7 +163,8 @@ class OpenSongImport(SongImport):
|
||||
else:
|
||||
success = False
|
||||
break
|
||||
return success
|
||||
if not success:
|
||||
return False
|
||||
|
||||
def do_import_file(self, file):
|
||||
"""
|
||||
|
@ -89,7 +89,7 @@ class SofImport(OooImport):
|
||||
while paragraphs.hasMoreElements():
|
||||
if self.stop_import_flag:
|
||||
self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
|
||||
return
|
||||
return False
|
||||
paragraph = paragraphs.nextElement()
|
||||
if paragraph.supportsService("com.sun.star.text.Paragraph"):
|
||||
self.process_paragraph(paragraph)
|
||||
|
@ -131,7 +131,6 @@ class SongBeamerImport(SongImport):
|
||||
self.finish()
|
||||
self.import_wizard.incrementProgressBar(
|
||||
WizardStrings.ImportingType % file_name)
|
||||
return True
|
||||
|
||||
def replace_html_tags(self):
|
||||
"""
|
||||
|
@ -107,7 +107,7 @@ class SongShowPlusImport(SongImport):
|
||||
self.import_wizard.incrementProgressBar(
|
||||
WizardStrings.ImportingType % file_name, 0)
|
||||
songData = open(file, 'rb')
|
||||
while (1):
|
||||
while True:
|
||||
blockKey, = struct.unpack("I", songData.read(4))
|
||||
# The file ends with 4 NUL's
|
||||
if blockKey == 0:
|
||||
@ -173,7 +173,6 @@ class SongShowPlusImport(SongImport):
|
||||
self.finish()
|
||||
self.import_wizard.incrementProgressBar(
|
||||
WizardStrings.ImportingType % file_name)
|
||||
return True
|
||||
|
||||
def toOpenLPVerseTag(self, verseName, ignoreUnique=False):
|
||||
if verseName.find(" ") != -1:
|
||||
|
@ -156,4 +156,3 @@ class WowImport(SongImport):
|
||||
self.finish()
|
||||
self.import_wizard.incrementProgressBar(
|
||||
WizardStrings.ImportingType % file_name)
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user