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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
/* ****************************************************************************
This file is part of KBabel
Copyright (C) 1999-2000 by Matthias Kiefer <matthias.kiefer@gmx.de>
2002-2003 by Stanislav Visnovsky <visnovsky@kde.org>
Copyright (C) 2006 by Nicolas GOUTTE <goutte@kde.org>
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.
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the TQt library by Trolltech AS, Norway (or with modified versions
of TQt that use the same license as TQt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
TQt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
**************************************************************************** */
#ifndef CATALOGITEM_H
#define CATALOGITEM_H
#include <tqstringlist.h>
#include <tqptrlist.h>
#include "pluralforms.h"
#include "editcmd.h"
#include "catalogfileplugin.h"
#include "kbproject.h"
class TQTextStream;
class GettextFlexLexer;
namespace KBabel
{
class RegExpExtractor;
class CatalogItemPrivate;
/**
* This class represents an entry in a catalog.
* It contains the comment, the Msgid and the Msgstr.
* It defines some functions to query the state of the entry
* (fuzzy, untranslated, cformat).
*
* @short Class, representing an entry in a catalog
* @author Matthias Kiefer <matthias.kiefer@gmx.de>
*/
class TDE_EXPORT CatalogItem
{
public:
/** Constructor for empty item*/
CatalogItem(Project::Ptr project = 0);
/** Copy constructor */
CatalogItem(const CatalogItem&);
/** Destructor */
~CatalogItem();
/**
* returns true, if the translation is fuzzy, this means
* if the string ", fuzzy" is contained in the comment
*/
bool isFuzzy() const;
/**
* returns true, if the translation in c-format, this means
* if the string ", c-format" is contained in the comment
* @since 1.11.2 (KDE 3.5.2) not only "c-format" is supported but also
* "possible-c-format" (from the debug parameter of xgettext)
*/
bool isCformat() const;
/**
* returns true, if the string ", no-c-format" is contained in the comment
*/
bool isNoCformat() const;
/**
* returns true, if the translation in qt-format, this means
* if the string ", qt-format" is contained in the comment
* @since 1.11.2 (KDE 3.5.2)
*/
bool isTQtformat() const;
/**
* returns true,
* if the string ", no-qt-format" is contained in the comment
* @since 1.11.2 (KDE 3.5.2)
*/
bool isNoTQtformat() const;
/**
* returns true, if the Msgid is untranslated, this means the
* Msgstr is empty
*/
bool isUntranslated() const;
/**
* @return type of the plural form, is any
*/
PluralFormType pluralForm() const;
bool isValid() const;
void setSyntaxError(bool);
/** returns the number of lines, the entry will need in a file */
int totalLines() const;
/**
* removes the string ", fuzzy" from the comment
* @param doIt if false, the comment is not changed, just the
* commands for doing it are calculated
*/
TQPtrList<EditCommand> removeFuzzy(bool doIt=true);
/**
* adds the string ", fuzzy" to the comment
* @param doIt if false, the comment is not changed, just the
* commands for doing it are calculated
*/
TQPtrList<EditCommand> addFuzzy(bool doIt=true);
/** cleares the item */
void clear();
/** returns the comment of this entry */
TQString comment() const;
/** returns the msgctxt of this entry */
TQString msgctxt(const bool noNewlines = false) const;
/** returns the msgid of the entry */
TQStringList msgid(const bool noNewlines = false) const;
/** returns the msgstr of the entry */
TQStringList msgstr(const bool noNewlines = false) const;
/**
* @param pluralNr If this item is a gettext plural form item,
* it returns the plural form number pluralNr, else always the msgstr
* is returned
* @return the msgstr as list
*/
TQStringList msgstrAsList(int pluralNr=0) const;
void setComment(TQString com);
void setMsgctxt(TQString msg);
void setMsgid(TQString msg);
void setMsgid(TQStringList msg);
void setMsgstr(TQString msg);
void setMsgstr(TQStringList msg);
void setGettextPluralForm( bool _gettextPlurals );
void processCommand(EditCommand* cmd, bool undo=false);
Project::Ptr project() const;
/** @return a list of tags in the msgid */
TQStringList tagList( RegExpExtractor& tagExtractor );
/** @return a list of args in the msgid */
TQStringList argList( RegExpExtractor& argExtractor);
/**
* @return the list of all errors of this item
*/
TQStringList errors() const;
TQString nextError() const;
void clearErrors();
void removeError(const TQString& error);
void appendError(const TQString& error);
/**
* makes some sanity checks and set status accordingly
* @return the new status of this item
* @see CatalogItem::Error
* @param accelMarker a char, that marks the keyboard accelerators
* @param contextInfo a regular expression, that determines what is
* the context information
* @param singularPlural a regular expression, that determines what is
* string with singular and plural form
* @param neededLines how many lines a string with singular-plural form
* must have
*/
int checkErrors(TQChar accelMarker, const TQRegExp& contextInfo
, const TQRegExp& singularPlural, const int neededLines);
void operator=(const CatalogItem& rhs);
private:
void setProject( Project::Ptr project );
friend class Catalog;
private:
CatalogItemPrivate* d;
};
}
#endif // CATALOGITEM_H
|