def testDefaultActions(self): view = QgsLayerTreeView() view.setModel(self.model) actions = QgsLayerTreeViewDefaultActions(view) # show in overview action view.setCurrentLayer(self.layer) self.assertEqual(view.currentNode().customProperty('overview', 0), False) show_in_overview = actions.actionShowInOverview() show_in_overview.trigger() self.assertEqual(view.currentNode().customProperty('overview', 0), True) show_in_overview.trigger() self.assertEqual(view.currentNode().customProperty('overview', 0), False)
def testAddGroupActionGroups(self): """Test add group action on several groups""" view = QgsLayerTreeView() group = self.project.layerTreeRoot().insertGroup(0, "embeddedgroup") group.addLayer(self.layer4) groupname = group.name() group2 = self.project.layerTreeRoot().insertGroup(0, "embeddedgroup2") group2.addLayer(self.layer5) groupname2 = group2.name() view.setModel(self.model) if USE_MODEL_TESTER: proxy_tester = QAbstractItemModelTester(view.model()) actions = QgsLayerTreeViewDefaultActions(view) self.assertEqual( self.nodeOrder(self.project.layerTreeRoot().children()), [ groupname2, groupname2 + '-' + self.layer5.name(), groupname, groupname + '-' + self.layer4.name(), self.layer.name(), self.layer2.name(), self.layer3.name(), ]) selectionMode = view.selectionMode() view.setSelectionMode(QgsLayerTreeView.MultiSelection) nodeLayerIndex = view.node2index(group) view.setCurrentIndex(nodeLayerIndex) nodeLayerIndex2 = view.node2index(group2) view.setCurrentIndex(nodeLayerIndex2) view.setSelectionMode(selectionMode) addgroup = actions.actionAddGroup() addgroup.trigger() self.assertEqual( self.nodeOrder(self.project.layerTreeRoot().children()), [ self.groupname + '1', self.groupname + '1' + '-' + groupname, self.groupname + '1' + '-' + groupname + '-' + self.layer4.name(), self.groupname + '1' + '-' + groupname2, self.groupname + '1' + '-' + groupname2 + '-' + self.layer5.name(), self.layer.name(), self.layer2.name(), self.layer3.name() ])
def testDefaultActions(self): view = QgsLayerTreeView() view.setModel(self.model) if USE_MODEL_TESTER: proxy_tester = QAbstractItemModelTester(view.model()) actions = QgsLayerTreeViewDefaultActions(view) # show in overview action view.setCurrentLayer(self.layer) self.assertEqual(view.currentNode().customProperty('overview', 0), False) show_in_overview = actions.actionShowInOverview() show_in_overview.trigger() self.assertEqual(view.currentNode().customProperty('overview', 0), True) show_in_overview.trigger() self.assertEqual(view.currentNode().customProperty('overview', 0), False)
def testMoveToBottomActionLayerAndGroup(self): """Test move to top action for a group and it's layer simultaneously""" view = QgsLayerTreeView() group = self.project.layerTreeRoot().insertGroup(0, "embeddedgroup") group.addLayer(self.layer4) group.addLayer(self.layer5) groupname = group.name() view.setModel(self.model) if USE_MODEL_TESTER: proxy_tester = QAbstractItemModelTester(view.model()) actions = QgsLayerTreeViewDefaultActions(view) self.assertEqual( self.nodeOrder(self.project.layerTreeRoot().children()), [ groupname, groupname + '-' + self.layer4.name(), groupname + '-' + self.layer5.name(), self.layer.name(), self.layer2.name(), self.layer3.name(), ]) selectionMode = view.selectionMode() view.setSelectionMode(QgsLayerTreeView.MultiSelection) nodeLayerIndex = view.node2index(group) view.setCurrentIndex(nodeLayerIndex) view.setCurrentLayer(self.layer4) view.setSelectionMode(selectionMode) movetobottom = actions.actionMoveToBottom() movetobottom.trigger() self.assertEqual( self.nodeOrder(self.project.layerTreeRoot().children()), [ self.layer.name(), self.layer2.name(), self.layer3.name(), groupname, groupname + '-' + self.layer5.name(), groupname + '-' + self.layer4.name(), ])