|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Assistant of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef HELPDIALOG_H |
|
43 #define HELPDIALOG_H |
|
44 |
|
45 #include "ui_helpdialog.h" |
|
46 #include "index.h" |
|
47 #include "helpwindow.h" |
|
48 #include "docuparser.h" |
|
49 |
|
50 #include <QList> |
|
51 #include <QPair> |
|
52 #include <QListWidget> |
|
53 #include <QTreeWidget> |
|
54 #include <QMap> |
|
55 #include <QStringList> |
|
56 #include <QValidator> |
|
57 #include <qmenu.h> |
|
58 #include <QHash> |
|
59 |
|
60 QT_BEGIN_NAMESPACE |
|
61 |
|
62 class QProgressBar; |
|
63 class MainWindow; |
|
64 class QTextBrowser; |
|
65 class IndexListModel; |
|
66 |
|
67 class HelpNavigationListItem : public QListWidgetItem |
|
68 { |
|
69 public: |
|
70 HelpNavigationListItem(QListWidget *ls, const QString &txt); |
|
71 |
|
72 void addLink(const QString &link); |
|
73 QStringList links() const { return linkList; } |
|
74 private: |
|
75 QStringList linkList; |
|
76 |
|
77 }; |
|
78 |
|
79 class SearchValidator : public QValidator |
|
80 { |
|
81 Q_OBJECT |
|
82 public: |
|
83 SearchValidator(QObject *parent) |
|
84 : QValidator(parent) {} |
|
85 ~SearchValidator() {} |
|
86 QValidator::State validate(QString &str, int &) const; |
|
87 }; |
|
88 |
|
89 class HelpDialog : public QWidget |
|
90 { |
|
91 Q_OBJECT |
|
92 public: |
|
93 HelpDialog(QWidget *parent, MainWindow *h); |
|
94 |
|
95 inline QTabWidget *tabWidget() const |
|
96 { return ui.tabWidget; } |
|
97 |
|
98 QString titleOfLink(const QString &link); |
|
99 bool eventFilter(QObject *, QEvent *); |
|
100 bool lastWindowClosed() { return lwClosed; } |
|
101 |
|
102 void timerEvent(QTimerEvent *e); |
|
103 static QString removeAnchorFromLink(const QString &link); |
|
104 |
|
105 signals: |
|
106 void showLink(const QString &s); |
|
107 void showSearchLink(const QString &s, const QStringList &terms); |
|
108 |
|
109 public slots: |
|
110 void initialize(); |
|
111 void startSearch(); |
|
112 void addBookmark(); |
|
113 void currentTabChanged(int index); |
|
114 void locateContents(const QString &link); |
|
115 |
|
116 private slots: |
|
117 void on_buttonAdd_clicked(); |
|
118 void on_buttonRemove_clicked(); |
|
119 void on_termsEdit_returnPressed(); |
|
120 void on_helpButton_clicked(); |
|
121 void on_searchButton_clicked(); |
|
122 void on_resultBox_itemActivated(QListWidgetItem*); |
|
123 void updateSearchButton(const QString &txt); |
|
124 |
|
125 void showResultPage(QListWidgetItem *); |
|
126 |
|
127 void showTopic(QTreeWidgetItem *); |
|
128 void loadIndexFile(); |
|
129 void insertContents(); |
|
130 void setupFullTextIndex(); |
|
131 void showTopic(); |
|
132 void searchInIndex(const QString &s); |
|
133 void toggleContents(); |
|
134 void toggleIndex(); |
|
135 void toggleBookmarks(); |
|
136 void toggleSearch(); |
|
137 void lastWinClosed(); |
|
138 void setIndexingProgress(int prog); |
|
139 void showListItemMenu(const QPoint &pos); |
|
140 void showIndexItemMenu(const QPoint &pos); |
|
141 void showTreeItemMenu(const QPoint &pos); |
|
142 void insertBookmarks(); |
|
143 void processEvents(); |
|
144 |
|
145 private: |
|
146 typedef QList<ContentItem> ContentList; |
|
147 void removeOldCacheFiles(bool onlyFulltextSearchIndex = false); |
|
148 void buildKeywordDB(); |
|
149 quint32 getFileAges(); |
|
150 void showIndexTopic(); |
|
151 void showBookmarkTopic(); |
|
152 void setupTitleMap(); |
|
153 void saveBookmarks(); |
|
154 void showContentsTopic(); |
|
155 void showInitDoneMessage(); |
|
156 void buildContentDict(); |
|
157 QTreeWidgetItem * locateLink(QTreeWidgetItem *item, const QString &link); |
|
158 |
|
159 private: |
|
160 Ui::HelpDialog ui; |
|
161 |
|
162 IndexListModel *indexModel; |
|
163 QMap<QString, QString> titleMap; |
|
164 bool indexDone, bookmarksInserted, titleMapDone, contentsInserted; |
|
165 bool lwClosed; |
|
166 MainWindow *help; |
|
167 QString documentationPath; |
|
168 Index *fullTextIndex; |
|
169 QStringList terms, foundDocs; |
|
170 bool initDoneMsgShown; |
|
171 void getAllContents(); |
|
172 QList<QPair<QString, ContentList> > contentList; |
|
173 QMenu *itemPopup; |
|
174 QString cacheFilesPath; |
|
175 QStringList keywordDocuments; |
|
176 |
|
177 QAction *actionOpenCurrentTab; |
|
178 QAction *actionOpenLinkInNewWindow; |
|
179 QAction *actionOpenLinkInNewTab; |
|
180 }; |
|
181 |
|
182 QT_END_NAMESPACE |
|
183 |
|
184 #endif // HELPDIALOG_H |