Libksieve

findbarwebengineview.cpp
1 /* Copyright (C) 2016-2020 Laurent Montel <[email protected]>
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Library General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU Library General Public License
14  * along with this library; see the file COPYING.LIB. If not, write to
15  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  * Boston, MA 02110-1301, USA.
17  */
18 
19 #include "findbarwebengineview.h"
20 #include <PimCommon/LineEditWithCompleterNg>
21 #include <QWebEngineView>
22 #include <QAction>
23 using namespace KSieveUi;
24 
25 class KSieveUi::FindBarWebEngineViewPrivate
26 {
27 public:
28  FindBarWebEngineViewPrivate()
29  {
30  }
31 
32  QWebEngineView *mView = nullptr;
33 };
34 
35 FindBarWebEngineView::FindBarWebEngineView(QWebEngineView *view, QWidget *parent)
36  : FindBarBase(parent)
37  , d(new KSieveUi::FindBarWebEngineViewPrivate)
38 {
39  d->mView = view;
40 }
41 
42 FindBarWebEngineView::~FindBarWebEngineView()
43 {
44  delete d;
45 }
46 
47 void FindBarWebEngineView::searchText(bool backward, bool isAutoSearch)
48 {
49  QWebEnginePage::FindFlags searchOptions;
50 
51  if (backward) {
52  searchOptions |= QWebEnginePage::FindBackward;
53  }
54  if (mCaseSensitiveAct->isChecked()) {
55  searchOptions |= QWebEnginePage::FindCaseSensitively;
56  }
57  const QString searchWord(mSearch->text());
58  if (!isAutoSearch && !mLastSearchStr.contains(searchWord, Qt::CaseSensitive)) {
59  clearSelections();
60  }
61  d->mView->findText(QString()); //Clear an existing highlight
62  mLastSearchStr = searchWord;
63  d->mView->findText(mLastSearchStr, searchOptions, [this](bool found) {
64  setFoundMatch(found);
65  });
66 }
67 
68 void FindBarWebEngineView::updateSensitivity(bool sensitivity)
69 {
70  QWebEnginePage::FindFlags searchOptions;
71  if (sensitivity) {
72  searchOptions |= QWebEnginePage::FindCaseSensitively;
73  d->mView->findText(QString()); //Clear an existing highligh
74  }
75  d->mView->findText(QString(), searchOptions, [this](bool found) {
76  setFoundMatch(found);
77  });
78 }
79 
80 void FindBarWebEngineView::clearSelections()
81 {
82  d->mView->findText(QString());
83  mLastSearchStr.clear();
84  FindBarBase::clearSelections();
85 }
CaseSensitive
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jul 13 2020 23:08:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.