From 0a80cfd57d271dd44221467efb426675fa470356 Mon Sep 17 00:00:00 2001 From: tpearson Date: Tue, 28 Jun 2011 18:31:12 +0000 Subject: TQt4 port kvirc This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kvirc@1238719 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/modules/help/index.cpp | 176 ++++++++++++++++++++++----------------------- 1 file changed, 88 insertions(+), 88 deletions(-) (limited to 'src/modules/help/index.cpp') diff --git a/src/modules/help/index.cpp b/src/modules/help/index.cpp index 659ff44c..ba5e72f3 100755 --- a/src/modules/help/index.cpp +++ b/src/modules/help/index.cpp @@ -1,11 +1,11 @@ #include "index.h" #include "kvi_file.h" -#include -#include +#include +#include #include "kvi_pointerhashtable.h" -#include -#include +#include +#include #include @@ -18,43 +18,43 @@ int kvi_compare(const Term * p1,const Term * p2) return 1; } -QDataStream &operator>>( QDataStream &s, Document &l ) +TQDataStream &operator>>( TQDataStream &s, Document &l ) { s >> l.docNumber; s >> l.frequency; return s; } -QDataStream &operator<<( QDataStream &s, const Document &l ) +TQDataStream &operator<<( TQDataStream &s, const Document &l ) { - s << (Q_INT16)l.docNumber; - s << (Q_INT16)l.frequency; + s << (TQ_INT16)l.docNumber; + s << (TQ_INT16)l.frequency; return s; } -Index::Index( const QString &dp, const QString &hp ) +Index::Index( const TQString &dp, const TQString &hp ) - : QObject( 0, 0 ), dict( 8999 ), docPath( dp ) + : TQObject( 0, 0 ), dict( 8999 ), docPath( dp ) { alreadyHaveDocList = FALSE; lastWindowClosed = FALSE; - connect( qApp, SIGNAL( lastWindowClosed() ), - this, SLOT( setLastWinClosed() ) ); + connect( tqApp, TQT_SIGNAL( lastWindowClosed() ), + this, TQT_SLOT( setLastWinClosed() ) ); } -Index::Index( const QStringList &dl, const QString &hp ) +Index::Index( const TQStringList &dl, const TQString &hp ) - : QObject( 0, 0 ), dict( 8999 ) + : TQObject( 0, 0 ), dict( 8999 ) { docList = dl; alreadyHaveDocList = TRUE; lastWindowClosed = FALSE; - connect( qApp, SIGNAL( lastWindowClosed() ), - this, SLOT( setLastWinClosed() ) ); + connect( tqApp, TQT_SIGNAL( lastWindowClosed() ), + this, TQT_SLOT( setLastWinClosed() ) ); } @@ -69,7 +69,7 @@ void Index::setLastWinClosed() -void Index::setDictionaryFile( const QString &f ) +void Index::setDictionaryFile( const TQString &f ) { @@ -79,7 +79,7 @@ void Index::setDictionaryFile( const QString &f ) -void Index::setDocListFile( const QString &f ) +void Index::setDocListFile( const TQString &f ) { docListFile = f; } @@ -93,7 +93,7 @@ int Index::makeIndex() if ( docList.isEmpty() ) return 1; dict.clear(); - QStringList::Iterator it = docList.begin(); + TQStringList::Iterator it = docList.begin(); int steps = docList.count() / 100; if ( !steps ) steps++; @@ -118,10 +118,10 @@ void Index::setupDocumentList() { docList.clear(); titleList.clear(); - QDir d( docPath ); - QString szCur; - QStringList lst = d.entryList( "*.html" ); - QStringList::ConstIterator it = lst.begin(); + TQDir d( docPath ); + TQString szCur; + TQStringList lst = d.entryList( "*.html" ); + TQStringList::ConstIterator it = lst.begin(); for ( ; it != lst.end(); ++it ) { szCur=docPath + "/" + *it; @@ -132,7 +132,7 @@ void Index::setupDocumentList() -void Index::insertInDict( const QString &str, int docNum ) +void Index::insertInDict( const TQString &str, int docNum ) { if ( strcmp( str, "amp" ) == 0 || strcmp( str, "nbsp" ) == 0 ) return; @@ -152,28 +152,28 @@ void Index::insertInDict( const QString &str, int docNum ) -void Index::parseDocument( const QString &filename, int docNum ) +void Index::parseDocument( const TQString &filename, int docNum ) { KviFile file( filename ); if ( !file.openForReading() ) { qWarning( "can not open file " + filename ); return; } - QTextStream s( &file ); - QString text = s.read(); + TQTextStream s( &file ); + TQString text = s.read(); if (text.isNull()) return; bool valid = TRUE; - const QChar *buf = text.unicode(); - QChar str[64]; - QChar c = buf[0]; + const TQChar *buf = text.tqunicode(); + TQChar str[64]; + TQChar c = buf[0]; int j = 0; int i = 0; while ( (uint)j < text.length() ) { if ( c == '<' || c == '&' ) { valid = FALSE; if ( i > 1 ) - insertInDict( QString(str,i), docNum ); + insertInDict( TQString(str,i), docNum ); i = 0; c = buf[++j]; continue; @@ -202,7 +202,7 @@ void Index::parseDocument( const QString &filename, int docNum ) if ( i > 1 ) - insertInDict( QString(str,i), docNum ); + insertInDict( TQString(str,i), docNum ); i = 0; @@ -214,7 +214,7 @@ void Index::parseDocument( const QString &filename, int docNum ) if ( i > 1 ) - insertInDict( QString(str,i), docNum ); + insertInDict( TQString(str,i), docNum ); file.close(); @@ -226,7 +226,7 @@ void Index::writeDict() { - KviPointerHashTableIterator it( dict ); + KviPointerHashTableIterator it( dict ); KviFile f( dictFile ); @@ -234,7 +234,7 @@ void Index::writeDict() return; - QDataStream s( &f ); + TQDataStream s( &f ); for( ; it.current(); ++it ) { @@ -260,14 +260,14 @@ void Index::writeDocumentList() KviFile f( docListFile ); if ( !f.openForWriting() ) return; - QTextStream s( &f ); - QString docs = docList.join("[#item#]"); + TQTextStream s( &f ); + TQString docs = docList.join("[#item#]"); s << docs; KviFile f1( docListFile+".titles" ); if ( !f1.openForWriting() ) return; - QTextStream s1( &f1 ); + TQTextStream s1( &f1 ); docs = titleList.join("[#item#]"); s1 << docs; } @@ -281,8 +281,8 @@ void Index::readDict() if ( !f.openForReading() ) return; dict.clear(); - QDataStream s( &f ); - QString key; + TQDataStream s( &f ); + TQString key; KviValueList docs; while ( !s.atEnd() ) { s >> key; @@ -301,21 +301,21 @@ void Index::readDocumentList() KviFile f( docListFile ); if ( !f.openForReading() ) return; - QTextStream s( &f ); - docList = QStringList::split("[#item#]",s.read()); + TQTextStream s( &f ); + docList = TQStringList::split("[#item#]",s.read()); //reading titles KviFile f1( docListFile+".titles" ); if ( !f1.openForReading() ) return; - QTextStream s1( &f1 ); - titleList = QStringList::split("[#item#]",s1.read()); + TQTextStream s1( &f1 ); + titleList = TQStringList::split("[#item#]",s1.read()); // debug(titleList); } -QStringList Index::query( const QStringList &terms, const QStringList &termSeq, const QStringList &seqWords ) +TQStringList Index::query( const TQStringList &terms, const TQStringList &termSeq, const TQStringList &seqWords ) { @@ -323,13 +323,13 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq, - QStringList::ConstIterator it = terms.begin(); + TQStringList::ConstIterator it = terms.begin(); for ( it = terms.begin(); it != terms.end(); ++it ) { Entry *e = 0; - if ( (*it).contains( '*' ) ) { + if ( (*it).tqcontains( '*' ) ) { KviValueList wcts = setupDummyTerm( getWildcardTerms( *it ) ); @@ -343,7 +343,7 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq, } else { - return QStringList(); + return TQStringList(); } @@ -357,7 +357,7 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq, if ( !termList.count() ) - return QStringList(); + return TQStringList(); termList.removeFirst(); @@ -409,7 +409,7 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq, - QStringList results; + TQStringList results; #ifndef COMPILE_USE_QT4 qHeapSort( minDocs ); @@ -426,7 +426,7 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq, - QString fileName; + TQString fileName; for ( C = minDocs.begin(); C != minDocs.end(); ++C ) { @@ -444,7 +444,7 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq, -QString Index::getDocumentTitle( const QString &fileName ) +TQString Index::getDocumentTitle( const TQString &fileName ) { @@ -458,19 +458,19 @@ QString Index::getDocumentTitle( const QString &fileName ) } - QTextStream s( &file ); + TQTextStream s( &file ); - QString text = s.read(); + TQString text = s.read(); - int start = text.find( "", 0, FALSE ) + 7; + int start = text.tqfind( "<title>", 0, FALSE ) + 7; - int end = text.find( "", 0, FALSE ); + int end = text.tqfind( "", 0, FALSE ); - QString title = ( end - start <= 0 ? tr("Untitled") : text.mid( start, end - start ) ); + TQString title = ( end - start <= 0 ? tr("Untitled") : text.mid( start, end - start ) ); return title; @@ -478,22 +478,22 @@ QString Index::getDocumentTitle( const QString &fileName ) -QStringList Index::getWildcardTerms( const QString &term ) +TQStringList Index::getWildcardTerms( const TQString &term ) { - QStringList lst; + TQStringList lst; - QStringList terms = split( term ); + TQStringList terms = split( term ); #ifdef COMPILE_USE_QT4 - QStringList::Iterator iter; + TQStringList::Iterator iter; #else - KviValueList::iterator iter; + KviValueList::iterator iter; #endif - KviPointerHashTableIterator it( dict ); + KviPointerHashTableIterator it( dict ); for( ; it.current(); ++it ) { @@ -501,7 +501,7 @@ QStringList Index::getWildcardTerms( const QString &term ) bool found = FALSE; - QString text( it.currentKey() ); + TQString text( it.currentKey() ); for ( iter = terms.begin(); iter != terms.end(); ++iter ) { @@ -521,11 +521,11 @@ QStringList Index::getWildcardTerms( const QString &term ) } - index = text.find( *iter, index ); + index = text.tqfind( *iter, index ); if ( *iter == terms.last() && index != (int)text.length()-1 ) { - index = text.findRev( *iter ); + index = text.tqfindRev( *iter ); if ( index != (int)text.length() - (int)(*iter).length() ) { @@ -569,15 +569,15 @@ QStringList Index::getWildcardTerms( const QString &term ) -QStringList Index::split( const QString &str ) +TQStringList Index::split( const TQString &str ) { - QStringList lst; + TQStringList lst; int j = 0; - int i = str.find( '*', j ); + int i = str.tqfind( '*', j ); @@ -593,7 +593,7 @@ QStringList Index::split( const QString &str ) j = i + 1; - i = str.find( '*', j ); + i = str.tqfind( '*', j ); } @@ -613,13 +613,13 @@ QStringList Index::split( const QString &str ) -KviValueList Index::setupDummyTerm( const QStringList &terms ) +KviValueList Index::setupDummyTerm( const TQStringList &terms ) { TermList termList; - QStringList::ConstIterator it = terms.begin(); + TQStringList::ConstIterator it = terms.begin(); for ( ; it != terms.end(); ++it ) { @@ -663,7 +663,7 @@ KviValueList Index::setupDummyTerm( const QStringList &terms ) for ( docIt = docs.begin(); docIt != docs.end(); ++docIt ) { - if ( maxList.findIndex( *docIt ) == -1 ) + if ( maxList.tqfindIndex( *docIt ) == -1 ) maxList.append( *docIt ); @@ -679,7 +679,7 @@ KviValueList Index::setupDummyTerm( const QStringList &terms ) -void Index::buildMiniDict( const QString &str ) +void Index::buildMiniDict( const TQString &str ) { @@ -693,7 +693,7 @@ void Index::buildMiniDict( const QString &str ) -bool Index::searchForPattern( const QStringList &patterns, const QStringList &words, const QString &fileName ) +bool Index::searchForPattern( const TQStringList &patterns, const TQStringList &words, const TQString &fileName ) { @@ -713,7 +713,7 @@ bool Index::searchForPattern( const QStringList &patterns, const QStringList &wo miniDict.clear(); - QStringList::ConstIterator cIt = words.begin(); + TQStringList::ConstIterator cIt = words.begin(); for ( ; cIt != words.end(); ++cIt ) @@ -721,17 +721,17 @@ bool Index::searchForPattern( const QStringList &patterns, const QStringList &wo - QTextStream s( &file ); + TQTextStream s( &file ); - QString text = s.read(); + TQString text = s.read(); bool valid = TRUE; - const QChar *buf = text.unicode(); + const TQChar *buf = text.tqunicode(); - QChar str[64]; + TQChar str[64]; - QChar c = buf[0]; + TQChar c = buf[0]; int j = 0; @@ -745,7 +745,7 @@ bool Index::searchForPattern( const QStringList &patterns, const QStringList &wo if ( i > 1 ) - buildMiniDict( QString(str,i) ); + buildMiniDict( TQString(str,i) ); i = 0; @@ -783,7 +783,7 @@ bool Index::searchForPattern( const QStringList &patterns, const QStringList &wo if ( i > 1 ) - buildMiniDict( QString(str,i) ); + buildMiniDict( TQString(str,i) ); i = 0; @@ -795,15 +795,15 @@ bool Index::searchForPattern( const QStringList &patterns, const QStringList &wo if ( i > 1 ) - buildMiniDict( QString(str,i) ); + buildMiniDict( TQString(str,i) ); file.close(); - QStringList::ConstIterator patIt = patterns.begin(); + TQStringList::ConstIterator patIt = patterns.begin(); - QStringList wordLst; + TQStringList wordLst; KviValueList a, b; @@ -811,7 +811,7 @@ bool Index::searchForPattern( const QStringList &patterns, const QStringList &wo for ( ; patIt != patterns.end(); ++patIt ) { - wordLst = QStringList::split( ' ', *patIt ); + wordLst = TQStringList::split( ' ', *patIt ); a = miniDict[ wordLst[0] ]->positions; @@ -823,7 +823,7 @@ bool Index::searchForPattern( const QStringList &patterns, const QStringList &wo while ( aIt != a.end() ) { - if ( b.find( *aIt + 1 ) != b.end() ) { + if ( b.tqfind( *aIt + 1 ) != b.end() ) { (*aIt)++; -- cgit v1.2.1