QGIS API Documentation  3.0.2-Girona (307d082)
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 "qgis_core.h"
22 #include "qgscolorscheme.h"
23 #include <QList>
24 
34 class CORE_EXPORT QgsColorSchemeRegistry
35 {
36 
37  public:
38 
42  QgsColorSchemeRegistry() = default;
43 
44  virtual ~QgsColorSchemeRegistry();
45 
51  void populateFromInstance();
52 
59  void addDefaultSchemes();
60 
67  void addUserSchemes();
68 
76  void addColorScheme( QgsColorScheme *scheme SIP_TRANSFER );
77 
84  bool removeColorScheme( QgsColorScheme *scheme );
85 
90  QList<QgsColorScheme *> schemes() const;
91 
97  QList<QgsColorScheme *> schemes( const QgsColorScheme::SchemeFlag flag ) const;
98 
99 
105 #ifndef SIP_RUN
106  template<class T> void schemes( QList<T *> &schemeList )
107  {
108  schemeList.clear();
109  QList<QgsColorScheme *> schemeInstanceList = schemes();
110  QList<QgsColorScheme *>::iterator schemeIt = schemeInstanceList.begin();
111  for ( ; schemeIt != schemeInstanceList.end(); ++schemeIt )
112  {
113  T *scheme = dynamic_cast<T *>( *schemeIt );
114  if ( scheme )
115  {
116  schemeList.push_back( scheme );
117  }
118  }
119  }
120 #endif
121 
122  private:
123 
124  QList< QgsColorScheme * > mColorSchemeList;
125 
126 };
127 
128 
129 
130 #endif
Registry of color schemes.
void schemes(QList< T *> &schemeList)
Return color schemes of a specific type.
Abstract base class for color schemes.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
SchemeFlag
Flags for controlling behavior of color scheme.