From 6ed807f52d7837e1e8e87a182ca053ca17f45b5b Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Mon, 17 Jul 2017 22:59:14 +0300 Subject: maplocationmodel: add the addList() method This method should be used if many markers are added at once. It's main purpose is to reduces the number of beingInsertRows() calls. Make MapWidgetHelper::reloadMapLocations() use it. Signed-off-by: Lubomir I. Ivanov --- qt-models/maplocationmodel.cpp | 9 +++++++++ qt-models/maplocationmodel.h | 1 + 2 files changed, 10 insertions(+) (limited to 'qt-models') 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 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); void clear(); protected: -- cgit v1.2.3-70-g09d2