mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Update QgsLegend::selectedLayers() and add to QgsLegendInterface
- Add option to return selected layers in drawing order
This commit is contained in:
parent
a4484b217e
commit
8260eab94b
@ -22,7 +22,12 @@ class QgsLegendInterface : QObject
|
||||
//! Return the relationship between groups and layers in the legend
|
||||
virtual QList< QPair< QString, QList<QString> > > groupLayerRelationship();
|
||||
|
||||
//! Return all layers in the project in legend order
|
||||
//! Returns the currently selected layers of QgsLegendLayers.
|
||||
//! @param inDrawOrder return layers in drawing order (added in 1.9)
|
||||
//! @returns list of layers, else an empty list
|
||||
virtual QList<QgsMapLayer *> selectedLayers( bool inDrawOrder = false ) const = 0;
|
||||
|
||||
//! Return all layers in the project in drawing order
|
||||
//! @note added in 1.5
|
||||
virtual QList< QgsMapLayer * > layers() const = 0;
|
||||
|
||||
|
@ -166,6 +166,11 @@ bool QgsAppLegendInterface::isLayerVisible( QgsMapLayer * ml )
|
||||
return ( Qt::Checked == mLegend->layerCheckState( ml ) );
|
||||
}
|
||||
|
||||
QList<QgsMapLayer *> QgsAppLegendInterface::selectedLayers( bool inDrawOrder ) const
|
||||
{
|
||||
return mLegend->selectedLayers( inDrawOrder );
|
||||
}
|
||||
|
||||
QList< QgsMapLayer * > QgsAppLegendInterface::layers() const
|
||||
{
|
||||
return mLegend->layers();
|
||||
|
@ -46,7 +46,10 @@ class QgsAppLegendInterface : public QgsLegendInterface
|
||||
//! Return the relationship between groups and layers in the legend
|
||||
QList< GroupLayerInfo > groupLayerRelationship();
|
||||
|
||||
//! Return all layers in the project in legend order
|
||||
//! Returns the currently selected layers of QgsLegendLayers.
|
||||
QList<QgsMapLayer *> selectedLayers( bool inDrawOrder = false ) const;
|
||||
|
||||
//! Return all layers in the project in drawing order
|
||||
QList< QgsMapLayer * > layers() const;
|
||||
|
||||
//! Check if a group exists
|
||||
|
@ -1093,15 +1093,26 @@ QgsMapLayer* QgsLegend::currentLayer()
|
||||
}
|
||||
}
|
||||
|
||||
QList<QgsMapLayer *> QgsLegend::selectedLayers()
|
||||
QList<QgsMapLayer *> QgsLegend::selectedLayers( bool inDrawOrder )
|
||||
{
|
||||
QList<QgsMapLayer *> layers;
|
||||
|
||||
foreach ( QTreeWidgetItem * item, selectedItems() )
|
||||
if ( inDrawOrder )
|
||||
{
|
||||
QgsLegendLayer *ll = dynamic_cast<QgsLegendLayer *>( item );
|
||||
if ( ll )
|
||||
layers << ll->layer();
|
||||
foreach ( QgsLegendLayer *ll, legendLayers() )
|
||||
{
|
||||
if ( ll->isSelected() )
|
||||
layers << ll->layer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( QTreeWidgetItem * item, selectedItems() )
|
||||
{
|
||||
QgsLegendLayer *ll = dynamic_cast<QgsLegendLayer *>( item );
|
||||
if ( ll )
|
||||
layers << ll->layer();
|
||||
}
|
||||
}
|
||||
|
||||
return layers;
|
||||
|
@ -117,9 +117,10 @@ class QgsLegend : public QTreeWidget
|
||||
Else, 0 is returned.*/
|
||||
QgsMapLayer* currentLayer();
|
||||
|
||||
/*!Returns the currently selected layer QgsLegendLayers.
|
||||
Else, an empty list is returned.*/
|
||||
QList<QgsMapLayer *> selectedLayers();
|
||||
/** Returns the currently selected layers of QgsLegendLayers.
|
||||
* @param inDrawOrder return layers in drawing order (added in 1.9)
|
||||
* @returns list of layers, else an empty list */
|
||||
QList<QgsMapLayer *> selectedLayers( bool inDrawOrder = false );
|
||||
|
||||
/*!Returns all layers loaded in QgsMapCanvas in drawing order
|
||||
Else, an empty list is returned.*/
|
||||
|
@ -54,7 +54,12 @@ class GUI_EXPORT QgsLegendInterface : public QObject
|
||||
//! Return the relationship between groups and layers in the legend
|
||||
virtual QList< GroupLayerInfo > groupLayerRelationship() { return QList< GroupLayerInfo >(); }
|
||||
|
||||
//! Return all layers in the project in legend order
|
||||
//! Returns the currently selected layers of QgsLegendLayers.
|
||||
//! @param inDrawOrder return layers in drawing order (added in 1.9)
|
||||
//! @returns list of layers, else an empty list
|
||||
virtual QList<QgsMapLayer *> selectedLayers( bool inDrawOrder = false ) const = 0;
|
||||
|
||||
//! Return all layers in the project in drawing order
|
||||
//! @note added in 1.5
|
||||
virtual QList< QgsMapLayer * > layers() const = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user