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/latex/latexplugin.cpp | 88 ++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'kopete/plugins/latex/latexplugin.cpp') diff --git a/kopete/plugins/latex/latexplugin.cpp b/kopete/plugins/latex/latexplugin.cpp index 7ceab209..11537aba 100644 --- a/kopete/plugins/latex/latexplugin.cpp +++ b/kopete/plugins/latex/latexplugin.cpp @@ -16,11 +16,11 @@ ************************************************************************* */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -41,7 +41,7 @@ typedef KGenericFactory LatexPluginFactory; K_EXPORT_COMPONENT_FACTORY( kopete_latex, LatexPluginFactory( "kopete_latex" ) ) -LatexPlugin::LatexPlugin( QObject *parent, const char *name, const QStringList &/*args*/ ) +LatexPlugin::LatexPlugin( TQObject *parent, const char *name, const TQStringList &/*args*/ ) : Kopete::Plugin( LatexPluginFactory::instance(), parent, name ) { // kdDebug() << k_funcinfo << endl; @@ -49,18 +49,18 @@ LatexPlugin::LatexPlugin( QObject *parent, const char *name, const QStringList & s_pluginStatic = this; mMagickNotFoundShown = false; - connect( Kopete::ChatSessionManager::self(), SIGNAL( aboutToDisplay( Kopete::Message & ) ), SLOT( slotMessageAboutToShow( Kopete::Message & ) ) ); - connect( Kopete::ChatSessionManager::self(), SIGNAL( aboutToSend(Kopete::Message& ) ), this, SLOT(slotMessageAboutToSend(Kopete::Message& ) ) ); - connect ( this , SIGNAL( settingsChanged() ) , this , SLOT( slotSettingsChanged() ) ); - connect( Kopete::ChatSessionManager::self(), SIGNAL( chatSessionCreated( Kopete::ChatSession * ) ), - this, SLOT( slotNewChatSession( Kopete::ChatSession * ) ) ); + connect( Kopete::ChatSessionManager::self(), TQT_SIGNAL( aboutToDisplay( Kopete::Message & ) ), TQT_SLOT( slotMessageAboutToShow( Kopete::Message & ) ) ); + connect( Kopete::ChatSessionManager::self(), TQT_SIGNAL( aboutToSend(Kopete::Message& ) ), this, TQT_SLOT(slotMessageAboutToSend(Kopete::Message& ) ) ); + connect ( this , TQT_SIGNAL( settingsChanged() ) , this , TQT_SLOT( slotSettingsChanged() ) ); + connect( Kopete::ChatSessionManager::self(), TQT_SIGNAL( chatSessionCreated( Kopete::ChatSession * ) ), + this, TQT_SLOT( slotNewChatSession( Kopete::ChatSession * ) ) ); m_convScript = KStandardDirs::findExe("kopete_latexconvert.sh"); slotSettingsChanged(); //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) slotNewChatSession( *it ); } @@ -84,7 +84,7 @@ void LatexPlugin::slotNewChatSession( Kopete::ChatSession *KMM ) void LatexPlugin::slotMessageAboutToShow( Kopete::Message& msg ) { - QString mMagick = KStandardDirs::findExe("convert"); + TQString mMagick = KStandardDirs::findExe("convert"); if ( mMagick.isEmpty() ) { // show just once @@ -100,7 +100,7 @@ void LatexPlugin::slotMessageAboutToShow( Kopete::Message& msg ) return; } - QString messageText = msg.plainBody(); + TQString messageText = msg.plainBody(); if( !messageText.contains("$$")) return; @@ -110,14 +110,14 @@ void LatexPlugin::slotMessageAboutToShow( Kopete::Message& msg ) // \$\$.+?\$\$ // this searches for $$formula$$ - QRegExp rg("\\$\\$.+\\$\\$"); + TQRegExp rg("\\$\\$.+\\$\\$"); rg.setMinimal(true); // this searches for [latex]formula[/latex] - //QRegExp rg("\\[([^]\]).*?\\[/$1\\]"); + //TQRegExp rg("\\[([^]\]).*?\\[/$1\\]"); int pos = 0; - QMap replaceMap; + TQMap replaceMap; while (pos >= 0 && (unsigned int)pos < messageText.length()) { // kdDebug() << k_funcinfo << " searching pos: " << pos << endl; @@ -125,27 +125,27 @@ void LatexPlugin::slotMessageAboutToShow( Kopete::Message& msg ) if (pos >= 0 ) { - QString match = rg.cap(0); + TQString match = rg.cap(0); pos += rg.matchedLength(); - QString formul=match; + TQString formul=match; if(!securityCheck(formul)) continue; - QString fileName=handleLatex(formul.replace("$$","")); + TQString fileName=handleLatex(formul.replace("$$","")); // get the image and encode it with base64 #if ENCODED_IMAGE_MODE - QImage renderedImage( fileName ); + TQImage renderedImage( fileName ); imagePxWidth = renderedImage.width(); imagePxHeight = renderedImage.height(); if ( !renderedImage.isNull() ) { - QByteArray ba; - QBuffer buffer( ba ); + TQByteArray ba; + TQBuffer buffer( ba ); buffer.open( IO_WriteOnly ); renderedImage.save( &buffer, "PNG" ); - QString imageURL = QString::fromLatin1("data:image/png;base64,%1").arg( KCodecs::base64Encode( ba ) ); + TQString imageURL = TQString::fromLatin1("data:image/png;base64,%1").arg( KCodecs::base64Encode( ba ) ); replaceMap[match] = imageURL; } #else @@ -160,15 +160,15 @@ void LatexPlugin::slotMessageAboutToShow( Kopete::Message& msg ) messageText= msg.escapedBody(); int imagePxWidth,imagePxHeight; - for (QMap::ConstIterator it = replaceMap.begin(); it != replaceMap.end(); ++it) + for (TQMap::ConstIterator it = replaceMap.begin(); it != replaceMap.end(); ++it) { - QImage theImage(*it); + TQImage theImage(*it); if(theImage.isNull()) continue; imagePxWidth = theImage.width(); imagePxHeight = theImage.height(); - QString escapedLATEX=QStyleSheet::escape(it.key()).replace("\"","""); //we need the escape quotes because that string will be in a title="" argument, but not the \n - messageText.replace(Kopete::Message::escape(it.key()), " \"" "); + TQString escapedLATEX=TQStyleSheet::escape(it.key()).replace("\"","""); //we need the escape quotes because that string will be in a title="" argument, but not the \n + messageText.replace(Kopete::Message::escape(it.key()), " \"" "); } msg.setBody( messageText, Kopete::Message::RichText ); @@ -186,62 +186,62 @@ void LatexPlugin::slotMessageAboutToSend( Kopete::Message& msg) if(!config->readBoolEntry("ParseOutgoing", false)) return; - QString messageText = msg.plainBody(); + TQString messageText = msg.plainBody(); if( !messageText.contains("$$")) return; /* if( msg.from()->protocol()->pluginId()!="MSNProtocol" ) return;*/ // this searches for $$formula$$ - QRegExp rg("^\\s*\\$\\$([^$]+)\\$\\$\\s*$"); + TQRegExp rg("^\\s*\\$\\$([^$]+)\\$\\$\\s*$"); if( rg.search(messageText) != -1 ) { - QString latexFormula = rg.cap(1); + TQString latexFormula = rg.cap(1); if(!securityCheck( latexFormula )) return; - QString url = handleLatex(latexFormula); + TQString url = handleLatex(latexFormula); if(!url.isNull()) { - QString escapedLATEX= QStyleSheet::escape(messageText).replace("\"","""); - QString messageText="\"""; + TQString escapedLATEX= TQStyleSheet::escape(messageText).replace("\"","""); + TQString messageText="\"""; msg.setBody( messageText, Kopete::Message::RichText ); } } #endif } -QString LatexPlugin::handleLatex(const QString &latexFormula) +TQString LatexPlugin::handleLatex(const TQString &latexFormula) { KTempFile *tempFile=new KTempFile( locateLocal( "tmp", "kopetelatex-" ), ".png" ); tempFile->setAutoDelete(true); m_tempFiles.append(tempFile); m_tempFiles.setAutoDelete(true); - QString fileName = tempFile->name(); + TQString fileName = tempFile->name(); KProcess p; - QString argumentRes = "-r %1x%2"; - QString argumentOut = "-o %1"; - //QString argumentFormat = "-fgif"; //we uses gif format because MSN only handle gif + TQString argumentRes = "-r %1x%2"; + TQString argumentOut = "-o %1"; + //TQString argumentFormat = "-fgif"; //we uses gif format because MSN only handle gif int hDPI, vDPI; hDPI = LatexConfig::self()->horizontalDPI(); vDPI = LatexConfig::self()->verticalDPI(); - p << m_convScript << argumentRes.arg(QString::number(hDPI), QString::number(vDPI)) << argumentOut.arg(fileName) /*<< argumentFormat*/ << latexFormula ; + p << m_convScript << argumentRes.arg(TQString::number(hDPI), TQString::number(vDPI)) << argumentOut.arg(fileName) /*<< argumentFormat*/ << latexFormula ; - kdDebug() << k_funcinfo << " Rendering " << m_convScript << " " << argumentRes.arg(QString::number(hDPI), QString::number(vDPI)) << " " << argumentOut.arg(fileName) << endl; + kdDebug() << k_funcinfo << " Rendering " << m_convScript << " " << argumentRes.arg(TQString::number(hDPI), TQString::number(vDPI)) << " " << argumentOut.arg(fileName) << endl; // FIXME our sucky sync filter API limitations :-) p.start(KProcess::Block); return fileName; } -bool LatexPlugin::securityCheck(const QString &latexFormula) +bool LatexPlugin::securityCheck(const TQString &latexFormula) { - return !latexFormula.contains(QRegExp("\\\\(def|let|futurelet|newcommand|renewcomment|else|fi|write|input|include" + return !latexFormula.contains(TQRegExp("\\\\(def|let|futurelet|newcommand|renewcomment|else|fi|write|input|include" "|chardef|catcode|makeatletter|noexpand|toksdef|every|errhelp|errorstopmode|scrollmode|nonstopmode|batchmode" "|read|csname|newhelp|relax|afterground|afterassignment|expandafter|noexpand|special|command|loop|repeat|toks" "|output|line|mathcode|name|item|section|mbox|DeclareRobustCommand)[^a-zA-Z]")); -- cgit v1.2.1