From 87ea781595dfbe0274ede247f9d50610079787c8 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Tue, 28 Feb 2017 17:43:28 +0100 Subject: Batch add and removes into the model --- libqmenumodel/src/unitymenumodelevents.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'libqmenumodel/src/unitymenumodelevents.cpp') diff --git a/libqmenumodel/src/unitymenumodelevents.cpp b/libqmenumodel/src/unitymenumodelevents.cpp index e03d1c7..55cbaf0 100644 --- a/libqmenumodel/src/unitymenumodelevents.cpp +++ b/libqmenumodel/src/unitymenumodelevents.cpp @@ -35,26 +35,30 @@ UnityMenuModelClearEvent::UnityMenuModelClearEvent(bool _reset) reset(_reset) {} -UnityMenuModelAddRowEvent::UnityMenuModelAddRowEvent(GtkMenuTrackerItem *_item, int _position) +UnityMenuModelAddRowEvent::UnityMenuModelAddRowEvent(GPtrArray *_items, int _position) : QEvent(UnityMenuModelAddRowEvent::eventType), - item(_item), + items(_items), position(_position) { - if (item) { - g_object_ref(item); + if (items) { + for (gint i = 0; i < items->len; ++i) + g_object_ref(g_ptr_array_index(items, i)); + g_ptr_array_ref(items); } } UnityMenuModelAddRowEvent::~UnityMenuModelAddRowEvent() { - if (item) { - g_object_unref(item); + if (items) { + for (gint i = 0; i < items->len; ++i) + g_object_ref(g_ptr_array_index(items, i)); + g_ptr_array_unref(items); } } -UnityMenuModelRemoveRowEvent::UnityMenuModelRemoveRowEvent(int _position) +UnityMenuModelRemoveRowEvent::UnityMenuModelRemoveRowEvent(int _position, int _nItems) : QEvent(UnityMenuModelRemoveRowEvent::eventType), - position(_position) + position(_position), nItems(_nItems) {} UnityMenuModelDataChangeEvent::UnityMenuModelDataChangeEvent(int _position) -- cgit v1.2.3