~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/sdk/kis_id.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

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