DataProvider

#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

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( latChanged(double) ),
    ddp, SLOT( onLatChanged(double) ) );
QObject::connect( map, SIGNAL( lonChanged(double) ),
    ddp, SLOT( onLonChanged(double) ) );
QObject::connect( map, SIGNAL( altitudeChanged(int) ),
    ddp, SLOT( onAltitudeChanged(int) ) );

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.

Since:

BlackBerry 10.0.0

Public Functions Index

DataProvider (const QString &id="", QObject *parent=0)
virtual ~DataProvider ()
QStringproviderId () const
voidsetProviderId (const QString &id)
boolisVisible () const
voidsetVisible (bool visible)
bb::platform::geo::GeoListtoGeoList () const
booladd (bb::platform::geo::Geographic *element)
intadd (const bb::platform::geo::GeoList &elements)
boolremove (const QString &elementId)
intremove (const QStringList &elements)
voidclear ()
bb::platform::geo::GeoListfind (const bb::platform::geo::BoundingBox &box) const
intcount () const
bb::platform::geo::BoundingBoxboundingBox () 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)
voidvisibilityChanged (const QString &providerId, bool visible)
voidtopographyChanged (const QString &providerId, const QString &elementId)

Public Functions

DataProvider (

Constructor.

Parameters
id

The unique identifier for this data provider.

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

QString providerId ()

Gets the unique identifier for this data provider.

Since:

BlackBerry 10.0.0

void setProviderId (

Sets the unique identifier for this data provider.

Since:

BlackBerry 10.0.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

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::GeoList toGeoList ()

Gets the data for this data provider.

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

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

void clear ()

Removes all data in this data provider.

Since:

BlackBerry 10.0.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

int count ()

Returns the number of Geographic elements in this data provider.

Since:

BlackBerry 10.1.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

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

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