delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / khelpcenter / searchhandler.h
blobe85e6441c1252bb8aeba8438af1ab69c8b90ecc9
1 /*
2 This file is part of KHelpCenter.
4 Copyright (c) 2005 Cornelius Schumacher <schumacher@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef KHC_SEARCHHANDLER_H
21 #define KHC_SEARCHHANDLER_H
23 #include "searchengine.h"
25 #include <QObject>
26 #include <KProcess>
28 class KConfigGroup;
29 namespace KIO {
30 class Job;
33 namespace KHC {
35 class SearchJob : public QObject {
36 Q_OBJECT
37 public:
38 SearchJob(DocEntry *entry);
39 ~SearchJob();
41 bool startLocal(const QString &cmdString);
42 bool startRemote(const QString &url);
44 Q_SIGNALS:
45 void searchFinished( SearchJob *, DocEntry *, const QString & );
46 void searchError( SearchJob *, DocEntry *, const QString & );
48 protected Q_SLOTS:
49 void searchExited( int exitCode, QProcess::ExitStatus );
50 void slotJobResult( KJob *job );
51 void slotJobData( KIO::Job *, const QByteArray &data );
53 protected:
54 DocEntry *mEntry;
55 KProcess *mProcess;
56 KIO::Job *mKioJob;
57 QString mCmd;
58 QString mResult;
59 QString mError;
62 class SearchHandler : public QObject
64 Q_OBJECT
65 public:
66 static SearchHandler *initFromFile( const QString &filename );
68 virtual ~SearchHandler();
70 virtual void search( DocEntry *, const QStringList &words,
71 int maxResults = 10,
72 SearchEngine::Operation operation = SearchEngine::And ) = 0;
74 virtual QString indexCommand( const QString &identifier ) = 0;
76 QStringList documentTypes() const;
78 virtual bool checkPaths() const = 0;
80 Q_SIGNALS:
81 void searchFinished( SearchHandler *, DocEntry *, const QString & );
82 void searchError( SearchHandler *, DocEntry *, const QString & );
84 protected:
85 SearchHandler( const KConfigGroup &cg );
87 QString mLang;
88 QStringList mDocumentTypes;
91 class ExternalProcessSearchHandler : public SearchHandler
93 Q_OBJECT
94 public:
95 ExternalProcessSearchHandler( const KConfigGroup &cg );
97 void search( DocEntry *, const QStringList &words,
98 int maxResults = 10,
99 SearchEngine::Operation operation = SearchEngine::And );
101 QString indexCommand( const QString &identifier );
103 bool checkPaths() const;
105 private:
106 bool checkBinary( const QString &cmd ) const;
108 private slots:
109 void slotSearchFinished( SearchJob *, DocEntry *, const QString & );
110 void slotSearchError( SearchJob *, DocEntry *, const QString & );
112 private:
113 QString mSearchCommand;
114 QString mSearchUrl;
115 QString mIndexCommand;
120 #endif