QGIS API Documentation  2.0.1-Dufour
 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 
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  addRenderer( new QgsRendererV2Metadata( "graduatedSymbol",
38  QObject::tr( "Graduated" ),
40 
41  addRenderer( new QgsRendererV2Metadata( "RuleRenderer",
42  QObject::tr( "Rule-based" ),
45 
46  addRenderer( new QgsRendererV2Metadata( "pointDisplacement",
47  QObject::tr( "Point displacement" ),
49 }
50 
52 {
53  foreach ( QString name, mRenderers.keys() )
54  {
55  delete mRenderers[name];
56  }
57  mRenderers.clear();
58 }
59 
61 {
62  if ( !mInstance )
64 
65  return mInstance;
66 }
67 
68 
70 {
71  if ( metadata == NULL || mRenderers.contains( metadata->name() ) )
72  return false;
73 
74  mRenderers[metadata->name()] = metadata;
75  mRenderersOrder << metadata->name();
76  return true;
77 }
78 
79 bool QgsRendererV2Registry::removeRenderer( QString rendererName )
80 {
81  if ( !mRenderers.contains( rendererName ) )
82  return false;
83 
84  delete mRenderers[rendererName];
85  mRenderers.remove( rendererName );
86  mRenderersOrder.removeAll( rendererName );
87  return true;
88 }
89 
91 {
92  return mRenderers.value( rendererName );
93 }
94 
96 {
97  return mRenderersOrder;
98 }