From d12c5c0db8c198a540682befbafdafb73dbdfa45 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 5 Mar 2016 16:48:21 -0800 Subject: [PATCH] Add clearAndDeleteContents --- src/QmlControls/QmlObjectListModel.cc | 8 ++++++++ src/QmlControls/QmlObjectListModel.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/src/QmlControls/QmlObjectListModel.cc b/src/QmlControls/QmlObjectListModel.cc index 86db3ba9f..507ae0e52 100644 --- a/src/QmlControls/QmlObjectListModel.cc +++ b/src/QmlControls/QmlObjectListModel.cc @@ -228,3 +228,11 @@ void QmlObjectListModel::deleteListAndContents(void) } deleteLater(); } + +void QmlObjectListModel::clearAndDeleteContents(void) +{ + for (int i=0; i<_objectList.count(); i++) { + _objectList[i]->deleteLater(); + } + clear(); +} diff --git a/src/QmlControls/QmlObjectListModel.h b/src/QmlControls/QmlObjectListModel.h index 9a5d4f60f..ced6e2e15 100644 --- a/src/QmlControls/QmlObjectListModel.h +++ b/src/QmlControls/QmlObjectListModel.h @@ -63,6 +63,9 @@ public: /// Calls deleteLater on all items and this itself. void deleteListAndContents(void); + /// Clears the list and calls delete on each entry + void clearAndDeleteContents(void); + signals: void countChanged(int count); void dirtyChanged(bool dirtyChanged); -- 2.22.0