10 #include "docentrytraverser.h"
20 class SearchTraverser
: public QObject
, public DocEntryTraverser
24 SearchTraverser( SearchEngine
*engine
, int level
);
27 void process( DocEntry
* );
29 void startProcess( DocEntry
* );
31 DocEntryTraverser
*createChild( DocEntry
* );
33 DocEntryTraverser
*parentTraverser();
35 void deleteTraverser();
37 void finishTraversal();
40 void connectHandler( SearchHandler
*handler
);
41 void disconnectHandler( SearchHandler
*handler
);
44 void showSearchResult( SearchHandler
*, DocEntry
*, const QString
&result
);
45 void showSearchError( SearchHandler
*, DocEntry
*, const QString
&error
);
50 SearchEngine
*mEngine
;
58 QMap
<SearchHandler
*, int> mConnectCount
;
62 class SearchEngine
: public QObject
66 enum Operation
{ And
, Or
};
68 SearchEngine( View
* );
71 bool initSearchHandlers();
73 bool search( const QString
& words
, const QString
& method
= "and", int matches
= 5,
74 const QString
& scope
= "" );
76 Formatter
*formatter() const;
79 QString
substituteSearchQuery( const QString
&query
);
81 static QString
substituteSearchQuery( const QString
&query
,
82 const QString
&identifier
, const QStringList
&words
, int maxResults
,
83 Operation operation
, const QString
&lang
);
88 Append error message to error log.
90 void logError( DocEntry
*entry
, const QString
&msg
);
95 QString
errorLog() const;
97 bool isRunning() const;
99 SearchHandler
*handler( const QString
&documentType
) const;
101 QStringList
words() const;
102 int maxResults() const;
103 Operation
operation() const;
105 bool canSearch( DocEntry
* );
106 bool needsIndex( DocEntry
* );
109 void searchFinished();
112 void searchExited(int, QProcess::ExitStatus
);
115 void processSearchQueue();
120 QString mSearchResult
;
132 QStringList mWordList
;
134 Operation mOperation
;
136 DocEntryTraverser
*mRootTraverser
;
138 QMap
<QString
, SearchHandler
*> mHandlers
;