openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #03282
[Merge] lp:~j-corwin/openlp/sof-wizard into lp:openlp
Jonathan Corwin has proposed merging lp:~j-corwin/openlp/sof-wizard into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
Hook generic and SoF imports to the wizard
--
https://code.launchpad.net/~j-corwin/openlp/sof-wizard/+merge/34636
Your team OpenLP Core is requested to review the proposed merge of lp:~j-corwin/openlp/sof-wizard into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/oooimport.py'
--- openlp/plugins/songs/lib/oooimport.py 2010-07-27 09:32:52 +0000
+++ openlp/plugins/songs/lib/oooimport.py 2010-09-05 15:26:38 +0000
@@ -28,6 +28,7 @@
from PyQt4 import QtCore
+from openlp.core.lib import Receiver
from songimport import SongImport
if os.name == u'nt':
@@ -43,23 +44,32 @@
except ImportError:
pass
-class OooImport(object):
+class OooImport(SongImport):
"""
Import songs from Impress/Powerpoint docs using Impress
"""
- def __init__(self, songmanager):
+ def __init__(self, master_manager, **kwargs):
"""
Initialise the class. Requires a songmanager class which is passed
to SongImport for writing song to disk
"""
+ SongImport.__init__(self, master_manager)
self.song = None
- self.manager = songmanager
+ self.master_manager = master_manager
self.document = None
self.process_started = False
+ self.filenames = kwargs[u'filenames']
+ QtCore.QObject.connect(Receiver.get_receiver(),
+ QtCore.SIGNAL(u'song_stop_import'), self.stop_import)
- def import_docs(self, filenames):
+ def do_import(self):
+ self.abort = False
+ self.import_wizard.importProgressBar.setMaximum(0)
self.start_ooo()
- for filename in filenames:
+ for filename in self.filenames:
+ if self.abort:
+ self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
+ return
filename = unicode(filename)
if os.path.isfile(filename):
self.open_ooo_file(filename)
@@ -72,6 +82,12 @@
self.process_doc()
self.close_ooo_file()
self.close_ooo()
+ self.import_wizard.importProgressBar.setMaximum(1)
+ self.import_wizard.incrementProgressBar(u'', 1)
+ return True
+
+ def stop_import(self):
+ self.abort = True
def start_ooo(self):
"""
@@ -135,6 +151,9 @@
"com.sun.star.presentation.PresentationDocument") and not \
self.document.supportsService("com.sun.star.text.TextDocument"):
self.close_ooo_file()
+ else:
+ self.import_wizard.incrementProgressBar(
+ u'Processing file ' + filepath, 0)
except:
pass
return
@@ -161,6 +180,9 @@
slides = doc.getDrawPages()
text = u''
for slide_no in range(slides.getCount()):
+ if self.abort:
+ self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
+ return
slide = slides.getByIndex(slide_no)
slidetext = u''
for idx in range(slide.getCount()):
=== modified file 'openlp/plugins/songs/lib/sofimport.py'
--- openlp/plugins/songs/lib/sofimport.py 2010-07-27 09:32:52 +0000
+++ openlp/plugins/songs/lib/sofimport.py 2010-09-05 15:26:38 +0000
@@ -68,19 +68,30 @@
It attempts to detect italiced verses, and treats these as choruses in
the verse ordering. Again not perfect, but a start.
"""
- def __init__(self, songmanager):
+ def __init__(self, master_manager, **kwargs):
"""
Initialise the class. Requires a songmanager class which is passed
to SongImport for writing song to disk
"""
- OooImport.__init__(self, songmanager)
+ OooImport.__init__(self, master_manager, **kwargs)
- def import_sof(self, filename):
+ def do_import(self):
+ self.abort = False
self.start_ooo()
- self.open_ooo_file(filename)
- self.process_sof_file()
- self.close_ooo_file()
+ for filename in self.filenames:
+ if self.abort:
+ self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
+ return
+ filename = unicode(filename)
+ if os.path.isfile(filename):
+ self.open_ooo_file(filename)
+ if self.document:
+ self.process_sof_file()
+ self.close_ooo_file()
self.close_ooo()
+ self.import_wizard.importProgressBar.setMaximum(1)
+ self.import_wizard.incrementProgressBar(u'', 1)
+ return True
def process_sof_file(self):
"""
@@ -90,6 +101,9 @@
self.new_song()
paragraphs = self.document.getText().createEnumeration()
while paragraphs.hasMoreElements():
+ if self.abort:
+ self.import_wizard.incrementProgressBar(u'Import cancelled', 0)
+ return
paragraph = paragraphs.nextElement()
if paragraph.supportsService("com.sun.star.text.Paragraph"):
self.process_paragraph(paragraph)
@@ -244,6 +258,7 @@
if title.endswith(u','):
title = title[:-1]
self.song.title = title
+ self.import_wizard.incrementProgressBar(u'Processing song ' + title, 0)
def add_author(self, text):
"""
=== modified file 'openlp/plugins/songs/lib/songimport.py'
--- openlp/plugins/songs/lib/songimport.py 2010-09-04 14:26:04 +0000
+++ openlp/plugins/songs/lib/songimport.py 2010-09-05 15:26:38 +0000
@@ -129,13 +129,13 @@
def process_verse_text(self, text):
lines = text.split(u'\n')
- if text.lower().find(COPYRIGHT_STRING) >= 0 \
- or text.lower().find(COPYRIGHT_SYMBOL) >= 0:
+ if text.lower().find(self.copyright_string) >= 0 \
+ or text.lower().find(self.copyright_symbol) >= 0:
copyright_found = False
for line in lines:
if (copyright_found or
- line.lower().find(COPYRIGHT_STRING) >= 0 or
- line.lower().find(COPYRIGHT_SYMBOL) >= 0):
+ line.lower().find(self.copyright_string) >= 0 or
+ line.lower().find(self.copyright_symbol) >= 0):
copyright_found = True
self.add_copyright(line)
else:
Follow ups