~indicator-applet-developers/qmenumodel/trunk

« back to all changes in this revision

Viewing changes to libqmenumodel/src/unitymenumodelevents.cpp

  • Committer: Bileto Bot
  • Author(s): Albert Astals Cid
  • Date: 2017-03-16 16:55:18 UTC
  • mfrom: (128.1.3 batch_menu_adds)
  • Revision ID: ci-train-bot@canonical.com-20170316165518-if8jh31hvmj735d6
Batch add and removes into the model

Works much better with Qt Quick views to have all the insert/removes at once (LP: #1666701)

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
      reset(_reset)
36
36
{}
37
37
 
38
 
UnityMenuModelAddRowEvent::UnityMenuModelAddRowEvent(GtkMenuTrackerItem *_item, int _position)
 
38
UnityMenuModelAddRowEvent::UnityMenuModelAddRowEvent(GPtrArray *_items, int _position)
39
39
    : QEvent(UnityMenuModelAddRowEvent::eventType),
40
 
      item(_item),
 
40
      items(_items),
41
41
      position(_position)
42
42
{
43
 
    if (item) {
44
 
        g_object_ref(item);
 
43
    if (items) {
 
44
        for (gint i = 0; i < items->len; ++i)
 
45
            g_object_ref(g_ptr_array_index(items, i));
 
46
        g_ptr_array_ref(items);
45
47
    }
46
48
}
47
49
 
48
50
UnityMenuModelAddRowEvent::~UnityMenuModelAddRowEvent()
49
51
{
50
 
    if (item) {
51
 
        g_object_unref(item);
 
52
    if (items) {
 
53
        for (gint i = 0; i < items->len; ++i)
 
54
            g_object_unref(g_ptr_array_index(items, i));
 
55
        g_ptr_array_unref(items);
52
56
    }
53
57
}
54
58
 
55
 
UnityMenuModelRemoveRowEvent::UnityMenuModelRemoveRowEvent(int _position)
 
59
UnityMenuModelRemoveRowEvent::UnityMenuModelRemoveRowEvent(int _position, int _nItems)
56
60
    : QEvent(UnityMenuModelRemoveRowEvent::eventType),
57
 
      position(_position)
 
61
      position(_position), nItems(_nItems)
58
62
{}
59
63
 
60
64
UnityMenuModelDataChangeEvent::UnityMenuModelDataChangeEvent(int _position)