[Genlist] Fix genlist index get bug
[framework/uifw/elementary.git] / src / lib / elm_genlist.c
index 8526cfd..721efae 100644 (file)
@@ -185,10 +185,6 @@ _item_cache_push(Elm_Gen_Item *it)
    Elm_Genlist_Smart_Data *sd = GL_IT(it)->wsd;
    Item_Cache *ic = NULL;
 
-#if GENLIST_FX_SUPPORT
-   if (sd->pending_del_items) return;
-#endif
-
    if (sd->item_cache_count >= sd->item_cache_max)
     {
         ic = EINA_INLIST_CONTAINER_GET(sd->item_cache->last, Item_Cache);
@@ -218,7 +214,11 @@ _item_cache_push(Elm_Gen_Item *it)
                                         _contract_signal_cb, it);
    _item_mouse_callbacks_del(it, VIEW(it));
 
+#if GENLIST_FX_SUPPORT
+   if ((it->item->nocache_once) || (it->item->nocache) || (sd->pending_del_items))
+#else
    if ((it->item->nocache_once) || (it->item->nocache))
+#endif
      {
         if (VIEW(it)) evas_object_del(VIEW(it));
         if (it->spacer) evas_object_del(it->spacer);
@@ -1671,7 +1671,8 @@ _item_realize(Elm_Gen_Item *it,
 #endif
    treesize = edje_object_data_get(VIEW(it), "treesize");
    if (treesize) tsize = atoi(treesize);
-   if (!it->spacer && treesize)
+   if (it->parent && GL_IT(it->parent)->type == ELM_GENLIST_ITEM_TREE &&
+       !it->spacer && treesize)
      {
         it->spacer =
           evas_object_rectangle_add(evas_object_evas_get(WIDGET(it)));
@@ -5661,6 +5662,7 @@ elm_genlist_clear(Evas_Object *obj)
    while (sd->items)
      {
         it = EINA_INLIST_CONTAINER_GET(sd->items->last, Elm_Gen_Item);
+        it->item->nocache_once = EINA_TRUE;
         elm_widget_item_del(it);
      }
    sd->items = NULL;
@@ -6489,14 +6491,18 @@ elm_genlist_item_cursor_engine_only_get(const Elm_Object_Item *it)
 EAPI int
 elm_genlist_item_index_get(const Elm_Object_Item *item)
 {
+   int cnt = 0;
+   Elm_Gen_Item *tmp;
    Elm_Gen_Item *it = (Elm_Gen_Item *)item;
 
    ELM_GENLIST_ITEM_CHECK_OR_RETURN(item, -1);
 
-   if (it->item->block)
-     return it->position + (it->item->block->position *
-                            GL_IT(it)->wsd->max_items_per_block);
-   return -1;
+   EINA_INLIST_FOREACH(GL_IT(it)->wsd->items, tmp)
+     {
+        if (tmp == it) break;
+        cnt++;
+     }
+   return cnt;
 }
 
 EAPI void