Public Member Functions | Protected Member Functions | List of all members
pqExtendedSortFilterProxyModel Class Reference

: A custom QSortFilterProxyModel to do extended search. More...

#include <pqExtendedSortFilterProxyModel.h>

Inherits QSortFilterProxyModel.

Public Member Functions

 pqExtendedSortFilterProxyModel (QObject *parent)
 
 ~pqExtendedSortFilterProxyModel () override=default
 
void update ()
 Triggers an update of the sort filter model. More...
 
void setRequest (const QString &request)
 Set the user requests. More...
 
void setRequest (int role, const QVariant &value)
 Set the user request for the given ItemRole. More...
 
void clearRequests ()
 Clear user requests. More...
 
void setExclusion (int role, const QVariant &value)
 Set the Exclusions list. More...
 
void clearExclusions ()
 Clear the exclusion list. More...
 

Protected Member Functions

bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override
 Returns false if row is excluded. More...
 
bool lessThan (const QModelIndex &left, const QModelIndex &right) const override
 Sort elements depending on their priority: More...
 

Detailed Description

: A custom QSortFilterProxyModel to do extended search.

: Allow to do extended search in a model, using different ItemRole.

Different kind of matches can be used to filter elements:

Items are sorted per match kind: exact match first, then standard match and finally user match. Within a match kind, alphabetical sort is used.

Items matching an Exlusion criteria are always hidden, regardless of the requests.

Definition at line 24 of file pqExtendedSortFilterProxyModel.h.

Constructor & Destructor Documentation

◆ pqExtendedSortFilterProxyModel()

pqExtendedSortFilterProxyModel::pqExtendedSortFilterProxyModel ( QObject *  parent)

◆ ~pqExtendedSortFilterProxyModel()

pqExtendedSortFilterProxyModel::~pqExtendedSortFilterProxyModel ( )
overridedefault

Member Function Documentation

◆ setRequest() [1/2]

void pqExtendedSortFilterProxyModel::setRequest ( const QString &  request)

Set the user requests.

Set the user string request for default role.

This is used for match operations. Matching items are visible (if not excluded).

filterRole is intended to be Qt::DisplayRole (default) or at least a role for QString data.

◆ setRequest() [2/2]

void pqExtendedSortFilterProxyModel::setRequest ( int  role,
const QVariant &  value 
)

Set the user request for the given ItemRole.

Items matching this value will be shown. This acts as a "white list"

see clearUserRequests(), setExclusion()

◆ clearRequests()

void pqExtendedSortFilterProxyModel::clearRequests ( )

Clear user requests.

Remove custom role checks. Note that the main request is not touched.

◆ setExclusion()

void pqExtendedSortFilterProxyModel::setExclusion ( int  role,
const QVariant &  value 
)

Set the Exclusions list.

Set an exclusion rule for ItemRole.

Items matching this value will always be hidden.

see clearExclusions(), setUserRequest()

◆ clearExclusions()

void pqExtendedSortFilterProxyModel::clearExclusions ( )

Clear the exclusion list.

◆ update()

void pqExtendedSortFilterProxyModel::update ( )

Triggers an update of the sort filter model.

◆ filterAcceptsRow()

bool pqExtendedSortFilterProxyModel::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  sourceParent 
) const
overrideprotected

Returns false if row is excluded.

Returns true if every sub part of the Request has a match. Returns false otherwise.

◆ lessThan()

bool pqExtendedSortFilterProxyModel::lessThan ( const QModelIndex &  left,
const QModelIndex &  right 
) const
overrideprotected

Sort elements depending on their priority:

  • default filterRole has a match
  • any userRole has a match

At same priority, it uses alphanumeric comparison.


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