From a5824120c3088c8147bc3f0e8831dcf7716ed67b Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Mon, 15 Oct 2012 17:20:23 +0100 Subject: [PATCH] Lite save works --- openlp/core/lib/serviceitem.py | 20 +++++++++++++++----- openlp/core/ui/servicemanager.py | 8 +++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 2227fb8fb..5c606740e 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -257,7 +257,7 @@ class ServiceItem(object): {u'title': file_name, u'image': image, u'path': path}) self._new_item() - def get_service_repr(self): + def get_service_repr(self, lite_save): """ This method returns some text which can be saved into the service file to represent this item. @@ -288,7 +288,12 @@ class ServiceItem(object): if self.service_item_type == ServiceItemType.Text: service_data = [slide for slide in self._raw_frames] elif self.service_item_type == ServiceItemType.Image: - service_data = [slide[u'title'] for slide in self._raw_frames] + if lite_save: + for slide in self._raw_frames: + service_data.append( + {u'title': slide[u'title'], u'path': slide[u'path']}) + else: + service_data = [slide[u'title'] for slide in self._raw_frames] elif self.service_item_type == ServiceItemType.Command: for slide in self._raw_frames: service_data.append( @@ -338,9 +343,14 @@ class ServiceItem(object): for slide in serviceitem[u'serviceitem'][u'data']: self._raw_frames.append(slide) elif self.service_item_type == ServiceItemType.Image: - for text_image in serviceitem[u'serviceitem'][u'data']: - filename = os.path.join(path, text_image) - self.add_from_image(filename, text_image) + if path: + for text_image in serviceitem[u'serviceitem'][u'data']: + filename = os.path.join(path, text_image) + self.add_from_image(filename, text_image) + else: + for text_image in serviceitem[u'serviceitem'][u'data']: + self.add_from_image(text_image[u'path'], + text_image[u'title']) elif self.service_item_type == ServiceItemType.Command: for text_image in serviceitem[u'serviceitem'][u'data']: if path: diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index d1a274a14..0f06317f6 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -502,7 +502,8 @@ class ServiceManager(QtGui.QWidget): self.mainwindow.displayProgressBar(len(self.serviceItems) + 1) for item in self.serviceItems: self.mainwindow.incrementProgressBar() - service_item = item[u'service_item'].get_service_repr() + service_item = item[u'service_item']. \ + get_service_repr(self._saveLite) # Get all the audio files, and ready them for embedding in the # service file. if service_item[u'header'][u'background_audio']: @@ -634,7 +635,8 @@ class ServiceManager(QtGui.QWidget): self.mainwindow.displayProgressBar(len(self.serviceItems) + 1) for item in self.serviceItems: self.mainwindow.incrementProgressBar() - service_item = item[u'service_item'].get_service_repr() + service_item = item[u'service_item']. \ + get_service_repr(self._saveLite) service.append({u'serviceitem': service_item}) service_content = cPickle.dumps(service) # Usual Zip file cannot exceed 2GiB, file with Zip64 cannot be @@ -713,7 +715,7 @@ class ServiceManager(QtGui.QWidget): UiStrings().SaveService, path, translate('OpenLP.ServiceManager', 'OpenLP Service Files (*.osz);;' - 'OpenLP Service Files - light (*.oszl)'))) + 'OpenLP Service Files - lite (*.oszl)'))) if not fileName: return False if os.path.splitext(fileName)[1] == u'':