QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgscolorschemeregistry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscolorschemeregistry.h
3  ------------------------
4  begin : July 2014
5  copyright : (C) 2014 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSCOLORSCHEMEREGISTRY_H
19 #define QGSCOLORSCHEMEREGISTRY_H
20 
21 #include "qgscolorscheme.h"
22 #include <QList>
23 
32 class CORE_EXPORT QgsColorSchemeRegistry
33 {
34 
35  public:
36 
39  static QgsColorSchemeRegistry * instance();
40 
44 
45  virtual ~QgsColorSchemeRegistry();
46 
51  void populateFromInstance();
52 
58  void addDefaultSchemes();
59 
65  void addUserSchemes();
66 
73  void addColorScheme( QgsColorScheme* scheme );
74 
80  bool removeColorScheme( QgsColorScheme* scheme );
81 
85  QList<QgsColorScheme *> schemes() const;
86 
91  QList<QgsColorScheme *> schemes( const QgsColorScheme::SchemeFlag flag ) const;
92 
97  template<class T> void schemes( QList<T*>& schemeList );
98 
99  private:
100 
101  static QgsColorSchemeRegistry *mInstance;
102 
103  QList< QgsColorScheme* > mColorSchemeList;
104 
105 };
106 
107 template<class T> void QgsColorSchemeRegistry::schemes( QList<T*>& schemeList )
108 {
109  schemeList.clear();
110  QList<QgsColorScheme *> schemeInstanceList = schemes();
111  QList<QgsColorScheme *>::iterator schemeIt = schemeInstanceList.begin();
112  for ( ; schemeIt != schemeInstanceList.end(); ++schemeIt )
113  {
114  T* scheme = dynamic_cast<T*>( *schemeIt );
115  if ( scheme )
116  {
117  schemeList.push_back( scheme );
118  }
119  }
120 }
121 
122 #endif