KTextWidgets 5.109.0
Signals | Public Member Functions | Protected Member Functions | List of all members
KFindDialog

A generic "find" dialog. More...

#include <KFindDialog>

Signals

void cancelClicked ()
 This signal is sent when the user clicks on Cancel button.
 
void okClicked ()
 This signal is sent when the user clicks on Ok button.
 
void optionsChanged ()
 This signal is sent whenever one of the option checkboxes is toggled.
 

Public Member Functions

 KFindDialog (QWidget *parent=nullptr, long options=0, const QStringList &findStrings=QStringList(), bool hasSelection=false, bool replaceDialog=false)
 Construct a modal find dialog.
 
 ~KFindDialog () override
 Destructor.
 
QWidget * findExtension () const
 Returns an empty widget which the user may fill with additional UI elements as required.
 
QStringList findHistory () const
 Returns the list of history items.
 
long options () const
 Returns the state of the options.
 
QString pattern () const
 Returns the pattern to find.
 
void setFindHistory (const QStringList &history)
 Provide the list of strings to be displayed as the history of find strings.
 
void setHasCursor (bool hasCursor)
 Hide/show the 'from cursor' option, depending on whether the application implements a cursor.
 
void setHasSelection (bool hasSelection)
 Enable/disable the 'search in selection' option, depending on whether there actually is a selection.
 
void setOptions (long options)
 Set the options which are checked.
 
void setPattern (const QString &pattern)
 Sets the pattern to find.
 
void setSupportsBackwardsFind (bool supports)
 Enable/disable the 'Find backwards' option, depending on whether the application supports it.
 
void setSupportsCaseSensitiveFind (bool supports)
 Enable/disable the 'Case sensitive' option, depending on whether the application supports it.
 
void setSupportsRegularExpressionFind (bool supports)
 Enable/disable the 'Regular expression' option, depending on whether the application supports it.
 
void setSupportsWholeWordsFind (bool supports)
 Enable/disable the 'Whole words only' option, depending on whether the application supports it.
 

Protected Member Functions

KTEXTWIDGETS_NO_EXPORT KFindDialog (KFindDialogPrivate &dd, QWidget *parent=nullptr, long options=0, const QStringList &findStrings=QStringList(), bool hasSelection=false, bool replaceDialog=false)
 
void showEvent (QShowEvent *) override
 

Detailed Description

A generic "find" dialog.

Author
S.R.Haque srhaq.nosp@m.ue@i.nosp@m.ee.or.nosp@m.g

Detail:

This widget inherits from KDialog and implements the following additional functionalities: a find string object and an area for a user-defined widget to extend the dialog.

Example:

To use the basic modal find dialog, and then run the search:

KFindDialog dlg(....)
if (dlg.exec() != QDialog::Accepted)
return;
// proceed with KFind from here
A generic "find" dialog.
Definition kfinddialog.h:66

To create a non-modal find dialog:

if (m_findDialog) {
m_findDialog->activateWindow();
} else {
m_findDialog = new KFindDialog(...);
connect(m_findDialog, &KFindDialog::okClicked, this, [this] {
m_findDialog->close();
delete m_find;
m_find = new KFind(m_findDialog->pattern(), m_findDialog->options(), this);
// ... see KFind documentation for what else should be done here
});
}
void okClicked()
This signal is sent when the user clicks on Ok button.
A generic implementation of the "find" function.
Definition kfind.h:94

Don't forget to delete and reset m_findDialog when closed. (But do NOT delete your KFind object at that point, it's needed for "Find Next".)

To use your own extensions: see findExtension().

KFindDialog Widget

Constructor & Destructor Documentation

◆ KFindDialog()

KFindDialog::KFindDialog ( QWidget *  parent = nullptr,
long  options = 0,
const QStringList &  findStrings = QStringList(),
bool  hasSelection = false,
bool  replaceDialog = false 
)
explicit

Construct a modal find dialog.

Parameters
parentThe parent object of this widget.
optionsA bitfield of the Options to be checked.
findStringsThe find history, see findHistory()
hasSelectionWhether a selection exists

◆ ~KFindDialog()

KFindDialog::~KFindDialog ( )
override

Destructor.

Member Function Documentation

◆ cancelClicked

void KFindDialog::cancelClicked ( )
signal

This signal is sent when the user clicks on Cancel button.

◆ findExtension()

QWidget * KFindDialog::findExtension ( ) const

Returns an empty widget which the user may fill with additional UI elements as required.

The widget occupies the width of the dialog, and is positioned immediately below the regular expression support widgets for the pattern string.

◆ findHistory()

QStringList KFindDialog::findHistory ( ) const

Returns the list of history items.

See also
setFindHistory

◆ okClicked

void KFindDialog::okClicked ( )
signal

This signal is sent when the user clicks on Ok button.

◆ options()

long KFindDialog::options ( ) const

Returns the state of the options.

Disabled options may be returned in an indeterminate state.

See also
setOptions()
KFind::Options

◆ optionsChanged

void KFindDialog::optionsChanged ( )
signal

This signal is sent whenever one of the option checkboxes is toggled.

Call options() to get the new state of the checkboxes.

◆ pattern()

QString KFindDialog::pattern ( ) const

Returns the pattern to find.

◆ setFindHistory()

void KFindDialog::setFindHistory ( const QStringList &  history)

Provide the list of strings to be displayed as the history of find strings.

strings might get truncated if it is too long.

Parameters
historyThe find history.
See also
findHistory

◆ setHasCursor()

void KFindDialog::setHasCursor ( bool  hasCursor)

Hide/show the 'from cursor' option, depending on whether the application implements a cursor.

Parameters
hasCursortrue if the application features a cursor This is assumed to be the case by default.

◆ setHasSelection()

void KFindDialog::setHasSelection ( bool  hasSelection)

Enable/disable the 'search in selection' option, depending on whether there actually is a selection.

Parameters
hasSelectiontrue if a selection exists

◆ setOptions()

void KFindDialog::setOptions ( long  options)

Set the options which are checked.

Parameters
optionsThe setting of the Options.
See also
options()
KFind::Options

◆ setPattern()

void KFindDialog::setPattern ( const QString &  pattern)

Sets the pattern to find.

◆ setSupportsBackwardsFind()

void KFindDialog::setSupportsBackwardsFind ( bool  supports)

Enable/disable the 'Find backwards' option, depending on whether the application supports it.

Parameters
supportstrue if the application supports backwards find This is assumed to be the case by default.

◆ setSupportsCaseSensitiveFind()

void KFindDialog::setSupportsCaseSensitiveFind ( bool  supports)

Enable/disable the 'Case sensitive' option, depending on whether the application supports it.

Parameters
supportstrue if the application supports case sensitive find This is assumed to be the case by default.

◆ setSupportsRegularExpressionFind()

void KFindDialog::setSupportsRegularExpressionFind ( bool  supports)

Enable/disable the 'Regular expression' option, depending on whether the application supports it.

Parameters
supportstrue if the application supports regular expression find This is assumed to be the case by default.

◆ setSupportsWholeWordsFind()

void KFindDialog::setSupportsWholeWordsFind ( bool  supports)

Enable/disable the 'Whole words only' option, depending on whether the application supports it.

Parameters
supportstrue if the application supports whole words only find This is assumed to be the case by default.