SVN_SILENT made messages (.desktop file)
[kdepim.git] / knode / kndisplayedheader.cpp
blob5a15a1ea6355aff018d20ffa1f7beb39c915d77b
1 /*
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
15 #include <klocale.h>
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 };
26 void dummyHeader()
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() )
81 predef << "Approved"
82 << "Content-Transfer-Encoding"
83 << "Content-Type"
84 << "Control"
85 << "Date"
86 << "Distribution"
87 << "Expires"
88 << "Followup-To"
89 << "From"
90 << "Lines"
91 << "Mail-Copies-To"
92 << "Message-ID"
93 << "Mime-Version"
94 << "NNTP-Posting-Host"
95 << "Newsgroups"
96 << "Organization"
97 << "Path"
98 << "References"
99 << "Reply-To"
100 << "Sender"
101 << "Subject"
102 << "Supersedes"
103 << "To"
104 << "User-Agent"
105 << "X-Mailer"
106 << "X-Newsreader"
107 << "X-No-Archive"
108 << "XRef";
109 return predef;
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());
121 else
122 return n_ame;
123 } else
124 return QString();
125 } else
126 return n_ame;
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()) ) {
137 n_ame = c;
138 retranslated = true;
139 break;
143 if (!retranslated) {
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);
147 retranslated = true;
148 break;
152 if (!retranslated) { // ok, we give up and store the maybe non-english string
153 n_ame = s;
154 t_ranslateName = false; // and don't try to translate it, so a german user *can* use the original english name
155 } else
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 )
166 t_ags[i].clear();
168 if(f_lags.at(0)) { // <big>
169 t_ags[0]=tokens[0];
170 t_ags[1]=tokens[1];
172 if(f_lags.at(4)) {
173 t_ags[2]=tokens[0];
174 t_ags[3]=tokens[1];
177 if(f_lags.at(1)) { // <b>
178 t_ags[0]+=(tokens[2]);
179 t_ags[1].prepend(tokens[3]);
181 if(f_lags.at(5)) {
182 t_ags[2]+=tokens[2];
183 t_ags[3].prepend(tokens[3]);
186 if(f_lags.at(2)) { // <i>
187 t_ags[0]+=tokens[4];
188 t_ags[1].prepend(tokens[5]);
190 if(f_lags.at(6)) {
191 t_ags[2]+=tokens[4];
192 t_ags[3].prepend(tokens[5]);
195 if(f_lags.at(3)) { // <u>
196 t_ags[0]+=tokens[6];
197 t_ags[1].prepend(tokens[7]);
199 if(f_lags.at(7)) {
200 t_ags[2]+=tokens[6];
201 t_ags[3].prepend(tokens[7]);