Home · All Classes · Main Classes · Deprecated
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions

MListFilter Class Reference

MListFilter implements live filtering, for searching through the list content. More...

Inherits QObject.

List of all members.

Public Types

enum  FilterMode { FilterAsSubstring, FilterAsBeginningOfLine, FilterByApplication }

Public Slots

void editorTextChanged ()

Signals

void listPannedUpFromTop ()

Public Member Functions

 MListFilter (MList *parent=NULL)
virtual ~MListFilter ()
void setEnabled (bool enabled)
bool enabled ()
MTextEditeditor () const
MSortFilterProxyModelproxy () const
void setFilterRole (int role)
int filterRole () const
void keyPressEvent (QKeyEvent *event)
void setFilterMode (MListFilter::FilterMode mode)
MListFilter::FilterMode filterMode () const

Protected Member Functions

QAbstractItemModelupdateItemModel (QAbstractItemModel *itemModel)

Detailed Description

MListFilter implements live filtering, for searching through the list content.

MListFilter creates a text editor and an item proxy model to be used to filter MList items. Application is responsible of putting the text editor into layout.

MListFilter filters items to match text editor content as a substring by default. This behaviour can be changed with setFilterMode. See FilterMode description for details.

Example of using list filtering with a custom regular expression by application:

 list->filtering()->setEnabled(true);
 list->filtering()->setFilterMode(MListFilter::FilterByApplication);
 connect(list->filtering()->editor(), SIGNAL(textChanged()), this, SLOT(liveFilteringTextChanged()));
 ...

 void MListPage::liveFilteringTextChanged()
 {
 QRegExp regExp(list->filtering()->proxy()->filterRegExp());
 regExp.setPattern('^' + list->filtering()->editor()->text());
 list->filtering()->proxy()->setFilterRegExp(regExp);
 ...

Member Enumeration Documentation

This enumerated type is used by MListFilter to indicate how it filters items.

Enumerator:
FilterAsSubstring 

Items are filtered to match text edit content as a substring

FilterAsBeginningOfLine 

Items are filtered to match text edit content in the beginning of line

FilterByApplication 

Application sets a regular expression by itself whenever text edit content changes.


Constructor & Destructor Documentation

MListFilter::MListFilter ( MList parent = NULL  ) 

Default constructor. Constructs the list filter.

Parameters:
parent The list controller of the list filter content.
MListFilter::~MListFilter (  )  [virtual]

Default destructor. Cleanups and destroys the list filter.


Member Function Documentation

MTextEdit * MListFilter::editor (  )  const
Returns:
text editor used in live filtering
void MListFilter::editorTextChanged (  )  [slot]

Handles text changes in live filtering text editor. Updates live filtering model regular expression.

bool MListFilter::enabled (  ) 
Returns:
true if live filtering is enabled, otherwise false
MListFilter::FilterMode MListFilter::filterMode (  )  const
Returns:
filter mode of a list
int MListFilter::filterRole (  )  const
Returns:
filter role used in live filtering proxy. Default is Qt::DisplayRole
void MListFilter::keyPressEvent ( QKeyEvent event  ) 

Handling of key events - used to pass key presses to text editor when live filtering is enabled.

void MListFilter::listPannedUpFromTop (  )  [signal]

Emitted when list is panned up starting from top position. This signal can be used in applications as a starter for list filtering with virtual keyboard.

MSortFilterProxyModel * MListFilter::proxy (  )  const
Returns:
proxy model used in live filtering
void MListFilter::setEnabled ( bool  enabled  ) 

Sets live filtering to enabled or disabled. When live filtering is enabled list uses QSortFilterProxyModel as item model. By default live filtering is disabled.

void MListFilter::setFilterMode ( MListFilter::FilterMode  mode  ) 

Sets filter mode. By default FilterBySubstring is set. Check FilterMode enumeration for details.

void MListFilter::setFilterRole ( int  role  ) 

Sets filter role to be used in live filtering proxy. Default is Qt::DisplayRole.

QAbstractItemModel * MListFilter::updateItemModel ( QAbstractItemModel itemModel  )  [protected]

Copyright © 2010 Nokia Corporation
MeeGo Touch