mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Dox++, unit tests
This commit is contained in:
parent
62f5f5e8e3
commit
b9482dda6b
@ -169,6 +169,8 @@ Returns whether a node is checked (independently of its ancestors or children)
|
||||
%Docstring
|
||||
Check or uncheck a node (independently of its ancestors or children)
|
||||
|
||||
.. seealso:: :py:func:`QgsLayerTreeView.setLayerVisible`
|
||||
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
|
@ -79,7 +79,9 @@ Returns the currently selected layer, or ``None`` if no layers is selected.
|
||||
|
||||
void setLayerVisible( QgsMapLayer *layer, bool visible );
|
||||
%Docstring
|
||||
Sets the visible state of the specified layer
|
||||
Convenience methods which sets the visible state of the specified map ``layer``.
|
||||
|
||||
.. seealso:: :py:func:`QgsLayerTreeNode.setItemVisibilityChecked`
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
@ -170,6 +170,9 @@ class CORE_EXPORT QgsLayerTreeNode : public QObject
|
||||
|
||||
/**
|
||||
* Check or uncheck a node (independently of its ancestors or children)
|
||||
*
|
||||
* \see QgsLayerTreeView::setLayerVisible()
|
||||
*
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
void setItemVisibilityChecked( bool checked );
|
||||
|
@ -88,8 +88,9 @@ class GUI_EXPORT QgsLayerTreeView : public QTreeView
|
||||
QgsMapLayer *currentLayer() const;
|
||||
|
||||
/**
|
||||
* Sets the visible state of the specified layer
|
||||
* Convenience methods which sets the visible state of the specified map \a layer.
|
||||
*
|
||||
* \see QgsLayerTreeNode::setItemVisibilityChecked()
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
void setLayerVisible( QgsMapLayer *layer, bool visible );
|
||||
|
@ -211,6 +211,22 @@ class TestQgsLayerTreeView(unittest.TestCase):
|
||||
groupname + '-' + self.layer4.name(),
|
||||
])
|
||||
|
||||
def testSetLayerVisible(self):
|
||||
view = QgsLayerTreeView()
|
||||
view.setModel(self.model)
|
||||
self.project.layerTreeRoot().findLayer(self.layer).setItemVisibilityChecked(True)
|
||||
self.project.layerTreeRoot().findLayer(self.layer2).setItemVisibilityChecked(True)
|
||||
self.assertTrue(self.project.layerTreeRoot().findLayer(self.layer).itemVisibilityChecked())
|
||||
self.assertTrue(self.project.layerTreeRoot().findLayer(self.layer2).itemVisibilityChecked())
|
||||
|
||||
view.setLayerVisible(None, True)
|
||||
view.setLayerVisible(self.layer, True)
|
||||
self.assertTrue(self.project.layerTreeRoot().findLayer(self.layer).itemVisibilityChecked())
|
||||
view.setLayerVisible(self.layer2, False)
|
||||
self.assertFalse(self.project.layerTreeRoot().findLayer(self.layer2).itemVisibilityChecked())
|
||||
view.setLayerVisible(self.layer2, True)
|
||||
self.assertTrue(self.project.layerTreeRoot().findLayer(self.layer2).itemVisibilityChecked())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user