Diffstat (limited to 'development/translation/shared/metatranslator.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | development/translation/shared/metatranslator.h | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/development/translation/shared/metatranslator.h b/development/translation/shared/metatranslator.h new file mode 100644 index 0000000..d35b202 --- a/dev/null +++ b/development/translation/shared/metatranslator.h | |||
@@ -0,0 +1,99 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qt Linguist. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef METATRANSLATOR_H | ||
22 | #define METATRANSLATOR_H | ||
23 | |||
24 | #include <qmap.h> | ||
25 | #include <qstring.h> | ||
26 | #include <qtranslator.h> | ||
27 | #include <qvaluelist.h> | ||
28 | |||
29 | class QTextCodec; | ||
30 | |||
31 | class MetaTranslatorMessage : public QTranslatorMessage | ||
32 | { | ||
33 | public: | ||
34 | enum Type { Unfinished, Finished, Obsolete }; | ||
35 | |||
36 | MetaTranslatorMessage(); | ||
37 | MetaTranslatorMessage( const char *context, const char *sourceText, | ||
38 | const char *comment, | ||
39 | const QString& translation = QString::null, | ||
40 | bool utf8 = FALSE, Type type = Unfinished ); | ||
41 | MetaTranslatorMessage( const MetaTranslatorMessage& m ); | ||
42 | |||
43 | MetaTranslatorMessage& operator=( const MetaTranslatorMessage& m ); | ||
44 | |||
45 | void setType( Type nt ) { ty = nt; } | ||
46 | Type type() const { return ty; } | ||
47 | bool utf8() const { return utfeight; } | ||
48 | |||
49 | bool operator==( const MetaTranslatorMessage& m ) const; | ||
50 | bool operator!=( const MetaTranslatorMessage& m ) const | ||
51 | { return !operator==( m ); } | ||
52 | bool operator<( const MetaTranslatorMessage& m ) const; | ||
53 | bool operator<=( const MetaTranslatorMessage& m ) | ||
54 | { return !operator>( m ); } | ||
55 | bool operator>( const MetaTranslatorMessage& m ) const | ||
56 | { return this->operator<( m ); } | ||
57 | bool operator>=( const MetaTranslatorMessage& m ) const | ||
58 | { return !operator<( m ); } | ||
59 | |||
60 | private: | ||
61 | bool utfeight; | ||
62 | Type ty; | ||
63 | }; | ||
64 | |||
65 | class MetaTranslator | ||
66 | { | ||
67 | public: | ||
68 | MetaTranslator(); | ||
69 | MetaTranslator( const MetaTranslator& tor ); | ||
70 | |||
71 | MetaTranslator& operator=( const MetaTranslator& tor ); | ||
72 | |||
73 | bool load( const QString& filename ); | ||
74 | bool save( const QString& filename ) const; | ||
75 | bool release( const QString& filename, bool verbose = FALSE ) const; | ||
76 | |||
77 | bool contains( const char *context, const char *sourceText, | ||
78 | const char *comment ) const; | ||
79 | void insert( const MetaTranslatorMessage& m ); | ||
80 | |||
81 | void stripObsoleteMessages(); | ||
82 | void stripEmptyContexts(); | ||
83 | |||
84 | void setCodec( const char *name ); | ||
85 | QString toUnicode( const char *str, bool utf8 ) const; | ||
86 | |||
87 | QValueList<MetaTranslatorMessage> messages() const; | ||
88 | QValueList<MetaTranslatorMessage> translatedMessages() const; | ||
89 | |||
90 | private: | ||
91 | typedef QMap<MetaTranslatorMessage, int> TMM; | ||
92 | typedef QMap<int, MetaTranslatorMessage> TMMInv; | ||
93 | |||
94 | TMM mm; | ||
95 | QCString codecName; | ||
96 | QTextCodec *codec; | ||
97 | }; | ||
98 | |||
99 | #endif | ||