1 | /* |
2 | This file is part of KHelpcenter. |
3 | |
4 | Copyright (C) 2002 Cornelius Schumacher <schumacher@kde.org> |
5 | |
6 | This program is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU General Public |
8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. |
10 | |
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 GNU |
14 | General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with this program; see the file COPYING. If not, write to |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. |
20 | */ |
21 | #ifndef KHC_KCMHELPCENTER_H |
22 | #define KHC_KCMHELPCENTER_H |
23 | |
24 | #include <KDialog> |
25 | #include <KSharedConfig> |
26 | #include <KProcess> |
27 | |
28 | #include "scopeitem.h" |
29 | |
30 | class QPushButton; |
31 | class QProgressBar; |
32 | class QTextEdit; |
33 | class QLabel; |
34 | |
35 | class KAboutData; |
36 | class KTemporaryFile; |
37 | class KUrlRequester; |
38 | class QTreeWidget; |
39 | |
40 | namespace KHC { |
41 | class HtmlSearchConfig; |
42 | class DocEntry; |
43 | class SearchEngine; |
44 | } |
45 | |
46 | class IndexDirDialog : public KDialog |
47 | { |
48 | Q_OBJECT |
49 | public: |
50 | IndexDirDialog( QWidget *parent ); |
51 | |
52 | protected Q_SLOTS: |
53 | void slotOk(); |
54 | void slotUrlChanged( const QString &_url); |
55 | private: |
56 | KUrlRequester *mIndexUrlRequester; |
57 | }; |
58 | |
59 | class IndexProgressDialog : public KDialog |
60 | { |
61 | Q_OBJECT |
62 | public: |
63 | IndexProgressDialog( QWidget *parent ); |
64 | ~IndexProgressDialog(); |
65 | |
66 | void setTotalSteps( int ); |
67 | void advanceProgress(); |
68 | void setLabelText( const QString & ); |
69 | void setMinimumLabelWidth( int width ); |
70 | void setFinished( bool ); |
71 | |
72 | void appendLog( const QString &text ); |
73 | |
74 | Q_SIGNALS: |
75 | void closed(); |
76 | void cancelled(); |
77 | |
78 | protected: |
79 | void hideDetails(); |
80 | |
81 | protected Q_SLOTS: |
82 | void slotEnd(); |
83 | void toggleDetails(); |
84 | |
85 | private: |
86 | QLabel *mLabel; |
87 | QProgressBar *mProgressBar; |
88 | QLabel *mLogLabel; |
89 | QTextEdit *mLogView; |
90 | |
91 | bool mFinished; |
92 | }; |
93 | |
94 | class KCMHelpCenter : public KDialog |
95 | { |
96 | Q_OBJECT |
97 | public: |
98 | explicit KCMHelpCenter( KHC::SearchEngine *, QWidget *parent = 0, |
99 | const char *name = 0 ); |
100 | ~KCMHelpCenter(); |
101 | |
102 | void load(); |
103 | bool save(); |
104 | void defaults(); |
105 | |
106 | public Q_SLOTS: |
107 | |
108 | Q_SIGNALS: |
109 | void searchIndexUpdated(); |
110 | public Q_SLOTS: |
111 | void slotIndexError( const QString & ); |
112 | void slotIndexProgress(); |
113 | protected Q_SLOTS: |
114 | bool buildIndex(); |
115 | void cancelBuildIndex(); |
116 | void slotIndexFinished( int exitCode, QProcess::ExitStatus exitStatus ); |
117 | void slotReceivedStdout(); |
118 | void slotReceivedStderr(); |
119 | void slotProgressClosed(); |
120 | |
121 | void slotOk(); |
122 | |
123 | void showIndexDirDialog(); |
124 | |
125 | void checkSelection(); |
126 | |
127 | protected: |
128 | void setupMainWidget( QWidget *parent ); |
129 | void updateStatus(); |
130 | void startIndexProcess(); |
131 | |
132 | void deleteProcess(); |
133 | void deleteCmdFile(); |
134 | |
135 | void advanceProgress(); |
136 | |
137 | private: |
138 | KHC::SearchEngine *mEngine; |
139 | |
140 | QTreeWidget *mListView; |
141 | QLabel *mIndexDirLabel; |
142 | QPushButton *mBuildButton; |
143 | IndexProgressDialog *mProgressDialog; |
144 | |
145 | QList<KHC::DocEntry *> mIndexQueue; |
146 | QList<KHC::DocEntry *>::ConstIterator mCurrentEntry; |
147 | |
148 | KSharedConfigPtr mConfig; |
149 | |
150 | KAboutData *mAboutData; |
151 | |
152 | KHC::HtmlSearchConfig *mHtmlSearchTab; |
153 | QWidget *mScopeTab; |
154 | |
155 | KTemporaryFile *mCmdFile; |
156 | |
157 | KProcess *mProcess; |
158 | |
159 | bool mIsClosing; |
160 | |
161 | QByteArray mStdOut; |
162 | QByteArray mStdErr; |
163 | |
164 | bool mRunAsRoot; |
165 | }; |
166 | |
167 | #endif //KHC_KCMHELPCENTER_H |
168 | // vim:ts=2:sw=2:et |
169 | |