| 1 | // Copyright (C) 2016 The Qt Company Ltd. | 
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only | 
| 3 |  | 
| 4 | // | 
| 5 | //  W A R N I N G | 
| 6 | //  ------------- | 
| 7 | // | 
| 8 | // This file is not part of the Qt API. It exists for the convenience | 
| 9 | // of Qt Designer. This header file may change from version to version | 
| 10 | // without notice, or even be removed. | 
| 11 | // | 
| 12 | // We mean it. | 
| 13 | // | 
| 14 |  | 
| 15 | #ifndef ABSTRACTFINDWIDGET_H | 
| 16 | #define ABSTRACTFINDWIDGET_H | 
| 17 |  | 
| 18 | #include <QtGui/QIcon> | 
| 19 | #include <QtWidgets/QWidget> | 
| 20 |  | 
| 21 | QT_BEGIN_NAMESPACE | 
| 22 |  | 
| 23 | class QAction; | 
| 24 | class QCheckBox; | 
| 25 | class QEvent; | 
| 26 | class QKeyEvent; | 
| 27 | class QLabel; | 
| 28 | class QLineEdit; | 
| 29 | class QObject; | 
| 30 | class QToolButton; | 
| 31 |  | 
| 32 | class AbstractFindWidget : public QWidget | 
| 33 | { | 
| 34 |     Q_OBJECT | 
| 35 |  | 
| 36 | public: | 
| 37 |     enum FindFlag { | 
| 38 |         /// Use a layout that is roughly half as wide and twice as high as the regular one. | 
| 39 |         NarrowLayout = 1, | 
| 40 |         /// Do not show the "Whole words" checkbox. | 
| 41 |         NoWholeWords = 2, | 
| 42 |         /// Do not show the "Case sensitive" checkbox. | 
| 43 |         NoCaseSensitive = 4 | 
| 44 |     }; | 
| 45 |     Q_DECLARE_FLAGS(FindFlags, FindFlag) | 
| 46 |  | 
| 47 |     explicit AbstractFindWidget(FindFlags flags = FindFlags(), QWidget *parent = 0); | 
| 48 |     ~AbstractFindWidget() override; | 
| 49 |  | 
| 50 |     bool eventFilter(QObject *object, QEvent *e) override; | 
| 51 |  | 
| 52 |     static QIcon findIconSet(); | 
| 53 |     QAction *createFindAction(QObject *parent); | 
| 54 |  | 
| 55 | public slots: | 
| 56 |     void activate(); | 
| 57 |     virtual void deactivate(); | 
| 58 |     void findNext(); | 
| 59 |     void findPrevious(); | 
| 60 |     void findCurrentText(); | 
| 61 |  | 
| 62 | protected: | 
| 63 |     void keyPressEvent(QKeyEvent *event) override; | 
| 64 |  | 
| 65 | private slots: | 
| 66 |     void updateButtons(); | 
| 67 |  | 
| 68 | protected: | 
| 69 |     virtual void find(const QString &textToFind, bool skipCurrent, bool backward, bool *found, bool *wrapped) = 0; | 
| 70 |  | 
| 71 |     bool caseSensitive() const; | 
| 72 |     bool wholeWords() const; | 
| 73 |  | 
| 74 | private: | 
| 75 |     void findInternal(const QString &textToFind, bool skipCurrent, bool backward); | 
| 76 |  | 
| 77 |     QLineEdit *m_editFind; | 
| 78 |     QLabel *m_labelWrapped; | 
| 79 |     QToolButton *m_toolNext; | 
| 80 |     QToolButton *m_toolClose; | 
| 81 |     QToolButton *m_toolPrevious; | 
| 82 |     QCheckBox *m_checkCase; | 
| 83 |     QCheckBox *m_checkWholeWords; | 
| 84 | }; | 
| 85 |  | 
| 86 | Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractFindWidget::FindFlags) | 
| 87 |  | 
| 88 | QT_END_NAMESPACE | 
| 89 |  | 
| 90 | #endif  // ABSTRACTFINDWIDGET_H | 
| 91 |  |