void QDeclarativeGeoMapObjectView::modelRowsInserted(QModelIndex, int start, int end) { if (!componentCompleted_ || !map_ || !map_->mapData_ || !delegate_ || !model_) return; Q_ASSERT(declarativeObjectList_.count() == group_.childObjects().count()); QDeclarativeGeoMapObject* mapObject; for (int i = start; i <= end; ++i) { mapObject = createItem(i); if (!mapObject) { break; } declarativeObjectList_.append(mapObject); mapObject->setVisible(visible_); mapObject->setMap(map_); group_.addChildObject(mapObject->mapObject()); // Needed in order for mouse areas to work. map_->objectMap_.insert(mapObject->mapObject(), mapObject); } Q_ASSERT(declarativeObjectList_.count() == group_.childObjects().count()); }
// Removes and repopulates all items. void QDeclarativeGeoMapObjectView::repopulate() { if (!componentCompleted_ || !map_ || !map_->mapData_ || !delegate_ || !model_) return; // Free any earlier instances removeInstantiatedItems(); // Iterate model data and instantiate delegates. // We could use more specialized landmark model calls here too, // but hopefully the support will be leveraged to a general model // level. QDeclarativeGeoMapObject* mapObject; for (int i = 0; i < model_->rowCount(); ++i) { mapObject = createItem(i); if (!mapObject) break; declarativeObjectList_.append(mapObject); mapObject->setVisible(visible_); mapObject->setMap(map_); group_.addChildObject(mapObject->mapObject()); // Needed in order for mouse areas to work. map_->recursiveAddToObjectMap(mapObject); } }