• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

knode

  • sources
  • kde-4.12
  • kdepim
  • knode
kndisplayedheader.cpp
Go to the documentation of this file.
1 /*
2  KNode, the KDE newsreader
3  Copyright (c) 1999-2006 the KNode authors.
4  See file AUTHORS for details
5 
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
13 */
14 
15 #include <klocale.h>
16 
17 #include "kndisplayedheader.h"
18 
19 
20 // some standard headers
21 static QStringList predef;
22 
23 // default display names KNode uses
24 static const char *disp[] = { "Groups", 0 };
25 
26 void dummyHeader()
27 {
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");
56 
57  i18nc("collection of article headers","Groups");
58 }
59 
60 
61 //=============================================================================================================
62 
63 
64 KNDisplayedHeader::KNDisplayedHeader()
65  : t_ranslateName(true)
66 {
67  f_lags.fill(false, 8);
68  f_lags[1] = true; // header name bold by default
69 }
70 
71 
72 KNDisplayedHeader::~KNDisplayedHeader()
73 {
74 }
75 
76 
77 // some common headers
78 QStringList KNDisplayedHeader::predefs()
79 {
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;
110 }
111 
112 
113 // *tries* to translate the name
114 QString KNDisplayedHeader::translatedName()
115 {
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;
127 }
128 
129 
130 // *tries* to retranslate the name to english
131 void KNDisplayedHeader::setTranslatedName(const QString &s)
132 {
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;
140  }
141  }
142 
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;
149  }
150  }
151 
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;
157 }
158 
159 
160 void KNDisplayedHeader::createTags()
161 {
162  const char *tokens[] = { "<big>","</big>","<b>","</b>",
163  "<i>","</i>","<u>","</u>" };
164 
165  for ( int i = 0; i < 4; ++i )
166  t_ags[i].clear();
167 
168  if(f_lags.at(0)) { // <big>
169  t_ags[0]=tokens[0];
170  t_ags[1]=tokens[1];
171  }
172  if(f_lags.at(4)) {
173  t_ags[2]=tokens[0];
174  t_ags[3]=tokens[1];
175  }
176 
177  if(f_lags.at(1)) { // <b>
178  t_ags[0]+=(tokens[2]);
179  t_ags[1].prepend(tokens[3]);
180  }
181  if(f_lags.at(5)) {
182  t_ags[2]+=tokens[2];
183  t_ags[3].prepend(tokens[3]);
184  }
185 
186  if(f_lags.at(2)) { // <i>
187  t_ags[0]+=tokens[4];
188  t_ags[1].prepend(tokens[5]);
189  }
190  if(f_lags.at(6)) {
191  t_ags[2]+=tokens[4];
192  t_ags[3].prepend(tokens[5]);
193  }
194 
195  if(f_lags.at(3)) { // <u>
196  t_ags[0]+=tokens[6];
197  t_ags[1].prepend(tokens[7]);
198  }
199  if(f_lags.at(7)) {
200  t_ags[2]+=tokens[6];
201  t_ags[3].prepend(tokens[7]);
202  }
203 }
KNDisplayedHeader::~KNDisplayedHeader
~KNDisplayedHeader()
Definition: kndisplayedheader.cpp:72
KNDisplayedHeader::setTranslatedName
void setTranslatedName(const QString &s)
Definition: kndisplayedheader.cpp:131
KNDisplayedHeader::f_lags
QBitArray f_lags
Definition: kndisplayedheader.h:63
KNDisplayedHeader::translatedName
QString translatedName()
Definition: kndisplayedheader.cpp:114
KNDisplayedHeader::t_ranslateName
bool t_ranslateName
Definition: kndisplayedheader.h:61
KNDisplayedHeader::KNDisplayedHeader
KNDisplayedHeader()
Definition: kndisplayedheader.cpp:64
KNDisplayedHeader::createTags
void createTags()
Definition: kndisplayedheader.cpp:160
KNDisplayedHeader::n_ame
QString n_ame
Definition: kndisplayedheader.h:62
dummyHeader
void dummyHeader()
Definition: kndisplayedheader.cpp:26
KNDisplayedHeader::t_ags
QString t_ags[4]
Definition: kndisplayedheader.h:62
predef
static QStringList predef
Definition: kndisplayedheader.cpp:21
kndisplayedheader.h
disp
static const char * disp[]
Definition: kndisplayedheader.cpp:24
KNDisplayedHeader::predefs
static QStringList predefs()
Definition: kndisplayedheader.cpp:78
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:36 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knode

Skip menu "knode"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal