From 09ca240c3ee41f8d8fb029873d63e301da37fc99 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Thu, 4 Jun 2015 00:05:05 -0300 Subject: Do not reset the model when adding a new dive site This makes insertion faster, and also it doesn't break the current selection in the QComboBox. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-models/divelocationmodel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'qt-models') diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp index 3e17f4fe2..ea6efda95 100644 --- a/qt-models/divelocationmodel.cpp +++ b/qt-models/divelocationmodel.cpp @@ -54,8 +54,11 @@ int32_t LocationInformationModel::addDiveSite(const QString& name, int lon, int latitude.udeg = lat; longitude.udeg = lon; + beginInsertRows(QModelIndex(), dive_site_table.nr, dive_site_table.nr); int32_t uuid = create_dive_site_with_gps(name.toUtf8().data(), latitude, longitude); - update(); + std::sort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than); + internalRowCount = dive_site_table.nr; + endInsertRows(); return uuid; } -- cgit v1.2.3-70-g09d2