KTextAddons

texteditfindbarbase.h
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "textcustomeditor_export.h"
10#include <QRegularExpression>
11#include <QWidget>
12namespace TextCustomEditor
13{
14class TextFindWidget;
15class TextReplaceWidget;
16/**
17 * @brief The TextEditFindBarBase class
18 * @author Laurent Montel <montel@kde.org>
19 */
20class TEXTCUSTOMEDITOR_EXPORT TextEditFindBarBase : public QWidget
21{
22 Q_OBJECT
23
24public:
25 enum FindFlag {
26 FindBackward = 0x00001,
27 FindCaseSensitively = 0x00002,
28 FindWholeWords = 0x00004,
29 FindRespectDiacritics = 0x00008,
30 };
31 Q_DECLARE_FLAGS(FindFlags, FindFlag)
32
33 explicit TextEditFindBarBase(QWidget *parent = nullptr);
34 ~TextEditFindBarBase() override;
35
36 [[nodiscard]] QString text() const;
37 void setText(const QString &text);
38
39 void focusAndSetCursor();
40
41 void showReplace();
42 void showFind();
43 void setHideWhenClose(bool hide);
44
45Q_SIGNALS:
46 void displayMessageIndicator(const QString &message);
47 void hideFindBar();
48
49protected:
50 [[nodiscard]] virtual bool viewIsReadOnly() const = 0;
51 [[nodiscard]] virtual bool documentIsEmpty() const = 0;
52 virtual bool searchInDocument(const QString &text, TextEditFindBarBase::FindFlags searchOptions) = 0;
53 virtual bool searchInDocument(const QRegularExpression &regExp, TextEditFindBarBase::FindFlags searchOptions) = 0;
54 virtual void autoSearchMoveCursor() = 0;
55
56 [[nodiscard]] bool event(QEvent *e) override;
57 void clearSelections();
58 bool searchText(bool backward, bool isAutoSearch);
59
60 void setFoundMatch(bool match);
61 void messageInfo(bool backward, bool isAutoSearch, bool found);
62
63public Q_SLOTS:
64 void findNext();
65 void findPrev();
66 void autoSearch(const QString &str);
67 virtual void slotSearchText(bool backward = false, bool isAutoSearch = true) = 0;
68 void closeBar();
69
70private Q_SLOTS:
71 TEXTCUSTOMEDITOR_NO_EXPORT void slotClearSearch();
72 TEXTCUSTOMEDITOR_NO_EXPORT void slotUpdateSearchOptions();
73 virtual void slotReplaceText() = 0;
74 virtual void slotReplaceAllText() = 0;
75
76protected:
77 QString mLastSearchStr;
78 QRegularExpression mLastSearchRegExp;
79 TextFindWidget *const mFindWidget;
80 TextReplaceWidget *const mReplaceWidget;
81 bool mHideWhenClose = true;
82};
83}
The TextEditFindBarBase class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 27 2024 11:48:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.