-
-
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] Support for custom plugin layers. Applied patch from #2392 …
…contributed by Mathias Walker. Thanks! Some parts modified to make plugin layers easier to use and more robust. git-svn-id: http://svn.osgeo.org/qgis/trunk@12834 c8812cc2-4d05-0410-92ff-de0c093fc19c
- Loading branch information
wonder
committed
Jan 26, 2010
1 parent
d8e8ee4
commit 8f32f25
Showing
14 changed files
with
387 additions
and
7 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
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,14 @@ | ||
|
||
class QgsPluginLayer : QgsMapLayer | ||
{ | ||
%TypeHeaderCode | ||
#include "qgspluginlayer.h" | ||
%End | ||
|
||
public: | ||
QgsPluginLayer(QString layerType, QString layerName = QString()); | ||
|
||
/** return plugin layer type (the same as used in QgsPluginLayerRegistry) */ | ||
QString pluginLayerType(); | ||
|
||
}; |
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,52 @@ | ||
|
||
class QgsPluginLayerType | ||
{ | ||
%TypeHeaderCode | ||
#include "qgspluginlayerregistry.h" | ||
%End | ||
public: | ||
|
||
QgsPluginLayerType(QString name); | ||
virtual ~QgsPluginLayerType(); | ||
|
||
QString name(); | ||
|
||
/** return new layer of this type. Return NULL on error */ | ||
virtual QgsPluginLayer* createLayer() /Factory/; | ||
|
||
/** show plugin layer properties dialog. Return FALSE if the dialog cannot be shown. */ | ||
virtual bool showLayerProperties(QgsPluginLayer* layer); | ||
|
||
}; | ||
|
||
|
||
class QgsPluginLayerRegistry | ||
{ | ||
%TypeHeaderCode | ||
#include "qgspluginlayerregistry.h" | ||
%End | ||
public: | ||
|
||
/** means of accessing canonical single instance */ | ||
static QgsPluginLayerRegistry* instance(); | ||
|
||
~QgsPluginLayerRegistry(); | ||
|
||
/** add plugin layer type (take ownership) and return TRUE on success */ | ||
bool addPluginLayerType(QgsPluginLayerType* pluginLayerType /Transfer/); | ||
|
||
/** remove plugin layer type and return TRUE on success */ | ||
bool removePluginLayerType(QString typeName); | ||
|
||
/** return plugin layer type metadata or NULL if doesn't exist */ | ||
QgsPluginLayerType* pluginLayerType(QString typeName); | ||
|
||
/** return new layer if corresponding plugin has been found, else return NULL */ | ||
// to be resolved | ||
//QgsPluginLayer* createLayer(QString typeName); | ||
|
||
private: | ||
|
||
/** private since instance() creates it */ | ||
QgsPluginLayerRegistry(); | ||
}; |
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
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,11 @@ | ||
#include "qgspluginlayer.h" | ||
|
||
QgsPluginLayer::QgsPluginLayer( QString layerType, QString layerName ) | ||
: QgsMapLayer( PluginLayer, layerName ), mPluginLayerType( layerType ) | ||
{ | ||
} | ||
|
||
QString QgsPluginLayer::pluginLayerType() | ||
{ | ||
return mPluginLayerType; | ||
} |
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,28 @@ | ||
#ifndef QGSPLUGINLAYER_H | ||
#define QGSPLUGINLAYER_H | ||
|
||
#include "qgsmaplayer.h" | ||
|
||
/** \ingroup core | ||
Base class for plugin layers. These can be implemented by plugins | ||
and registered in QgsPluginLayerRegistry. | ||
In order to be readable from project files, they should set these attributes in layer DOM node: | ||
"type" = "plugin" | ||
"name" = "your_layer_type" | ||
*/ | ||
class CORE_EXPORT QgsPluginLayer : public QgsMapLayer | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QgsPluginLayer( QString layerType, QString layerName = QString() ); | ||
|
||
/** return plugin layer type (the same as used in QgsPluginLayerRegistry) */ | ||
QString pluginLayerType(); | ||
|
||
protected: | ||
QString mPluginLayerType; | ||
}; | ||
|
||
#endif // QGSPLUGINLAYER_H |
Oops, something went wrong.