[QGIS-trac] [Quantum GIS] #2392: Plugin layer registry

Quantum GIS qgis at qgis.org
Mon Jan 25 10:28:00 EST 2010


#2392: Plugin layer registry
------------------------------------------------+---------------------------
   Reporter:  mwalker                           |              Owner:  borysiasty
       Type:  enhancement                       |             Status:  new       
   Priority:  major: does not work as expected  |          Milestone:            
  Component:  Python plugins and bindings       |            Version:  HEAD      
   Keywords:  plugin layer                      |   Platform_version:            
   Platform:  All                               |           Must_fix:  No        
Status_info:  0                                 |  
------------------------------------------------+---------------------------
 This patch adds a plugin layer registry to support plugin specific
 maplayers.

 Plugins can register a function that creates the specific subclass of
 !QgsMapLayer. This allows to instantiate the corresponding plugin layer
 when reading the project file.

 === Workflow ===
 see sample plugin for details

  * create subclass of `QgsMapLayer`
    * implement `isEditable()`, `draw()` and `writeXml()`

  * create subclass of `QgsPluginLayerCreator`
    * implement `createLayer()` e.g. as callback to a plugin function

  * init plugin
    * register !PluginLayerCreator using
 `QgsPluginLayerRegistry.instance().addCreator()`

  * add layer
    * create !PluginMapLayer instance of layer type
 `QgsMapLayer.PluginLayer`
    * add layer using `QgsMapLayerRegistry.instance().addMapLayer()`

  * save project
    * calls `PluginMapLayer.writeXml()`
    * save plugin id string as attribute `"type"`

  * load project
    * `QgsPluginLayerRegistry` calls `createLayer()` for all registered
 `QgsPluginLayerCreators`
    * plugin creates and adds a new !PluginMapLayer instance if the
 attribute `"type"` matches their id string

  * unload plugin
    * unregister !PluginLayerCreator using
 `QgsPluginLayerRegistry.instance().removeCreator()`

-- 
Ticket URL: <https://trac.osgeo.org/qgis/ticket/2392>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list