QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
qgscolorscheme.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscolorscheme.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 QGSCOLORSCHEME_H
19 #define QGSCOLORSCHEME_H
20 
21 #include <QString>
22 #include <QColor>
23 #include <QPair>
24 
28 typedef QList< QPair< QColor, QString > > QgsNamedColorList;
29 
39 class CORE_EXPORT QgsColorScheme
40 {
41  public:
42 
44 
45  virtual ~QgsColorScheme();
46 
50  virtual QString schemeName() const = 0;
51 
62  virtual QgsNamedColorList fetchColors( const QString context = QString(),
63  const QColor baseColor = QColor() ) = 0;
64 
69  virtual bool isEditable() const { return false; }
70 
78  virtual bool setColors( const QgsNamedColorList colors, const QString context = QString(), const QColor baseColor = QColor() );
79 
83  virtual QgsColorScheme* clone() const = 0;
84 };
85 
91 class CORE_EXPORT QgsRecentColorScheme : public QgsColorScheme
92 {
93  public:
94 
96 
97  virtual ~QgsRecentColorScheme();
98 
99  virtual QString schemeName() const { return QT_TR_NOOP( "Recent colors" ); }
100 
101  virtual QgsNamedColorList fetchColors( const QString context = QString(),
102  const QColor baseColor = QColor() );
103 
104  QgsColorScheme* clone() const;
105 };
106 
112 class CORE_EXPORT QgsCustomColorScheme : public QgsColorScheme
113 {
114  public:
115 
117 
118  virtual ~QgsCustomColorScheme();
119 
120  virtual QString schemeName() const { return QT_TR_NOOP( "Standard colors" ); }
121 
122  virtual QgsNamedColorList fetchColors( const QString context = QString(),
123  const QColor baseColor = QColor() );
124 
125  virtual bool isEditable() const { return true; }
126 
127  virtual bool setColors( const QgsNamedColorList colors, const QString context = QString(), const QColor baseColor = QColor() );
128 
129  QgsColorScheme* clone() const;
130 };
131 
137 class CORE_EXPORT QgsProjectColorScheme : public QgsColorScheme
138 {
139  public:
140 
142 
143  virtual ~QgsProjectColorScheme();
144 
145  virtual QString schemeName() const { return QT_TR_NOOP( "Project colors" ); }
146 
147  virtual QgsNamedColorList fetchColors( const QString context = QString(),
148  const QColor baseColor = QColor() );
149 
150  virtual bool isEditable() const { return true; }
151 
152  virtual bool setColors( const QgsNamedColorList colors, const QString context = QString(), const QColor baseColor = QColor() );
153 
154  QgsColorScheme* clone() const;
155 };
156 
157 #endif
A color scheme which contains custom colors set through QGIS app options dialog.
Definition: qgscolorscheme.h:112
virtual QString schemeName() const
Gets the name for the color scheme.
Definition: qgscolorscheme.h:99
virtual bool isEditable() const
Returns whether the color scheme is editable.
Definition: qgscolorscheme.h:125
A color scheme which contains project specific colors set through project properties dialog...
Definition: qgscolorscheme.h:137
virtual QgsColorScheme * clone() const =0
Clones a color scheme.
Abstract base class for color schemes.
Definition: qgscolorscheme.h:39
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.
Definition: qgscolorscheme.h:28
virtual bool isEditable() const
Returns whether the color scheme is editable.
Definition: qgscolorscheme.h:150
virtual bool setColors(const QgsNamedColorList colors, const QString context=QString(), const QColor baseColor=QColor())
Sets the colors for the scheme.
Definition: qgscolorscheme.cpp:34
virtual bool isEditable() const
Returns whether the color scheme is editable.
Definition: qgscolorscheme.h:69
virtual QString schemeName() const
Gets the name for the color scheme.
Definition: qgscolorscheme.h:120
A color scheme which contains the most recently used colors.
Definition: qgscolorscheme.h:91
virtual QString schemeName() const
Gets the name for the color scheme.
Definition: qgscolorscheme.h:145
virtual QgsNamedColorList fetchColors(const QString context=QString(), const QColor baseColor=QColor())=0
Gets a list of colors from the scheme.