2 * This file is part of KMail.
3 * Copyright (c) 2009 Constantin Berzan <exit3219@gmail.com>
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.
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.
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.
21 #include "codecaction.h"
24 #include "codecmanager.h"
32 class CodecAction::Private
35 Private( CodecAction::Mode mod
, CodecAction
*qq
)
41 const CodecAction::Mode mode
;
47 CodecAction::CodecAction( Mode mode
, QObject
*parent
)
48 : KCodecAction( parent
, mode
== ReaderMode
)
49 , d( new Private( mode
, this ) )
51 if( mode
== ComposerMode
) {
52 // Add 'us-ascii' entry. We want it at the top, so remove then re-add everything.
53 // FIXME is there a better way?
54 QList
<QAction
*> oldActions
= actions();
56 addAction( oldActions
.takeFirst() ); // 'Default'
57 addAction( i18nc( "Encodings menu", "us-ascii" ) );
58 foreach( QAction
*a
, oldActions
) {
61 } else if( mode
== ReaderMode
) {
66 setIcon( KIcon( "accessories-character-map" ) );
67 setText( i18nc( "Menu item", "Encoding" ) );
70 CodecAction::~CodecAction()
75 QList
<QByteArray
> CodecAction::mimeCharsets() const
77 QList
<QByteArray
> ret
;
78 kDebug() << "current item" << currentItem() << currentText();
79 if( currentItem() == 0 ) {
80 // 'Default' selected: return the preferred charsets.
81 ret
= CodecManager::self()->preferredCharsets();
82 } else if( currentItem() == 1 ) {
83 // 'us-ascii' selected.
86 // Specific codec selected.
87 // ret << currentCodecName().toLatin1().toLower(); // FIXME in kdelibs: returns e.g. '&koi8-r'
88 ret
<< currentCodec()->name();
89 kDebug() << "current codec name" << ret
.first();
94 #include "codecaction.moc"