65 public: |
65 public: |
66 QDefaultResultWidget(QWidget *parent = 0) |
66 QDefaultResultWidget(QWidget *parent = 0) |
67 : QTreeWidget(parent) |
67 : QTreeWidget(parent) |
68 { |
68 { |
69 header()->hide(); |
69 header()->hide(); |
70 connect(this, SIGNAL(itemActivated(QTreeWidgetItem*, int)), |
70 connect(this, SIGNAL(itemActivated(QTreeWidgetItem*,int)), |
71 this, SLOT(itemActivated(QTreeWidgetItem*, int))); |
71 this, SLOT(itemActivated(QTreeWidgetItem*,int))); |
72 } |
72 } |
73 |
73 |
74 void showResultPage(const QList<QHelpSearchEngine::SearchHit> hits) |
74 void showResultPage(const QList<QHelpSearchEngine::SearchHit> hits) |
75 { |
75 { |
76 foreach (const QHelpSearchEngine::SearchHit hit, hits) |
76 foreach (const QHelpSearchEngine::SearchHit hit, hits) |
97 |
97 |
98 public: |
98 public: |
99 QCLuceneResultWidget(QWidget *parent = 0) |
99 QCLuceneResultWidget(QWidget *parent = 0) |
100 : QTextBrowser(parent) |
100 : QTextBrowser(parent) |
101 { |
101 { |
102 connect(this, SIGNAL(anchorClicked(const QUrl&)), |
102 connect(this, SIGNAL(anchorClicked(QUrl)), |
103 this, SIGNAL(requestShowLink(const QUrl&))); |
103 this, SIGNAL(requestShowLink(QUrl))); |
104 setContextMenuPolicy(Qt::NoContextMenu); |
104 setContextMenuPolicy(Qt::NoContextMenu); |
105 } |
105 } |
106 |
106 |
107 void showResultPage(const QList<QHelpSearchEngine::SearchHit> hits, bool isIndexing) |
107 void showResultPage(const QList<QHelpSearchEngine::SearchHit> hits, bool isIndexing) |
108 { |
108 { |
167 } |
167 } |
168 |
168 |
169 void showNextResultPage() |
169 void showNextResultPage() |
170 { |
170 { |
171 if (!searchEngine.isNull() |
171 if (!searchEngine.isNull() |
172 && resultLastToShow < searchEngine->hitsCount()) { |
172 && resultLastToShow < searchEngine->hitCount()) { |
173 resultLastToShow += 20; |
173 resultLastToShow += 20; |
174 resultFirstToShow += 20; |
174 resultFirstToShow += 20; |
175 |
175 |
176 resultTextBrowser->showResultPage(searchEngine->hits(resultFirstToShow, |
176 resultTextBrowser->showResultPage(searchEngine->hits(resultFirstToShow, |
177 resultLastToShow), isIndexing); |
177 resultLastToShow), isIndexing); |
178 if (resultLastToShow >= searchEngine->hitsCount()) |
178 if (resultLastToShow >= searchEngine->hitCount()) |
179 updateNextButtonState(false); |
179 updateNextButtonState(false); |
180 } |
180 } |
181 updateHitRange(); |
181 updateHitRange(); |
182 } |
182 } |
183 |
183 |
184 void showLastResultPage() |
184 void showLastResultPage() |
185 { |
185 { |
186 if (!searchEngine.isNull()) { |
186 if (!searchEngine.isNull()) { |
187 resultLastToShow = searchEngine->hitsCount(); |
187 resultLastToShow = searchEngine->hitCount(); |
188 resultFirstToShow = resultLastToShow - (resultLastToShow % 20); |
188 resultFirstToShow = resultLastToShow - (resultLastToShow % 20); |
189 |
189 |
190 if (resultFirstToShow == resultLastToShow) |
190 if (resultFirstToShow == resultLastToShow) |
191 resultFirstToShow -= 20; |
191 resultFirstToShow -= 20; |
192 |
192 |
212 |
212 |
213 void showPreviousResultPage() |
213 void showPreviousResultPage() |
214 { |
214 { |
215 if (!searchEngine.isNull()) { |
215 if (!searchEngine.isNull()) { |
216 int count = resultLastToShow % 20; |
216 int count = resultLastToShow % 20; |
217 if (count == 0 || resultLastToShow != searchEngine->hitsCount()) |
217 if (count == 0 || resultLastToShow != searchEngine->hitCount()) |
218 count = 20; |
218 count = 20; |
219 |
219 |
220 resultLastToShow -= count; |
220 resultLastToShow -= count; |
221 resultFirstToShow = resultLastToShow -20; |
221 resultFirstToShow = resultLastToShow -20; |
222 |
222 |
383 vLayout->addLayout(hBoxLayout); |
383 vLayout->addLayout(hBoxLayout); |
384 |
384 |
385 d->resultTextBrowser = new QCLuceneResultWidget(this); |
385 d->resultTextBrowser = new QCLuceneResultWidget(this); |
386 vLayout->addWidget(d->resultTextBrowser); |
386 vLayout->addWidget(d->resultTextBrowser); |
387 |
387 |
388 connect(d->resultTextBrowser, SIGNAL(requestShowLink(const QUrl&)), this, |
388 connect(d->resultTextBrowser, SIGNAL(requestShowLink(QUrl)), this, |
389 SIGNAL(requestShowLink(const QUrl&))); |
389 SIGNAL(requestShowLink(QUrl))); |
390 |
390 |
391 connect(d->nextResultPage, SIGNAL(clicked()), d, SLOT(showNextResultPage())); |
391 connect(d->nextResultPage, SIGNAL(clicked()), d, SLOT(showNextResultPage())); |
392 connect(d->lastResultPage, SIGNAL(clicked()), d, SLOT(showLastResultPage())); |
392 connect(d->lastResultPage, SIGNAL(clicked()), d, SLOT(showLastResultPage())); |
393 connect(d->firstResultPage, SIGNAL(clicked()), d, SLOT(showFirstResultPage())); |
393 connect(d->firstResultPage, SIGNAL(clicked()), d, SLOT(showFirstResultPage())); |
394 connect(d->previousResultPage, SIGNAL(clicked()), d, SLOT(showPreviousResultPage())); |
394 connect(d->previousResultPage, SIGNAL(clicked()), d, SLOT(showPreviousResultPage())); |
399 connect(d->lastResultPage, SIGNAL(clicked()), d, SLOT(updatePrevButtonState())); |
399 connect(d->lastResultPage, SIGNAL(clicked()), d, SLOT(updatePrevButtonState())); |
400 |
400 |
401 #else |
401 #else |
402 d->resultTreeWidget = new QDefaultResultWidget(this); |
402 d->resultTreeWidget = new QDefaultResultWidget(this); |
403 vLayout->addWidget(d->resultTreeWidget); |
403 vLayout->addWidget(d->resultTreeWidget); |
404 connect(d->resultTreeWidget, SIGNAL(requestShowLink(const QUrl&)), this, |
404 connect(d->resultTreeWidget, SIGNAL(requestShowLink(QUrl)), this, |
405 SIGNAL(requestShowLink(const QUrl&))); |
405 SIGNAL(requestShowLink(QUrl))); |
406 #endif |
406 #endif |
407 |
407 |
408 connect(engine, SIGNAL(searchingFinished(int)), d, SLOT(setResults(int))); |
408 connect(engine, SIGNAL(searchingFinished(int)), d, SLOT(setResults(int))); |
409 } |
409 } |
410 |
410 |