/*************************************************************************** * * * begin : 07 May 2004 * * copyright : (C) 2003 by Samokhvalov Anton :) * * * ***************************************************************************/ /*************************************************************************** * * * 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 #include #include #include "Encoding.h" Encoding::Encoding( QWidget* parent, const char* name, WFlags /*fl*/ ): KComboBox( true, parent, name ) { KCharsets* cs = KGlobal::charsets(); QStringList lst = cs->descriptiveEncodingNames(); insertStringList( lst ); for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it ) { // printf( "%s %s\n", cs->encodingForName( *it ).latin1(), (*it).latin1() ); d_map[ cs->encodingForName( *it ).upper() ] = *it; } setInsertionPolicy( NoInsertion ); setCurrentItem( 0 ); connect( this, SIGNAL(activated(const QString&)), this, SLOT(slotTextChanged(const QString&)) ); } Encoding::~Encoding() { } void Encoding::slotTextChanged( const QString& text ) { QString cfn = KGlobal::charsets()->encodingForName( text ); emit codecChanged( QTextCodec::codecForName( cfn.latin1() ) ); } void Encoding::setCurrentText( const QString& txt ) { KComboBox::setCurrentText( txt ); emit activated( txt ); } void Encoding::slotSetCodec( QTextCodec* codec ) { // printf( "%s\n", codec->name() ); KComboBox::setCurrentText( d_map[ QString::fromLatin1( codec->name() ).upper() ] ); } #include "Encoding.moc"