aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src/unitymenumodelevents.cpp
diff options
context:
space:
mode:
authorAlbert Astals Cid <albert.astals@canonical.com>2017-03-16 16:55:18 +0000
committerBileto Bot <ci-train-bot@canonical.com>2017-03-16 16:55:18 +0000
commite2b335b0ccb0b156283a320c2e1b7a2f4063b70b (patch)
treefd4c974396446dc7efcfe9858974b27e6a845a63 /libqmenumodel/src/unitymenumodelevents.cpp
parent2eaa36e38c910a0ee2450ac7ccae6473d359eb58 (diff)
parent4216eb744d580195628611f0aab698cd483a8675 (diff)
downloadqmenumodel-e2b335b0ccb0b156283a320c2e1b7a2f4063b70b.tar.gz
qmenumodel-e2b335b0ccb0b156283a320c2e1b7a2f4063b70b.tar.bz2
qmenumodel-e2b335b0ccb0b156283a320c2e1b7a2f4063b70b.zip
Batch add and removes into the model
Works much better with Qt Quick views to have all the insert/removes at once (LP: #1666701)
Diffstat (limited to 'libqmenumodel/src/unitymenumodelevents.cpp')
-rw-r--r--libqmenumodel/src/unitymenumodelevents.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/libqmenumodel/src/unitymenumodelevents.cpp b/libqmenumodel/src/unitymenumodelevents.cpp
index e03d1c7..68dacde 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_unref(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)