diff options
Diffstat (limited to 'klinkstatus/src/utils/xsl.cpp')
-rw-r--r-- | klinkstatus/src/utils/xsl.cpp | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/klinkstatus/src/utils/xsl.cpp b/klinkstatus/src/utils/xsl.cpp index c3b13412..27f61cb8 100644 --- a/klinkstatus/src/utils/xsl.cpp +++ b/klinkstatus/src/utils/xsl.cpp @@ -33,12 +33,12 @@ // stdlib.h is required to build on Solaris #include <stdlib.h> -#include <qregexp.h> -#include <qsignal.h> -#include <qstylesheet.h> -#include <qthread.h> -#include <qevent.h> -#include <qmutex.h> +#include <tqregexp.h> +#include <tqsignal.h> +#include <tqstylesheet.h> +#include <tqthread.h> +#include <tqevent.h> +#include <tqmutex.h> #include <kapplication.h> #include <kdebug.h> @@ -51,7 +51,7 @@ * The thread class that actually performs the XSL processing. * Using a thread allows async operation. */ -class KopeteXSLThread : public QObject, public QThread +class KopeteXSLThread : public TQObject, public QThread { public: /** @@ -62,36 +62,36 @@ public: * @param target Target object to connect to for async operation * @param slotCompleted Slot to fire on completion in asnc operation */ - KopeteXSLThread( const QString &xmlString, xsltStylesheetPtr xslDoc, QObject *target = 0L, const char *slotCompleted = 0L ); + KopeteXSLThread( const TQString &xmlString, xsltStylesheetPtr xslDoc, TQObject *target = 0L, const char *slotCompleted = 0L ); /** - * Reimplemented from QThread. Does the processing. + * Reimplemented from TQThread. Does the processing. */ virtual void run(); /** * A user event is used to get back to the UI thread to emit the completed signal */ - bool event( QEvent *event ); + bool event( TQEvent *event ); - static QString xsltTransform( const QString &xmlString, xsltStylesheetPtr xslDoc ); + static TQString xsltTransform( const TQString &xmlString, xsltStylesheetPtr xslDoc ); /** * Returns the result string */ - const QString &result() + const TQString &result() { return m_resultString; }; private: - QString m_xml; + TQString m_xml; xsltStylesheetPtr m_xsl; - QString m_resultString; - QObject *m_target; + TQString m_resultString; + TQObject *m_target; const char *m_slotCompleted; - QMutex dataMutex; + TQMutex dataMutex; }; -KopeteXSLThread::KopeteXSLThread( const QString &xmlString, xsltStylesheetPtr xslDoc, QObject *target, const char *slotCompleted ) +KopeteXSLThread::KopeteXSLThread( const TQString &xmlString, xsltStylesheetPtr xslDoc, TQObject *target, const char *slotCompleted ) { m_xml = xmlString; m_xsl = xslDoc; @@ -106,17 +106,17 @@ void KopeteXSLThread::run() m_resultString = xsltTransform( m_xml, m_xsl ); dataMutex.unlock(); // get back to the main thread - qApp->postEvent( this, new QEvent( QEvent::User ) ); + qApp->postEvent( this, new TQEvent( TQEvent::User ) ); } -bool KopeteXSLThread::event( QEvent *event ) +bool KopeteXSLThread::event( TQEvent *event ) { - if ( event->type() == QEvent::User ) + if ( event->type() == TQEvent::User ) { dataMutex.lock(); if( m_target && m_slotCompleted ) { - QSignal completeSignal( m_target ); + TQSignal completeSignal( m_target ); completeSignal.connect( m_target, m_slotCompleted ); completeSignal.setValue( m_resultString ); completeSignal.activate(); @@ -125,23 +125,23 @@ bool KopeteXSLThread::event( QEvent *event ) delete this; return true; } - return QObject::event( event ); + return TQObject::event( event ); } -QString KopeteXSLThread::xsltTransform( const QString &xmlString, xsltStylesheetPtr styleSheet ) +TQString KopeteXSLThread::xsltTransform( const TQString &xmlString, xsltStylesheetPtr styleSheet ) { - // Convert QString into a C string - QCString xmlCString = xmlString.utf8(); + // Convert TQString into a C string + TQCString xmlCString = xmlString.utf8(); - QString resultString; - QString errorMsg; + TQString resultString; + TQString errorMsg; xmlDocPtr xmlDoc = xmlParseMemory( xmlCString, xmlCString.length() ); if ( xmlDoc ) { if ( styleSheet ) { - static QCString appPath( QString::fromLatin1("\"%1\"").arg( KApplication::kApplication()->dirs()->findDirs("appdata", QString::fromLatin1("styles/data") ).front() ).utf8() ); + static TQCString appPath( TQString::fromLatin1("\"%1\"").arg( KApplication::kApplication()->dirs()->findDirs("appdata", TQString::fromLatin1("styles/data") ).front() ).utf8() ); static const char* params[3] = { "appdata", @@ -156,7 +156,7 @@ QString KopeteXSLThread::xsltTransform( const QString &xmlString, xsltStylesheet xmlChar *mem; int size; xmlDocDumpMemory( resultDoc, &mem, &size ); - resultString = QString::fromUtf8( QCString( ( char * )( mem ), size + 1 ) ); + resultString = TQString::fromUtf8( TQCString( ( char * )( mem ), size + 1 ) ); xmlFree( mem ); xmlFreeDoc( resultDoc ); } @@ -196,8 +196,8 @@ public: unsigned int flags; }; -XSLT::XSLT( const QString &document, QObject *parent ) - : QObject( parent ), d(new XSLTPrivate) +XSLT::XSLT( const TQString &document, TQObject *parent ) + : TQObject( parent ), d(new XSLTPrivate) { d->flags = 0; d->xslDoc = 0; @@ -217,12 +217,12 @@ XSLT::~XSLT() delete d; } -void XSLT::setXSLT( const QString &_document ) +void XSLT::setXSLT( const TQString &_document ) { // Search for '<kopete-i18n>' elements and feed them through i18n(). // After that replace the %VAR% variables with their proper XSLT counterpart. // - // FIXME: Preprocessing the document using the QString API is fast and simple, + // FIXME: Preprocessing the document using the TQString API is fast and simple, // but also error-sensitive. // In fact, there are a couple of known issues with this algorithm that // depend on the strings in the current styles. If these strings change @@ -235,47 +235,47 @@ void XSLT::setXSLT( const QString &_document ) // Actually, since we need to parse into a libxml2 document anyway, this whole // nonsense could be replaced with some simple XPath expressions - JK // - QRegExp elementMatch( QString::fromLatin1( "<kopete-i18n>(.*)</kopete-i18n>" ) ); + TQRegExp elementMatch( TQString::fromLatin1( "<kopete-i18n>(.*)</kopete-i18n>" ) ); elementMatch.setMinimal( true ); - QString document = _document; + TQString document = _document; int pos; while ( ( pos = elementMatch.search( document ) ) != -1 ) { - QString orig = elementMatch.cap( 1 ); + TQString orig = elementMatch.cap( 1 ); //kdDebug( 14010 ) << k_funcinfo << "Original text: " << orig << endl; // Split on % and go over all parts // WARNING: If you change the translator comment, also change it in the // styles/extracti18n Perl script, because the strings have to be // identical! - QStringList parts = QStringList::split( '%', i18n( + TQStringList parts = TQStringList::split( '%', i18n( "Translators: The %FOO% placeholders are variables that are substituted " "in the code, please leave them untranslated", orig.utf8() ), true ); // The first part is always text, as our variables are written like %FOO% - QStringList::Iterator it = parts.begin(); - QString trans = *it; + TQStringList::Iterator it = parts.begin(); + TQString trans = *it; bool prependPercent = true; it = parts.remove( it ); for ( it = parts.begin(); it != parts.end(); ++it ) { prependPercent = false; - if ( *it == QString::fromLatin1( "TIME" ) ) + if ( *it == TQString::fromLatin1( "TIME" ) ) { - trans += QString::fromLatin1( "<xsl:value-of select=\"@time\"/>" ); + trans += TQString::fromLatin1( "<xsl:value-of select=\"@time\"/>" ); } - else if ( *it == QString::fromLatin1( "TIMESTAMP" ) ) + else if ( *it == TQString::fromLatin1( "TIMESTAMP" ) ) { - trans += QString::fromLatin1( "<xsl:value-of select=\"@timestamp\"/>" ); + trans += TQString::fromLatin1( "<xsl:value-of select=\"@timestamp\"/>" ); } - else if ( *it == QString::fromLatin1( "FORMATTEDTIMESTAMP" ) ) + else if ( *it == TQString::fromLatin1( "FORMATTEDTIMESTAMP" ) ) { - trans += QString::fromLatin1( "<xsl:value-of select=\"@formattedTimestamp\"/>" ); + trans += TQString::fromLatin1( "<xsl:value-of select=\"@formattedTimestamp\"/>" ); } - else if ( *it == QString::fromLatin1( "FROM_CONTACT_DISPLAYNAME" ) ) + else if ( *it == TQString::fromLatin1( "FROM_CONTACT_DISPLAYNAME" ) ) { - trans += QString::fromLatin1( "<span><xsl:attribute name=\"title\">" + trans += TQString::fromLatin1( "<span><xsl:attribute name=\"title\">" "<xsl:choose>" "<xsl:when test='from/contact/@contactId=from/contact/contactDisplayName/@text'>" "<xsl:value-of disable-output-escaping=\"yes\" select=\"from/contact/metaContactDisplayName/@text\"/>" @@ -290,9 +290,9 @@ void XSLT::setXSLT( const QString &_document ) "</xsl:attribute>" "<xsl:value-of disable-output-escaping=\"yes\" select=\"from/contact/contactDisplayName/@text\"/></span>" ); } - else if ( *it == QString::fromLatin1( "TO_CONTACT_DISPLAYNAME" ) ) + else if ( *it == TQString::fromLatin1( "TO_CONTACT_DISPLAYNAME" ) ) { - trans += QString::fromLatin1( "<span><xsl:attribute name=\"title\">" + trans += TQString::fromLatin1( "<span><xsl:attribute name=\"title\">" "<xsl:choose>" "<xsl:when test='to/contact/@contactId=from/contact/contactDisplayName/@text'>" "<xsl:value-of disable-output-escaping=\"yes\" select=\"to/contact/metaContactDisplayName/@text\"/>" @@ -307,37 +307,37 @@ void XSLT::setXSLT( const QString &_document ) "</xsl:attribute>" "<xsl:value-of disable-output-escaping=\"yes\" select=\"to/contact/contactDisplayName/@text\"/></span>" ); } - else if ( *it == QString::fromLatin1( "FROM_METACONTACT_DISPLAYNAME" ) ) + else if ( *it == TQString::fromLatin1( "FROM_METACONTACT_DISPLAYNAME" ) ) { - trans += QString::fromLatin1( "<span>" + trans += TQString::fromLatin1( "<span>" "<xsl:attribute name=\"dir\">" "<xsl:value-of select=\"from/contact/metaContactDisplayName/@dir\"/>" "</xsl:attribute>" "<xsl:value-of disable-output-escaping=\"yes\" select=\"from/contact/metaContactDisplayName/@text\"/></span>" ); } - else if ( *it == QString::fromLatin1( "TO_METACONTACT_DISPLAYNAME" ) ) + else if ( *it == TQString::fromLatin1( "TO_METACONTACT_DISPLAYNAME" ) ) { - trans += QString::fromLatin1( "<span>" + trans += TQString::fromLatin1( "<span>" "<xsl:attribute name=\"dir\">" "<xsl:value-of select=\"to/contact/metaContactDisplayName/@dir\"/>" "</xsl:attribute>" "<xsl:value-of disable-output-escaping=\"yes\" select=\"to/contact/metaContactDisplayName/@text\"/></span>" ); } - else if ( *it == QString::fromLatin1( "FROM_CONTACT_ID" ) ) + else if ( *it == TQString::fromLatin1( "FROM_CONTACT_ID" ) ) { - trans += QString::fromLatin1( "<span><xsl:attribute name=\"title\">" + trans += TQString::fromLatin1( "<span><xsl:attribute name=\"title\">" "<xsl:value-of disable-output-escaping=\"yes\" select=\"from/contact/contactDisplayName/@text\"/></xsl:attribute>" "<xsl:value-of disable-output-escaping=\"yes\" select=\"from/contact/@contactId\"/></span>" ); } - else if ( *it == QString::fromLatin1( "TO_CONTACT_ID" ) ) + else if ( *it == TQString::fromLatin1( "TO_CONTACT_ID" ) ) { - trans += QString::fromLatin1( "<span><xsl:attribute name=\"title\">" + trans += TQString::fromLatin1( "<span><xsl:attribute name=\"title\">" "<xsl:value-of disable-output-escaping=\"yes\" select=\"to/contact/contactDisplayName/@text\"/></xsl:attribute>" "<xsl:value-of disable-output-escaping=\"yes\" select=\"to/contact/@contactId\"/></span>" ); } - else if ( *it == QString::fromLatin1( "BODY" ) ) + else if ( *it == TQString::fromLatin1( "BODY" ) ) { - trans += QString::fromLatin1( "<xsl:value-of disable-output-escaping=\"yes\" select=\"body\"/>" ); + trans += TQString::fromLatin1( "<xsl:value-of disable-output-escaping=\"yes\" select=\"body\"/>" ); } else { @@ -362,7 +362,7 @@ void XSLT::setXSLT( const QString &_document ) d->xslDoc = 0; d->flags = 0; - QCString rawDocument = document.utf8(); + TQCString rawDocument = document.utf8(); d->xslDoc = xmlParseMemory( rawDocument, rawDocument.length() ); if( d->xslDoc ) @@ -371,13 +371,13 @@ void XSLT::setXSLT( const QString &_document ) if( d->styleSheet ) { // Check for flags - QStringList flags; + TQStringList flags; for( xmlNodePtr child = d->xslDoc->children; child != d->xslDoc->last; child = child->next ) { if( child->type == XML_PI_NODE ) { //We have a flag. Enable it; - QCString flagData( (const char*)child->content ); + TQCString flagData( (const char*)child->content ); if( flagData.contains( "Flag:" ) ) { @@ -387,7 +387,7 @@ void XSLT::setXSLT( const QString &_document ) } if( !flags.isEmpty() ) - setProperty("flags", flags.join( QString::fromLatin1("|") ) ); + setProperty("flags", flags.join( TQString::fromLatin1("|") ) ); } else { @@ -406,12 +406,12 @@ void XSLT::setXSLT( const QString &_document ) } } -QString XSLT::transform( const QString &xmlString ) +TQString XSLT::transform( const TQString &xmlString ) { return KopeteXSLThread::xsltTransform( xmlString, d->styleSheet ); } -void XSLT::transformAsync( const QString &xmlString, QObject *target, const char *slotCompleted ) +void XSLT::transformAsync( const TQString &xmlString, TQObject *target, const char *slotCompleted ) { ( new KopeteXSLThread( xmlString, d->styleSheet, target, slotCompleted ) )->start(); } |