Skip to content
Permalink
Browse files

allow opening properties dialog for layer from plugins (better versio…

…n of r12814)

git-svn-id: http://svn.osgeo.org/qgis/trunk@12828 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Jan 23, 2010
1 parent fcca821 commit 5608ccc1f289f200d29770d7b32fe914421301e9
@@ -100,9 +100,16 @@ class QgisInterface : QObject
/** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
virtual void removeDockWidget ( QDockWidget * dockwidget )=0;

/** refresh legend of a layer */
/** refresh legend of a layer
\note deprecated - use QgsLegendInterface::refreshLayerSymbology()
*/
virtual void refreshLegend( QgsMapLayer * layer )=0;

/** open layer properties
\note added in 1.5
*/
virtual void showLayerProperties( QgsMapLayer * layer )=0;

/** Add window to Window menu. The action title is the window title
* and the action should raise, unminimize and activate the window. */
virtual void addWindow( QAction *action ) = 0;
@@ -34,8 +34,8 @@ class QgsLegendInterface : QObject
//! Move a layer to a group
virtual void moveLayer( QgsMapLayer * layer, int groupIndex ) =0;

//! show layer propeties
//! @note added in 1.5
virtual void legendLayerShowProperties() =0;
//! refresh layer symbology
//! \note added in 1.5
virtual void refreshLayerSymbology( QgsMapLayer *layer ) =0;
};

@@ -18,7 +18,7 @@
#include "qgsapplegendinterface.h"

#include "qgslegend.h"

#include "qgsmaplayer.h"

QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend )
: mLegend( legend )
@@ -58,7 +58,7 @@ QStringList QgsAppLegendInterface::groups()
return mLegend->groups();
}

void QgsAppLegendInterface::legendLayerShowProperties()
void QgsAppLegendInterface::refreshLayerSymbology( QgsMapLayer *ml )
{
mLegend->legendLayerShowProperties();
mLegend->refreshLayerSymbology( ml->getLayerID() );
}
@@ -53,13 +53,13 @@ class QgsAppLegendInterface : public QgsLegendInterface
void removeGroup( int groupIndex );

//! Move a layer to a group
void moveLayer( QgsMapLayer * ml, int groupIndex );
void moveLayer( QgsMapLayer *ml, int groupIndex );

//! Update an index
void updateIndex( QModelIndex oldIndex, QModelIndex newIndex );

//! Show layer properties
void legendLayerShowProperties();
//! refresh layer symbology
void refreshLayerSymbology( QgsMapLayer *ml );

private:

@@ -717,49 +717,7 @@ void QgsLegend::legendLayerShowProperties()

//QgsDebugMsg("Showing layer properties dialog");

QgsMapLayer* ml = ll->layer();

/*
TODO: Consider reusing the property dialogs again.
Sometimes around mid 2005, the property dialogs were saved for later reuse;
this resulted in a time savings when reopening the dialog. The code below
cannot be used as is, however, simply by saving the dialog pointer here.
Either the map layer needs to be passed as an argument to sync or else
a separate copy of the dialog pointer needs to be stored with each layer.
*/

if ( ml->type() == QgsMapLayer::RasterLayer )
{
QgsRasterLayerProperties *rlp = NULL; // See note above about reusing this
if ( rlp )
{
rlp->sync();
}
else
{
rlp = new QgsRasterLayerProperties( ml );
connect( rlp, SIGNAL( refreshLegend( QString, bool ) ), this, SLOT( refreshLayerSymbology( QString, bool ) ) );
}
rlp->exec();
delete rlp; // delete since dialog cannot be reused without updating code
}
else // VECTOR
{
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( ml );

QgsVectorLayerProperties *vlp = NULL; // See note above about reusing this
if ( vlp )
{
vlp->reset();
}
else
{
vlp = new QgsVectorLayerProperties( vlayer );
connect( vlp, SIGNAL( refreshLegend( QString, bool ) ), this, SLOT( refreshLayerSymbology( QString, bool ) ) );
}
vlp->exec();
delete vlp; // delete since dialog cannot be reused without updating code
}
QgisApp::instance()->showLayerProperties( ll->layer() );

ll->updateIcon();

@@ -128,6 +128,7 @@
#include "qgsproviderregistry.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerproperties.h"
#include "qgsvectorlayerproperties.h"
#include "qgsrectangle.h"
#include "qgsrenderer.h"
#include "qgswmssourceselect.h"
@@ -6080,3 +6081,48 @@ void QgisApp::readProject( const QDomDocument &doc )
{
projectChanged( doc );
}

void QgisApp::showLayerProperties( QgsMapLayer *ml )
{
/*
TODO: Consider reusing the property dialogs again.
Sometimes around mid 2005, the property dialogs were saved for later reuse;
this resulted in a time savings when reopening the dialog. The code below
cannot be used as is, however, simply by saving the dialog pointer here.
Either the map layer needs to be passed as an argument to sync or else
a separate copy of the dialog pointer needs to be stored with each layer.
*/

if ( ml->type() == QgsMapLayer::RasterLayer )
{
QgsRasterLayerProperties *rlp = NULL; // See note above about reusing this
if ( rlp )
{
rlp->sync();
}
else
{
rlp = new QgsRasterLayerProperties( ml );
connect( rlp, SIGNAL( refreshLegend( QString, bool ) ), mMapLegend, SLOT( refreshLayerSymbology( QString, bool ) ) );
}
rlp->exec();
delete rlp; // delete since dialog cannot be reused without updating code
}
else // VECTOR
{
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( ml );

QgsVectorLayerProperties *vlp = NULL; // See note above about reusing this
if ( vlp )
{
vlp->reset();
}
else
{
vlp = new QgsVectorLayerProperties( vlayer );
connect( vlp, SIGNAL( refreshLegend( QString, bool ) ), mMapLegend, SLOT( refreshLayerSymbology( QString, bool ) ) );
}
vlp->exec();
delete vlp; // delete since dialog cannot be reused without updating code
}
}
@@ -352,6 +352,9 @@ class QgisApp : public QMainWindow
//! run python
void runPythonString( const QString &expr );

//! show layer properties
void showLayerProperties( QgsMapLayer *ml );

public slots:
//! Zoom to full extent
void zoomFull();
@@ -198,6 +198,14 @@ void QgisAppInterface::refreshLegend( QgsMapLayer *l )
}
}

void QgisAppInterface::showLayerProperties( QgsMapLayer *l )
{
if( l && qgis )
{
qgis->showLayerProperties( l );
}
}

void QgisAppInterface::addWindow( QAction *action ) { qgis->addWindow( action ); }
void QgisAppInterface::removeWindow( QAction *action ) { qgis->removeWindow( action ); }

@@ -115,6 +115,8 @@ class QgisAppInterface : public QgisInterface

virtual void refreshLegend( QgsMapLayer *l );

virtual void showLayerProperties( QgsMapLayer *l );

/** Add window to Window menu. The action title is the window title
* and the action should raise, unminimize and activate the window. */
virtual void addWindow( QAction *action );
@@ -31,7 +31,6 @@ class QWidget;
#include <map>


class QgisApp;
class QgsComposerView;
class QgsMapLayer;
class QgsMapCanvas;
@@ -135,9 +134,16 @@ class GUI_EXPORT QgisInterface : public QObject
/** Remove specified dock widget from main window (doesn't delete it). Added in QGIS 1.1. */
virtual void removeDockWidget( QDockWidget * dockwidget ) = 0;

/** refresh the legend of a layer */
/** refresh the legend of a layer
\note deprecated - use QgsLegendInterface::refreshLayerSymbology
*/
virtual void refreshLegend( QgsMapLayer *l ) = 0;

/** open layer properties dialog
\note added in 1.5
*/
virtual void showLayerProperties( QgsMapLayer *l ) = 0;

/** Add window to Window menu. The action title is the window title
* and the action should raise, unminimize and activate the window. */
virtual void addWindow( QAction *action ) = 0;
@@ -60,9 +60,9 @@ class GUI_EXPORT QgsLegendInterface : public QObject
//! Move a layer to a group
virtual void moveLayer( QgsMapLayer * ml, int groupIndex ) = 0;

//! Show layer properties dialog
// @note added in 1.5
virtual void legendLayerShowProperties() = 0;
//! Refresh layer symbology
// @noted added in 1.5
virtual void refreshLayerSymbology( QgsMapLayer *ml ) = 0;
};

#endif

0 comments on commit 5608ccc

Please sign in to comment.
You can’t perform that action at this time.