From 47c8a359c5276062c4bc17f0e82410f29081b502 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 31 Jul 2010 19:48:06 +0000 Subject: Trinity Qt initial conversion git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kopete/plugins/translator/translatorplugin.cpp | 108 ++++++++++++------------- 1 file changed, 54 insertions(+), 54 deletions(-) (limited to 'kopete/plugins/translator/translatorplugin.cpp') diff --git a/kopete/plugins/translator/translatorplugin.cpp b/kopete/plugins/translator/translatorplugin.cpp index 4ac8367f..0767e24e 100644 --- a/kopete/plugins/translator/translatorplugin.cpp +++ b/kopete/plugins/translator/translatorplugin.cpp @@ -20,10 +20,10 @@ google translation page layout (13-sept-2007) */ -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -51,7 +51,7 @@ K_EXPORT_COMPONENT_FACTORY( kopete_translator, TranslatorPluginFactory( &aboutda K_EXPORT_COMPONENT_FACTORY( kopete_translator, TranslatorPluginFactory( "kopete_translator" ) ) #endif -TranslatorPlugin::TranslatorPlugin( QObject *parent, const char *name, const QStringList & /* args */ ) +TranslatorPlugin::TranslatorPlugin( TQObject *parent, const char *name, const TQStringList & /* args */ ) : Kopete::Plugin( TranslatorPluginFactory::instance(), parent, name ) { kdDebug( 14308 ) << k_funcinfo << endl; @@ -64,32 +64,32 @@ TranslatorPlugin::TranslatorPlugin( QObject *parent, const char *name, const QSt m_languages = new TranslatorLanguages; - connect( Kopete::ChatSessionManager::self(), SIGNAL( aboutToDisplay( Kopete::Message & ) ), - this, SLOT( slotIncomingMessage( Kopete::Message & ) ) ); - connect( Kopete::ChatSessionManager::self(), SIGNAL( aboutToSend( Kopete::Message & ) ), - this, SLOT( slotOutgoingMessage( Kopete::Message & ) ) ); - connect( Kopete::ChatSessionManager::self(), SIGNAL( chatSessionCreated( Kopete::ChatSession * ) ), - this, SLOT( slotNewKMM( Kopete::ChatSession * ) ) ); + connect( Kopete::ChatSessionManager::self(), TQT_SIGNAL( aboutToDisplay( Kopete::Message & ) ), + this, TQT_SLOT( slotIncomingMessage( Kopete::Message & ) ) ); + connect( Kopete::ChatSessionManager::self(), TQT_SIGNAL( aboutToSend( Kopete::Message & ) ), + this, TQT_SLOT( slotOutgoingMessage( Kopete::Message & ) ) ); + connect( Kopete::ChatSessionManager::self(), TQT_SIGNAL( chatSessionCreated( Kopete::ChatSession * ) ), + this, TQT_SLOT( slotNewKMM( Kopete::ChatSession * ) ) ); - QStringList keys; - QMap m = m_languages->languagesMap(); + TQStringList keys; + TQMap m = m_languages->languagesMap(); for ( int k = 0; k <= m_languages->numLanguages(); k++ ) keys << m[ m_languages->languageKey( k ) ]; m_actionLanguage = new KSelectAction( i18n( "Set &Language" ), "locale", 0, actionCollection(), "contactLanguage" ); m_actionLanguage->setItems( keys ); - connect( m_actionLanguage, SIGNAL( activated() ), this, SLOT(slotSetLanguage() ) ); - connect( Kopete::ContactList::self(), SIGNAL( metaContactSelected( bool ) ), this, SLOT( slotSelectionChanged( bool ) ) ); + connect( m_actionLanguage, TQT_SIGNAL( activated() ), this, TQT_SLOT(slotSetLanguage() ) ); + connect( Kopete::ContactList::self(), TQT_SIGNAL( metaContactSelected( bool ) ), this, TQT_SLOT( slotSelectionChanged( bool ) ) ); setXMLFile( "translatorui.rc" ); //Add GUI action to all already existing kmm (if the plugin is launched when kopete already rining) - QValueList sessions = Kopete::ChatSessionManager::self()->sessions(); - for (QValueListIterator it= sessions.begin(); it!=sessions.end() ; ++it) + TQValueList sessions = Kopete::ChatSessionManager::self()->sessions(); + for (TQValueListIterator it= sessions.begin(); it!=sessions.end() ; ++it) slotNewKMM( *it ); loadSettings(); - connect( this, SIGNAL( settingsChanged() ), this, SLOT( loadSettings() ) ); + connect( this, TQT_SIGNAL( settingsChanged() ), this, TQT_SLOT( loadSettings() ) ); } TranslatorPlugin::~TranslatorPlugin() @@ -147,7 +147,7 @@ void TranslatorPlugin::slotSelectionChanged( bool b ) if( !m ) return; - QString languageKey = m->pluginData( this, "languageKey" ); + TQString languageKey = m->pluginData( this, "languageKey" ); if ( !languageKey.isEmpty() && languageKey != "null" ) m_actionLanguage->setCurrentItem( m_languages->languageIndex( languageKey ) ); else @@ -164,8 +164,8 @@ void TranslatorPlugin::slotIncomingMessage( Kopete::Message &msg ) if ( m_incomingMode == DontTranslate ) return; - QString src_lang; - QString dst_lang; + TQString src_lang; + TQString dst_lang; if ( ( msg.direction() == Kopete::Message::Inbound ) && !msg.plainBody().isEmpty() ) { @@ -193,8 +193,8 @@ void TranslatorPlugin::slotOutgoingMessage( Kopete::Message &msg ) if ( m_outgoingMode == DontTranslate ) return; - QString src_lang; - QString dst_lang; + TQString src_lang; + TQString dst_lang; if ( ( msg.direction() == Kopete::Message::Outbound ) && ( !msg.plainBody().isEmpty() ) ) { @@ -218,12 +218,12 @@ void TranslatorPlugin::slotOutgoingMessage( Kopete::Message &msg ) } } -void TranslatorPlugin::translateMessage( const QString &msg, const QString &from, const QString &to, QObject *obj, const char* slot ) +void TranslatorPlugin::translateMessage( const TQString &msg, const TQString &from, const TQString &to, TQObject *obj, const char* slot ) { - QSignal completeSignal; + TQSignal completeSignal; completeSignal.connect( obj, slot ); - QString result = translateMessage( msg, from, to ); + TQString result = translateMessage( msg, from, to ); if(!result.isNull()) { @@ -232,19 +232,19 @@ void TranslatorPlugin::translateMessage( const QString &msg, const QString &from } } -QString TranslatorPlugin::translateMessage( const QString &msg, const QString &from, const QString &to ) +TQString TranslatorPlugin::translateMessage( const TQString &msg, const TQString &from, const TQString &to ) { if ( from == to ) { kdDebug( 14308 ) << k_funcinfo << "Src and Dst languages are the same" << endl; - return QString::null; + return TQString::null; } // We search for src_dst if(! m_languages->supported( m_service ).contains( from + "_" + to ) ) { kdDebug( 14308 ) << k_funcinfo << from << "_" << to << " is not supported by service " << m_service << endl; - return QString::null; + return TQString::null; } @@ -253,19 +253,19 @@ QString TranslatorPlugin::translateMessage( const QString &msg, const QString &f else if ( m_service == "google" ) return googleTranslateMessage( msg ,from, to ); else - return QString::null; + return TQString::null; } -QString TranslatorPlugin::googleTranslateMessage( const QString &msg, const QString &from, const QString &to ) +TQString TranslatorPlugin::googleTranslateMessage( const TQString &msg, const TQString &from, const TQString &to ) { KURL translatorURL ( "http://translate.google.com/translate_t"); - QString body = KURL::encode_string( msg ); - QString lp = from + "|" + to; + TQString body = KURL::encode_string( msg ); + TQString lp = from + "|" + to; - QCString postData = QString( "text=" + body + "&langpair=" + lp ).utf8(); + TQCString postData = TQString( "text=" + body + "&langpair=" + lp ).utf8(); - QString gurl = "http://translate.google.com/translate_t?text=" + body +"&langpair=" + lp; + TQString gurl = "http://translate.google.com/translate_t?text=" + body +"&langpair=" + lp; kdDebug(14308) << k_funcinfo << " URL: " << gurl << endl; KURL geturl ( gurl ); @@ -275,8 +275,8 @@ QString TranslatorPlugin::googleTranslateMessage( const QString &msg, const QStr //job->addMetaData( "content-type", "application/x-www-form-urlencoded" ); //job->addMetaData( "referrer", "http://www.google.com" ); - QObject::connect( job, SIGNAL( data( KIO::Job *, const QByteArray & ) ), this, SLOT( slotDataReceived( KIO::Job *, const QByteArray & ) ) ); - QObject::connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotJobDone( KIO::Job * ) ) ); + TQObject::connect( job, TQT_SIGNAL( data( KIO::Job *, const TQByteArray & ) ), this, TQT_SLOT( slotDataReceived( KIO::Job *, const TQByteArray & ) ) ); + TQObject::connect( job, TQT_SIGNAL( result( KIO::Job * ) ), this, TQT_SLOT( slotJobDone( KIO::Job * ) ) ); // KIO is async and we use a sync API, so use the processEvents hack to work around that // FIXME: We need to make the libkopete API async to get rid of this processEvents. @@ -284,7 +284,7 @@ QString TranslatorPlugin::googleTranslateMessage( const QString &msg, const QStr while ( !m_completed[ job ] ) qApp->processEvents(); - QString data = QString::fromLatin1( m_data[ job ] ); + TQString data = TQString::fromLatin1( m_data[ job ] ); // After hacks, we need to clean m_data.remove( job ); @@ -292,27 +292,27 @@ QString TranslatorPlugin::googleTranslateMessage( const QString &msg, const QStr // kdDebug( 14308 ) << k_funcinfo << "Google response:"<< endl << data << endl; -// QRegExp re( "" ); - QRegExp re( ""); +// TQRegExp re( "" ); + TQRegExp re( ""); re.setMinimal( true ); re.search( data ); return re.cap( 1 ); } -QString TranslatorPlugin::babelTranslateMessage( const QString &msg, const QString &from, const QString &to ) +TQString TranslatorPlugin::babelTranslateMessage( const TQString &msg, const TQString &from, const TQString &to ) { - QString body = KURL::encode_string( msg); - QString lp = from + "_" + to; - QString gurl = "http://babelfish.altavista.com/babelfish/tr?enc=utf8&doit=done&tt=urltext&urltext=" + body + "&lp=" + lp; + TQString body = KURL::encode_string( msg); + TQString lp = from + "_" + to; + TQString gurl = "http://babelfish.altavista.com/babelfish/tr?enc=utf8&doit=done&tt=urltext&urltext=" + body + "&lp=" + lp; KURL geturl ( gurl ); kdDebug( 14308 ) << k_funcinfo << "URL: " << gurl << endl; KIO::TransferJob *job = KIO::get( geturl, false, true ); - QObject::connect( job, SIGNAL( data( KIO::Job *, const QByteArray & ) ), this, SLOT( slotDataReceived( KIO::Job *, const QByteArray & ) ) ); - QObject::connect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotJobDone( KIO::Job * ) ) ); + TQObject::connect( job, TQT_SIGNAL( data( KIO::Job *, const TQByteArray & ) ), this, TQT_SLOT( slotDataReceived( KIO::Job *, const TQByteArray & ) ) ); + TQObject::connect( job, TQT_SIGNAL( result( KIO::Job * ) ), this, TQT_SLOT( slotJobDone( KIO::Job * ) ) ); // KIO is async and we use a sync API, so use the processEvents hack to work around that // FIXME: We need to make the libkopete API async to get rid of this processEvents. @@ -320,7 +320,7 @@ QString TranslatorPlugin::babelTranslateMessage( const QString &msg, const QStri while ( !m_completed[ job ] ) qApp->processEvents(); - QString data = QString::fromUtf8( m_data[ job ] ); + TQString data = TQString::fromUtf8( m_data[ job ] ); // After hacks, we need to clean m_data.remove( job ); @@ -328,15 +328,15 @@ QString TranslatorPlugin::babelTranslateMessage( const QString &msg, const QStri //kdDebug( 14308 ) << k_funcinfo << "Babelfish response: " << endl << data << endl; -// QRegExp re( "
(.*)(.*)
" ); +// TQRegExp re( "
(.*)(.*)
" ); re.setMinimal( true ); re.search( data ); return re.cap( 1 ); } -void TranslatorPlugin::sendTranslation( Kopete::Message &msg, const QString &translated ) +void TranslatorPlugin::sendTranslation( Kopete::Message &msg, const TQString &translated ) { if ( translated.isEmpty() ) { @@ -381,16 +381,16 @@ void TranslatorPlugin::sendTranslation( Kopete::Message &msg, const QString &tra }; } -void TranslatorPlugin::slotDataReceived ( KIO::Job *job, const QByteArray &data ) +void TranslatorPlugin::slotDataReceived ( KIO::Job *job, const TQByteArray &data ) { - m_data[ job ] += QCString( data, data.size() + 1 ); + m_data[ job ] += TQCString( data, data.size() + 1 ); } void TranslatorPlugin::slotJobDone ( KIO::Job *job ) { m_completed[ job ] = true; - QObject::disconnect( job, SIGNAL( data( KIO::Job *, const QByteArray & ) ), this, SLOT( slotDataReceived( KIO::Job *, const QByteArray & ) ) ); - QObject::disconnect( job, SIGNAL( result( KIO::Job * ) ), this, SLOT( slotJobDone( KIO::Job * ) ) ); + TQObject::disconnect( job, TQT_SIGNAL( data( KIO::Job *, const TQByteArray & ) ), this, TQT_SLOT( slotDataReceived( KIO::Job *, const TQByteArray & ) ) ); + TQObject::disconnect( job, TQT_SIGNAL( result( KIO::Job * ) ), this, TQT_SLOT( slotJobDone( KIO::Job * ) ) ); } void TranslatorPlugin::slotSetLanguage() -- cgit v1.2.1