cedric pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=6c04d13a8a1b34940d418051a0a5fff560f5e5c7

commit 6c04d13a8a1b34940d418051a0a5fff560f5e5c7
Author: shashank.p <shashan...@samsung.com>
Date:   Mon Nov 9 16:03:05 2015 -0800

    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 <ced...@osg.samsung.com>
---
 src/bin/test_genlist.c       | 19 +++++++-----
 src/lib/elm_genlist.c        | 72 ++++++++++++++++++++++++++++++++++++++------
 src/lib/elm_genlist.eo       |  6 ++++
 src/lib/elm_genlist_common.h |  5 +++
 src/lib/elm_genlist_item.eo  |  6 ++++
 5 files changed, 91 insertions(+), 17 deletions(-)

diff --git a/src/bin/test_genlist.c b/src/bin/test_genlist.c
index 2dd636e..9ed3725 100644
--- a/src/bin/test_genlist.c
+++ b/src/bin/test_genlist.c
@@ -4996,7 +4996,6 @@ _entry_change_cb(void *data, Evas_Object *obj, void 
*event EINA_UNUSED)
 {
    api_data *api = (api_data *)data;
    char buf[100];
-   Eina_Iterator *filter_iter;
    unsigned int count = 0;
    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");
         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);
-   //Iterator needs to be freed by application using eina_iterator_free
-   eina_iterator_free(filter_iter);
-
 }
 
 void
diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c
index a706bd9..3c51e40 100644
--- a/src/lib/elm_genlist.c
+++ b/src/lib/elm_genlist.c
@@ -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*
 _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*
@@ -6535,19 +6550,44 @@ _elm_genlist_last_item_get(Eo *obj EINA_UNUSED, 
Elm_Genlist_Data *sd)
    Elm_Gen_Item *it;
 
    if (!sd->items) return NULL;
-
    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 *
 _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);
-        if (it) break;
+        while (it)
+          {
+             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);
@@ -6557,10 +6597,24 @@ _elm_genlist_item_next_get(Eo *eo_it EINA_UNUSED, 
Elm_Gen_Item *it)
 EOLIAN static Elm_Object_Item *
 _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);
-        if (it) break;
+        while (it)
+          {
+            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);
diff --git a/src/lib/elm_genlist.eo b/src/lib/elm_genlist.eo
index 5bf03a5..ebe0733 100644
--- a/src/lib/elm_genlist.eo
+++ b/src/lib/elm_genlist.eo
@@ -283,6 +283,9 @@ class Elm.Genlist (Elm.Layout, Elm_Interface_Scrollable, 
Evas.Clickable_Interfac
             [[Get the first item in the genlist.
 
               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.]]
          }
@@ -323,6 +326,9 @@ class Elm.Genlist (Elm.Layout, Elm_Interface_Scrollable, 
Evas.Clickable_Interfac
             [[Get the last item in the genlist
 
               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 *;
          }
diff --git a/src/lib/elm_genlist_common.h b/src/lib/elm_genlist_common.h
index d3ed39d..b1d1d9f 100644
--- a/src/lib/elm_genlist_common.h
+++ b/src/lib/elm_genlist_common.h
@@ -27,6 +27,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;
 
 /**
+ * @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.
  *
  * @return New allocated genlist item class.
diff --git a/src/lib/elm_genlist_item.eo b/src/lib/elm_genlist_item.eo
index ef35ded..e78c956 100644
--- a/src/lib/elm_genlist_item.eo
+++ b/src/lib/elm_genlist_item.eo
@@ -47,6 +47,9 @@ class Elm.Genlist_Item(Elm.Widget_Item)
 
                        This returns the item placed before the $item, on
                        the container genlist.
+                       
+                       If filter is set on genlist, this returns the filtered
+                       item placed before $item in the list.
                      ]]
                 }
                 values {
@@ -60,6 +63,9 @@ class Elm.Genlist_Item(Elm.Widget_Item)
 
                        This returns the item placed after the $item, on
                        the container genlist.
+
+                       If filter is set on genlist, this returns the filtered
+                       item placed after $item in the list.
                      ]]
                 }
                 values {

-- 


Reply via email to