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

kmail

  • sources
  • kde-4.12
  • kdepim
  • kmail
  • editor
codecaction.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of KMail.
3  * Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 // Own
21 #include "codecaction.h"
22 
23 // KMail
24 #include "codecmanager.h"
25 
26 // Qt
27 #include <QTextCodec>
28 
29 // KDE libs
30 #include <KDebug>
31 #include <KLocale>
32 
33 class CodecAction::Private
34 {
35 public:
36  Private( CodecAction::Mode mod, CodecAction *qq )
37  : mode( mod )
38  , q( qq )
39  {
40  }
41 
42  const CodecAction::Mode mode;
43  CodecAction *const q;
44 };
45 
46 
47 
48 CodecAction::CodecAction( Mode mode, QObject *parent )
49  : KCodecAction( parent, mode == ReaderMode )
50  , d( new Private( mode, this ) )
51 {
52  if( mode == ComposerMode ) {
53  // Add 'us-ascii' entry. We want it at the top, so remove then re-add everything.
54  // FIXME is there a better way?
55  QList<QAction*> oldActions = actions();
56  removeAllActions();
57  addAction( oldActions.takeFirst() ); // 'Default'
58  addAction( i18nc( "Encodings menu", "us-ascii" ) );
59  foreach( QAction *a, oldActions ) {
60  addAction( a );
61  }
62  } else if( mode == ReaderMode ) {
63  // Nothing to do.
64  }
65 
66  // Eye candy.
67  setIcon( KIcon( QLatin1String("accessories-character-map") ) );
68  setText( i18nc( "Menu item", "Encoding" ) );
69 }
70 
71 CodecAction::~CodecAction()
72 {
73  delete d;
74 }
75 
76 QList<QByteArray> CodecAction::mimeCharsets() const
77 {
78  QList<QByteArray> ret;
79  kDebug() << "current item" << currentItem() << currentText();
80  if( currentItem() == 0 ) {
81  // 'Default' selected: return the preferred charsets.
82  ret = CodecManager::self()->preferredCharsets();
83  } else if( currentItem() == 1 ) {
84  // 'us-ascii' selected.
85  ret << "us-ascii";
86  } else {
87  // Specific codec selected.
88  // ret << currentCodecName().toLatin1().toLower(); // FIXME in kdelibs: returns e.g. '&koi8-r'
89  ret << currentCodec()->name();
90  kDebug() << "current codec name" << ret.first();
91  }
92  return ret;
93 }
94 
95 #include "codecaction.moc"
CodecAction::Mode
Mode
Definition: codecaction.h:36
QObject
CodecAction::ReaderMode
which uses one of the preferred codecs. Also show 'us-ascii'.
Definition: codecaction.h:40
CodecAction::Private
friend class Private
Definition: codecaction.h:56
CodecManager::preferredCharsets
QList< QByteArray > preferredCharsets() const
A list of preferred charsets to use when composing messages.
Definition: codecmanager.cpp:76
CodecAction::ComposerMode
Used in the composer.
Definition: codecaction.h:38
KCodecAction
CodecAction
Definition: codecaction.h:31
codecmanager.h
CodecAction::CodecAction
CodecAction(Mode mode, QObject *parent=0)
Definition: codecaction.cpp:48
codecaction.h
CodecManager::self
static CodecManager * self()
Returns the CodecManager instance.
Definition: codecmanager.cpp:71
CodecAction::~CodecAction
~CodecAction()
Definition: codecaction.cpp:71
QList< QAction * >
CodecAction::mimeCharsets
QList< QByteArray > mimeCharsets() const
The name of the charset, if a specific encoding was selected, or a list containing the names of the p...
Definition: codecaction.cpp:76
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kmail

Skip menu "kmail"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

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