1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*
* This file is part of the KDE project
*
* Copyright (c) 2005 Boudewijn Rempt <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _KIS_ID_H_
#define _KIS_ID_H_
#include <qvaluelist.h>
#include <qstring.h>
/**
* Krita has a large number of extensible resources. Think:
*
* - Brushes
* - Palettes
* - Patterns
* - Gradients
* - Color models
* - Filters
* - Composition operations
* - Paint operations
* - Tools
* - Docker tabs
*
* and more...
*
* Many of these resources are stored in KisGenericRegistry-based
* registries. If we store these resources with a descriptive string
* as a key use the same string in our UI, then our UI will not be
* localizable, because the identifications of particular resources
* will be stored in files, and those files need to be exchangeable.
*
* So, instead we use and ID class that couples an identification
* string that will be the same across all languages, an i18n-able
* string that will be used in comboboxes and that has a fast equality
* operator to make it well suited for use as key in a registry map.
*
* That last bit has not been solved yet.
*
*/
class KisID {
public:
KisID() : m_id(QString::null), m_name(QString::null) {}
KisID(const QString & id, const QString & name = QString::null)
: m_id(id),
m_name(name) {};
QString id() const { return m_id; };
QString name() const { return m_name; };
friend inline bool operator==(const KisID &, const KisID &);
friend inline bool operator!=(const KisID &, const KisID &);
friend inline bool operator<(const KisID &, const KisID &);
friend inline bool operator>(const KisID &, const KisID &);
private:
QString m_id;
QString m_name;
};
inline bool operator==(const KisID &v1, const KisID &v2)
{
return v1.m_id == v2.m_id;
}
inline bool operator!=(const KisID &v1, const KisID &v2)
{
return v1.m_id != v2.m_id;
}
inline bool operator<(const KisID &v1, const KisID &v2)
{
return v1.m_id < v2.m_id;
}
inline bool operator>(const KisID &v1, const KisID &v2)
{
return v1.m_id < v2.m_id;
}
typedef QValueList<KisID> KisIDList;
#endif // _KIS_ID_H_
|