QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrendererv2registry.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrendererv2registry.cpp
3  ---------------------
4  begin : November 2009
5  copyright : (C) 2009 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #include "qgsrendererv2registry.h"
16 
17 // default renderers
21 #include "qgsrulebasedrendererv2.h"
24 #include "qgsheatmaprenderer.h"
25 
27 {
28  // add default renderers
29  addRenderer( new QgsRendererV2Metadata( "singleSymbol",
30  QObject::tr( "Single Symbol" ),
33 
34  addRenderer( new QgsRendererV2Metadata( "categorizedSymbol",
35  QObject::tr( "Categorized" ),
37 
38  addRenderer( new QgsRendererV2Metadata( "graduatedSymbol",
39  QObject::tr( "Graduated" ),
41 
42  addRenderer( new QgsRendererV2Metadata( "RuleRenderer",
43  QObject::tr( "Rule-based" ),
46 
47  addRenderer( new QgsRendererV2Metadata( "pointDisplacement",
48  QObject::tr( "Point displacement" ),
50 
51  addRenderer( new QgsRendererV2Metadata( "invertedPolygonRenderer",
52  QObject::tr( "Inverted polygons" ),
54 
55  addRenderer( new QgsRendererV2Metadata( "heatmapRenderer",
56  QObject::tr( "Heatmap" ),
58 }
59 
61 {
62  foreach ( QString name, mRenderers.keys() )
63  {
64  delete mRenderers[name];
65  }
66  mRenderers.clear();
67 }
68 
70 {
71  static QgsRendererV2Registry mInstance;
72  return &mInstance;
73 }
74 
75 
77 {
78  if ( metadata == NULL || mRenderers.contains( metadata->name() ) )
79  return false;
80 
81  mRenderers[metadata->name()] = metadata;
82  mRenderersOrder << metadata->name();
83  return true;
84 }
85 
86 bool QgsRendererV2Registry::removeRenderer( QString rendererName )
87 {
88  if ( !mRenderers.contains( rendererName ) )
89  return false;
90 
91  delete mRenderers[rendererName];
92  mRenderers.remove( rendererName );
93  mRenderersOrder.removeAll( rendererName );
94  return true;
95 }
96 
98 {
99  return mRenderers.value( rendererName );
100 }
101 
103 
105 {
106  return mRenderersOrder;
107 }