AsyncHierarchicalDataModel

Since: BlackBerry 10.2.0

#include <bb/cascades/datamanager/AsyncHierarchicalDataModel>

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

A data model that supports index paths with length greater than one.

See the DataModel class description for a definition of index paths and how they are used.

You need to provide a HeaderDataQuery in order to populate the DataModel. A HeaderDescriptor is needed to specify the structure of the header data returned by HeaderDataQuery. This is done by extending this class and implementing the pure virtual headerDescriptor() method of this class.

Note:

The header data from the HeaderDataQuery is cached in its full size and used to refer to child data level (leaf) items. Only the data level items are partially cached.


Overview

Classes

HeaderDescriptor

HeaderDescriptor is used to describe the header data returned by the HeaderDataQuery.

QML properties

Only has inherited QML properties

cacheSize: intInherited
query: bb::cascades::datamanager::DataQueryInherited

QML signals

Only has inherited QML signals

onCacheSizeChangedInherited: {}
onItemAddedInherited: {}
onItemMovedInherited: {}
onItemRemovedInherited: {}
onItemsChangedInherited: {}
onItemUpdatedInherited: {}
onLoadedInherited: {}
onQueryChangedInherited: {}

Properties Index

Only has inherited properties

intcacheSizeInherited
bb::cascades::datamanager::DataQueryqueryInherited

Public Functions Index

AsyncHierarchicalDataModel (QObject *parent=0)
virtual ~AsyncHierarchicalDataModel ()
QSharedPointer< AsyncHierarchicalDataModel::HeaderDescriptor >headerDescriptor () const =0
AsyncDataModel (QObject *parent=0)Inherited
intcacheSize () const Inherited
virtual Q_INVOKABLE intchildCount (const QVariantList &indexPath)Inherited
virtual Q_INVOKABLE QVariantdata (const QVariantList &indexPath)Inherited
DataModel (QObject *parent=0)Inherited
virtual Q_INVOKABLE boolhasChildren (const QVariantList &indexPath)Inherited
virtual Q_INVOKABLE QStringitemType (const QVariantList &indexPath)Inherited
virtual Q_INVOKABLE voidload ()Inherited
virtual bb::cascades::datamanager::DataQuery *query ()Inherited
QueryDataModel (QObject *parent=0)Inherited
voidsetCacheSize (int cacheSize)Inherited
virtual voidsetQuery (bb::cascades::datamanager::DataQuery *query)Inherited

Signals Index

Only has inherited signals

voidcacheSizeChanged (int cacheSize)Inherited
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
voidloaded ()Inherited
voidqueryChanged ()Inherited

Properties

(Only has inherited properties)

int cacheSizeInherited

The maximum count of data items maintained in the cache.

Since:

BlackBerry 10.2.0

bb::cascades::datamanager::DataQuery queryInherited

The data query to use for obtaining data.

Note:

Ownership of the query object is taken over by this model.

Since:

BlackBerry 10.2.0

Public Functions

AsyncHierarchicalDataModel (

Parameters
parent

The parent owner or 0. Optional and defaults to 0 if not specified.

Since:

BlackBerry 10.2.0

virtual~AsyncHierarchicalDataModel ()

Destructor.

Since:

BlackBerry 10.2.0

QSharedPointer< AsyncHierarchicalDataModel::HeaderDescriptor > headerDescriptor ()

Get the header descriptor of the header DataModel.

Return:

The header descriptor.

See also:

HeaderContiguousCacheModel::HeaderDescriptor

Since:

BlackBerry 10.2.0

AsyncDataModel (Inherited

Constructs an AsyncDataModel.

Parameters
parent

The parent owner or 0. Optional and defaults to 0 if not specified.

Since:

BlackBerry 10.2.0

int cacheSize ()Inherited

Return the current capacity for the data cache for this model.

The default capacity is 200 data items.

Return:

The current data cache capacity.

Since:

BlackBerry 10.2.0

virtual Q_INVOKABLE int childCount (Inherited

Returns the number of children for the data item specified by indexPath.

The root item is represented by an empty index path. This example shows how to get the number of top level items (items having the root item as parent):

int numberOfHeaders = model->childCount(QVariantList());
Parameters
indexPath

The path to the data item to get the child count for.

Return:

The number of children. The return value for invalid index paths is undefined.

Since:

BlackBerry 10.2.0

virtual Q_INVOKABLE QVariant data (Inherited

Returns the data associated with the specified item.

This method does not transfer any ownership, any returned QObject is still owned by its parent. A QObject returned by this function always has a parent. The ListView will pass on the data as a parameter to ListItemProvider::updateItem().

Parameters
indexPath

The path to the item in the model.

Return:

A QVariantMap wrapped in a QVariant.

Since:

BlackBerry 10.2.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 bool hasChildren (Inherited

Indicates whether the data item specified by indexPath has children.

Parameters
indexPath

The path to the data item to query for children.

Return:

True if the data item has one or more children, false otherwise. ListView never calls this function for its root node (but does call childCount() for the root node), therefore the return value for an empty index path is undefined.

Since:

BlackBerry 10.2.0

virtual Q_INVOKABLE QString itemType (Inherited

Returns the type for the specified item.

Parameters
indexPath

The path to the item in the model.

Return:

A string identifying the type for this item.

Since:

BlackBerry 10.2.0

virtual Q_INVOKABLE void load ()Inherited

Load the initial cache of data.

After setting the data query and other properties, call this method to load the data.

Since:

BlackBerry 10.2.0

virtualbb::cascades::datamanager::DataQuery * query ()Inherited

Return the data query for this model.

Return:

The data query to use with this data model.

Since:

BlackBerry 10.2.0

QueryDataModel (Inherited

Constructs a QueryDataModel.

Parameters
parent

The parent owner or 0. Optional and defaults to 0 if not specified.

Since:

BlackBerry 10.2.0

void setCacheSize (
  • intcacheSize)
Inherited

Set the capacity for the data cache for this model.

The default capacity is 200 data items.

Parameters
cacheSize

The new data cache capacity.

Since:

BlackBerry 10.2.0

virtual void setQuery (Inherited

Set the data query that this model uses to load data.

Note:

Ownership of the query is taken over by the model and the query is executed in a secondary thread.

Parameters
query

The data query to use with this data model.

Since:

BlackBerry 10.2.0

Signals

(Only has inherited signals)

void cacheSizeChanged (
  • intcacheSize)
Inherited

Emitted when the cache capacity for this data model has changed.

Parameters
cacheSize

The new cache capacity.

Since:

BlackBerry 10.2.0

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.0.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

void loaded ()Inherited

Emitted when the DataModel is first loaded after calling the load() method.

The number of loaded() signals may not equal the number of load() method calls but it's always guaranteed that a call to load() results in a loaded() signal being emitted. For example, two consecutive load() method calls could result in only one loaded() signal.

Since:

BlackBerry 10.2.0

void queryChanged ()Inherited

Emitted when the query has changed.

Since:

BlackBerry 10.2.0

Last modified: 2014-06-24



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

comments powered by Disqus