LeechCraft  0.6.70-13729-g7046a9d2a7
Modular cross-platform feature rich live environment.
LC::Util::FindNotification Class Referenceabstract

A horizontal bar with typical widgets for text search. More...

#include "findnotification.h"

+ Inheritance diagram for LC::Util::FindNotification:
+ Collaboration diagram for LC::Util::FindNotification:

Public Types

enum  FindFlag {
  FindNoFlags = 0x0,
  FindCaseSensitively = 0x1,
  FindBackwards = 0x2,
  FindWrapsAround = 0x4
}
 

Public Slots

void findNext ()
 Search for the next occurrence of the search text. More...
 
void findPrevious ()
 Search for the previous occurrence of the search text. More...
 
void clear ()
 Clears the text in the find field. More...
 

Public Member Functions

 FindNotification (ICoreProxy_ptr proxy, QWidget *near)
 Creates the search widget in parent layout of near. More...
 
 ~FindNotification ()
 
void SetEscCloses (bool close)
 Sets whether Esc closes the widget. More...
 
void SetText (const QString &text)
 Sets the text in the find field. More...
 
QString GetText () const
 Returns the currently entered text in the find field. More...
 
void SetSuccessful (bool successful)
 Updates the widget to show whether the search has been successful. More...
 
FindFlags GetFlags () const
 Returns the current find flags except the direction. More...
 
- Public Member Functions inherited from LC::Util::PageNotification
 PageNotification (QWidget *parent)
 Creates the widget embedding into the parent layout of the parent widget. More...
 

Protected Slots

virtual void reject ()
 

Protected Member Functions

virtual void handleNext (const QString &text, FindFlags flags)=0
 Called each time the user requests a search. More...
 

Detailed Description

A horizontal bar with typical widgets for text search.

This widget provides typical features for text searching: a text input field, checkboxes for selecting find mode and buttons for searching and closing the notification, as well as convenience slots findNext() and findPrevious().

The widget will automatically be embedded into the layout of the parent widget of near after the near widget (which is passed to the constructor).

This class is typically used as following:

  1. It's subclassed, and an implementation of handleNext() function is provided, which deals with the search process. For example, a WebKit-based browser calls QWebPage::findText(). The implementation may also call SetSuccessful() to indicate whether anything has been found.
  2. An object of the subclass is created as a child of some page containing searchable text, like a web page or a text document.
  3. It's hidden after that to not disturb the user until he explicitly wishes to search for text.
  4. A QAction is created to trigger showing this notification, and its triggered() signal is connected to this class' show() and setFocus() slots (latter is needed so that user can start typing his search query immediately).
  5. Optionally a couple of QShortCuts or QActions can be created and connected to findNext() and findPrevious() slots to support shortcuts for the corresponding actions.

The FindNotificationWk class provides some utilities to aid integrating this class with a QWebPage.

See also
FindNotificationWk

Definition at line 83 of file findnotification.h.

Member Enumeration Documentation

◆ FindFlag

Various options controlling the search behavior.

Enumerator
FindNoFlags 

Default search flags: case-insensitive forward search.

FindCaseSensitively 

Search should be performed case sensitively.

FindBackwards 

Search should be performed in the reverse direction.

FindWrapsAround 

Search should continue from the beginning when the end is reached (or from the end if the beginning is reached and FindBackwards is also set).

Definition at line 92 of file findnotification.h.

Constructor & Destructor Documentation

◆ FindNotification()

LC::Util::FindNotification::FindNotification ( ICoreProxy_ptr  proxy,
QWidget *  near 
)

Creates the search widget in parent layout of near.

Embedding is done only if possible — that is, if parent's layout is QVBoxLayout. Otherwise one should place this widget where needed himself.

Parameters
[in]proxyThe core proxy to be used by this find notification.
[in]nearThe widget near which to embed.

Definition at line 42 of file findnotification.cpp.

◆ ~FindNotification()

LC::Util::FindNotification::~FindNotification ( )

Definition at line 73 of file findnotification.cpp.

Member Function Documentation

◆ clear

void LC::Util::FindNotification::clear ( )
slot

Clears the text in the find field.

This is equivalent to SetText ({}).

Definition at line 145 of file findnotification.cpp.

References SetText().

+ Here is the call graph for this function:

◆ findNext

void LC::Util::FindNotification::findNext ( )
slot

Search for the next occurrence of the search text.

If the text has been modified since the previous call to either findPrevious() or findNext() either programmatically (via SetText()) or by the user, the search will be restarted.

See also
findPrevious()

Definition at line 127 of file findnotification.cpp.

References GetFlags(), GetText(), and handleNext().

+ Here is the call graph for this function:

◆ findPrevious

void LC::Util::FindNotification::findPrevious ( )
slot

Search for the previous occurrence of the search text.

If the text has been modified since the previous call to either findPrevious() or findNext() either programmatically (via SetText()) or by the user, the search will be restarted.

See also
findNext()

Definition at line 136 of file findnotification.cpp.

References FindBackwards, GetFlags(), GetText(), and handleNext().

+ Here is the call graph for this function:

◆ GetFlags()

auto LC::Util::FindNotification::GetFlags ( ) const

Returns the current find flags except the direction.

Please note that the direction flag (FindBackwards) never appears in the return result.

Returns
The find flags corresponding to the user choices.

Definition at line 117 of file findnotification.cpp.

References FindCaseSensitively, and FindWrapsAround.

Referenced by findNext(), and findPrevious().

+ Here is the caller graph for this function:

◆ GetText()

QString LC::Util::FindNotification::GetText ( ) const

Returns the currently entered text in the find field.

Returns
Currently entered text in the find field.

Definition at line 88 of file findnotification.cpp.

Referenced by findNext(), and findPrevious().

+ Here is the caller graph for this function:

◆ handleNext()

virtual void LC::Util::FindNotification::handleNext ( const QString &  text,
FindFlags  flags 
)
protectedpure virtual

Called each time the user requests a search.

Reimplement this function to perform the actual search.

Parameters
[in]textThe text to search for.
[in]flagsThe flags to search with.

Implemented in LC::Util::FindNotificationWk.

Referenced by findNext(), and findPrevious().

+ Here is the caller graph for this function:

◆ reject

void LC::Util::FindNotification::reject ( )
protectedvirtualslot

Reimplemented in LC::Util::FindNotificationWk.

Definition at line 150 of file findnotification.cpp.

Referenced by LC::Util::FindNotificationWk::reject().

+ Here is the caller graph for this function:

◆ SetEscCloses()

void LC::Util::FindNotification::SetEscCloses ( bool  close)

Sets whether Esc closes the widget.

Parameters
[in]closeWhether pressing Esc button closes the widget.

Definition at line 78 of file findnotification.cpp.

◆ SetSuccessful()

void LC::Util::FindNotification::SetSuccessful ( bool  successful)

Updates the widget to show whether the search has been successful.

Parameters
[in]successfulWhether the search has been successful.

Definition at line 93 of file findnotification.cpp.

Referenced by LC::Util::FindNotificationWk::handleNext().

+ Here is the caller graph for this function:

◆ SetText()

void LC::Util::FindNotification::SetText ( const QString &  text)

Sets the text in the find field.

This does not trigger the search. To perform the search, call findNext() after calling this method.

Parameters
[in]textThe text to set in find field.
See also
findNext()

Definition at line 83 of file findnotification.cpp.

Referenced by clear().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: