[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
Public Slots | Signals | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Properties | List of all members
KLFSearchBar Class Reference

An Search Bar for Incremental Search. More...

#include <klfsearchbar.h>

Inheritance diagram for KLFSearchBar:
Inheritance graph
[legend]
Collaboration diagram for KLFSearchBar:
Collaboration graph
[legend]

Public Slots

void clear ()
 
void focusOrNext (bool forward=true)
 
void focusOrPrev ()
 
void find (const QString &string)
 
void find (const QString &string, bool forward)
 
void findNext (bool forward=true)
 
void findPrev ()
 
void abortSearch ()
 
void focus ()
 
virtual void setSearchText (const QString &text)
 
void setFocusOutText (const QString &focusOutText)
 

Signals

void searchPerformed (bool found)
 
void found ()
 
void found (const QString &queryString, bool forward)
 
void didNotFind ()
 
void didNotFind (const QString &queryString, bool forward)
 
void searchAborted ()
 
void escapePressed ()
 

Public Member Functions

 KLFSearchBar (QWidget *parent=NULL)
 
virtual ~KLFSearchBar ()
 
virtual void registerShortcuts (QWidget *parent)
 
virtual void setSearchTarget (KLFSearchable *object)
 
QString currentSearchText () const
 
bool showOverlayMode () const
 
QRect showOverlayRelativeGeometry () const
 
QString focusOutText () const
 
QColor colorFound () const
 
QColor colorNotFound () const
 
bool hideButtonShown () const
 
void setShowOverlayMode (bool showOverlayMode)
 
void setShowOverlayRelativeGeometry (const QRect &relativeGeometryPercent)
 
void setShowOverlayRelativeGeometry (int widthPercent, int heightPercent, int positionXPercent, int positionYPercent)
 
void setColorFound (const QColor &color)
 
void setColorNotFound (const QColor &color)
 
void setShowHideButton (bool showHideButton)
 
virtual bool eventFilter (QObject *obj, QEvent *ev)
 
QLineEditeditor ()
 
- Public Member Functions inherited from QFrame
 QFrame (QWidget *parent=0, Qt::WindowFlags f=0)
 
 frameStyle ()
 
 setFrameStyle (int style)
 
 QFrame (QWidget *parent, const char *name, Qt::WindowFlags f=0)
 

Protected Types

enum  SearchState {
  Default, FocusOut, Found, NotFound,
  Aborted
}
 

Protected Member Functions

virtual void slotSearchFocusIn ()
 
virtual void slotSearchFocusOut ()
 
virtual void updateSearchFound (bool found)
 
virtual void displayState (SearchState state)
 
void emitFoundSignals (bool found, const QString &searchstring, bool forward)
 
void showSearchBarText (const QString &text)
 
bool searchBarHasFocus ()
 
virtual bool event (QEvent *event)
 

Protected Attributes

Ui::KLFSearchBar * u
 

Properties

QString currentSearchText
 
bool showOverlayMode
 
QRect showOverlayRelativeGeometry
 
QString focusOutText
 
QColor colorFound
 
QColor colorNotFound
 
bool showHideButton
 

Detailed Description

An Search Bar for Incremental Search.

This widget provides a set of controls an incremental search. This includes a line edit to input the query string, a clear button, 'find next' and 'find previous' buttons.

This widget acts upon an abstract KLFSearchable object, which the object or display being searched will have to implement. You only need to implement three straightforward functions providing the actual search functionality. The search target can be set with setSearchTarget().

The user interface is inspired from (X)Emacs' I-search. More specifically:

Shortcuts can be enabled so that Ctrl-F, Ctrl-S, F3, and such other keys work. See registerShortcuts().

The search bar will turn red or green depending on whether the query string is found or not, you can customize these colors with setColorFound() and setColorNotFound(). To customize these colors using stylesheets, you may use the rules

QLineEdit[searchState="found"] {
    background-color: rgb(128,255,128,128);
}
QLineEdit[searchState="not-found"] {
    background-color: rgb(255,128,128,128);
}

since the property searchState is set to one of "default", "focus-out", "found", "not-found", or "aborted" depending on the current state.

Definition at line 172 of file klfsearchbar.h.

Member Enumeration Documentation

enum KLFSearchBar::SearchState
protected
Enumerator
Default 
FocusOut 
Found 
NotFound 
Aborted 

Definition at line 252 of file klfsearchbar.h.

Constructor & Destructor Documentation

KLFSearchBar::KLFSearchBar ( QWidget parent = NULL)
KLFSearchBar::~KLFSearchBar ( )
virtual

Member Function Documentation

void KLFSearchBar::abortSearch ( )
slot
void KLFSearchBar::clear ( )
slot

Clears the search bar and takes focus.

Definition at line 293 of file klfsearchbar.cpp.

References focus(), klfDbgT, and u.

Referenced by KLFSearchBar(), and registerShortcuts().

QColor KLFSearchBar::colorFound ( ) const

This value is read from the palette. It does not take into account style sheets.

Referenced by ~KLFSearchBar().

QColor KLFSearchBar::colorNotFound ( ) const

This value is read from the palette. It does not take into account style sheets.

Referenced by ~KLFSearchBar().

QString KLFSearchBar::currentSearchText ( ) const

Referenced by ~KLFSearchBar().

void KLFSearchBar::didNotFind ( )
signal

Referenced by emitFoundSignals().

void KLFSearchBar::didNotFind ( const QString queryString,
bool  forward 
)
signal
void KLFSearchBar::displayState ( SearchState  state)
protectedvirtual
QLineEdit * KLFSearchBar::editor ( )

Definition at line 261 of file klfsearchbar.cpp.

References u.

void KLFSearchBar::emitFoundSignals ( bool  found,
const QString searchstring,
bool  forward 
)
protected

Definition at line 492 of file klfsearchbar.cpp.

References didNotFind(), found(), and searchPerformed().

Referenced by find(), and findNext().

void KLFSearchBar::escapePressed ( )
signal

Referenced by eventFilter().

bool KLFSearchBar::event ( QEvent event)
protectedvirtual

Definition at line 516 of file klfsearchbar.cpp.

References QEvent::type().

bool KLFSearchBar::eventFilter ( QObject obj,
QEvent ev 
)
virtual
void KLFSearchBar::find ( const QString string)
inlineslot

Definition at line 234 of file klfsearchbar.h.

References find().

Referenced by find(), findNext(), focusOrNext(), and KLFSearchBar().

void KLFSearchBar::find ( const QString string,
bool  forward 
)
slot
void KLFSearchBar::findNext ( bool  forward = true)
slot
void KLFSearchBar::findPrev ( )
inlineslot

Definition at line 237 of file klfsearchbar.h.

Referenced by KLFSearchBar(), and registerShortcuts().

void KLFSearchBar::focus ( )
slot
void KLFSearchBar::focusOrNext ( bool  forward = true)
slot

If the search bar does not have focus, takes focus and clears the bar, preparing to search in forward direction (unless forward is FALSE). If it has focus, finds the next occurence (resp. previous if forward is FALSE) of the current or last search string.

Definition at line 300 of file klfsearchbar.cpp.

References find(), findNext(), focus(), QApplication::focusWidget(), QString::isEmpty(), klfDbgT, and u.

Referenced by registerShortcuts().

void KLFSearchBar::focusOrPrev ( )
inlineslot

If the search bar does not have focus, takes focus and clears the bar, preparing for a backwards search. If it has focus, finds the previous occurence of the current or last search string.

Definition at line 233 of file klfsearchbar.h.

Referenced by registerShortcuts().

QString KLFSearchBar::focusOutText ( ) const
inline

Definition at line 196 of file klfsearchbar.h.

Referenced by setFocusOutText().

void KLFSearchBar::found ( )
signal

Referenced by emitFoundSignals(), find(), and findNext().

void KLFSearchBar::found ( const QString queryString,
bool  forward 
)
signal
bool KLFSearchBar::hideButtonShown ( ) const

Definition at line 165 of file klfsearchbar.cpp.

References u.

void KLFSearchBar::registerShortcuts ( QWidget parent)
virtual
void KLFSearchBar::searchAborted ( )
signal

Referenced by abortSearch().

bool KLFSearchBar::searchBarHasFocus ( )
protected

Little helper: returns TRUE if the search bar has focus, FALSE otherwise.

Definition at line 510 of file klfsearchbar.cpp.

References QApplication::focusWidget(), and u.

Referenced by abortSearch(), findNext(), and setShowOverlayMode().

void KLFSearchBar::searchPerformed ( bool  found)
signal

Referenced by emitFoundSignals().

void KLFSearchBar::setColorFound ( const QColor color)

Definition at line 170 of file klfsearchbar.cpp.

References Default, Found, QPalette::setColor(), and u.

Referenced by KLFSearchBar().

void KLFSearchBar::setColorNotFound ( const QColor color)

Definition at line 178 of file klfsearchbar.cpp.

References Default, NotFound, QPalette::setColor(), and u.

Referenced by KLFSearchBar().

void KLFSearchBar::setFocusOutText ( const QString focusOutText)
slot

Definition at line 231 of file klfsearchbar.cpp.

References focusOutText().

void KLFSearchBar::setSearchTarget ( KLFSearchable object)
virtual

Set the object upon which we will perform searches. As long as no object is set this bar is unusable.

Definition at line 208 of file klfsearchbar.cpp.

References abortSearch(), QList::append(), KLF_DEBUG_BLOCK, KLF_FUNC_NAME, klfDbg, and QList::removeAll().

Referenced by KLFSearchBar().

void KLFSearchBar::setSearchText ( const QString text)
virtualslot

Definition at line 226 of file klfsearchbar.cpp.

References u.

void KLFSearchBar::setShowHideButton ( bool  showHideButton)

Definition at line 187 of file klfsearchbar.cpp.

References u.

Referenced by KLFSearchBar().

void KLFSearchBar::setShowOverlayMode ( bool  showOverlayMode)
Todo:
..... the search bar should install an event filter on the parent to listen for resize events, and to resize appropriately.

Definition at line 266 of file klfsearchbar.cpp.

References klfDbg, and searchBarHasFocus().

void KLFSearchBar::setShowOverlayRelativeGeometry ( const QRect relativeGeometryPercent)

Definition at line 280 of file klfsearchbar.cpp.

Referenced by setShowOverlayRelativeGeometry().

void KLFSearchBar::setShowOverlayRelativeGeometry ( int  widthPercent,
int  heightPercent,
int  positionXPercent,
int  positionYPercent 
)

Definition at line 284 of file klfsearchbar.cpp.

References setShowOverlayRelativeGeometry().

bool KLFSearchBar::showOverlayMode ( ) const
inline

Definition at line 194 of file klfsearchbar.h.

QRect KLFSearchBar::showOverlayRelativeGeometry ( ) const
inline

Definition at line 195 of file klfsearchbar.h.

void KLFSearchBar::showSearchBarText ( const QString text)
protected

sets the given text in the search bar, ensuring that the search bar will NOT emit any textChanged() signals.

Definition at line 504 of file klfsearchbar.cpp.

References u.

Referenced by abortSearch(), displayState(), findNext(), and slotSearchFocusIn().

void KLFSearchBar::slotSearchFocusIn ( )
protectedvirtual

Definition at line 431 of file klfsearchbar.cpp.

References Default, displayState(), klfDbgT, and showSearchBarText().

Referenced by eventFilter().

void KLFSearchBar::slotSearchFocusOut ( )
protectedvirtual

Definition at line 438 of file klfsearchbar.cpp.

References displayState(), FocusOut, and klfDbgT.

Referenced by eventFilter(), and KLFSearchBar().

void KLFSearchBar::updateSearchFound ( bool  found)
protectedvirtual

Definition at line 446 of file klfsearchbar.cpp.

References Aborted, Default, displayState(), FocusOut, Found, KLF_FUNC_NAME, and NotFound.

Referenced by find(), and findNext().

Member Data Documentation

Ui::KLFSearchBar* KLFSearchBar::u
protected

Property Documentation

QColor KLFSearchBar::colorFound
readwrite

Definition at line 180 of file klfsearchbar.h.

QColor KLFSearchBar::colorNotFound
readwrite

Definition at line 181 of file klfsearchbar.h.

QString KLFSearchBar::currentSearchText
readwrite

Definition at line 176 of file klfsearchbar.h.

QString KLFSearchBar::focusOutText
readwrite

Definition at line 179 of file klfsearchbar.h.

bool KLFSearchBar::showHideButton
readwrite

Definition at line 182 of file klfsearchbar.h.

bool KLFSearchBar::showOverlayMode
readwrite

Definition at line 176 of file klfsearchbar.h.

QRect KLFSearchBar::showOverlayRelativeGeometry
readwrite

Definition at line 177 of file klfsearchbar.h.


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

Generated by doxygen 1.8.11