LeechCraft  %{LEECHCRAFT_VERSION}
Modular cross-platform feature rich live environment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LeechCraft::Util::FindNotification Class Referenceabstract

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

#include "findnotification.h"

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

Public Types

enum  FindFlag {
  FindCaseSensitively,
  FindBackwards,
  FindWrapsAround
}
 

Public Slots

void findNext ()
 Search for the next occurrence of the current search. More...
 
void findPrevious ()
 Search for the previous occurrence of the current search. More...
 

Public Member Functions

 FindNotification (QWidget *)
 Creates the search widget and embeds into parent layout. More...
 
 ~FindNotification ()
 
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...
 
void Focus ()
 Sets the focus to the search edit field. More...
 
FindFlags GetFlags () const
 Returns the current find flags except the direction. More...
 
- Public Member Functions inherited from LeechCraft::Util::PageNotification
 PageNotification (QWidget *)
 

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 notification will automatically embed into a QVBoxLayout of its parent widget at the bottom, like in Poshuku or Monocle plugins.

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.

Definition at line 73 of file findnotification.h.

Member Enumeration Documentation

Various options controlling the search behavior.

Enumerator
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 81 of file findnotification.h.

Constructor & Destructor Documentation

LeechCraft::Util::FindNotification::FindNotification ( QWidget *  parent)

Creates the search widget and embeds into parent layout.

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

Definition at line 37 of file findnotification.cpp.

LeechCraft::Util::FindNotification::~FindNotification ( )

Definition at line 46 of file findnotification.cpp.

Member Function Documentation

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

Search for the next occurrence of the current search.

Definition at line 88 of file findnotification.cpp.

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

+ Here is the call graph for this function:

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

Search for the previous occurrence of the current search.

Definition at line 97 of file findnotification.cpp.

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

+ Here is the call graph for this function:

void LeechCraft::Util::FindNotification::Focus ( )

Sets the focus to the search edit field.

Deprecated:
This function is deprecated, QWidget::setFocus() should be used instead.

Definition at line 73 of file findnotification.cpp.

auto LeechCraft::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 78 of file findnotification.cpp.

References FindCaseSensitively, and FindWrapsAround.

Referenced by findNext(), and findPrevious().

+ Here is the caller graph for this function:

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

Returns the currently entered text in the find field.

Returns
Currently entered text in the find field.

Definition at line 56 of file findnotification.cpp.

Referenced by findNext(), and findPrevious().

+ Here is the caller graph for this function:

virtual void LeechCraft::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.

Referenced by findNext(), and findPrevious().

+ Here is the caller graph for this function:

void LeechCraft::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 61 of file findnotification.cpp.

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

Sets the text in the find field.

Parameters
[in]textThe text to set in find field.

Definition at line 51 of file findnotification.cpp.


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