-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Applied patch from Andres Manz from #2185
Adds QgsLegendInterface class to GUI library to allow users to do some operations with groups. git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12359 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
wonder
committed
Dec 7, 2009
1 parent
cf519de
commit b0d68ae
Showing
15 changed files
with
384 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,4 @@ Milena Nowotarska | |
Anita Graser | ||
Richard Duivenvoorde | ||
Alexander Bruy | ||
Andres Manz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* \class QgsLegendInterface | ||
* \brief Abstract base class to make QgsLegend available to plugins. | ||
*/ | ||
class QgsLegendInterface : QObject | ||
{ | ||
%TypeHeaderCode | ||
#include <qgslegendinterface.h> | ||
%End | ||
|
||
public: | ||
|
||
/** Constructor */ | ||
QgsLegendInterface(); | ||
|
||
/** Virtual destructor */ | ||
~QgsLegendInterface(); | ||
|
||
virtual QStringList groups() =0; | ||
|
||
signals: | ||
|
||
//! emitted when a group index has changed | ||
void groupIndexChanged( int oldIndex, int newIndex ); | ||
|
||
public slots: | ||
|
||
//! Add a new group | ||
virtual int addGroup( QString name, bool expand = true ) =0; | ||
|
||
//! Remove group on index | ||
virtual void removeGroup( int groupIndex ) =0; | ||
|
||
//! Move a layer to a group | ||
virtual void moveLayer( QgsMapLayer * layer, int groupIndex ) =0; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/*************************************************************************** | ||
qgsapplegendinterface.cpp | ||
-------------------------------------- | ||
Date : 19-Nov-2009 | ||
Copyright : (C) 2009 by Andres Manz | ||
Email : manz dot andres at gmail dot com | ||
****************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
/* $Id$ */ | ||
|
||
#include "qgsapplegendinterface.h" | ||
|
||
#include "qgslegend.h" | ||
|
||
|
||
QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend ) | ||
: mLegend( legend ) | ||
{ | ||
} | ||
|
||
QgsAppLegendInterface::~QgsAppLegendInterface() | ||
{ | ||
} | ||
|
||
int QgsAppLegendInterface::addGroup( QString name, bool expand ) | ||
{ | ||
return mLegend->addGroup( name, expand ); | ||
} | ||
|
||
void QgsAppLegendInterface::removeGroup( int groupIndex ) | ||
{ | ||
mLegend->removeGroup( groupIndex ); | ||
} | ||
|
||
void QgsAppLegendInterface::moveLayer( QgsMapLayer * ml, int groupIndex ) | ||
{ | ||
mLegend->moveLayer( ml, groupIndex ); | ||
} | ||
|
||
void QgsAppLegendInterface::updateIndex( const QModelIndex &oldIndex, const QModelIndex& newIndex) | ||
{ | ||
if ( mLegend->isLegendGroup( newIndex ) ) | ||
{ | ||
emit groupIndexChanged( oldIndex.row(), newIndex.row() ); | ||
} | ||
} | ||
|
||
QStringList QgsAppLegendInterface::groups() | ||
{ | ||
return mLegend->groups(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/*************************************************************************** | ||
qgsapplegendinterface.h | ||
-------------------------------------- | ||
Date : 23-Nov-2009 | ||
Copyright : (C) 2009 by Andres Manz | ||
Email : manz dot andres at gmail dot com | ||
****************************************************************************/ | ||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
/* $Id$ */ | ||
|
||
#ifndef QGSLEGENDAPPIFACE_H | ||
#define QGSLEGENDAPPIFACE_H | ||
|
||
#include "qgslegendinterface.h" | ||
|
||
class QModelIndex; | ||
class QgsLegend; | ||
class QgsMapLayer; | ||
|
||
/** \ingroup gui | ||
* QgsLegendInterface | ||
* Abstract base class to make QgsLegend available to plugins. | ||
*/ | ||
class QgsAppLegendInterface : public QgsLegendInterface | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
/** Constructor */ | ||
explicit QgsAppLegendInterface( QgsLegend * legend ); | ||
|
||
/** Virtual destructor */ | ||
~QgsAppLegendInterface(); | ||
|
||
//! Return a string list of groups | ||
QStringList groups(); | ||
|
||
public slots: | ||
|
||
//! Add a new group | ||
int addGroup( QString name, bool expand = true ); | ||
|
||
//! Remove all groups with the given name | ||
void removeGroup( int groupIndex ); | ||
|
||
//! Move a layer to a group | ||
void moveLayer( QgsMapLayer * ml, int groupIndex ); | ||
|
||
//! Update an index | ||
void updateIndex( const QModelIndex &oldIndex, const QModelIndex &newIndex ); | ||
|
||
private: | ||
|
||
//! Pointer to QgsLegend object | ||
QgsLegend *mLegend; | ||
}; | ||
|
||
#endif //QGSLEGENDAPPIFACE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.