summaryrefslogtreecommitdiffstats
path: root/src/kchmsearchengine_impl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kchmsearchengine_impl.cpp')
-rw-r--r--src/kchmsearchengine_impl.cpp152
1 files changed, 76 insertions, 76 deletions
diff --git a/src/kchmsearchengine_impl.cpp b/src/kchmsearchengine_impl.cpp
index 286832a..52515c7 100644
--- a/src/kchmsearchengine_impl.cpp
+++ b/src/kchmsearchengine_impl.cpp
@@ -21,11 +21,11 @@
***************************************************************************/
-#include <qfile.h>
-#include <qdir.h>
-#include <qstringlist.h>
-#include <qdict.h>
-#include <qapplication.h>
+#include <tqfile.h>
+#include <tqdir.h>
+#include <tqstringlist.h>
+#include <tqdict.h>
+#include <tqapplication.h>
#include <ctype.h>
@@ -45,7 +45,7 @@ static const char SPLIT_CHARACTERS[] = "!()*&^%#@[]{}':;,.?/|/?<>\\-+=~`";
static const char WORD_CHARACTERS[] = "$_";
-int TermList::compareItems( QPtrCollection::Item i1, QPtrCollection::Item i2 )
+int TermList::compareItems( TQPtrCollection::Item i1, TQPtrCollection::Item i2 )
{
if( ( (Term*)i1 )->frequency == ( (Term*)i2 )->frequency )
return 0;
@@ -54,35 +54,35 @@ int TermList::compareItems( QPtrCollection::Item i1, QPtrCollection::Item i2 )
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 & )
- : QObject( 0, 0 ), dict( 8999 ), docPath( dp )
+Index::Index( const TQString &dp, const TQString & )
+ : TQObject( 0, 0 ), dict( 8999 ), docPath( dp )
{
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 & )
- : QObject( 0, 0 ), dict( 20011 )
+Index::Index( const TQStringList &dl, const TQString & )
+ : TQObject( 0, 0 ), dict( 20011 )
{
docList = dl;
lastWindowClosed = false;
- connect( qApp, SIGNAL( lastWindowClosed() ),
- this, SLOT( setLastWinClosed() ) );
+ connect( tqApp, TQT_SIGNAL( lastWindowClosed() ),
+ this, TQT_SLOT( setLastWinClosed() ) );
}
void Index::setLastWinClosed()
@@ -90,17 +90,17 @@ void Index::setLastWinClosed()
lastWindowClosed = true;
}
-void Index::setDictionaryFile( const QString &f )
+void Index::setDictionaryFile( const TQString &f )
{
dictFile = f;
}
-void Index::setDocListFile( const QString &f )
+void Index::setDocListFile( const TQString &f )
{
docListFile = f;
}
-void Index::setDocList( const QStringList &lst )
+void Index::setDocList( const TQStringList &lst )
{
docList = lst;
}
@@ -110,7 +110,7 @@ bool Index::makeIndex()
if ( docList.isEmpty() )
return false;
- QStringList::Iterator it = docList.begin();
+ TQStringList::Iterator it = docList.begin();
int steps = docList.count() / 100;
if ( !steps )
@@ -136,7 +136,7 @@ bool Index::makeIndex()
}
-void Index::insertInDict( const QString &str, int docNum )
+void Index::insertInDict( const TQString &str, int docNum )
{
Entry *e = 0;
if ( dict.count() )
@@ -156,10 +156,10 @@ void Index::insertInDict( const QString &str, int docNum )
}
-bool Index::parseDocumentToStringlist( const QString & filename, QStringList & tokenlist )
+bool Index::parseDocumentToStringlist( const TQString & filename, TQStringList & tokenlist )
{
- QString parsedbuf, parseentity;
- QString text;
+ TQString parsedbuf, parseentity;
+ TQString text;
if ( !::mainWindow->chmFile()->getFileContentAsString( &text, filename ) )
{
@@ -183,19 +183,19 @@ bool Index::parseDocumentToStringlist( const QString & filename, QStringList & t
{
STATE_OUTSIDE_TAGS, // outside HTML tags; parse text
STATE_IN_HTML_TAG, // inside HTML tags; wait for end tag
- STATE_IN_QUOTES, // inside HTML tags and inside quotes; wait for end quote (in var QuoteChar)
+ STATE_IN_TQUOTES, // inside HTML tags and inside quotes; wait for end quote (in var QuoteChar)
STATE_IN_HTML_ENTITY, // inside HTML entity; parse the entity
};
state_t state = STATE_OUTSIDE_TAGS;
- QChar QuoteChar; // used in STATE_IN_QUOTES
+ TQChar QuoteChar; // used in STATE_IN_TQUOTES
for ( unsigned int j = 0; j < text.length(); j++ )
{
- QChar ch = text[j];
+ TQChar ch = text[j];
if ( (j % 20000) == 0 )
- qApp->processEvents( QEventLoop::ExcludeUserInput );
+ tqApp->tqprocessEvents( TQEventLoop::ExcludeUserInput );
if ( state == STATE_IN_HTML_TAG )
{
@@ -203,7 +203,7 @@ bool Index::parseDocumentToStringlist( const QString & filename, QStringList & t
// Ignore everything until we see '>' (end of HTML tag) or quote char (quote start)
if ( ch == '"' || ch == '\'' )
{
- state = STATE_IN_QUOTES;
+ state = STATE_IN_TQUOTES;
QuoteChar = ch;
}
else if ( ch == '>' )
@@ -211,7 +211,7 @@ bool Index::parseDocumentToStringlist( const QString & filename, QStringList & t
continue;
}
- else if ( state == STATE_IN_QUOTES )
+ else if ( state == STATE_IN_TQUOTES )
{
// We are inside quoted text inside HTML tag.
// Ignore everything until we see the quote character again
@@ -252,7 +252,7 @@ bool Index::parseDocumentToStringlist( const QString & filename, QStringList & t
// Don't we have a space?
if ( parseentity.lower() != "nbsp" )
{
- QString entity = ::mainWindow->chmFile()->impl()->decodeEntity( parseentity );
+ TQString entity = ::mainWindow->chmFile()->impl()->decodeEntity( parseentity );
if ( entity.isNull() )
{
@@ -283,7 +283,7 @@ bool Index::parseDocumentToStringlist( const QString & filename, QStringList & t
if ( ch == '&' )
{
state = STATE_IN_HTML_ENTITY;
- parseentity = QString::null;
+ parseentity = TQString();
continue;
}
@@ -293,20 +293,20 @@ bool Index::parseDocumentToStringlist( const QString & filename, QStringList & t
// Ok, we have a valid character outside HTML tags, and probably some in buffer already.
// If it is char or letter, add it and continue
- if ( ch.isLetterOrNumber() || m_charsword.find( ch ) != -1 )
+ if ( ch.isLetterOrNumber() || m_charsword.tqfind( ch ) != -1 )
{
parsedbuf.append( ch );
continue;
}
// If it is a split char, add the word to the dictionary, and then add the char itself.
- if ( m_charssplit.find( ch ) != -1 )
+ if ( m_charssplit.tqfind( ch ) != -1 )
{
if ( !parsedbuf.isEmpty() )
tokenlist.push_back( parsedbuf.lower() );
tokenlist.push_back( ch.lower() );
- parsedbuf = QString::null;
+ parsedbuf = TQString();
continue;
}
@@ -315,7 +315,7 @@ tokenize_buf:
if ( !parsedbuf.isEmpty() )
{
tokenlist.push_back( parsedbuf.lower() );
- parsedbuf = QString::null;
+ parsedbuf = TQString();
}
}
@@ -327,22 +327,22 @@ tokenize_buf:
}
-void Index::parseDocument( const QString &filename, int docNum )
+void Index::parseDocument( const TQString &filename, int docNum )
{
- QStringList terms;
+ TQStringList terms;
if ( !parseDocumentToStringlist( filename, terms ) )
return;
- for ( QStringList::Iterator it = terms.begin(); it != terms.end(); ++it )
+ for ( TQStringList::Iterator it = terms.begin(); it != terms.end(); ++it )
insertInDict( *it, docNum );
}
void Index::writeDict()
{
- QDictIterator<Entry> it( dict );
- QFile f( dictFile );
+ TQDictIterator<Entry> it( dict );
+ TQFile f( dictFile );
if ( !f.open( IO_WriteOnly ) )
{
@@ -350,7 +350,7 @@ void Index::writeDict()
return;
}
- QDataStream s( &f );
+ TQDataStream s( &f );
s << (int) 1; // version
s << m_charssplit;
s << m_charsword;
@@ -368,27 +368,27 @@ void Index::writeDict()
void Index::writeDocumentList()
{
- QFile f( docListFile );
+ TQFile f( docListFile );
if ( !f.open( IO_WriteOnly ) )
{
qWarning( "Index::writeDocumentList: could not write dictionary file %s", docListFile.ascii() );
return;
}
- QDataStream s( &f );
+ TQDataStream s( &f );
s << docList;
}
bool Index::readDict()
{
- QFile f( dictFile );
+ TQFile f( dictFile );
if ( !f.open( IO_ReadOnly ) )
return false;
dict.clear();
- QDataStream s( &f );
- QString key;
+ TQDataStream s( &f );
+ TQString key;
int version;
- QValueList<Document> docs;
+ TQValueList<Document> docs;
s >> version;
s >> m_charssplit;
@@ -407,19 +407,19 @@ bool Index::readDict()
bool Index::readDocumentList()
{
- QFile f( docListFile );
+ TQFile f( docListFile );
if ( !f.open( IO_ReadOnly ) )
return false;
- QDataStream s( &f );
+ TQDataStream s( &f );
s >> docList;
return true;
}
-QStringList Index::query( const QStringList &terms, const QStringList &termSeq, const QStringList &seqWords )
+TQStringList Index::query( const TQStringList &terms, const TQStringList &termSeq, const TQStringList &seqWords )
{
TermList termList;
- QStringList::ConstIterator it = terms.begin();
+ TQStringList::ConstIterator it = terms.begin();
for ( it = terms.begin(); it != terms.end(); ++it )
{
Entry *e = 0;
@@ -431,7 +431,7 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq,
}
else
{
- return QStringList();
+ return TQStringList();
}
}
@@ -440,18 +440,18 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq,
Term *minTerm = termList.first();
if ( !termList.count() )
- return QStringList();
+ return TQStringList();
termList.removeFirst();
- QValueList<Document> minDocs = minTerm->documents;
- QValueList<Document>::iterator C;
- QValueList<Document>::ConstIterator It;
+ TQValueList<Document> minDocs = minTerm->documents;
+ TQValueList<Document>::iterator C;
+ TQValueList<Document>::ConstIterator It;
Term *t = termList.first();
for ( ; t; t = termList.next() )
{
- QValueList<Document> docs = t->documents;
+ TQValueList<Document> docs = t->documents;
C = minDocs.begin();
while ( C != minDocs.end() )
@@ -475,7 +475,7 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq,
}
}
- QStringList results;
+ TQStringList results;
qHeapSort( minDocs );
if ( termSeq.isEmpty() )
@@ -486,7 +486,7 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq,
return results;
}
- QString fileName;
+ TQString fileName;
for ( C = minDocs.begin(); C != minDocs.end(); ++C )
{
@@ -500,9 +500,9 @@ QStringList Index::query( const QStringList &terms, const QStringList &termSeq,
}
-bool Index::searchForPhrases( const QStringList &phrases, const QStringList &words, const QString &filename )
+bool Index::searchForPhrases( const TQStringList &phrases, const TQStringList &words, const TQString &filename )
{
- QStringList parsed_document;
+ TQStringList parsed_document;
if ( !parseDocumentToStringlist( filename, parsed_document ) )
return false;
@@ -510,12 +510,12 @@ bool Index::searchForPhrases( const QStringList &phrases, const QStringList &wor
miniDict.clear();
// Initialize the dictionary with the words in phrase(s)
- for ( QStringList::ConstIterator cIt = words.begin(); cIt != words.end(); ++cIt )
+ for ( TQStringList::ConstIterator cIt = words.begin(); cIt != words.end(); ++cIt )
miniDict.insert( *cIt, new PosEntry( 0 ) );
// Fill the dictionary with the words from the document
unsigned int word_offset = 3;
- for ( QStringList::ConstIterator it = parsed_document.begin(); it != parsed_document.end(); it++, word_offset++ )
+ for ( TQStringList::ConstIterator it = parsed_document.begin(); it != parsed_document.end(); it++, word_offset++ )
{
PosEntry * entry = miniDict[ *it ];
@@ -525,33 +525,33 @@ bool Index::searchForPhrases( const QStringList &phrases, const QStringList &wor
// Dump it
/*
- QDictIterator<PosEntry> it( miniDict );
+ TQDictIterator<PosEntry> it( miniDict );
for( ; it.current(); ++it )
{
- QString text( it.currentKey() );
- QValueList<uint> pos = miniDict[text]->positions;
+ TQString text( it.currentKey() );
+ TQValueList<uint> pos = miniDict[text]->positions;
for ( unsigned int i = 1; i < pos.size(); i++ )
- text += " " + QString::number( pos[i] );
+ text += " " + TQString::number( pos[i] );
qDebug( "%s", text.ascii());
}
*/
- QValueList<uint> first_word_positions;
+ TQValueList<uint> first_word_positions;
- for ( QStringList::ConstIterator phrase_it = phrases.begin(); phrase_it != phrases.end(); phrase_it++ )
+ for ( TQStringList::ConstIterator phrase_it = phrases.begin(); phrase_it != phrases.end(); phrase_it++ )
{
- QStringList phrasewords = QStringList::split( ' ', *phrase_it );
+ TQStringList phrasewords = TQStringList::split( ' ', *phrase_it );
first_word_positions = miniDict[ phrasewords[0] ]->positions;
for ( unsigned int j = 1; j < phrasewords.count(); ++j )
{
- QValueList<uint> next_word_it = miniDict[ phrasewords[j] ]->positions;
- QValueList<uint>::iterator dict_it = first_word_positions.begin();
+ TQValueList<uint> next_word_it = miniDict[ phrasewords[j] ]->positions;
+ TQValueList<uint>::iterator dict_it = first_word_positions.begin();
while ( dict_it != first_word_positions.end() )
{
- if ( next_word_it.find( *dict_it + 1 ) != next_word_it.end() )
+ if ( next_word_it.tqfind( *dict_it + 1 ) != next_word_it.end() )
{
(*dict_it)++;
++dict_it;