mobile/divelist: create memory management class for models

Since we want to add a second model, but not have to manage two models
everywhere, create a class MobileModels that contains both of the models. When
calling reset() on that class, it will reset both of the models, etc.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Berthold Stoeger 2019-12-11 10:37:50 +01:00 committed by Dirk Hohndel
parent 8e9e536ffd
commit 7e1ac2167b
4 changed files with 45 additions and 30 deletions

View file

@ -103,10 +103,9 @@ void run_ui()
gpsSortModel->setSortRole(GpsListModel::GpsWhenRole);
gpsSortModel->sort(0, Qt::DescendingOrder);
QQmlContext *ctxt = engine.rootContext();
MobileListModel *mlm(MobileListModel::instance());
ctxt->setContextProperty("diveModel", mlm);
ctxt->setContextProperty("gpsModel", gpsSortModel);
ctxt->setContextProperty("vendorList", vendorList);
ctxt->setContextProperty("diveModel", MobileModels::instance()->listModel());
set_non_bt_addresses();
ctxt->setContextProperty("connectionListModel", &connectionListModel);