1 /* ============================================================
2 *
3 * This file is a part of the rekonq project
4 *
5 * Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
6 * Copyright (C) 2009-2011 by Lionel Chauvin <megabigbug@yahoo.fr>
7 *
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License or (at your option) version 3 or any later version
13 * accepted by the membership of KDE e.V. (or its successor approved
14 * by the membership of KDE e.V.), which shall act as a proxy
15 * defined in Section 14 of version 3 of the license.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
24 *
25 * ============================================================ */
26 
27 
28 #ifndef GUI_FINDBAR_H
29 #define GUI_FINDBAR_H
30 
31 #include <QPointer>
32 #include <QWidget>
33 
34 class QCheckBox;
35 class QLineEdit;
36 class QString;
37 class QWebView;
38 
39 namespace Gui {
40 
41 class FindBar : public QWidget
42 {
43     Q_OBJECT
44 
45 public:
46     explicit FindBar(QWidget *parent);
47     enum FindDirection { Forward = 0, Backward };
48 
49     bool matchCase() const;
50     void notifyMatch(bool match);
51     bool highlightAllState() const;
52 
53     void setVisible(bool visible);
54     void setAssociatedWebView(QWebView *webView);
55 
56 protected:
57     void keyPressEvent(QKeyEvent *event);
58 
59 private slots:
60     void findText(const QString &search);
61     void matchCaseUpdate();
62     void findNext();
63     void findPrevious();
64     void updateHighlight();
65     void resetAssociatedWebView();
66 
67 signals:
68     void searchString(const QString &);
69 
70 private:
71     void find(FindDirection dir);
72 
73 private:
74     QLineEdit *m_lineEdit;
75     QCheckBox *m_matchCase;
76     QCheckBox *m_highlightAll;
77 
78     QString _lastStringSearched;
79     QPointer<QWebView> m_associatedWebView;
80 };
81 
82 }
83 
84 #endif
85