diff options
Diffstat (limited to 'kbarcode/encodingcombo.cpp')
-rw-r--r-- | kbarcode/encodingcombo.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/kbarcode/encodingcombo.cpp b/kbarcode/encodingcombo.cpp new file mode 100644 index 0000000..52f7a21 --- /dev/null +++ b/kbarcode/encodingcombo.cpp @@ -0,0 +1,47 @@ +/*************************************************************************** + encodingcombo.h - description + ------------------- + begin : Fri Dec 23 2005 + copyright : (C) 2005 by Dominik Seichter + email : domseichter@web.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include "encodingcombo.h" + +#include <kcharsets.h> +#include <kglobal.h> +#include <klocale.h> +#include <qtextcodec.h> + +EncodingCombo::EncodingCombo( QWidget* parent ) + : KComboBox( parent ) +{ + QString sEncoding = QString( KGlobal::locale()->encoding() ); + QStringList encodings (KGlobal::charsets()->availableEncodingNames()); + + this->insertStringList( encodings ); + + for (int i=0; i < encodings.count(); i++) + { + bool found = false; + QTextCodec *codecForEnc = KGlobal::charsets()->codecForName(encodings[i], found); + if (found && ( (codecForEnc->name() == sEncoding) || (encodings[i] == sEncoding) ) ) + { + this->setCurrentItem(i); + break; + } + } +} + +EncodingCombo::~EncodingCombo() +{ +} |