QGIS API Documentation  2.2.0-Valmiera
 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"
23 
25 {
26  // add default renderers
27  addRenderer( new QgsRendererV2Metadata( "singleSymbol",
28  QObject::tr( "Single Symbol" ),
31 
32  addRenderer( new QgsRendererV2Metadata( "categorizedSymbol",
33  QObject::tr( "Categorized" ),
35  addRenderer( new QgsRendererV2Metadata( "graduatedSymbol",
36  QObject::tr( "Graduated" ),
38 
39  addRenderer( new QgsRendererV2Metadata( "RuleRenderer",
40  QObject::tr( "Rule-based" ),
43 
44  addRenderer( new QgsRendererV2Metadata( "pointDisplacement",
45  QObject::tr( "Point displacement" ),
47 }
48 
50 {
51  foreach ( QString name, mRenderers.keys() )
52  {
53  delete mRenderers[name];
54  }
55  mRenderers.clear();
56 }
57 
59 {
60  static QgsRendererV2Registry mInstance;
61  return &mInstance;
62 }
63 
64 
66 {
67  if ( metadata == NULL || mRenderers.contains( metadata->name() ) )
68  return false;
69 
70  mRenderers[metadata->name()] = metadata;
71  mRenderersOrder << metadata->name();
72  return true;
73 }
74 
75 bool QgsRendererV2Registry::removeRenderer( QString rendererName )
76 {
77  if ( !mRenderers.contains( rendererName ) )
78  return false;
79 
80  delete mRenderers[rendererName];
81  mRenderers.remove( rendererName );
82  mRenderersOrder.removeAll( rendererName );
83  return true;
84 }
85 
87 {
88  return mRenderers.value( rendererName );
89 }
90 
92 
94 {
95  return mRenderersOrder;
96 }