genlist: modified first/last/prev/next get API for filtered list.

Summary: elm_genlist_first_item_get(), elm_genlist_last_item_get(), elm_genlist_item_prev_get(), elm_genlist_item_next_get() should return the next filtered item if filter is applied on the genlist.

Test Plan: test_genlist.c => Genlist Filter demo updated

Reviewers: shilpasingh, cedric, SanghyeonLee

Subscribers: divyesh, rajeshps

Differential Revision: https://phab.enlightenment.org/D3263

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
shashank.p 2015-11-09 16:03:05 -08:00 committed by Cedric BAIL
parent 278ceaa12e
commit 1e2b58a8c8
5 changed files with 91 additions and 17 deletions

View File

@ -4996,7 +4996,6 @@ _entry_change_cb(void *data, Evas_Object *obj, void *event EINA_UNUSED)
{ {
api_data *api = (api_data *)data; api_data *api = (api_data *)data;
char buf[100]; char buf[100];
Eina_Iterator *filter_iter;
unsigned int count = 0; unsigned int count = 0;
Elm_Object_Item *item; Elm_Object_Item *item;
@ -5010,15 +5009,19 @@ _entry_change_cb(void *data, Evas_Object *obj, void *event EINA_UNUSED)
printf("Input data string empty; returning\n"); printf("Input data string empty; returning\n");
return; return;
} }
filter_iter = elm_genlist_filter_iterator_new(api->gl);
EINA_ITERATOR_FOREACH(filter_iter, item)
if (item) count++;
item = elm_genlist_first_item_get(api->gl);
if (!item)
{
printf("No matches for the key %s\n", buf);
return;
}
while (item)
{
++count;
item = elm_genlist_item_next_get(item);
}
printf("Number of matches for %s is %d\n", buf, count); printf("Number of matches for %s is %d\n", buf, count);
//Iterator needs to be freed by application using eina_iterator_free
eina_iterator_free(filter_iter);
} }
void void

View File

@ -6526,7 +6526,22 @@ _elm_genlist_at_xy_item_get(const Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd, Eva
EOLIAN static Elm_Object_Item* EOLIAN static Elm_Object_Item*
_elm_genlist_first_item_get(Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd) _elm_genlist_first_item_get(Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd)
{ {
return EO_OBJ(ELM_GEN_ITEM_FROM_INLIST(sd->items)); Elm_Gen_Item *it = ELM_GEN_ITEM_FROM_INLIST(sd->items);
if (!sd->filter)
{
return EO_OBJ(it);
}
else
{
while (it)
{
if (_item_filtered_get(it)) break;
it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
}
if (it) return EO_OBJ(it);
return NULL;
}
} }
EOLIAN static Elm_Object_Item* EOLIAN static Elm_Object_Item*
@ -6535,19 +6550,44 @@ _elm_genlist_last_item_get(Eo *obj EINA_UNUSED, Elm_Genlist_Data *sd)
Elm_Gen_Item *it; Elm_Gen_Item *it;
if (!sd->items) return NULL; if (!sd->items) return NULL;
it = ELM_GEN_ITEM_FROM_INLIST(sd->items->last); it = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
return EO_OBJ(it); if (!sd->filter)
{
return EO_OBJ(it);
}
else
{
while (it)
{
if (_item_filtered_get(it)) break;
it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
}
if (it) return EO_OBJ(it);
return NULL;
}
} }
EOLIAN static Elm_Object_Item * EOLIAN static Elm_Object_Item *
_elm_genlist_item_next_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it) _elm_genlist_item_next_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
{ {
while (it) ELM_GENLIST_DATA_GET_FROM_ITEM(it, sd);
if (!sd->filter)
{ {
it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next); while (it)
if (it) break; {
it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
if (it) break;
}
}
else
{
while (it)
{
it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
if (it && _item_filtered_get(it)) break;
}
} }
if (it) return EO_OBJ(it); if (it) return EO_OBJ(it);
@ -6557,10 +6597,24 @@ _elm_genlist_item_next_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
EOLIAN static Elm_Object_Item * EOLIAN static Elm_Object_Item *
_elm_genlist_item_prev_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it) _elm_genlist_item_prev_get(Eo *eo_it EINA_UNUSED, Elm_Gen_Item *it)
{ {
while (it) ELM_GENLIST_DATA_GET_FROM_ITEM(it, sd);
if (!it) return NULL;
if (!sd->filter)
{ {
it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev); while (it)
if (it) break; {
it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
if (it) break;
}
}
else
{
while (it)
{
it = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
if (it && _item_filtered_get(it)) break;
}
} }
if (it) return EO_OBJ(it); if (it) return EO_OBJ(it);

View File

@ -283,6 +283,9 @@ class Elm.Genlist (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interfac
[[Get the first item in the genlist. [[Get the first item in the genlist.
This returns the first item in the list. This returns the first item in the list.
If filter is set on genlist, it returns
the first filtered item in the list.
]] ]]
return: Elm.Widget_Item *; [[The first item or $null.]] return: Elm.Widget_Item *; [[The first item or $null.]]
} }
@ -323,6 +326,9 @@ class Elm.Genlist (Elm.Layout, Elm_Interface_Scrollable, Evas.Clickable_Interfac
[[Get the last item in the genlist [[Get the last item in the genlist
This returns the last item in the list. This returns the last item in the list.
If filter is set to genlist, it returns
last filtered item in the list.
]] ]]
return: Elm.Widget_Item *; return: Elm.Widget_Item *;
} }

View File

@ -26,6 +26,11 @@ typedef Elm_Gen_Item_State_Get_Cb Elm_Genlist_Item_State_Get_Cb;
*/ */
typedef Elm_Gen_Item_Del_Cb Elm_Genlist_Item_Del_Cb; typedef Elm_Gen_Item_Del_Cb Elm_Genlist_Item_Del_Cb;
/**
* @see Elm_Gen_Item_Filter_Get_Cb
*/
typedef Elm_Gen_Item_Filter_Get_Cb Elm_Genlist_Item_Filter_Get_Cb;
/** /**
* Create a new genlist item class in a given genlist widget. * Create a new genlist item class in a given genlist widget.
* *

View File

@ -47,6 +47,9 @@ class Elm.Genlist_Item(Elm.Widget_Item)
This returns the item placed before the $item, on This returns the item placed before the $item, on
the container genlist. the container genlist.
If filter is set on genlist, this returns the filtered
item placed before $item in the list.
]] ]]
} }
values { values {
@ -60,6 +63,9 @@ class Elm.Genlist_Item(Elm.Widget_Item)
This returns the item placed after the $item, on This returns the item placed after the $item, on
the container genlist. the container genlist.
If filter is set on genlist, this returns the filtered
item placed after $item in the list.
]] ]]
} }
values { values {