forked from openlp/openlp
Saving OOS changes and other cleanups
This commit is contained in:
parent
4c2b9fe426
commit
94a3513bb1
@ -96,7 +96,6 @@ class ServiceItem(object):
|
||||
self.frames.append({u'title': slide[u'title'], u'image': frame})
|
||||
elif self.service_item_type == ServiceType.Command:
|
||||
self.frames = self.service_frames
|
||||
self.service_frames = []
|
||||
elif self.service_item_type == ServiceType.Image:
|
||||
for slide in self.service_frames:
|
||||
slide[u'image'] = self.RenderManager.resize_image(slide[u'image'])
|
||||
@ -135,7 +134,7 @@ class ServiceItem(object):
|
||||
frame_title = frame_title.split(u'\n')[0]
|
||||
self.service_frames.append({u'title': frame_title, u'raw_slide': raw_slide})
|
||||
|
||||
def add_from_command(self, path , frame_title, command):
|
||||
def add_from_command(self, path , frame_title):
|
||||
"""
|
||||
Add a slide from a command.
|
||||
|
||||
@ -147,7 +146,7 @@ class ServiceItem(object):
|
||||
"""
|
||||
self.service_item_type = ServiceType.Command
|
||||
self.service_item_path = path
|
||||
self.service_frames.append({u'title': frame_title, u'command': command})
|
||||
self.service_frames.append({u'title': frame_title, u'command': None})
|
||||
|
||||
def get_oos_repr(self):
|
||||
"""
|
||||
@ -169,6 +168,9 @@ class ServiceItem(object):
|
||||
elif self.service_item_type == ServiceType.Image:
|
||||
for slide in self.service_frames:
|
||||
oos_data.append(slide[u'title'])
|
||||
elif self.service_item_type == ServiceType.Command:
|
||||
for slide in self.service_frames:
|
||||
oos_data.append(slide[u'title'])
|
||||
return {u'header': oos_header, u'data': oos_data}
|
||||
|
||||
def set_from_oos(self, serviceitem, path=None):
|
||||
@ -197,3 +199,7 @@ class ServiceItem(object):
|
||||
filename = os.path.join(path, text_image)
|
||||
real_image = QtGui.QImage(unicode(filename))
|
||||
self.add_from_image(path, text_image, real_image)
|
||||
elif self.service_item_type == ServiceType.Command:
|
||||
for text_image in serviceitem[u'serviceitem'][u'data']:
|
||||
filename = os.path.join(path, text_image)
|
||||
self.add_from_command(path, text_image)
|
||||
|
@ -25,7 +25,7 @@ import shutil
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
from openlp.core.lib import PluginConfig, OpenLPToolbar, ServiceItem, \
|
||||
RenderManager, translate, buildIcon, \
|
||||
RenderManager, translate, buildIcon, ServiceType, \
|
||||
contextMenuAction, contextMenuSeparator, Receiver
|
||||
from openlp.core.utils import ConfigHelper
|
||||
|
||||
@ -341,7 +341,8 @@ class ServiceManager(QtGui.QWidget):
|
||||
zip = zipfile.ZipFile(unicode(filename) + u'.oos', 'w')
|
||||
for item in self.serviceItems:
|
||||
service.append({u'serviceitem':item[u'data'].get_oos_repr()})
|
||||
if item[u'data'].service_item_type == u'image':
|
||||
if item[u'data'].service_item_type == ServiceType.Image or \
|
||||
item[u'data'].service_item_type == ServiceType.Command:
|
||||
for frame in item[u'data'].frames:
|
||||
path_from = unicode(item[u'data'].service_item_path + u'/' + frame[u'title'])
|
||||
zip.write(path_from)
|
||||
@ -354,7 +355,7 @@ class ServiceManager(QtGui.QWidget):
|
||||
os.remove(servicefile)
|
||||
except:
|
||||
pass #if not present do not worry
|
||||
self.parent.OosChanged(True, self.serviceName)
|
||||
self.parent.OosChanged(True, filename + u'.oos')
|
||||
|
||||
def onLoadService(self):
|
||||
"""
|
||||
@ -368,31 +369,34 @@ class ServiceManager(QtGui.QWidget):
|
||||
name = filename.split(os.path.sep)
|
||||
if filename != u'':
|
||||
self.config.set_last_dir(filename)
|
||||
zip = zipfile.ZipFile(unicode(filename))
|
||||
filexml = None
|
||||
themename = None
|
||||
for file in zip.namelist():
|
||||
names = file.split(os.path.sep)
|
||||
file_to = os.path.join(self.servicePath, names[len(names) - 1])
|
||||
file_data = zip.read(file)
|
||||
f = open(file_to, u'w')
|
||||
f.write(file_data)
|
||||
f.close()
|
||||
if file_to.endswith(u'ood'):
|
||||
p_file = file_to
|
||||
f = open(p_file, u'r')
|
||||
items = cPickle.load(f)
|
||||
f.close()
|
||||
self.onNewService()
|
||||
for item in items:
|
||||
serviceitem = ServiceItem()
|
||||
serviceitem.RenderManager = self.parent.RenderManager
|
||||
serviceitem.set_from_oos(item, self.servicePath )
|
||||
self.addServiceItem(serviceitem)
|
||||
try:
|
||||
os.remove(p_file)
|
||||
zip = zipfile.ZipFile(unicode(filename))
|
||||
filexml = None
|
||||
themename = None
|
||||
for file in zip.namelist():
|
||||
names = file.split(os.path.sep)
|
||||
file_to = os.path.join(self.servicePath, names[len(names) - 1])
|
||||
file_data = zip.read(file)
|
||||
f = open(file_to, u'w')
|
||||
f.write(file_data)
|
||||
f.close()
|
||||
if file_to.endswith(u'ood'):
|
||||
p_file = file_to
|
||||
f = open(p_file, u'r')
|
||||
items = cPickle.load(f)
|
||||
f.close()
|
||||
self.onNewService()
|
||||
for item in items:
|
||||
serviceitem = ServiceItem()
|
||||
serviceitem.RenderManager = self.parent.RenderManager
|
||||
serviceitem.set_from_oos(item, self.servicePath )
|
||||
self.addServiceItem(serviceitem)
|
||||
try:
|
||||
os.remove(p_file)
|
||||
except:
|
||||
#if not present do not worry
|
||||
pass
|
||||
except:
|
||||
#if not present do not worry
|
||||
pass
|
||||
self.serviceName = name[len(name) - 1]
|
||||
self.parent.OosChanged(True, self.serviceName)
|
||||
|
@ -341,8 +341,10 @@ class BibleMediaItem(MediaManagerItem):
|
||||
def generateSlideData(self, service_item):
|
||||
log.debug(u'generating slide data')
|
||||
items = self.ListView.selectedIndexes()
|
||||
if len(items) > 1:
|
||||
return
|
||||
old_chapter = u''
|
||||
raw_slides=[]
|
||||
raw_slides = []
|
||||
raw_footer = []
|
||||
bible_text = u''
|
||||
for item in items:
|
||||
@ -445,17 +447,17 @@ class BibleMediaItem(MediaManagerItem):
|
||||
|
||||
def searchByReference(self, bible, search):
|
||||
log.debug(u'searchByReference %s ,%s', bible, search)
|
||||
book = ''
|
||||
start_chapter = ''
|
||||
end_chapter = ''
|
||||
start_verse = ''
|
||||
end_verse = ''
|
||||
book = u''
|
||||
start_chapter = u''
|
||||
end_chapter = u''
|
||||
start_verse = u''
|
||||
end_verse = u''
|
||||
search = search.replace(u' ', u' ').strip()
|
||||
original = search
|
||||
message = None
|
||||
# Remove book beware 0 index arrays
|
||||
for i in range (len(search)-1, 0, - 1):
|
||||
if search[i] == ' ':
|
||||
if search[i] == u' ':
|
||||
book = search[:i]
|
||||
# remove book from string
|
||||
search = search[i:]
|
||||
@ -469,7 +471,7 @@ class BibleMediaItem(MediaManagerItem):
|
||||
# number : found
|
||||
i = search.rfind(u' ')
|
||||
if i == -1:
|
||||
chapter = ''
|
||||
chapter = u''
|
||||
else:
|
||||
chapter = search[i:len(search)]
|
||||
hyphen = chapter.find(u'-')
|
||||
@ -496,29 +498,25 @@ class BibleMediaItem(MediaManagerItem):
|
||||
end_verse = start_verse
|
||||
else:
|
||||
sp1 = sp[1].split(u':')
|
||||
#print "2nd details", sp1, len(sp1)
|
||||
if len(sp1) == 1:
|
||||
end_chapter = start_chapter
|
||||
end_verse = sp1[0]
|
||||
else:
|
||||
end_chapter = sp1[0]
|
||||
end_verse = sp1[1]
|
||||
#print 'search = ' + unicode(original)
|
||||
#print 'results = ' + unicode(book) + ' @ '+ unicode(start_chapter)+' @ '+ unicode(end_chapter)+' @ '+ unicode(start_verse)+ ' @ '+ unicode(end_verse)
|
||||
if end_chapter == '':
|
||||
if end_chapter == u'':
|
||||
end_chapter = start_chapter.rstrip()
|
||||
if start_verse == '':
|
||||
if end_verse == '':
|
||||
if start_verse == u'':
|
||||
if end_verse == u'':
|
||||
start_verse = 1
|
||||
else:
|
||||
start_verse = end_verse
|
||||
if end_verse == '':
|
||||
if end_verse == u'':
|
||||
end_verse = 99
|
||||
if start_chapter == '':
|
||||
if start_chapter == u'':
|
||||
message = u'No chapter found for search criteria'
|
||||
#print 'message = ' + unicode(message)
|
||||
#print 'search = ' + unicode(original)
|
||||
#print 'results = ' + unicode(book) + ' @ '+ unicode(start_chapter)+' @ '+ unicode(end_chapter)+' @ '+ unicode(start_verse)+ ' @ '+ unicode(end_verse)
|
||||
log.debug(u'results = %s @ %s : %s @ %s : %s'% \
|
||||
(unicode(book), unicode(start_chapter), unicode(end_chapter), unicode(start_verse), unicode(end_verse)))
|
||||
if message == None:
|
||||
self.search_results = None
|
||||
self.search_results = self.parent.biblemanager.get_verse_text(bible, book,
|
||||
|
@ -99,11 +99,10 @@ class PresentationMediaItem(MediaManagerItem):
|
||||
|
||||
def generateSlideData(self, service_item):
|
||||
items = self.ListView.selectedIndexes()
|
||||
service_item.title = self.DisplayTypeComboBox.currentText()
|
||||
service_item.title = unicode(self.DisplayTypeComboBox.currentText())
|
||||
service_item.shortname = unicode(self.DisplayTypeComboBox.currentText())
|
||||
for item in items:
|
||||
bitem = self.ListView.item(item.row())
|
||||
filename = unicode((bitem.data(QtCore.Qt.UserRole)).toString())
|
||||
frame = QtGui.QImage(unicode(filename))
|
||||
(path, name) = os.path.split(filename)
|
||||
service_item.add_from_command(path, name, frame)
|
||||
service_item.add_from_command(path, name)
|
||||
|
Loading…
Reference in New Issue
Block a user