##

SearchModel Class Reference

Customize the proxy model to display search results. More...

`#include <Palette.hh>`

Inherits QSortFilterProxyModel.

## Public Member Functions

bool | filterAcceptsRow (const int _srcRow, const QModelIndex &_srcParent) const
| Customize so we accept rows where: More...
bool | filterAcceptsRowItself (const int _srcRow, const QModelIndex &_srcParent, QString _word) const
| Check if row contains the word on itself. More...
bool | hasAcceptedChildren (const int _srcRow, const QModelIndex &_srcParent) const
| Check if any of the children is fully accepted. More...
bool | hasChildAcceptsItself (const QModelIndex &_srcParent, const QString &_word) const
| Check if any of the children accepts a specific word. More...
void | SetSearch (const QString &_search)
| Set a new search value. More...

## Public Attributes

QString | search
| Full search string. More...

## Detailed Description

Customize the proxy model to display search results.

## Member Function Documentation

## filterAcceptsRow()

bool filterAcceptsRow | ( | const int | _srcRow,
|  | const QModelIndex & | _srcParent
| ) |  | const

Customize so we accept rows where:

1. Each of the words can be found in its ancestors or itself, but not necessarily all words on the same row, or
2. One of its descendants matches rule 1, or
3. One of its ancestors matches rule 1.

For example this structure:

- a – b – c — d
- A search of "a" will display all rows.
- A search of "b" or "a b" will display "a" and "b".
- A search of "c", "d", "a c", "a d", "a c d" or "c d" will display "a", "c" and "d".
- A search of "a b c d", "b c" or "b d" will display nothing.

Parameters

  [in] | _srcRow | Row on the source model.
  [in] | _srcParent | Parent on the source model.

Returns
  True if row is accepted.

## filterAcceptsRowItself()

bool filterAcceptsRowItself | ( | const int | _srcRow,
|  | const QModelIndex & | _srcParent,
|  | QString | _word
| ) |  | const

Check if row contains the word on itself.

Parameters

  [in] | _srcRow | Row on the source model.
  [in] | _srcParent | Parent on the source model.
  [in] | _word | Word to be checked.

Returns
  True if row matches.

## hasAcceptedChildren()

bool hasAcceptedChildren | ( | const int | _srcRow,
|  | const QModelIndex & | _srcParent
| ) |  | const

Check if any of the children is fully accepted.

Parameters

  [in] | _srcRow | Row on the source model.
  [in] | _srcParent | Parent on the source model.

Returns
  True if any of the children match.

## hasChildAcceptsItself()

bool hasChildAcceptsItself | ( | const QModelIndex & | _srcParent,
|  | const QString & | _word
| ) |  | const

Check if any of the children accepts a specific word.

Parameters

  [in] | _srcParent | Parent on the source model.
  [in] | _word | Word to be checked.

Returns
  True if any of the children match.

## SetSearch()

void SetSearch | ( | const QString & | _search | ) |

Set a new search value.

Parameters

  [in] | _search | Full search string.

## Member Data Documentation

## search

QString search

Full search string.

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

- Palette.hh