forked from openlp/openlp
fixed bug #1238385, but no tests
Fixes: https://launchpad.net/bugs/1238385
This commit is contained in:
parent
1c720ff101
commit
524d8f3acb
@ -66,6 +66,12 @@ class ServiceManagerList(QtWidgets.QTreeWidget):
|
|||||||
elif event.key() == QtCore.Qt.Key_Down:
|
elif event.key() == QtCore.Qt.Key_Down:
|
||||||
self.service_manager.on_move_selection_down()
|
self.service_manager.on_move_selection_down()
|
||||||
event.accept()
|
event.accept()
|
||||||
|
elif event.key() == QtCore.Qt.Key_Right:
|
||||||
|
self.service_manager.on_expand_selection()
|
||||||
|
event.accept()
|
||||||
|
elif event.key() == QtCore.Qt.Key_Left:
|
||||||
|
self.service_manager.on_collapse_selection()
|
||||||
|
event.accept()
|
||||||
elif event.key() == QtCore.Qt.Key_Delete:
|
elif event.key() == QtCore.Qt.Key_Delete:
|
||||||
self.service_manager.on_delete_from_service()
|
self.service_manager.on_delete_from_service()
|
||||||
event.accept()
|
event.accept()
|
||||||
@ -1119,6 +1125,37 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtWidgets.QWidget, Ui_ServiceMa
|
|||||||
return
|
return
|
||||||
self.service_manager_list.setCurrentItem(item_after)
|
self.service_manager_list.setCurrentItem(item_after)
|
||||||
|
|
||||||
|
def on_expand_selection(self):
|
||||||
|
"""
|
||||||
|
Expands cursor selection on the window. Called by the right arrow
|
||||||
|
"""
|
||||||
|
item = self.service_manager_list.currentItem()
|
||||||
|
|
||||||
|
if item.childCount(): # Since we only have 2 levels we find them by checking for children
|
||||||
|
if not self.service_manager_list.isExpanded(self.service_manager_list.currentIndex()):
|
||||||
|
self.service_manager_list.expandItem(item)
|
||||||
|
self.service_manager.expanded(item)
|
||||||
|
# If not expanded, Expand it
|
||||||
|
|
||||||
|
self.service_manager_list.setCurrentItem(self.service_manager_list.itemBelow(item))
|
||||||
|
# Then move selection down to child whether it needed to be expanded or not
|
||||||
|
|
||||||
|
def on_collapse_selection(self):
|
||||||
|
"""
|
||||||
|
Collapses cursor selection on the window Called by the left arrow
|
||||||
|
"""
|
||||||
|
item = self.service_manager_list.currentItem()
|
||||||
|
|
||||||
|
if item.childCount(): # Since we only have 2 levels we find them by checking for children
|
||||||
|
if self.service_manager_list.isExpanded(self.service_manager_list.currentIndex()):
|
||||||
|
self.service_manager_list.collapseItem(item)
|
||||||
|
self.service_manager.collapsed(item)
|
||||||
|
|
||||||
|
else: # If selection is lower level
|
||||||
|
self.service_manager_list.collapseItem(item.parent())
|
||||||
|
self.service_manager.collapsed(item.parent())
|
||||||
|
self.service_manager_list.setCurrentItem(item.parent())
|
||||||
|
|
||||||
def on_collapse_all(self, field=None):
|
def on_collapse_all(self, field=None):
|
||||||
"""
|
"""
|
||||||
Collapse all the service items.
|
Collapse all the service items.
|
||||||
|
@ -28,9 +28,11 @@ from unittest.mock import MagicMock, patch
|
|||||||
from openlp.core.common import Registry
|
from openlp.core.common import Registry
|
||||||
from openlp.core.lib import ScreenList, ServiceItem, ItemCapabilities
|
from openlp.core.lib import ScreenList, ServiceItem, ItemCapabilities
|
||||||
from openlp.core.ui.mainwindow import MainWindow
|
from openlp.core.ui.mainwindow import MainWindow
|
||||||
|
from openlp.core.ui.servicemanager import ServiceManagerList
|
||||||
|
from openlp.core.lib.serviceitem import ServiceItem
|
||||||
|
|
||||||
from tests.helpers.testmixin import TestMixin
|
from tests.helpers.testmixin import TestMixin
|
||||||
|
from PyQt5 import QtCore, QtGui, QtTest
|
||||||
|
|
||||||
class TestServiceManager(TestCase, TestMixin):
|
class TestServiceManager(TestCase, TestMixin):
|
||||||
|
|
||||||
@ -351,3 +353,38 @@ class TestServiceManager(TestCase, TestMixin):
|
|||||||
new_service.trigger()
|
new_service.trigger()
|
||||||
|
|
||||||
assert mocked_event.call_count == 1, 'The on_new_service_clicked method should have been called once'
|
assert mocked_event.call_count == 1, 'The on_new_service_clicked method should have been called once'
|
||||||
|
|
||||||
|
def test_keyboard_expand_selection(self):
|
||||||
|
"""
|
||||||
|
Test on on_expand_selection method caused by keyboard
|
||||||
|
"""
|
||||||
|
# GIVEN A collapsed song selected on the service manager.
|
||||||
|
self.service_manager.setup_ui(self.service_manager)
|
||||||
|
ServiceManagerList(self.service_manager)
|
||||||
|
|
||||||
|
item = ServiceItem()
|
||||||
|
item.title = "test"
|
||||||
|
item.add_from_text("slide 1")
|
||||||
|
item.add_from_text("slide 2")
|
||||||
|
item.add_icon(":/plugins/plugin_songs.png")
|
||||||
|
#SongMediaItem.generate_slide_data(item)
|
||||||
|
self.service_manager.add_service_item(item)
|
||||||
|
|
||||||
|
print(item._raw_frames)
|
||||||
|
|
||||||
|
song_to_expand = self.service_manager.service_manager_list.topLevelItem(0)
|
||||||
|
#print(song_to_expand)
|
||||||
|
self.service_manager.service_manager_list.setCurrentItem(song_to_expand)
|
||||||
|
#print(self.service_manager.service_manager_list.currentItem())
|
||||||
|
#print(self.service_manager.service_manager_list.topLevelItemCount())
|
||||||
|
|
||||||
|
# WHEN Pressing the right arrow key
|
||||||
|
#QtTest.QTest.keyPress(self.service_manager.service_manager_list, QtCore.Qt.Key_Right)
|
||||||
|
|
||||||
|
event = QtGui.QKeyEvent(QtCore.QEvent.KeyPress,QtCore.Qt.Key_Right,QtCore.Qt.NoModifier)
|
||||||
|
ServiceManagerList.keyPressEvent(self.service_manager,event)
|
||||||
|
|
||||||
|
# THEN Should be expanded
|
||||||
|
selected_index = self.service_manager.service_manager_list.currentIndex()
|
||||||
|
above_selection_index = self.service_manager.service_manager_list.indexAbove(selected_index)
|
||||||
|
self.assertTrue(self.service_manager.service_manager_list.isExpanded(above_selection_index), 'Item should have been expanded')
|
Loading…
Reference in New Issue
Block a user