1 | /* This file is part of the KDE project |
2 | Copyright 2000-2006 The KSpread Team <calligra-devel@kde.org> |
3 | Copyright 1998,1999 Torben Weis <weis@kde.org> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. |
9 | |
10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef CALLIGRA_SHEETS_CURRENCY |
22 | #define CALLIGRA_SHEETS_CURRENCY |
23 | |
24 | #include <QHash> |
25 | #include <QMetaType> |
26 | |
27 | #include "calligra_sheets_export.h" |
28 | |
29 | namespace Calligra |
30 | { |
31 | namespace Sheets |
32 | { |
33 | |
34 | /** |
35 | * \ingroup Style |
36 | * \class Currency |
37 | * Currency format information. |
38 | */ |
39 | class CALLIGRA_SHEETS_ODF_EXPORT Currency |
40 | { |
41 | public: |
42 | enum Format { Native, Gnumeric, OpenCalc, ApplixSpread, GobeProductiveSpread, HancomSheet }; |
43 | |
44 | /** |
45 | * Constructor. |
46 | * Creates a currency corresponding to the given currency table index. |
47 | * If \p index is omitted or zero, a currency with the locale default |
48 | * currency unit is created. |
49 | */ |
50 | explicit Currency(int index = 0); |
51 | |
52 | /** |
53 | * Constructor. |
54 | * Creates a currency corresponding to \p code . |
55 | * Looks up the index. |
56 | * If the code is found more than once: saved without country info. |
57 | * If the code is not found, \p code is handled as custom unit. |
58 | * \p code e.g. EUR, USD,.. |
59 | * \param format in Gnumeric the code is: [$EUR] |
60 | */ |
61 | explicit Currency(QString const & code, Format format = Native); |
62 | |
63 | /** |
64 | * Destructor. |
65 | */ |
66 | ~Currency(); |
67 | |
68 | |
69 | bool operator==(Currency const & other) const; |
70 | inline bool operator!=(Currency const & other) const { |
71 | return !operator==(other); |
72 | } |
73 | |
74 | QString code(Format format = Native) const; |
75 | QString country() const; |
76 | QString name() const; |
77 | QString symbol() const; |
78 | int index() const; |
79 | |
80 | static QString chooseString(int type, bool & ok); |
81 | |
82 | private: |
83 | int m_index; |
84 | QString m_code; |
85 | }; |
86 | |
87 | static inline uint qHash(const Currency& cur) { |
88 | return ::qHash(cur.code()); |
89 | } |
90 | |
91 | } // namespace Sheets |
92 | } // namespace Calligra |
93 | |
94 | Q_DECLARE_METATYPE(Calligra::Sheets::Currency) |
95 | |
96 | #endif |
97 | |