diff options
-rw-r--r-- | mobile-widgets/qmlmapwidgethelper.cpp | 4 | ||||
-rw-r--r-- | qt-models/maplocationmodel.cpp | 9 | ||||
-rw-r--r-- | qt-models/maplocationmodel.h | 1 |
3 files changed, 13 insertions, 1 deletions
diff --git a/mobile-widgets/qmlmapwidgethelper.cpp b/mobile-widgets/qmlmapwidgethelper.cpp index c560c5aaf..7e653692a 100644 --- a/mobile-widgets/qmlmapwidgethelper.cpp +++ b/mobile-widgets/qmlmapwidgethelper.cpp @@ -29,12 +29,14 @@ void MapWidgetHelper::reloadMapLocations() struct dive_site *ds;
int idx;
m_mapLocationModel->clear();
+ QList<MapLocation *> locationList;
for_each_dive_site(idx, ds) {
if (!dive_site_has_gps_location(ds))
continue;
const qreal longitude = ds->longitude.udeg / 1000000.0;
const qreal latitude = ds->latitude.udeg / 1000000.0;
- m_mapLocationModel->add(new MapLocation(QGeoCoordinate(latitude, longitude)));
+ locationList.append(new MapLocation(QGeoCoordinate(latitude, longitude)));
}
+ m_mapLocationModel->addList(locationList);
}
diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp index d08e7020c..ec554d004 100644 --- a/qt-models/maplocationmodel.cpp +++ b/qt-models/maplocationmodel.cpp @@ -68,6 +68,15 @@ void MapLocationModel::add(MapLocation *location) endInsertRows();
}
+void MapLocationModel::addList(QList<MapLocation *> list)
+{
+ if (!list.size())
+ return;
+ beginInsertRows(QModelIndex(), m_mapLocations.size(), m_mapLocations.size() + list.size() - 1);
+ m_mapLocations.append(list);
+ endInsertRows();
+}
+
void MapLocationModel::clear()
{
if (!m_mapLocations.size())
diff --git a/qt-models/maplocationmodel.h b/qt-models/maplocationmodel.h index 4aeee0364..c73fa246e 100644 --- a/qt-models/maplocationmodel.h +++ b/qt-models/maplocationmodel.h @@ -43,6 +43,7 @@ public: int rowCount(const QModelIndex &parent) const override; int count(); void add(MapLocation *); + void addList(QList<MapLocation *>); void clear(); protected: |