[QGIS Commit] r12828 - in trunk/qgis: python/gui src/app
src/app/legend src/gui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Jan 23 16:50:09 EST 2010
Author: jef
Date: 2010-01-23 16:50:09 -0500 (Sat, 23 Jan 2010)
New Revision: 12828
Modified:
trunk/qgis/python/gui/qgisinterface.sip
trunk/qgis/python/gui/qgslegendinterface.sip
trunk/qgis/src/app/legend/qgsapplegendinterface.cpp
trunk/qgis/src/app/legend/qgsapplegendinterface.h
trunk/qgis/src/app/legend/qgslegend.cpp
trunk/qgis/src/app/qgisapp.cpp
trunk/qgis/src/app/qgisapp.h
trunk/qgis/src/app/qgisappinterface.cpp
trunk/qgis/src/app/qgisappinterface.h
trunk/qgis/src/gui/qgisinterface.h
trunk/qgis/src/gui/qgslegendinterface.h
Log:
allow opening properties dialog for layer from plugins (better version of r12814)
Modified: trunk/qgis/python/gui/qgisinterface.sip
===================================================================
--- trunk/qgis/python/gui/qgisinterface.sip 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/python/gui/qgisinterface.sip 2010-01-23 21:50:09 UTC (rev 12828)
@@ -100,9 +100,16 @@
/** 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;
Modified: trunk/qgis/python/gui/qgslegendinterface.sip
===================================================================
--- trunk/qgis/python/gui/qgslegendinterface.sip 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/python/gui/qgslegendinterface.sip 2010-01-23 21:50:09 UTC (rev 12828)
@@ -34,8 +34,8 @@
//! 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;
};
Modified: trunk/qgis/src/app/legend/qgsapplegendinterface.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgsapplegendinterface.cpp 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/src/app/legend/qgsapplegendinterface.cpp 2010-01-23 21:50:09 UTC (rev 12828)
@@ -18,8 +18,8 @@
#include "qgsapplegendinterface.h"
#include "qgslegend.h"
+#include "qgsmaplayer.h"
-
QgsAppLegendInterface::QgsAppLegendInterface( QgsLegend * legend )
: mLegend( legend )
{
@@ -58,7 +58,7 @@
return mLegend->groups();
}
-void QgsAppLegendInterface::legendLayerShowProperties()
+void QgsAppLegendInterface::refreshLayerSymbology( QgsMapLayer *ml )
{
- mLegend->legendLayerShowProperties();
+ mLegend->refreshLayerSymbology( ml->getLayerID() );
}
Modified: trunk/qgis/src/app/legend/qgsapplegendinterface.h
===================================================================
--- trunk/qgis/src/app/legend/qgsapplegendinterface.h 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/src/app/legend/qgsapplegendinterface.h 2010-01-23 21:50:09 UTC (rev 12828)
@@ -53,13 +53,13 @@
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:
Modified: trunk/qgis/src/app/legend/qgslegend.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegend.cpp 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/src/app/legend/qgslegend.cpp 2010-01-23 21:50:09 UTC (rev 12828)
@@ -717,50 +717,8 @@
//QgsDebugMsg("Showing layer properties dialog");
- QgsMapLayer* ml = ll->layer();
+ QgisApp::instance()->showLayerProperties( 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
- }
-
ll->updateIcon();
}
Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/src/app/qgisapp.cpp 2010-01-23 21:50:09 UTC (rev 12828)
@@ -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 @@
{
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
+ }
+}
Modified: trunk/qgis/src/app/qgisapp.h
===================================================================
--- trunk/qgis/src/app/qgisapp.h 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/src/app/qgisapp.h 2010-01-23 21:50:09 UTC (rev 12828)
@@ -352,6 +352,9 @@
//! run python
void runPythonString( const QString &expr );
+ //! show layer properties
+ void showLayerProperties( QgsMapLayer *ml );
+
public slots:
//! Zoom to full extent
void zoomFull();
Modified: trunk/qgis/src/app/qgisappinterface.cpp
===================================================================
--- trunk/qgis/src/app/qgisappinterface.cpp 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/src/app/qgisappinterface.cpp 2010-01-23 21:50:09 UTC (rev 12828)
@@ -198,6 +198,14 @@
}
}
+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 ); }
Modified: trunk/qgis/src/app/qgisappinterface.h
===================================================================
--- trunk/qgis/src/app/qgisappinterface.h 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/src/app/qgisappinterface.h 2010-01-23 21:50:09 UTC (rev 12828)
@@ -115,6 +115,8 @@
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 );
Modified: trunk/qgis/src/gui/qgisinterface.h
===================================================================
--- trunk/qgis/src/gui/qgisinterface.h 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/src/gui/qgisinterface.h 2010-01-23 21:50:09 UTC (rev 12828)
@@ -31,7 +31,6 @@
#include <map>
-class QgisApp;
class QgsComposerView;
class QgsMapLayer;
class QgsMapCanvas;
@@ -135,9 +134,16 @@
/** 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;
Modified: trunk/qgis/src/gui/qgslegendinterface.h
===================================================================
--- trunk/qgis/src/gui/qgslegendinterface.h 2010-01-23 19:59:14 UTC (rev 12827)
+++ trunk/qgis/src/gui/qgslegendinterface.h 2010-01-23 21:50:09 UTC (rev 12828)
@@ -60,9 +60,9 @@
//! 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
More information about the QGIS-commit
mailing list