34 QWebView *
const WebView_;
35 QString PreviousFindText_;
51 &QWebView::loadFinished,
55 if (PreviousFindText_.isEmpty ())
71 QWebPage::FindFlags pageFlags;
72 auto check = [&pageFlags, findFlags] (
FindFlag ourFlag, QWebPage::FindFlag pageFlag)
74 if (findFlags & ourFlag)
75 pageFlags |= pageFlag;
77 check (FindCaseSensitively, QWebPage::FindCaseSensitively);
78 check (FindBackwards, QWebPage::FindBackward);
79 check (FindWrapsAround, QWebPage::FindWrapsAroundDocument);
83 void ClearFindResults ()
85 PreviousFindText_.clear ();
86 WebView_->page ()->findText ({}, QWebPage::HighlightAllOccurrences);
89 void HandleNext (
const QString& text, FindFlags findFlags)
override
91 const auto flags = ToPageFlags (findFlags);
93 if (PreviousFindText_ != text)
95 const auto nflags = flags | QWebPage::HighlightAllOccurrences;
96 WebView_->page ()->findText ({}, nflags);
97 WebView_->page ()->findText (text, nflags);
98 PreviousFindText_ = text;
101 const auto found = WebView_->page ()->findText (text, flags);
102 SetSuccessful (found);
107 FindNotification::Reject ();
A horizontal bar with typical widgets for text search.
A helper class to aid connecting FindNotification with Qt WebKit.
void HandleNext(const QString &text, FindFlags findFlags) override
Called each time the user requests a search.
static QWebPage::FindFlags ToPageFlags(FindFlags findFlags)
Converts the given findFlags to WebKit find flags.
FindNotificationWk(const ICoreProxy_ptr &proxy, QWebView *near)
Constructs the find notification using the given proxy and near widget.
std::shared_ptr< ICoreProxy > ICoreProxy_ptr