summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2011-07-28 16:43:15 +0000
committerCedric BAIL <cedric.bail@free.fr>2011-07-28 16:43:15 +0000
commita2fb230d533477f1b03c032f1f478a31b26654fa (patch)
treebf48a0ea456c8bbb6b529168ce7d39436ba5b63d
parentc65ba0c6cd73ff44902ef5b7846c836f55802b1a (diff)
elementary: fix some parental issue with genlist.
SVN revision: 61863
-rw-r--r--src/lib/elm_genlist.c71
1 files changed, 59 insertions, 12 deletions
diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c
index 3b8ef4d89..16da44e6b 100644
--- a/src/lib/elm_genlist.c
+++ b/src/lib/elm_genlist.c
@@ -3310,12 +3310,20 @@ _elm_genlist_item_compare_data(const void *data, const void *data1)
3310static int 3310static int
3311_elm_genlist_item_compare(const void *data, const void *data1) 3311_elm_genlist_item_compare(const void *data, const void *data1)
3312{ 3312{
3313 Elm_Genlist_Item *item, *item1; 3313 const Elm_Genlist_Item *item, *item1;
3314 item = ELM_GENLIST_ITEM_FROM_INLIST(data); 3314 item = ELM_GENLIST_ITEM_FROM_INLIST(data);
3315 item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1); 3315 item1 = ELM_GENLIST_ITEM_FROM_INLIST(data1);
3316 return _elm_genlist_item_compare_cb(item, item1); 3316 return _elm_genlist_item_compare_cb(item, item1);
3317} 3317}
3318 3318
3319static int
3320_elm_genlist_item_list_compare(const void *data, const void *data1)
3321{
3322 const Elm_Genlist_Item *item = data;
3323 const Elm_Genlist_Item *item1 = data1;
3324 return _elm_genlist_item_compare_cb(item, item1);
3325}
3326
3319static void 3327static void
3320_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after) 3328_item_move_after(Elm_Genlist_Item *it, Elm_Genlist_Item *after)
3321{ 3329{
@@ -3537,6 +3545,7 @@ elm_genlist_item_direct_sorted_insert(Evas_Object *obj,
3537 ELM_CHECK_WIDTYPE(obj, widtype) NULL; 3545 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3538 Widget_Data *wd = elm_widget_data_get(obj); 3546 Widget_Data *wd = elm_widget_data_get(obj);
3539 if (!wd) return NULL; 3547 if (!wd) return NULL;
3548 Elm_Genlist_Item *rel = NULL;
3540 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func, 3549 Elm_Genlist_Item *it = _item_new(wd, itc, data, parent, flags, func,
3541 func_data); 3550 func_data);
3542 if (!it) return NULL; 3551 if (!it) return NULL;
@@ -3545,23 +3554,61 @@ elm_genlist_item_direct_sorted_insert(Evas_Object *obj,
3545 3554
3546 if (it->parent) 3555 if (it->parent)
3547 { 3556 {
3548 it->parent->items = 3557 Eina_List *l;
3549 eina_list_sorted_insert(it->parent->items, _elm_genlist_item_compare, it); 3558 int cmp_result;
3559
3560 l = eina_list_search_sorted_near_list(it->parent->items,
3561 _elm_genlist_item_list_compare, it,
3562 &cmp_result);
3563 if (l)
3564 rel = eina_list_data_get(l);
3565 else
3566 rel = it->parent;
3567
3568 if (cmp_result > 0)
3569 {
3570 it->parent->items = eina_list_prepend_relative_list(it->parent->items, it, l);
3571 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
3572 it->before = EINA_FALSE;
3573 }
3574 else if (cmp_result < 0)
3575 {
3576 it->parent->items = eina_list_append_relative_list(it->parent->items, it, l);
3577 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(rel));
3578 it->before = EINA_TRUE;
3579 }
3580
3581 if (it->parent->flags & ELM_GENLIST_ITEM_GROUP)
3582 it->group_item = parent;
3583 else if (it->parent->group_item)
3584 it->group_item = it->parent->group_item;
3550 } 3585 }
3551 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(it), 3586 else
3552 _elm_genlist_item_compare);
3553 if (EINA_INLIST_GET(it)->next)
3554 { 3587 {
3555 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next); 3588 if (flags & ELM_GENLIST_ITEM_GROUP)
3556 it->rel->relcount++; 3589 wd->group_items = eina_list_append(wd->group_items, it);
3557 it->before = EINA_TRUE; 3590
3591 wd->items = eina_inlist_sorted_insert(wd->items, EINA_INLIST_GET(it),
3592 _elm_genlist_item_compare);
3593
3594 if (EINA_INLIST_GET(it)->next)
3595 {
3596 rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
3597 it->before = EINA_TRUE;
3598 }
3599 else if (EINA_INLIST_GET(it)->prev)
3600 {
3601 rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
3602 it->before = EINA_FALSE;
3603 }
3558 } 3604 }
3559 else if (EINA_INLIST_GET(it)->prev) 3605
3606 if (rel)
3560 { 3607 {
3561 it->rel = ELM_GENLIST_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev); 3608 it->rel = rel;
3562 it->rel->relcount++; 3609 it->rel->relcount++;
3563 it->before = EINA_FALSE;
3564 } 3610 }
3611
3565 _item_queue(wd, it); 3612 _item_queue(wd, it);
3566 3613
3567 return it; 3614 return it;