diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-07-31 19:48:06 +0000 |
commit | 47c8a359c5276062c4bc17f0e82410f29081b502 (patch) | |
tree | 2d54a5f60a5b74067632f9ef6df58c2bc38155e6 /kopete/plugins/latex/latexplugin.cpp | |
parent | 6f82532777a35e0e60bbd2b290b2e93e646f349b (diff) | |
download | tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.tar.gz tdenetwork-47c8a359c5276062c4bc17f0e82410f29081b502.zip |
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1157648 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/plugins/latex/latexplugin.cpp')
-rw-r--r-- | kopete/plugins/latex/latexplugin.cpp | 88 |
1 files changed, 44 insertions, 44 deletions
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 <qregexp.h> -#include <qimage.h> -#include <qbuffer.h> -#include <qcstring.h> -#include <qstylesheet.h> +#include <tqregexp.h> +#include <tqimage.h> +#include <tqbuffer.h> +#include <tqcstring.h> +#include <tqstylesheet.h> #include <kgenericfactory.h> #include <kdebug.h> #include <kstandarddirs.h> @@ -41,7 +41,7 @@ typedef KGenericFactory<LatexPlugin> 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<Kopete::ChatSession*> sessions = Kopete::ChatSessionManager::self()->sessions(); - for (QValueListIterator<Kopete::ChatSession*> it= sessions.begin(); it!=sessions.end() ; ++it) + TQValueList<Kopete::ChatSession*> sessions = Kopete::ChatSessionManager::self()->sessions(); + for (TQValueListIterator<Kopete::ChatSession*> 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<QString, QString> replaceMap; + TQMap<TQString, TQString> 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<QString,QString>::ConstIterator it = replaceMap.begin(); it != replaceMap.end(); ++it) + for (TQMap<TQString,TQString>::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()), " <img width=\"" + QString::number(imagePxWidth) + "\" height=\"" + QString::number(imagePxHeight) + "\" src=\"" + (*it) + "\" alt=\"" + escapedLATEX +"\" title=\"" + escapedLATEX +"\" /> "); + 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()), " <img width=\"" + TQString::number(imagePxWidth) + "\" height=\"" + TQString::number(imagePxHeight) + "\" src=\"" + (*it) + "\" alt=\"" + escapedLATEX +"\" title=\"" + escapedLATEX +"\" /> "); } 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="<img src=\"" + url + "\" alt=\"" + escapedLATEX + "\" title=\"" + escapedLATEX +"\" />"; + TQString escapedLATEX= TQStyleSheet::escape(messageText).replace("\"","""); + TQString messageText="<img src=\"" + url + "\" alt=\"" + escapedLATEX + "\" title=\"" + escapedLATEX +"\" />"; 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]")); |