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

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • header
headerstrategy.cpp
Go to the documentation of this file.
1 /* -*- c++ -*-
2  headerstrategy.cpp
3 
4  This file is part of KMail, the KDE mail client.
5  Copyright (c) 2003 Marc Mutz <mutz@kde.org>
6 
7  Copyright (c) 2013 Laurent Montel <montel@kde.org>
8 
9  KMail is free software; you can redistribute it and/or modify it
10  under the terms of the GNU General Public License, version 2, as
11  published by the Free Software Foundation.
12 
13  KMail is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 
22  In addition, as a special exception, the copyright holders give
23  permission to link the code of this program with any edition of
24  the Qt library by Trolltech AS, Norway (or with modified versions
25  of Qt that use the same license as Qt), and distribute linked
26  combinations including the two. You must obey the GNU General
27  Public License in all respects for all of the code used other than
28  Qt. If you modify this file, you may extend this exception to
29  your version of the file, but you are not obligated to do so. If
30  you do not wish to do so, delete this exception statement from
31  your version.
32 */
33 
34 
35 
36 
37 #include "headerstrategy.h"
38 #include "header/headerstrategy_p.h"
39 
40 #include <kdebug.h>
41 
42 //
43 // HeaderStrategy abstract base:
44 //
45 namespace MessageViewer {
46 HeaderStrategy::HeaderStrategy() {
47 
48 }
49 
50 HeaderStrategy::~HeaderStrategy() {
51 
52 }
53 
54 QStringList HeaderStrategy::headersToDisplay() const {
55  return QStringList();
56 }
57 
58 QStringList HeaderStrategy::headersToHide() const {
59  return QStringList();
60 }
61 
62 bool HeaderStrategy::showHeader( const QString & header ) const {
63  if ( headersToDisplay().contains( header.toLower() ) ) return true;
64  if ( headersToHide().contains( header.toLower() ) ) return false;
65  return defaultPolicy() == Display;
66 }
67 
68 HeaderStrategy * HeaderStrategy::create( Type type ) {
69  switch ( type ) {
70  case All: return all();
71  case Rich: return rich();
72  case Standard: return standard();
73  case Brief: return brief();
74  case Custom: return custom();
75  case Grantlee: return grantlee();
76  }
77  kFatal() << "Unknown header strategy ( type ==" << (int)type << ") requested!";
78  return 0; // make compiler happy
79 }
80 
81 HeaderStrategy * HeaderStrategy::create( const QString & type ) {
82  const QString lowerType = type.toLower();
83  if ( lowerType == QLatin1String( "all" ) )
84  return all();
85  else if ( lowerType == QLatin1String( "rich" ) )
86  return HeaderStrategy::rich();
87  //if ( lowerType == "standard" ) return standard(); // not needed, see below
88  else if ( lowerType == QLatin1String( "brief" ) )
89  return brief();
90  else if ( lowerType == QLatin1String( "custom" ) )
91  return custom();
92  else if ( lowerType == QLatin1String( "grantlee" ) )
93  return grantlee();
94  // don't kFatal here, b/c the strings are user-provided
95  // (KConfig), so fail gracefully to the default:
96  return standard();
97 }
98 
99 static HeaderStrategy * allStrategy = 0;
100 static HeaderStrategy * richStrategy = 0;
101 static HeaderStrategy * standardStrategy = 0;
102 static HeaderStrategy * briefStrategy = 0;
103 static HeaderStrategy * customStrategy = 0;
104 static HeaderStrategy * grantleeStrategy = 0;
105 
106 HeaderStrategy * HeaderStrategy::all() {
107  if ( !allStrategy )
108  allStrategy = new MessageViewer::AllHeaderStrategy();
109  return allStrategy;
110 }
111 
112 HeaderStrategy * HeaderStrategy::rich() {
113  if ( !richStrategy )
114  richStrategy = new MessageViewer::RichHeaderStrategy();
115  return richStrategy;
116 }
117 
118 HeaderStrategy * HeaderStrategy::standard() {
119  if ( !standardStrategy )
120  standardStrategy = new MessageViewer::StandardHeaderStrategy();
121  return standardStrategy;
122 }
123 
124 HeaderStrategy * HeaderStrategy::brief() {
125  if ( !briefStrategy )
126  briefStrategy = new MessageViewer::BriefHeaderStrategy();
127  return briefStrategy;
128 }
129 
130 HeaderStrategy * HeaderStrategy::custom() {
131  if ( !customStrategy )
132  customStrategy = new MessageViewer::CustomHeaderStrategy();
133  return customStrategy;
134 }
135 
136 void HeaderStrategy::readConfig() {
137  if(customStrategy) {
138  static_cast<MessageViewer::CustomHeaderStrategy*>(customStrategy)->loadConfig();
139  }
140 }
141 
142 HeaderStrategy * HeaderStrategy::grantlee() {
143  if ( !grantleeStrategy )
144  grantleeStrategy = new MessageViewer::GrantleeHeaderStrategy();
145  return grantleeStrategy;
146 }
147 
148 }
MessageViewer::briefStrategy
static HeaderStrategy * briefStrategy
Definition: headerstrategy.cpp:102
MessageViewer::GrantleeHeaderStrategy
Definition: headerstrategy_p.h:192
MessageViewer::HeaderStrategy::HeaderStrategy
HeaderStrategy()
Definition: headerstrategy.cpp:46
MessageViewer::AllHeaderStrategy
Definition: headerstrategy_p.h:77
MessageViewer::HeaderStrategy::grantlee
static HeaderStrategy * grantlee()
Definition: headerstrategy.cpp:142
MessageViewer::HeaderStrategy::Grantlee
Definition: headerstrategy.h:57
MessageViewer::HeaderStrategy::rich
static HeaderStrategy * rich()
Definition: headerstrategy.cpp:112
MessageViewer::HeaderStrategy::standard
static HeaderStrategy * standard()
Definition: headerstrategy.cpp:118
MessageViewer::customStrategy
static HeaderStrategy * customStrategy
Definition: headerstrategy.cpp:103
MessageViewer::StandardHeaderStrategy
Definition: headerstrategy_p.h:121
MessageViewer::HeaderStrategy::headersToHide
virtual QStringList headersToHide() const
Definition: headerstrategy.cpp:58
MessageViewer::HeaderStrategy
Definition: headerstrategy.h:42
MessageViewer::BriefHeaderStrategy
Definition: headerstrategy_p.h:144
MessageViewer::HeaderStrategy::All
Definition: headerstrategy.h:52
MessageViewer::standardStrategy
static HeaderStrategy * standardStrategy
Definition: headerstrategy.cpp:101
MessageViewer::HeaderStrategy::Display
Definition: headerstrategy.h:79
MessageViewer::HeaderStrategy::brief
static HeaderStrategy * brief()
Definition: headerstrategy.cpp:124
headerstrategy_p.h
MessageViewer::HeaderStrategy::custom
static HeaderStrategy * custom()
Definition: headerstrategy.cpp:130
MessageViewer::HeaderStrategy::Custom
Definition: headerstrategy.h:56
MessageViewer::HeaderStrategy::create
static HeaderStrategy * create(Type type)
Definition: headerstrategy.cpp:68
MessageViewer::HeaderStrategy::Type
Type
Definition: headerstrategy.h:52
MessageViewer::HeaderStrategy::defaultPolicy
virtual DefaultPolicy defaultPolicy() const =0
MessageViewer::HeaderStrategy::Standard
Definition: headerstrategy.h:54
MessageViewer::HeaderStrategy::Rich
Definition: headerstrategy.h:53
MessageViewer::CustomHeaderStrategy
Definition: headerstrategy_p.h:168
MessageViewer::grantleeStrategy
static HeaderStrategy * grantleeStrategy
Definition: headerstrategy.cpp:104
MessageViewer::HeaderStrategy::showHeader
virtual bool showHeader(const QString &header) const
Definition: headerstrategy.cpp:62
type
const char * type
Definition: bodypartformatter.cpp:192
MessageViewer::HeaderStrategy::headersToDisplay
virtual QStringList headersToDisplay() const
Definition: headerstrategy.cpp:54
MessageViewer::RichHeaderStrategy
Definition: headerstrategy_p.h:98
MessageViewer::HeaderStrategy::all
static HeaderStrategy * all()
Definition: headerstrategy.cpp:106
MessageViewer::HeaderStrategy::readConfig
void readConfig()
Definition: headerstrategy.cpp:136
MessageViewer::HeaderStrategy::Brief
Definition: headerstrategy.h:55
headerstrategy.h
MessageViewer::allStrategy
static HeaderStrategy * allStrategy
Definition: headerstrategy.cpp:99
MessageViewer::richStrategy
static HeaderStrategy * richStrategy
Definition: headerstrategy.cpp:100
MessageViewer::HeaderStrategy::~HeaderStrategy
virtual ~HeaderStrategy()
Definition: headerstrategy.cpp:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • 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