Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
abstractfindwidget_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the Qt API. It exists for the convenience
10// of Qt Designer. This header file may change from version to version
11// without notice, or even be removed.
12//
13// We mean it.
14//
15
16#ifndef ABSTRACTFINDWIDGET_H
17#define ABSTRACTFINDWIDGET_H
18
19#include <QtGui/qicon.h>
20#include <QtWidgets/qwidget.h>
21
23
24class QAction;
25class QCheckBox;
26class QEvent;
27class QKeyEvent;
28class QLabel;
29class QLineEdit;
30class QObject;
31class QToolButton;
32
34{
36
37public:
38 enum FindFlag {
39 /// Use a layout that is roughly half as wide and twice as high as the regular one.
41 /// Do not show the "Whole words" checkbox.
43 /// Do not show the "Case sensitive" checkbox.
45 };
46 Q_DECLARE_FLAGS(FindFlags, FindFlag)
47
48 explicit AbstractFindWidget(FindFlags flags = FindFlags(), QWidget *parent = nullptr);
50
51 bool eventFilter(QObject *object, QEvent *e) override;
52
53 static QIcon findIconSet();
54 QAction *createFindAction(QObject *parent);
55
56public slots:
57 void activate();
58 virtual void deactivate();
59 void findNext();
60 void findPrevious();
61 void findCurrentText();
62
63protected:
64 void keyPressEvent(QKeyEvent *event) override;
65
66private slots:
67 void updateButtons();
68
69protected:
70 virtual void find(const QString &textToFind, bool skipCurrent, bool backward, bool *found, bool *wrapped) = 0;
71
72 bool caseSensitive() const;
73 bool wholeWords() const;
74
75private:
76 void findInternal(const QString &textToFind, bool skipCurrent, bool backward);
77
78 QLineEdit *m_editFind;
79 QLabel *m_labelWrapped;
80 QToolButton *m_toolNext;
81 QToolButton *m_toolClose;
82 QToolButton *m_toolPrevious;
83 QCheckBox *m_checkCase;
84 QCheckBox *m_checkWholeWords;
85};
86
87Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractFindWidget::FindFlags)
88
89QT_END_NAMESPACE
90
91#endif // ABSTRACTFINDWIDGET_H
A search bar that is commonly added below a searchable widget.
virtual void deactivate()
Deactivates the find widget, making it invisible and handing focus to any associated QTextEdit.
~AbstractFindWidget() override
Destroys the AbstractFindWidget.
void keyPressEvent(QKeyEvent *event) override
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
static QIcon findIconSet()
Returns the icon set to be used for the action that initiates a search.
QAction * createFindAction(QObject *parent)
Creates an actions with standard icon and shortcut to activate the widget.
bool eventFilter(QObject *object, QEvent *e) override
Filters events if this object has been installed as an event filter for the watched object.
virtual void find(const QString &textToFind, bool skipCurrent, bool backward, bool *found, bool *wrapped)=0
A search bar that is commonly added below the searchable text.
void setTextEdit(QTextEdit *textEdit)
Associates a QTextEdit with this find widget.
void find(const QString &textToFind, bool skipCurrent, bool backward, bool *found, bool *wrapped) override
\reimp
QTextEdit * textEdit() const
void deactivate() override
\reimp
Combined button and popup list for selecting options.