source: trunk/tools/assistant/finddialog.ui.h

Last change on this file was 191, checked in by rudi, 14 years ago

Qt Assistant added

File size: 2.9 KB
Line 
1/**********************************************************************
2** Copyright (C) 2000-2007 Trolltech ASA. All rights reserved.
3**
4** This file is part of the Qt Assistant.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12** licenses may use this file in accordance with the Qt Commercial License
13** Agreement provided with the Software.
14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17**
18** See http://www.trolltech.com/gpl/ for GPL licensing information.
19** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20** information about Qt Commercial License Agreements.
21**
22** Contact info@trolltech.com if any conditions of this licensing are
23** not clear to you.
24**
25**********************************************************************/
26
27#include <qapplication.h>
28
29void FindDialog::init()
30{
31 lastBrowser = 0;
32 onceFound = FALSE;
33 findExpr = "";
34 sb = new QStatusBar( this );
35 FindDialogLayout->addWidget( sb );
36 sb->message( tr( "Enter the text you are looking for." ) );
37}
38
39void FindDialog::destroy()
40{
41}
42
43void FindDialog::doFind()
44{
45 doFind(radioForward->isChecked());
46}
47
48void FindDialog::doFind(bool forward)
49{
50 QTextBrowser *browser = (QTextBrowser*) mainWindow()->browsers()->currentBrowser();
51 sb->clear();
52
53 if (comboFind->currentText() != findExpr || lastBrowser != browser)
54 onceFound = false;
55 findExpr = comboFind->currentText();
56
57 bool found;
58 if (browser->hasSelectedText()) { // Search either forward or backward from cursor.
59 found = browser->find(findExpr, checkCase->isChecked(), checkWords->isChecked(),
60 forward);
61 } else {
62 int para = forward ? 0 : INT_MAX;
63 int index = forward ? 0 : INT_MAX;
64 found = browser->find(findExpr, checkCase->isChecked(), checkWords->isChecked(),
65 forward, &para, &index);
66 }
67
68 if (!found) {
69 if (onceFound) {
70 if (forward)
71 statusMessage(tr("Search reached end of the document"));
72 else
73 statusMessage(tr("Search reached start of the document"));
74 } else {
75 statusMessage(tr( "Text not found" ));
76 }
77 }
78 onceFound |= found;
79 lastBrowser = browser;
80}
81
82
83
84MainWindow* FindDialog::mainWindow()
85{
86 return (MainWindow*) parent();
87}
88
89bool FindDialog::hasFindExpression()
90{
91 return !findExpr.isEmpty();
92}
93
94void FindDialog::statusMessage(const QString &message)
95{
96 if (isVisible())
97 sb->message(message);
98 else
99 ((MainWindow*) parent())->statusBar()->message(message, 2000);
100
101}
Note: See TracBrowser for help on using the repository browser.