2 KNode, the KDE newsreader
3 Copyright (c) 1999-2006 the KNode authors.
4 See file AUTHORS for details
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 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software Foundation,
12 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
17 #include "kndisplayedheader.h"
20 // some standard headers
21 static QStringList predef
;
23 // default display names KNode uses
24 static const char *disp
[] = { "Groups", 0 };
28 i18nc("collection of article headers","Approved");
29 i18nc("collection of article headers","Content-Transfer-Encoding");
30 i18nc("collection of article headers","Content-Type");
31 i18nc("collection of article headers","Control");
32 i18nc("collection of article headers","Date");
33 i18nc("collection of article headers","Distribution");
34 i18nc("collection of article headers","Expires");
35 i18nc("collection of article headers","Followup-To");
36 i18nc("collection of article headers","From");
37 i18nc("collection of article headers","Lines");
38 i18nc("collection of article headers","Mail-Copies-To");
39 i18nc("collection of article headers","Message-ID");
40 i18nc("collection of article headers","Mime-Version");
41 i18nc("collection of article headers","NNTP-Posting-Host");
42 i18nc("collection of article headers","Newsgroups");
43 i18nc("collection of article headers","Organization");
44 i18nc("collection of article headers","Path");
45 i18nc("collection of article headers","References");
46 i18nc("collection of article headers","Reply-To");
47 i18nc("collection of article headers","Sender");
48 i18nc("collection of article headers","Subject");
49 i18nc("collection of article headers","Supersedes");
50 i18nc("collection of article headers","To");
51 i18nc("collection of article headers","User-Agent");
52 i18nc("collection of article headers","X-Mailer");
53 i18nc("collection of article headers","X-Newsreader");
54 i18nc("collection of article headers","X-No-Archive");
55 i18nc("collection of article headers","XRef");
57 i18nc("collection of article headers","Groups");
61 //=============================================================================================================
64 KNDisplayedHeader::KNDisplayedHeader()
65 : t_ranslateName(true)
67 f_lags
.fill(false, 8);
68 f_lags
[1] = true; // header name bold by default
72 KNDisplayedHeader::~KNDisplayedHeader()
77 // some common headers
78 QStringList
KNDisplayedHeader::predefs()
80 if ( predef
.isEmpty() )
82 << "Content-Transfer-Encoding"
94 << "NNTP-Posting-Host"
113 // *tries* to translate the name
114 QString
KNDisplayedHeader::translatedName()
116 if (t_ranslateName
) {
117 // major hack alert !!!
118 if (!n_ame
.isEmpty()) {
119 if (i18nc("collection of article headers",n_ame
.toLocal8Bit())!=n_ame
.toLocal8Bit().data()) // try to guess if this english or not
120 return i18nc("collection of article headers",n_ame
.toLocal8Bit());
130 // *tries* to retranslate the name to english
131 void KNDisplayedHeader::setTranslatedName(const QString
&s
)
133 bool retranslated
= false;
134 QStringList pd
= predefs();
135 Q_FOREACH( const QString
&c
, pd
) {
136 if ( s
== i18nc("collection of article headers", c
.toLatin1()) ) {
144 for (const char **c
=disp
;(*c
)!=0;c
++) // now our standard display names
145 if (s
==i18nc("collection of article headers",*c
)) {
146 n_ame
= QString::fromLatin1(*c
);
152 if (!retranslated
) { // ok, we give up and store the maybe non-english string
154 t_ranslateName
= false; // and don't try to translate it, so a german user *can* use the original english name
156 t_ranslateName
= true;
160 void KNDisplayedHeader::createTags()
162 const char *tokens
[] = { "<big>","</big>","<b>","</b>",
163 "<i>","</i>","<u>","</u>" };
165 for ( int i
= 0; i
< 4; i
++ )
168 if(f_lags
.at(0)) { // <big>
177 if(f_lags
.at(1)) { // <b>
178 t_ags
[0]+=(tokens
[2]);
179 t_ags
[1].prepend(tokens
[3]);
183 t_ags
[3].prepend(tokens
[3]);
186 if(f_lags
.at(2)) { // <i>
188 t_ags
[1].prepend(tokens
[5]);
192 t_ags
[3].prepend(tokens
[5]);
195 if(f_lags
.at(3)) { // <u>
197 t_ags
[1].prepend(tokens
[7]);
201 t_ags
[3].prepend(tokens
[7]);