From 714ae4647d7e13e6489496658ab2503194a70686 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 20 Jun 2009 08:08:17 +0100 Subject: [PATCH] preserve expansion on reorder of ServiceItems Fix menu items on Mainwindow where targets are developed --- openlp/core/ui/mainwindow.py | 3 ++- openlp/core/ui/servicemanager.py | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 164de353b..6da2e9875 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -64,6 +64,7 @@ class MainWindow(object): self.RenderManager = RenderManager(self.ThemeManagerContents, self.screenList, int(self.generalConfig.get_config(u'Monitor', 0))) log.info(u'Load Plugins') + #make the controllers available to the plugins self.plugin_helpers[u'preview'] = self.PreviewController self.plugin_helpers[u'live'] = self.LiveController self.plugin_helpers[u'event'] = self.EventManager @@ -74,7 +75,7 @@ class MainWindow(object): self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers, self.EventManager) # hook methods have to happen after find_plugins. Find plugins needs the - # controllershence the hooks have moved from setupUI() to here + # controllers hence the hooks have moved from setupUI() to here # Find and insert settings tabs log.info(u'hook settings') diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 4fd03b8bf..5f1a8290d 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -105,10 +105,22 @@ class ServiceManager(QtGui.QWidget): QtCore.SIGNAL(u'activated(int)'), self.onThemeComboBoxSelected) QtCore.QObject.connect(self.ServiceManagerList, QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.makeLive) + QtCore.QObject.connect(self.ServiceManagerList, + QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), self.collapsed) + QtCore.QObject.connect(self.ServiceManagerList, + QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded) # Last little bits of setting up self.config = PluginConfig(u'Main') self.service_theme = self.config.get_config(u'theme service theme', u'') + def collapsed(self, item): + pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + self.serviceItems[pos -1 ][u'expanded'] = False + + def expanded(self, item): + pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] + self.serviceItems[pos -1 ][u'expanded'] = True + def onServiceTop(self): """ Move the current ServiceItem to the top of the list @@ -185,6 +197,7 @@ class ServiceManager(QtGui.QWidget): treewidgetitem.setText(0,serviceitem.title) treewidgetitem.setIcon(0,serviceitem.iconic_representation) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(item[u'order'])) + treewidgetitem.setExpanded(item[u'expanded']) count = 0 for frame in serviceitem.frames: treewidgetitem1 = QtGui.QTreeWidgetItem(treewidgetitem) @@ -239,16 +252,16 @@ class ServiceManager(QtGui.QWidget): for item in tempServiceItems: self.addServiceItem(item[u'data']) - def addServiceItem(self, item, expand=True): + def addServiceItem(self, item): """ Add an item to the list """ - self.serviceItems.append({u'data': item, u'order': len(self.serviceItems)+1}) + self.serviceItems.append({u'data': item, u'order': len(self.serviceItems)+1, u'expanded':True}) treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList) treewidgetitem.setText(0,item.title) treewidgetitem.setIcon(0,item.iconic_representation) treewidgetitem.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(len(self.serviceItems))) - treewidgetitem.setExpanded(expand) + treewidgetitem.setExpanded(True) item.render() count = 0 for frame in item.frames: