Enhance ServiceItem Expand/Collapse features

bzr-revno: 1075
This commit is contained in:
Tim Bentley 2010-10-09 07:40:27 +01:00
commit 0099cb402a
2 changed files with 62 additions and 6 deletions

View File

@ -82,6 +82,9 @@ class AdvancedTab(SettingsTab):
self.doubleClickLiveCheckBox.setObjectName(u'doubleClickLiveCheckBox') self.doubleClickLiveCheckBox.setObjectName(u'doubleClickLiveCheckBox')
self.uiLayout.addWidget(self.doubleClickLiveCheckBox) self.uiLayout.addWidget(self.doubleClickLiveCheckBox)
self.leftLayout.addWidget(self.uiGroupBox) self.leftLayout.addWidget(self.uiGroupBox)
self.expandServiceItemCheckBox = QtGui.QCheckBox(self.uiGroupBox)
self.expandServiceItemCheckBox.setObjectName(u'expandServiceItemCheckBox')
self.uiLayout.addWidget(self.expandServiceItemCheckBox)
# self.sharedDirGroupBox = QtGui.QGroupBox(self.leftWidget) # self.sharedDirGroupBox = QtGui.QGroupBox(self.leftWidget)
# self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox') # self.sharedDirGroupBox.setObjectName(u'sharedDirGroupBox')
# self.sharedDirGroupBox.setGeometry(QtCore.QRect(0, 65, 500, 85)) # self.sharedDirGroupBox.setGeometry(QtCore.QRect(0, 65, 500, 85))
@ -140,6 +143,8 @@ class AdvancedTab(SettingsTab):
'Remember active media manager tab on startup')) 'Remember active media manager tab on startup'))
self.doubleClickLiveCheckBox.setText(translate('OpenLP.AdvancedTab', self.doubleClickLiveCheckBox.setText(translate('OpenLP.AdvancedTab',
'Double-click to send items straight to live (requires restart)')) 'Double-click to send items straight to live (requires restart)'))
self.expandServiceItemCheckBox.setText(translate('OpenLP.AdvancedTab',
'Expand new service items on creation'))
# self.sharedDirGroupBox.setTitle( # self.sharedDirGroupBox.setTitle(
# translate('AdvancedTab', 'Central Data Store')) # translate('AdvancedTab', 'Central Data Store'))
# self.sharedCheckBox.setText( # self.sharedCheckBox.setText(
@ -167,6 +172,9 @@ class AdvancedTab(SettingsTab):
self.doubleClickLiveCheckBox.setChecked( self.doubleClickLiveCheckBox.setChecked(
settings.value(u'double click live', settings.value(u'double click live',
QtCore.QVariant(False)).toBool()) QtCore.QVariant(False)).toBool())
self.expandServiceItemCheckBox.setChecked(
settings.value(u'expand service item',
QtCore.QVariant(False)).toBool())
settings.endGroup() settings.endGroup()
def save(self): def save(self):
@ -181,6 +189,8 @@ class AdvancedTab(SettingsTab):
QtCore.QVariant(self.mediaPluginCheckBox.isChecked())) QtCore.QVariant(self.mediaPluginCheckBox.isChecked()))
settings.setValue(u'double click live', settings.setValue(u'double click live',
QtCore.QVariant(self.doubleClickLiveCheckBox.isChecked())) QtCore.QVariant(self.doubleClickLiveCheckBox.isChecked()))
settings.setValue(u'expand service item',
QtCore.QVariant(self.expandServiceItemCheckBox.isChecked()))
settings.endGroup() settings.endGroup()
def onSharedCheckBoxChanged(self, checked): def onSharedCheckBoxChanged(self, checked):

View File

@ -107,6 +107,7 @@ class ServiceManager(QtGui.QWidget):
self.serviceName = u'' self.serviceName = u''
self.suffixes = [] self.suffixes = []
self.droppos = 0 self.droppos = 0
self.expandTabs = False
#is a new service and has not been saved #is a new service and has not been saved
self.isNew = True self.isNew = True
self.serviceNoteForm = ServiceNoteForm(self.parent) self.serviceNoteForm = ServiceNoteForm(self.parent)
@ -199,6 +200,19 @@ class ServiceManager(QtGui.QWidget):
translate('OpenLP.ServiceManager', translate('OpenLP.ServiceManager',
'Delete the selected item from the service.'), 'Delete the selected item from the service.'),
self.onDeleteFromService) self.onDeleteFromService)
self.orderToolbar.addSeparator()
self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', '&Expand all'),
u':/services/service_top.png',
translate('OpenLP.ServiceManager',
'Expand all the service items.'),
self.onExpandAll)
self.orderToolbar.addToolbarButton(
translate('OpenLP.ServiceManager', '&Collapse all'),
u':/services/service_bottom.png',
translate('OpenLP.ServiceManager',
'Collapse all the service items.'),
self.onCollapseAll)
self.layout.addWidget(self.orderToolbar) self.layout.addWidget(self.orderToolbar)
# Connect up our signals and slots # Connect up our signals and slots
QtCore.QObject.connect(self.themeComboBox, QtCore.QObject.connect(self.themeComboBox,
@ -220,7 +234,7 @@ class ServiceManager(QtGui.QWidget):
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'servicemanager_list_request'), self.listRequest) QtCore.SIGNAL(u'servicemanager_list_request'), self.listRequest)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'config_updated'), self.regenerateServiceItems) QtCore.SIGNAL(u'config_updated'), self.configUpdated)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_global'), self.themeChange) QtCore.SIGNAL(u'theme_update_global'), self.themeChange)
QtCore.QObject.connect(Receiver.get_receiver(), QtCore.QObject.connect(Receiver.get_receiver(),
@ -265,6 +279,17 @@ class ServiceManager(QtGui.QWidget):
self.themeMenu = QtGui.QMenu( self.themeMenu = QtGui.QMenu(
translate('OpenLP.ServiceManager', '&Change Item Theme')) translate('OpenLP.ServiceManager', '&Change Item Theme'))
self.menu.addMenu(self.themeMenu) self.menu.addMenu(self.themeMenu)
self.configUpdated(True)
def configUpdated(self, firstTime=False):
"""
Triggered when Config dialog is updated.
"""
self.expandTabs = QtCore.QSettings().value(
u'advanced/expand service item',
QtCore.QVariant(u'False')).toBool()
if not firstTime:
self.regenerateServiceItems()
def supportedSuffixes(self, suffix): def supportedSuffixes(self, suffix):
self.suffixes.append(suffix) self.suffixes.append(suffix)
@ -321,7 +346,7 @@ class ServiceManager(QtGui.QWidget):
self.serviceItems[item][u'service_item']) self.serviceItems[item][u'service_item'])
if self.serviceItemEditForm.exec_(): if self.serviceItemEditForm.exec_():
self.addServiceItem(self.serviceItemEditForm.getServiceItem(), self.addServiceItem(self.serviceItemEditForm.getServiceItem(),
replace=True) replace=True, expand=self.serviceItems[item][u'expand'])
def nextItem(self): def nextItem(self):
""" """
@ -423,6 +448,14 @@ class ServiceManager(QtGui.QWidget):
if setSelected: if setSelected:
firstItem.setSelected(True) firstItem.setSelected(True)
def onCollapseAll(self):
"""
Collapse all the service items
"""
for item in self.serviceItems:
item[u'expanded'] = False
self.regenerateServiceItems()
def collapsed(self, item): def collapsed(self, item):
""" """
Record if an item is collapsed Record if an item is collapsed
@ -431,6 +464,14 @@ class ServiceManager(QtGui.QWidget):
pos = item.data(0, QtCore.Qt.UserRole).toInt()[0] pos = item.data(0, QtCore.Qt.UserRole).toInt()[0]
self.serviceItems[pos -1 ][u'expanded'] = False self.serviceItems[pos -1 ][u'expanded'] = False
def onExpandAll(self):
"""
Collapse all the service items
"""
for item in self.serviceItems:
item[u'expanded'] = True
self.regenerateServiceItems()
def expanded(self, item): def expanded(self, item):
""" """
Record if an item is collapsed Record if an item is collapsed
@ -528,12 +569,12 @@ class ServiceManager(QtGui.QWidget):
Used when moving items as the move takes place in supporting array, Used when moving items as the move takes place in supporting array,
and when regenerating all the items due to theme changes and when regenerating all the items due to theme changes
""" """
#Correct order of items in array # Correct order of items in array
count = 1 count = 1
for item in self.serviceItems: for item in self.serviceItems:
item[u'order'] = count item[u'order'] = count
count += 1 count += 1
#Repaint the screen # Repaint the screen
self.serviceManagerList.clear() self.serviceManagerList.clear()
for itemcount, item in enumerate(self.serviceItems): for itemcount, item in enumerate(self.serviceItems):
serviceitem = item[u'service_item'] serviceitem = item[u'service_item']
@ -805,7 +846,7 @@ class ServiceManager(QtGui.QWidget):
self.isNew = True self.isNew = True
for item in tempServiceItems: for item in tempServiceItems:
self.addServiceItem( self.addServiceItem(
item[u'service_item'], False, item[u'expanded']) item[u'service_item'], False, expand=item[u'expanded'])
# Set to False as items may have changed rendering # Set to False as items may have changed rendering
# does not impact the saved song so True may also be valid # does not impact the saved song so True may also be valid
self.parent.serviceChanged(False, self.serviceName) self.parent.serviceChanged(False, self.serviceName)
@ -834,14 +875,19 @@ class ServiceManager(QtGui.QWidget):
self.parent.LiveController.replaceServiceManagerItem(newItem) self.parent.LiveController.replaceServiceManagerItem(newItem)
self.parent.serviceChanged(False, self.serviceName) self.parent.serviceChanged(False, self.serviceName)
def addServiceItem(self, item, rebuild=False, expand=False, replace=False): def addServiceItem(self, item, rebuild=False, expand=None, replace=False):
""" """
Add a Service item to the list Add a Service item to the list
``item`` ``item``
Service Item to be added Service Item to be added
``expand``
Override the default expand settings. (Tristate)
""" """
log.debug(u'addServiceItem') log.debug(u'addServiceItem')
if expand == None:
expand = self.expandTabs
sitem = self.findServiceItem()[0] sitem = self.findServiceItem()[0]
item.render() item.render()
if replace: if replace: