KProperty

KColorCollection.h
1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Waldo Bastian (bastian@kde.org)
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; version
7 2 of the License.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19//-----------------------------------------------------------------------------
20// KDE color collection.
21
22#ifndef KDELIBS_KCOLORCOLLECTION_H
23#define KDELIBS_KCOLORCOLLECTION_H
24
25#include <QColor>
26#include <QStringList>
27
28/**
29 * Class for handling color collections ("palettes").
30 *
31 * This class makes it easy to handle color collections, sometimes referred to
32 * as "palettes". This class can read and write collections from and to a file.
33 *
34 * This class uses the "GIMP" palette file format.
35 *
36 * @author Waldo Bastian (bastian@kde.org)
37 **/
39{
40public:
41 /**
42 * Query which KDE color collections are installed.
43 *
44 * @return A list with installed color collection names.
45 */
47
48 /**
49 * KColorCollection constructor. Creates a KColorCollection from a file
50 * the filename is derived from the name.
51 * @param name The name of collection as returned by installedCollections()
52 **/
53 explicit KColorCollection(const QString &name = QString());
54
55 /**
56 * KColorCollection copy constructor.
57 **/
59
60 /**
61 * KColorCollection destructor.
62 **/
64
65 /**
66 * KColorCollection assignment operator
67 **/
69
70 /**
71 * Save the collection
72 *
73 * @return 'true' if successful
74 **/
75 bool save();
76
77 /**
78 * Get the description of the collection.
79 * @return the description of the collection.
80 **/
81 QString description() const;
82
83 /**
84 * Set the description of the collection.
85 * @param desc the new description
86 **/
87 void setDescription(const QString &desc);
88
89 /**
90 * Get the name of the collection.
91 * @return the name of the collection
92 **/
93 QString name() const;
94
95 /**
96 * Set the name of the collection.
97 * @param name the name of the collection
98 **/
99 void setName(const QString &name);
100
101 /**
102 * Used to specify whether a collection may be edited.
103 * @see editable()
104 * @see setEditable()
105 */
106 enum Editable { Yes, ///< Collection may be edited
107 No, ///< Collection may not be edited
108 Ask ///< Ask user before editing
109 };
110
111 /**
112 * Returns whether the collection may be edited.
113 * @return the state of the collection
114 **/
115 Editable editable() const;
116
117 /**
118 * Change whether the collection may be edited.
119 * @param editable the state of the collection
120 **/
121 void setEditable(Editable editable);
122
123 /**
124 * Return the number of colors in the collection.
125 * @return the number of colors
126 **/
127 int count() const;
128
129 /**
130 * Find color by index.
131 * @param index the index of the desired color
132 * @return The @p index -th color of the collection, null if not found.
133 **/
134 QColor color(int index) const;
135
136 /**
137 * Find index by @p color.
138 * @param color the color to find
139 * @return The index of the color in the collection or -1 if the
140 * color is not found.
141 **/
142 int findColor(const QColor &color) const;
143
144 /**
145 * Find color name by @p index.
146 * @param index the index of the color
147 * @return The name of the @p index -th color.
148 * Note that not all collections have named the colors. Null is
149 * returned if the color does not exist or has no name.
150 **/
151 QString name(int index) const;
152
153 /**
154 * Find color name by @p color.
155 * @return The name of color according to this collection.
156 * Note that not all collections have named the colors.
157 * Note also that each collection can give the same color
158 * a different name.
159 **/
160 QString name(const QColor &color) const;
161
162 /**
163 * Add a color.
164 * @param newColor The color to add.
165 * @param newColorName The name of the color, null to remove
166 * the name.
167 * @return The index of the added color.
168 **/
169 int addColor(const QColor &newColor,
170 const QString &newColorName = QString());
171
172 /**
173 * Change a color.
174 * @param index Index of the color to change
175 * @param newColor The new color.
176 * @param newColorName The new color name, null to remove
177 * the name.
178 * @return The index of the new color or -1 if the color couldn't
179 * be changed.
180 **/
181 int changeColor(int index,
182 const QColor &newColor,
183 const QString &newColorName = QString());
184
185 /**
186 * Change a color.
187 * @param oldColor The original color
188 * @param newColor The new color.
189 * @param newColorName The new color name, null to remove
190 * the name.
191 * @return The index of the new color or -1 if the color couldn't
192 * be changed.
193 **/
194 int changeColor(const QColor &oldColor,
195 const QColor &newColor,
196 const QString &newColorName = QString());
197
198private:
199 class KColorCollectionPrivate *d;
200};
201
202#endif // KDELIBS_KCOLORCOLLECTION_H
203
int changeColor(const QColor &oldColor, const QColor &newColor, const QString &newColorName=QString())
KColorCollection & operator=(const KColorCollection &)
void setName(const QString &name)
Editable editable() const
QString name() const
void setDescription(const QString &desc)
QString description() const
QColor color(int index) const
void setEditable(Editable editable)
KColorCollection(const KColorCollection &)
static QStringList installedCollections()
int findColor(const QColor &color) const
int addColor(const QColor &newColor, const QString &newColorName=QString())
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 3 2024 11:46:25 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.