mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
implement currentLayer() and setCurrentLayer() in QgsLegendInterface to set/get current layer
This commit is contained in:
parent
42d637d9a0
commit
9bed789f2e
@ -68,6 +68,17 @@ class QgsLegendInterface : QObject
|
||||
*/
|
||||
virtual bool removeLegendLayerAction( QAction* action ) = 0;
|
||||
|
||||
//! Returns the current layer if the current item is a QgsLegendLayer.
|
||||
//! If the current item is a QgsLegendLayer, its first maplayer is returned.
|
||||
//! Else, 0 is returned.
|
||||
//! @note Added in 2.0
|
||||
virtual QgsMapLayer* currentLayer() = 0;
|
||||
|
||||
//! set the current layer
|
||||
//! returns true if the layer exists, false otherwise
|
||||
//! @note Added in 2.0
|
||||
virtual bool setCurrentLayer( QgsMapLayer *layer ) = 0;
|
||||
|
||||
signals:
|
||||
|
||||
//! emitted when a group index has changed
|
||||
|
@ -30,6 +30,7 @@ QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend )
|
||||
connect( legend, SIGNAL( itemMovedGroup( QgsLegendItem *, int ) ), this, SIGNAL( groupRelationsChanged() ) );
|
||||
// connect( legend, SIGNAL( itemChanged( QTreeWidgetItem*, int ) ), this, SIGNAL( groupRelationsChanged() ) );
|
||||
connect( legend, SIGNAL( itemRemoved() ), this, SIGNAL( itemRemoved() ) );
|
||||
connect( legend, SIGNAL( currentLayerChanged( QgsMapLayer * ) ), this, SIGNAL( currentLayerChanged( QgsMapLayer * ) ) );
|
||||
}
|
||||
|
||||
QgsAppLegendInterface::~QgsAppLegendInterface()
|
||||
@ -208,3 +209,12 @@ bool QgsAppLegendInterface::removeLegendLayerAction( QAction* action )
|
||||
return mLegend->removeLegendLayerAction( action );
|
||||
}
|
||||
|
||||
QgsMapLayer* QgsAppLegendInterface::currentLayer()
|
||||
{
|
||||
return mLegend->currentLayer();
|
||||
}
|
||||
|
||||
bool QgsAppLegendInterface::setCurrentLayer( QgsMapLayer *layer )
|
||||
{
|
||||
return mLegend->setCurrentLayer( layer );
|
||||
}
|
||||
|
@ -72,6 +72,9 @@ class QgsAppLegendInterface : public QgsLegendInterface
|
||||
void addLegendLayerActionForLayer( QAction* action, QgsMapLayer* layer );
|
||||
bool removeLegendLayerAction( QAction* action );
|
||||
|
||||
QgsMapLayer* currentLayer();
|
||||
bool setCurrentLayer( QgsMapLayer *layer );
|
||||
|
||||
public slots:
|
||||
|
||||
//! Add a new group
|
||||
|
@ -103,6 +103,17 @@ class GUI_EXPORT QgsLegendInterface : public QObject
|
||||
*/
|
||||
virtual bool removeLegendLayerAction( QAction* action ) = 0;
|
||||
|
||||
//! Returns the current layer if the current item is a QgsLegendLayer.
|
||||
//! If the current item is a QgsLegendLayer, its first maplayer is returned.
|
||||
//! Else, 0 is returned.
|
||||
//! @note Added in 2.0
|
||||
virtual QgsMapLayer* currentLayer() = 0;
|
||||
|
||||
//! set the current layer
|
||||
//! returns true if the layer exists, false otherwise
|
||||
//! @note Added in 2.0
|
||||
virtual bool setCurrentLayer( QgsMapLayer *layer ) = 0;
|
||||
|
||||
signals:
|
||||
|
||||
//! emitted when a group index has changed
|
||||
@ -117,6 +128,11 @@ class GUI_EXPORT QgsLegendInterface : public QObject
|
||||
/* //! emitted when an item (group/layer) is removed */
|
||||
void itemRemoved( );
|
||||
|
||||
//! Emitted whenever current (selected) layer changes
|
||||
// the pointer to layer can be null if no layer is selected
|
||||
//! @note Added in 2.0
|
||||
void currentLayerChanged( QgsMapLayer * layer );
|
||||
|
||||
public slots:
|
||||
|
||||
//! Add a new group
|
||||
|
Loading…
x
Reference in New Issue
Block a user