LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
Loading...
Searching...
No Matches
findnotificationwk.h
Go to the documentation of this file.
1
/**********************************************************************
2
* LeechCraft - modular cross-platform feature rich internet client.
3
* Copyright (C) 2006-2014 Georg Rudoy
4
*
5
* Distributed under the Boost Software License, Version 1.0.
6
* (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7
**********************************************************************/
8
9
#pragma once
10
11
#include "
findnotification.h
"
12
#include <QWebPage>
13
#include <QWebView>
14
15
namespace
LC::Util
16
{
32
class
UTIL_GUI_API
FindNotificationWk
:
public
FindNotification
33
{
34
QWebView *
const
WebView_;
35
QString PreviousFindText_;
36
public
:
46
FindNotificationWk
(
const
ICoreProxy_ptr
& proxy, QWebView *near)
47
:
FindNotification
{ proxy, near }
48
, WebView_ { near }
49
{
50
connect (near,
51
&QWebView::loadFinished,
52
this
,
53
[
this
]
54
{
55
if
(PreviousFindText_.isEmpty ())
56
return
;
57
58
ClearFindResults ();
59
FindNext
();
60
});
61
}
62
69
static
QWebPage::FindFlags
ToPageFlags
(FindFlags findFlags)
70
{
71
QWebPage::FindFlags pageFlags;
72
auto
check = [&pageFlags, findFlags] (
FindFlag
ourFlag, QWebPage::FindFlag pageFlag)
73
{
74
if
(findFlags & ourFlag)
75
pageFlags |= pageFlag;
76
};
77
check (
FindCaseSensitively
, QWebPage::FindCaseSensitively);
78
check (
FindBackwards
, QWebPage::FindBackward);
79
check (
FindWrapsAround
, QWebPage::FindWrapsAroundDocument);
80
return
pageFlags;
81
}
82
private
:
83
void
ClearFindResults ()
84
{
85
PreviousFindText_.clear ();
86
WebView_->page ()->findText ({}, QWebPage::HighlightAllOccurrences);
87
}
88
protected
:
89
void
HandleNext
(
const
QString& text, FindFlags findFlags)
override
90
{
91
const
auto
flags =
ToPageFlags
(findFlags);
92
93
if
(PreviousFindText_ != text)
94
{
95
const
auto
nflags = flags | QWebPage::HighlightAllOccurrences;
96
WebView_->page ()->findText ({}, nflags);
97
WebView_->page ()->findText (text, nflags);
98
PreviousFindText_ = text;
99
}
100
101
const
auto
found = WebView_->page ()->findText (text, flags);
102
SetSuccessful
(found);
103
}
104
105
void
Reject
()
override
106
{
107
FindNotification::Reject
();
108
ClearFindResults ();
109
}
110
};
111
}
LC::Util::FindNotification::FindFlag
FindFlag
Definition
findnotification.h:69
LC::Util::FindNotification::FindWrapsAround
@ FindWrapsAround
Definition
findnotification.h:86
LC::Util::FindNotification::FindCaseSensitively
@ FindCaseSensitively
Definition
findnotification.h:76
LC::Util::FindNotification::FindBackwards
@ FindBackwards
Definition
findnotification.h:80
LC::Util::FindNotification::Reject
virtual void Reject()
Definition
findnotification.cpp:132
LC::Util::FindNotification::FindNext
void FindNext()
Search for the next occurrence of the search text.
Definition
findnotification.cpp:109
LC::Util::FindNotification::FindNotification
FindNotification(const ICoreProxy_ptr &proxy, QWidget *near)
Creates the search widget in parent layout of near.
Definition
findnotification.cpp:19
LC::Util::FindNotification::SetSuccessful
void SetSuccessful(bool successful)
Updates the widget to show whether the search has been successful.
Definition
findnotification.cpp:83
LC::Util::FindNotificationWk::HandleNext
void HandleNext(const QString &text, FindFlags findFlags) override
Called each time the user requests a search.
Definition
findnotificationwk.h:89
LC::Util::FindNotificationWk::ToPageFlags
static QWebPage::FindFlags ToPageFlags(FindFlags findFlags)
Converts the given findFlags to WebKit find flags.
Definition
findnotificationwk.h:69
LC::Util::FindNotificationWk::Reject
void Reject() override
Definition
findnotificationwk.h:105
LC::Util::FindNotificationWk::FindNotificationWk
FindNotificationWk(const ICoreProxy_ptr &proxy, QWebView *near)
Constructs the find notification using the given proxy and near widget.
Definition
findnotificationwk.h:46
findnotification.h
UTIL_GUI_API
#define UTIL_GUI_API
Definition
guiconfig.h:16
ICoreProxy_ptr
std::shared_ptr< ICoreProxy > ICoreProxy_ptr
Definition
icoreproxy.h:177
LC::Util
Definition
icoreproxy.h:34
src
util
gui
findnotificationwk.h
Generated by
1.17.0