Add update to ServiceManager of Themes from ThemeManager

This commit is contained in:
Tim Bentley 2009-04-23 19:22:54 +01:00
parent a3e2bce831
commit 4696564c09
3 changed files with 18 additions and 10 deletions

View File

@ -87,6 +87,7 @@ class MainWindow(object):
log.info(u'Load Themes')
self.ThemeManagerContents.setEventManager(self.EventManager)
self.ThemeManagerContents.setRenderManager(self.RenderManager)
self.ThemeManagerContents.setServiceManager(self.ServiceManagerContents)
self.ThemeManagerContents.loadThemes()
def setupUi(self):

View File

@ -61,7 +61,7 @@ class ServiceData(QAbstractItemModel):
self.endRemoveRows()
def addRow(self, item):
self.insertRow(len(self.items), item)
def index(self, row, col, parent = QModelIndex()):
return self.createIndex(row,col)
@ -90,7 +90,7 @@ class ServiceData(QAbstractItemModel):
return QVariant(retval)
else:
return retval
def __iter__(self):
for i in self.items:
yield i
@ -99,7 +99,7 @@ class ServiceData(QAbstractItemModel):
log.info("Get Item:%d -> %s" %(row, str(self.items)))
return self.items[row]
class ServiceManager(QWidget):
"""Manages the orders of service. Currently this involves taking
@ -109,7 +109,7 @@ class ServiceManager(QWidget):
Also handles the UI tasks of moving things up and down etc.
"""
global log
log=logging.getLogger(u'ServiceManager')
log=logging.getLogger(u'ServiceManager')
def __init__(self, parent):
QWidget.__init__(self)
@ -128,9 +128,6 @@ class ServiceManager(QWidget):
self.Toolbar.addSeparator()
self.ThemeComboBox = QtGui.QComboBox(self.Toolbar)
self.ThemeComboBox.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToContents)
self.ThemeComboBox.addItem(QtCore.QString())
self.ThemeComboBox.addItem(QtCore.QString())
self.ThemeComboBox.addItem(QtCore.QString())
self.ThemeWidget = QtGui.QWidgetAction(self.Toolbar)
self.ThemeWidget.setDefaultWidget(self.ThemeComboBox)
self.Toolbar.addAction(self.ThemeWidget)
@ -141,7 +138,7 @@ class ServiceManager(QWidget):
self.service_data=ServiceData()
self.TreeView.setModel(self.service_data)
self.Layout.addWidget(self.TreeView)
def addServiceItem(self, item):
"""Adds service item"""
log.info("addServiceItem")
@ -165,7 +162,7 @@ class ServiceManager(QWidget):
self.service_data.addRow(item)
else:
self.service_data.insertRow(row+1, item)
def removeServiceItem(self):
"""Remove currently selected item"""
pass
@ -189,3 +186,8 @@ class ServiceManager(QWidget):
oosfile.write(self.oos_as_text)
oosfile.write("# END OOS\n")
oosfile.close()
def updateThemeList(self, theme_list):
self.ThemeComboBox.clear()
for theme in theme_list:
self.ThemeComboBox.addItem(theme)

View File

@ -31,6 +31,7 @@ from PyQt4.QtCore import *
from PyQt4.QtGui import *
from openlp.core.ui import AmendThemeForm
from openlp.core.ui import ServiceManager
from openlp.core import translate
from openlp.core.theme import Theme
from openlp.core.lib import Event
@ -41,7 +42,6 @@ from openlp.core.lib import ThemeXML
from openlp.core.lib import Renderer
from openlp.core.utils import ConfigHelper
import logging
class ThemeData(QAbstractItemModel):
@ -190,6 +190,9 @@ class ThemeManager(QWidget):
def setRenderManager(self, renderManager):
self.renderManager = renderManager
def setServiceManager(self, serviceManager):
self.serviceManager = serviceManager
def onAddTheme(self):
self.amendThemeForm.loadTheme(None)
self.amendThemeForm.exec_()
@ -240,6 +243,7 @@ class ThemeManager(QWidget):
self.Theme_data.addRow(os.path.join(self.path, name))
self.eventManager.post_event(Event(EventType.ThemeListChanged))
self.serviceManager.updateThemeList(self.getThemes())
def getThemes(self):
return self.Theme_data.getList()
@ -323,6 +327,7 @@ class ThemeManager(QWidget):
return newtheme.extract_xml()
def saveTheme(self, name, theme_xml) :
log.debug(u'saveTheme %s %s', name, theme_xml)
self.generateAndSaveImage(self.path, name, theme_xml)
theme_dir = os.path.join(self.path, name)
if os.path.exists(theme_dir) == False: