forked from openlp/openlp
OOS changes
This commit is contained in:
parent
7becc9cb56
commit
594ea63e22
@ -51,6 +51,7 @@ class ServiceItem():
|
||||
self.service_frames = []
|
||||
|
||||
def addIcon(self, icon):
|
||||
self.icon = icon
|
||||
self.iconic_representation = buildIcon(icon)
|
||||
|
||||
def render(self):
|
||||
@ -76,7 +77,7 @@ class ServiceItem():
|
||||
self.frames = self.service_frames
|
||||
self.service_frames = []
|
||||
else:
|
||||
assert(0 , u'Invalid value rendere :%s' % self.service_item_type)
|
||||
log.error(u'Invalid value rendere :%s' % self.service_item_type)
|
||||
|
||||
def add_from_image(self, frame_title, image):
|
||||
self.service_item_type = u'image'
|
||||
@ -91,14 +92,18 @@ class ServiceItem():
|
||||
self.service_item_type = u'command'
|
||||
self.service_frames.append({u'title': frame_title, u'command': command})
|
||||
|
||||
|
||||
|
||||
def get_oos_repr(self):
|
||||
"""
|
||||
This method returns some text which can be saved into the OOS
|
||||
file to represent this item
|
||||
"""
|
||||
pass
|
||||
oos_header = {u'type': self.shortname,u'theme':self.theme, u'title':self.title,
|
||||
u'icon':self.icon, u'footer':self.raw_footer}
|
||||
oos_data = []
|
||||
if self.service_item_type == u'text':
|
||||
for slide in self.service_frames:
|
||||
oos_data.append(slide[u'raw_slide'])
|
||||
return {u'header': oos_header, u'data': oos_data}
|
||||
|
||||
def set_from_oos(self, oostext):
|
||||
"""
|
||||
@ -106,9 +111,3 @@ class ServiceItem():
|
||||
and parses it into the data actually required
|
||||
"""
|
||||
pass
|
||||
|
||||
def set_from_plugin(self):
|
||||
"""
|
||||
Takes data from the plugin media chooser
|
||||
"""
|
||||
pass
|
||||
|
@ -119,7 +119,10 @@ class ServiceManager(QtGui.QWidget):
|
||||
pass
|
||||
|
||||
def onSaveService(self):
|
||||
pass
|
||||
service = []
|
||||
for item in self.serviceItems:
|
||||
service.append({u'serviceitem':item[u'data'].get_oos_repr()})
|
||||
print service
|
||||
|
||||
def onLoadService(self):
|
||||
pass
|
||||
@ -129,13 +132,13 @@ class ServiceManager(QtGui.QWidget):
|
||||
self.parent.RenderManager.set_service_theme(self.service_theme)
|
||||
self.config.set_config(u'theme service theme', self.service_theme)
|
||||
|
||||
def addServiceItem(self, item):
|
||||
def addServiceItem(self, item, expand=True):
|
||||
self.serviceItems.append({u'data': item, u'order': len(self.serviceItems)+1})
|
||||
treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
|
||||
treewidgetitem.setText(0,item.title) # + u':' + item.shortname)
|
||||
treewidgetitem.setText(0,item.title)
|
||||
treewidgetitem.setIcon(0,item.iconic_representation)
|
||||
treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(len(self.serviceItems)))
|
||||
treewidgetitem.setExpanded(True)
|
||||
treewidgetitem.setExpanded(expand)
|
||||
item.render()
|
||||
count = 0
|
||||
for frame in item.frames:
|
||||
@ -159,13 +162,14 @@ class ServiceManager(QtGui.QWidget):
|
||||
count = 0
|
||||
for item in items:
|
||||
childCount = item.childCount()
|
||||
if childCount >= 1: # is the parent
|
||||
if childCount >= 1:
|
||||
pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
else:
|
||||
parentitem = item.parent()
|
||||
pos = parentitem.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
count = item.data(0, QtCore.Qt.UserRole).toInt()[0]
|
||||
pos = pos - 1 #adjust for zeor indexing
|
||||
#adjuest for zero based arrays
|
||||
pos = pos - 1
|
||||
return pos, count
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
@ -184,26 +188,6 @@ class ServiceManager(QtGui.QWidget):
|
||||
plugin = event.mimeData().text()
|
||||
self.parent.EventManager.post_event(Event(EventType.LoadServiceItem, plugin))
|
||||
|
||||
def oos_as_text(self):
|
||||
text=[]
|
||||
log.info( "oos as text")
|
||||
log.info("Data:"+str(self.service_data))
|
||||
for i in self.service_data:
|
||||
text.append("# " + str(i))
|
||||
text.append(i.get_oos_text())
|
||||
return '\n'.join(text)
|
||||
|
||||
def write_oos(self, filename):
|
||||
"""
|
||||
Write a full OOS file out - iterate over plugins and call their respective methods
|
||||
This format is totally arbitrary testing purposes - something sensible needs to go in here!
|
||||
"""
|
||||
oosfile=open(filename, "w")
|
||||
oosfile.write("# BEGIN OOS\n")
|
||||
oosfile.write(self.oos_as_text)
|
||||
oosfile.write("# END OOS\n")
|
||||
oosfile.close()
|
||||
|
||||
def updateThemeList(self, theme_list):
|
||||
"""
|
||||
Called from ThemeManager when the Themes have changed
|
||||
|
Loading…
Reference in New Issue
Block a user