DataModelTextFilter

Since: does not exist in the filtered result set.

#include <bb/extensions/cascades/DataModelTextFilter>

To link against this class, add the following line to your .pro file: LIBS += -lbbextensionscascadesfilterlistview

This is an abstract class which extends Cascades DataModel.

This abstract class provides the necessary properties, signals, etc which child classes require to perform the text-base filtering. There are signals emitted for the different filter stages (started, canceled, complete).

There are times (ie when the DataModel being filtered has thousands of items) when the SimpleDataModelTextFilter provided may not be fast enough. A custom filtering class can be written which is tailored for the specific data given.


Overview

Inheritance

Public Functions Index

DataModelTextFilter (QObject *parent=0)
DataModelTextFilter (bb::cascades::DataModel *source, const QString &filterString="", QObject *parent=0)
virtual ~DataModelTextFilter ()
Q_INVOKABLE intchildCount (const QVariantList &indexPath)=0
Q_INVOKABLE QVariantListfilteredIndexPath (const QVariantList &indexPath)=0
Q_INVOKABLE QStringfilterString () const
Q_INVOKABLE boolhasChildren (const QVariantList &indexPath)=0
Q_SLOT voidsetFilterString (const QString &filterString)
Q_SLOT voidsetSource (bb::cascades::DataModel *source)
Q_INVOKABLE bb::cascades::DataModel *source ()
Q_INVOKABLE QVariantListunfilteredIndexPath (const QVariantList &filteredIndexPath)=0
Q_INVOKABLE QVariantdata (const QVariantList &indexPath)=0Inherited
DataModel (QObject *parent=0)Inherited
virtual Q_INVOKABLE QStringitemType (const QVariantList &indexPath)Inherited

Protected Functions Index

voidfilterStringUpdated (const QString &oldFilterString)=0
voidsourceUpdated (DataModel *oldDataModel)=0

Signals Index

voidfilterCanceled ()
voidfilterCompleted ()
voidfilterStarted ()
voidfilterStringChanged (const QString &filterString)
voidsourceChanged (bb::cascades::DataModel *dataModel)
voiditemAdded (QVariantList indexPath)Inherited
voiditemMoved (QVariantList fromIndexPath, QVariantList toIndexPath)Inherited
voiditemRemoved (QVariantList indexPath)Inherited
voiditemsChanged (bb::cascades::DataModelChangeType::Type eChangeType=bb::cascades::DataModelChangeType::Init, QSharedPointer< bb::cascades::DataModel::IndexMapper > indexMapper=QSharedPointer< bb::cascades::DataModel::IndexMapper >(0))Inherited
voiditemUpdated (QVariantList indexPath)Inherited

Properties

QString filterString

The string to use as a filter.

Matching is done in a case-insensitive manner.

bb::cascades::DataModel source

The source DataModel to pull items from.

Public Functions

DataModelTextFilter (

Construct a DataModelTextFilter instance.

Parameters
parent

The object's parent, or 0. Optional and will default to 0 if not specified. The parent takes responsibility for this object (ie this object is added to the parent's child list).

DataModelTextFilter (

Construct a DataModelTextFilter instance with the provided source and filterString.

Parameters
source

The DataModel to filter. If source has no parent, this DataModelTextFilter takes ownership of it and sets itself as parent to it (which means that DataModelTextFilter deletes it when DataModelTextFilter is deleted).

filterString

The string to filter on. Will default to "" if not specified

parent

The object's parent, or 0. Optional and will default to 0 if not specified. The parent takes responsibility for this object (ie this object is added to the parent's child list).

virtual~DataModelTextFilter ()

Destructor.

Q_INVOKABLE int childCount (

See superclass DataModel.

Q_INVOKABLE QVariantList filteredIndexPath (

Fetch the filtered index path for the requested true index path.

Parameters
indexPath

The index path to find the filtered index path of

Return:

The filtered index path for the requested index path An empty QVariantList is returned if indexPath does not exist in the filtered result set.

Q_INVOKABLE QString filterString ()

Retrieve the Filter string.

Return:

The Filter string

Q_INVOKABLE bool hasChildren (

See superclass DataModel.

Q_SLOT void setFilterString (

Specify the Filter string.

Parameters
filterString

The string to Filter on

Q_SLOT void setSource (

Specify the Data Model.

If source has no parent, this DataModelTextFilter takes ownership of it and sets itself as parent to it (which means that DataModelTextFilter deletes it when DataModelTextFilter is deleted). Any previously set source is unaffected by this call, its parent won't change and it won't be deleted as a result of calling setSource().

Parameters
source

The DataModel to filter

Q_INVOKABLE bb::cascades::DataModel * source ()

Retrieve the Data Model.

Ownership of the returned object is not transferred.

Return:

The Data Model

Q_INVOKABLE QVariantList unfilteredIndexPath (

Fetch the true index path for the requested filtered index path.

Parameters
filteredIndexPath

The filtered index path to find the index path of

Return:

The index path for the requested filtered index path An empty QVariantList is returned if filteredIndexPath does not exist.

Q_INVOKABLE QVariant data (Inherited

Returns the data item that is associated with indexPath.

This function transfers ownership for QObject objects, if the returned object doesn't have any parent.

The ListView will pass the data item as a parameter to ListItemProvider::updateItem(). If item visuals are created by using ListItemComponent in QML, ListView makes the data returned from this function available in the item visuals as the context property ListItemData, and also as the property ListItem.data attached to the item visual root node.

Parameters
indexPath

The index path to the data item.

Return:

The data item associated with the indexPath. The caller must take ownership of any returned QObject objects, if the returned object doesn't already have a parent.

Since:

BlackBerry 10.0.0

DataModel (Inherited

Constructs a DataModel instance with the specified parent.

Parameters
parent

The data model owner, or 0. Optional and will default to 0 if not specified.

Since:

BlackBerry 10.0.0

virtual Q_INVOKABLE QString itemType (Inherited

Returns the item type for the data item at indexPath.

The item type will then be used when the ListView requests items from its ListItemProvider. It will also be used when the DataModel has indicated that items have been updated using the signals DataModel::itemUpdated or DataModel::itemsChanged with DataModelChangeType::Update.

If a ListItemTypeMapper has been provided to a ListView, the ListView calls ListItemTypeMapper::itemType() instead of DataModel::itemType().

Parameters
indexPath

The index path to the data item.

Return:

A string representing the user-defined type of the item. The default implementation returns an empty string.

Since:

BlackBerry 10.0.0

Protected Functions

void filterStringUpdated (

Called when the filter string has changed.

Parameters
oldFilterString

The filterString before it was updated

void sourceUpdated (
  • DataModel *oldDataModel)

Called when the source DataModel has changed.

Parameters
oldDataModel

The dataModel before it was updated

Signals

void filterCanceled ()

Emitted when the filtering has been canceled.

void filterCompleted ()

Emitted when the filtering has finished.

void filterStarted ()

Emitted when the filtering starts.

void filterStringChanged (

Emitted when the filterString has changed.

Parameters
filterString

The new filterString

void sourceChanged (

Emitted when the source has changed.

Parameters
dataModel

The new source DataModel

void itemAdded (Inherited

Emitted when a data item has been added to this DataModel.

Parameters
indexPath

The index path to the new item.

Since:

BlackBerry 10.0.0

void itemMoved (Inherited

Emitted when a data item has been moved within the DataModel.

A moved item will retain its visual appearance and data on the server.

Parameters
fromIndexPath

The original index path of the moved item.

toIndexPath

The new index path of the moved item.

Since:

BlackBerry 10.3.0

void itemRemoved (Inherited

Emitted when a data item has been removed from this DataModel.

Parameters
indexPath

The index path to the removed item.

Since:

BlackBerry 10.0.0

void itemsChanged (Inherited

Emitted when the model has changed in a way that would be inefficient to describe with single instances of the other signals.

No other signals (DataModel::itemAdded, DataModel::itemUpdated, or DataModel::itemRemoved) are emitted if this signal is emitted when a change occurs in this DataModel.

Typical examples of when this signal is emitted: data has been sorted (so that many items have changed places), the DataModel has been cleared (all items have been removed), or a batch of items has been added.

If eChangeType is DataModelChangeType::Init, or if eChangeType is DataModelChangeType::AddRemove and indexMapper is 0, a ListView reacts to this signal by releasing all of the items in its cache.

If eChangeType is AddRemove and an IndexMapper is provided, the ListView instead calls IndexMapper::newIndexPath() for each item in its cache.

If eChangeType is DataModelChangeType::Update, a ListView reacts to this signal by calling DataModel::data() again for every item in its cache.

Parameters
eChangeType

The type of change.

indexMapper

An index mapper that contains update information.

Since:

BlackBerry 10.0.0

void itemUpdated (Inherited

Emitted when a data item in this DataModel has been updated.

Parameters
indexPath

IndexPath to the updated item.

Since:

BlackBerry 10.0.0

Last modified: 2015-07-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus