DataProvider

Since: BlackBerry 10.0.0

#include <bb/cascades/maps/DataProvider>

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

A source of mappable data.

Dynamic DataProvider Example ---------------------------- It is possible to have a DataProvider whose contents change as the map's viewport changes. To accomplish this, create a subclass of DataProvider. Add slots to the class to be connected to the signals from MapView. For example:

MapView* map = new MapView();
DynamicDataProvider* ddp = new DynamicDataProvider();
QObject::connect( map, SIGNAL( latitudeChanged( double ) ), ddp, SLOT( onLatChanged( double ) ) );
QObject::connect( map, SIGNAL( longitudeChanged( double ) ), ddp, SLOT( onLonChanged( double ) ) );
QObject::connect( map, SIGNAL( altitudeChanged( double ) ), ddp, SLOT( onAltitudeChanged( double ) ) );
Finally, emit notifications, such as geoAdded(), when elements have been added or removed from the container.

Object Ownership ---------------- Elements added to this DataProvider (that is, instances of Geographic objects) are owned by this DataProvider. When this DataProvider is deleted, all of its Geographic objects are also deleted.

When this DataProvider is added to a MapData object, the MapData instance owns this object (through parent child relationships).

Reference Type -------------- DataProvider is expected to be used as a reference type. As such, care needs to be made when referencing this object in multi-threaded environments. For example, deletion in one thread can cause a dangling pointer in another thread.

Also note that the contents of this container (bb::platform::geo::Geographic) are also reference types.


Overview

QML properties

providerId: QString
styles: bb::platform::geo::StyleSheet
visible: bool

Public Functions Index

DataProvider (QObject *parent=0)
DataProvider (const QString &id, QObject *parent=0)
virtual ~DataProvider ()
booladd (bb::platform::geo::Geographic *element)
intadd (const bb::platform::geo::GeoList &elements)
bb::platform::geo::BoundingBoxboundingBox () const
voidclear ()
intcount () const
bb::platform::geo::GeoListfind (const bb::platform::geo::BoundingBox &box) const
bb::platform::geo::Geographic *geographic (const QString &id) const
boolisVisible () const
QStringproviderId () const
boolremove (const QString &elementId)
intremove (const QStringList &elements)
Q_SLOT voidresetStyles ()
voidsetProviderId (const QString &id)
Q_SLOT voidsetStyles (const bb::platform::geo::StyleSheet &styles)
voidsetVisible (bool visible)
bb::platform::geo::StyleSheetstyles () const
bb::platform::geo::GeoListtoGeoList () const

Signals Index

voidgeoAdded (const QString &providerId, const QString &elementId)
voidgeoAddedBulk (const QString &providerId, const QStringList &elementIds)
voidgeoRemoved (const QString &providerId, const QString &elementId)
voidgeoRemovedBulk (const QString &providerId, const QStringList &elementIds)
voidproviderIdChanged (const QString &providerId)
voidstylesChanged (const bb::platform::geo::StyleSheet &newStyles)
voidtopographyChanged (const QString &providerId, const QString &elementId)
voidvisibilityChanged (const QString &providerId, bool visible)

Properties

QString providerId

The ID of the data provider.

Since:

BlackBerry 10.2.0

bb::platform::geo::StyleSheet styles

The styles associated with the data provider.

Since:

BlackBerry 10.2.0

bool visible

The visibility of the data provider.

Since:

BlackBerry 10.2.0

Public Functions

DataProvider (

Simple constructor.

A unique identifier will be generated for the providerId property.

Parameters
parent

The QObject parent. If this object is handed to a MapData instance, that instance will become this object's parent.

Since:

BlackBerry 10.2.0

DataProvider (

Multi-parameter constructor.

Parameters
id

The unique identifier for this data provider. If this parameter is QString::null or empty, a unique ID will be generated.

parent

The QObject parent. If this object is handed to a MapData instance, that instance will become this object's parent.

Since:

BlackBerry 10.0.0

virtual~DataProvider ()

Destructor.

Since:

BlackBerry 10.0.0

bool add (

Adds the element to this data provider's collection.

Elements that are added to this data provider become children of this instance. When something has been added, a notification is emitted.

Parameters
element

The element to be added.

Return:

true if the addition was successful, false otherwise.

Since:

BlackBerry 10.0.0

int add (

Adds all the Geographic elements to this data provider.

Elements that are added to this data provider become children of this instance. When all these elements are added, a single notification is emitted.

Parameters
elements

The elements to be added.

Return:

The number of elements added.

Since:

BlackBerry 10.0.0

bb::platform::geo::BoundingBox boundingBox ()

Returns the bounding box of the elements within this data provider.

If the number of elements is zero, then an invalid box is returned.

Return:

The BoundingBox of all elements within this data provider, or an invalid box if there are no elements.

Since:

BlackBerry 10.1.0

void clear ()

Removes all data in this data provider.

Since:

BlackBerry 10.0.0

int count ()

Returns the number of Geographic elements in this data provider.

Since:

BlackBerry 10.1.0

bb::platform::geo::GeoList find (

Retrieves all the visible data that's in the given lat/lon box.

Parameters
box

The bounding box to search within.

Return:

A list of visible entities.

Since:

BlackBerry 10.0.0

bb::platform::geo::Geographic * geographic (

Gets the Geographic element with the given ID from this collection.

Return:

NULL if the element was not found.

Since:

BlackBerry 10.2.0

bool isVisible ()

Determines if this data provider is currently visible or not.

Return:

true if is visible, false otherwise.

Since:

BlackBerry 10.0.0

QString providerId ()

Gets the unique identifier for this data provider.

Since:

BlackBerry 10.0.0

bool remove (

Removes the element with the ID from this data provider's collection.

If the element has been successfully removed, then a notification is performed.

Parameters
elementId

The ID of the element to remove.

Return:

true if the element was removed successfully, false otherwise.

Since:

BlackBerry 10.0.0

int remove (

Removes all the elements with the given IDs from this data provider's collection.

A notification is triggered with the elements that have been removed. A removed element is freed from memory.

Parameters
elements

The list of IDs to be removed.

Return:

The number of elements removed.

Since:

BlackBerry 10.0.0

Q_SLOT void resetStyles ()

Resets the collection of styles to an empty collection.

Since:

BlackBerry 10.2.0

void setProviderId (

Sets the unique identifier for this data provider.

Parameters
id

The unique identifier for this data provider. If this parameter is QString::null or empty, a unique ID will be generated.

Since:

BlackBerry 10.0.0

Q_SLOT void setStyles (

Sets the collection of styles to be used when drawing the Geographic elements within this data provider.

Parameters
styles

The new styles for this provider.

Since:

BlackBerry 10.2.0

void setVisible (
  • boolvisible)

Makes this data provider visible.

Parameters
visible

If true, the contents of this data provider will become visible to the map (the view will not change to make them "on screen"). If false, this data provider's contents will become invisible to the map.

Since:

BlackBerry 10.0.0

bb::platform::geo::StyleSheet styles ()

Retrieves the collection of styles to be used when drawing the Geographic elements within this data provider.

Return:

The styles for this provider.

Since:

BlackBerry 10.2.0

bb::platform::geo::GeoList toGeoList ()

Gets the data for this data provider.

Since:

BlackBerry 10.0.0

Signals

void geoAdded (

Emitted when a Geographic element has been added to this data provider.

Parameters
providerId

The ID of the data provider that the Geographic was added to.

elementId

The ID of the element that was added.

Since:

BlackBerry 10.0.0

void geoAddedBulk (

Emitted when multiple Geographic elements have been added to this data provider.

Parameters
providerId

The ID of the data provider that the Geographic was added to.

elementIds

The IDs of the elements that were added.

Since:

BlackBerry 10.0.0

void geoRemoved (

Emitted when a Geographic element has been removed from this data provider.

Parameters
providerId

The ID of the data provider that the Geographic was removed from.

elementId

The ID of the element that was removed.

Since:

BlackBerry 10.0.0

void geoRemovedBulk (

Emitted when multiple Geographic elements have been removed from this data provider.

Parameters
providerId

The ID of the data provider that the Geographic was removed from.

elementIds

The IDs of the elements that were removed.

Since:

BlackBerry 10.0.0

void providerIdChanged (

Emitted when provider ID has changed.

Parameters
providerId

The new provider ID.

Since:

BlackBerry 10.2.0

void stylesChanged (

Emitted when the styles property for this DataProvider has changed.

Parameters
newStyles

The new StyleSheet for this provider.

Since:

BlackBerry 10.2.0

void topographyChanged (

Emitted when the topography of a Geographic within this data provider has changed.

Parameters
providerId

The ID of the data provider that contains the Geographic that was changed.

elementId

The ID of the element that was changed.

Since:

BlackBerry 10.1.0

void visibilityChanged (
  • const QString &providerId,
  • boolvisible )

Emitted when the visibility of this data provider has changed.

Parameters
providerId

The ID of the data provider whose visibility has changed.

visible

The new visible state.

Since:

BlackBerry 10.0.0

Last modified: 2014-11-17



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

comments powered by Disqus