Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_mvc.c ewl_mvc.h 


Log Message:
- fill in some mvc unit tests
- fix some mvc selected bugs

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_mvc.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_mvc.c   15 Oct 2006 22:34:14 -0000      1.5
+++ ewl_mvc.c   17 Oct 2006 15:35:37 -0000      1.6
@@ -331,11 +331,27 @@
                                         int erow, int ecolumn)
 {
        Ewl_Selection *sel;
+       int tmp;
 
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("mvc", mvc);
        DCHECK_TYPE("mvc", mvc, EWL_MVC_TYPE);
 
+       /* make sure the start comes before the end */
+       if (erow < srow)
+       {
+               tmp = erow;
+               erow = srow;
+               srow = tmp;
+       }
+
+       if (ecolumn < scolumn)
+       {
+               tmp = ecolumn;
+               ecolumn = scolumn;
+               scolumn = tmp;
+       }
+
        if (mvc->selection_mode == EWL_SELECTION_MODE_SINGLE)
        {
                Ewl_Selection_Idx *si;
@@ -543,11 +559,41 @@
 int
 ewl_mvc_selected_count_get(Ewl_MVC *mvc)
 {
+       int count = 0;
+       Ewl_Selection *sel;
+
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("mvc", mvc, 0);
        DCHECK_TYPE_RET("mvc", mvc, EWL_MVC_TYPE, 0);
 
-       DRETURN_INT(ecore_list_nodes(mvc->selected), DLEVEL_STABLE);
+       /* make sure we only return 1 or 0 for the single select case */
+       if (mvc->selection_mode == EWL_SELECTION_MODE_SINGLE)
+       {
+               if (ecore_list_nodes(mvc->selected))
+                       DRETURN_INT(1, DLEVEL_STABLE);
+
+               DRETURN_INT(0, DLEVEL_STABLE);
+       }
+
+       ecore_list_goto_first(mvc->selected);
+       while ((sel = ecore_list_next(mvc->selected)))
+       {
+               if (sel->type == EWL_SELECTION_TYPE_INDEX)
+                       count ++;
+               else if (sel->type == EWL_SELECTION_TYPE_RANGE)
+               {
+                       Ewl_Selection_Range *r;
+                       int rows = 0, columns = 0;
+
+                       r = EWL_SELECTION_RANGE(sel);
+                       rows = (r->end.row - r->start.row) + 1;
+                       columns = (r->end.column - r->start.column) + 1;
+
+                       count += (rows * columns);
+               }
+       }
+
+       DRETURN_INT(count, DLEVEL_STABLE);
 }
 
 /**
@@ -557,7 +603,7 @@
  * @brief Checks if the given index is selected or not.
  */
 unsigned int
-ewl_mvc_is_selected(Ewl_MVC *mvc, int row, int column)
+ewl_mvc_selected_is(Ewl_MVC *mvc, int row, int column)
 {
        Ewl_Selection *sel;
        int ret = FALSE;
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_mvc.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- ewl_mvc.h   15 Oct 2006 22:34:14 -0000      1.5
+++ ewl_mvc.h   17 Oct 2006 15:35:37 -0000      1.6
@@ -111,7 +111,7 @@
 void            ewl_mvc_selected_rm(Ewl_MVC *mvc, int row, int column);
 
 int             ewl_mvc_selected_count_get(Ewl_MVC *mvc);
-unsigned int    ewl_mvc_is_selected(Ewl_MVC *mvc, int row, int column);
+unsigned int    ewl_mvc_selected_is(Ewl_MVC *mvc, int row, int column);
 
 /* 
  * internal



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to