Libksieve

findbarwebengineview.cpp
1 /* SPDX-FileCopyrightText: 2016-2021 Laurent Montel <[email protected]>
2  *
3  * SPDX-License-Identifier: LGPL-2.0-or-later
4  */
5 
6 #include "findbarwebengineview.h"
7 #include <PimCommon/LineEditWithCompleterNg>
8 #include <QAction>
9 #include <QWebEngineView>
10 using namespace KSieveUi;
11 
12 class KSieveUi::FindBarWebEngineViewPrivate
13 {
14 public:
15  FindBarWebEngineViewPrivate()
16  {
17  }
18 
19  QWebEngineView *mView = nullptr;
20 };
21 
22 FindBarWebEngineView::FindBarWebEngineView(QWebEngineView *view, QWidget *parent)
23  : FindBarBase(parent)
24  , d(new KSieveUi::FindBarWebEngineViewPrivate)
25 {
26  d->mView = view;
27 }
28 
29 FindBarWebEngineView::~FindBarWebEngineView()
30 {
31 }
32 
33 void FindBarWebEngineView::searchText(bool backward, bool isAutoSearch)
34 {
35  QWebEnginePage::FindFlags searchOptions;
36 
37  if (backward) {
38  searchOptions |= QWebEnginePage::FindBackward;
39  }
40  if (mCaseSensitiveAct->isChecked()) {
41  searchOptions |= QWebEnginePage::FindCaseSensitively;
42  }
43  const QString searchWord(mSearch->text());
44  if (!isAutoSearch && !mLastSearchStr.contains(searchWord, Qt::CaseSensitive)) {
45  clearSelections();
46  }
47  d->mView->findText(QString()); // Clear an existing highlight
48  mLastSearchStr = searchWord;
49  d->mView->findText(mLastSearchStr, searchOptions, [this](bool found) {
50  setFoundMatch(found);
51  });
52 }
53 
54 void FindBarWebEngineView::updateSensitivity(bool sensitivity)
55 {
56  QWebEnginePage::FindFlags searchOptions;
57  if (sensitivity) {
58  searchOptions |= QWebEnginePage::FindCaseSensitively;
59  d->mView->findText(QString()); // Clear an existing highligh
60  }
61  d->mView->findText(QString(), searchOptions, [this](bool found) {
62  setFoundMatch(found);
63  });
64 }
65 
66 void FindBarWebEngineView::clearSelections()
67 {
68  d->mView->findText(QString());
69  mLastSearchStr.clear();
70  FindBarBase::clearSelections();
71 }
CaseSensitive
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Apr 17 2021 23:09:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.