[gnumeric] Remove undesired interaction between Advanced Filters and Autofilters.



commit 4837f3f3a1faf605c9567fd448b9a7a2d1993de5
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date:   Tue May 4 19:10:30 2010 -0600

    Remove undesired interaction between Advanced Filters and Autofilters.
    
    2010-05-04 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* src/colrow.h (_ColRowInfo): add in_advanced_filter field
    	* src/wbc-gtk-actions.c (actions): make it clear that ShowAll
    	  relates to Advanced Filters
    	* src/wbc-gtk.c (wbcg_menu_state_update): keep has_filtered_rows
    	  for advanced filters separate from the auto filters.
    
    2010-05-04 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* filter.c (filter): use ri->in_advanced_filter rather
    	  than ri->in_filter
    	(cb_show_all): set ri->in_advanced_filter to false
    	(filter_show_all): don't touch the auto filters

 ChangeLog             |    8 ++++++++
 NEWS                  |    2 ++
 src/colrow.h          |    1 +
 src/tools/ChangeLog   |    7 +++++++
 src/tools/filter.c    |   23 +++++++++--------------
 src/wbc-gtk-actions.c |    4 ++--
 src/wbc-gtk.c         |   12 +-----------
 7 files changed, 30 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0099c56..9b7e105 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-05-04 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* src/colrow.h (_ColRowInfo): add in_advanced_filter field
+	* src/wbc-gtk-actions.c (actions): make it clear that ShowAll 
+	  relates to Advanced Filters
+	* src/wbc-gtk.c (wbcg_menu_state_update): keep has_filtered_rows
+	  for advanced filters separate from the auto filters.
+
+2010-05-04 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* src/wbc-gtk-actions.c: change argument to filter_show_all
 	* src/wbc-gtk.c (wbcg_menu_state_update): use MS_FILTER_STATE_CHANGED
 	  rather than MS_CONSOLIDATE
diff --git a/NEWS b/NEWS
index c7e897d..366c15f 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ Andreas:
 	* Protect against accidentally pushing data off the sheet. [#98562]
 	* Make Advanced Filter (except filter-in-place) undoable.
 	* Fix Data->Filter->ShowAll for Advanced Filter. [#611079]
+	* Remove undesired interaction between Advanced Filters and 
+	  Autofilters.
 
 Jean:
 	* Implement graph only sheets. [#158170]
diff --git a/src/colrow.h b/src/colrow.h
index e314ea9..863404e 100644
--- a/src/colrow.h
+++ b/src/colrow.h
@@ -17,6 +17,7 @@ struct _ColRowInfo {
 	unsigned  hard_size     : 1;	/* are dimensions explicitly set ? */
 	unsigned  visible       : 1;	/* visible */
 	unsigned  in_filter     : 1;	/* in a filter */
+	unsigned  in_advanced_filter : 1; /* in an advanced filter */
 	unsigned  needs_respan  : 1;	/* mark a row as needing span generation */
 
 	/* TODO : Add per row/col min/max */
diff --git a/src/tools/ChangeLog b/src/tools/ChangeLog
index d4d510c..290a793 100644
--- a/src/tools/ChangeLog
+++ b/src/tools/ChangeLog
@@ -1,5 +1,12 @@
 2010-05-04 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	* filter.c (filter): use ri->in_advanced_filter rather
+	  than ri->in_filter
+	(cb_show_all): set ri->in_advanced_filter to false
+	(filter_show_all): don't touch the auto filters
+	
+2010-05-04 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* filter.h (filter_show_all): require WorkbookControl rather 
 	  than Sheet.
 	* filter.c (filter_show_all): require WorkbookControl rather 
diff --git a/src/tools/filter.c b/src/tools/filter.c
index dadd3f1..d2b6987 100644
--- a/src/tools/filter.c
+++ b/src/tools/filter.c
@@ -50,7 +50,7 @@ filter (data_analysis_output_t *dao, Sheet *sheet, GSList *rows,
 				       FALSE, input_row_b+1, input_row_e);
 		for (i=input_row_b; i<=input_row_e; i++) {
 			ColRowInfo *ri = sheet_row_fetch (sheet, i);
-			ri->in_filter = TRUE;
+			ri->in_advanced_filter = TRUE;
 		}
 		while (rows != NULL) {
 			gint *row = (gint *) rows->data;
@@ -147,9 +147,13 @@ advanced_filter (WorkbookControl        *wbc,
 static gboolean
 cb_show_all (GnmColRowIter const *iter, Sheet *sheet)
 {
-	if (iter->cri->in_filter && !iter->cri->visible)
-		colrow_set_visibility (sheet, FALSE, TRUE,
-				       iter->pos, iter->pos);
+	if (iter->cri->in_advanced_filter) {
+		ColRowInfo *ri = sheet_row_fetch (sheet, iter->pos);
+		if (!iter->cri->visible)
+			colrow_set_visibility (sheet, FALSE, TRUE,
+					       iter->pos, iter->pos);
+		ri->in_advanced_filter = FALSE;
+	}
 	return FALSE;
 }
 
@@ -157,19 +161,10 @@ void
 filter_show_all (WorkbookControl *wbc)
 {
 	Sheet *sheet = wb_control_cur_sheet (wbc);
-	GSList *ptr = sheet->filters;
-	GnmFilter *filter;
-	unsigned i;
-
-	for (; ptr != NULL ; ptr = ptr->next) {
-		filter = ptr->data;
-		for (i = filter->fields->len; i-- > 0 ;)
-			gnm_filter_set_condition (filter, i, NULL, FALSE);
-	}
 
 	/* FIXME: This is slow. We should probably have a linked list
 	 * containing the filtered rows in the sheet structure. */
-	colrow_foreach (&sheet->rows, 0, gnm_sheet_get_max_rows (sheet),
+	colrow_foreach (&sheet->rows, FALSE, gnm_sheet_get_max_rows (sheet),
 			(ColRowHandler) cb_show_all, sheet);
 	sheet->has_filtered_rows = FALSE;
 	sheet_redraw_all (sheet, TRUE);
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 67f7623..5e8f08a 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -2269,8 +2269,8 @@ static GtkActionEntry const actions[] = {
 	{ "DataAutoFilter", "Gnumeric_AutoFilter", N_("Add _Auto Filter"),
 		NULL, N_("Add or remove a filter"),
 		G_CALLBACK (cb_auto_filter) },
-	{ "DataFilterShowAll", NULL, N_("_Show All"),
-		NULL, N_("Show all filtered and hidden rows"),
+	{ "DataFilterShowAll", NULL, N_("_Clear Advanced Filter"),
+		NULL, N_("Show all rows hidden by an advanced filter"),
 		G_CALLBACK (cb_show_all) },
 	{ "DataFilterAdvancedfilter", NULL, N_("Advanced _Filter..."),
 		NULL, N_("Filter data with given criteria"),
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 80220ea..7ce4e59 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -1512,20 +1512,10 @@ wbcg_menu_state_update (WorkbookControl *wbc, int flags)
 	SheetView const *sv  = wb_control_cur_sheet_view (wbc);
 	Sheet const *sheet = wb_control_cur_sheet (wbc);
 	gboolean const has_guru = wbc_gtk_get_guru (wbcg) != NULL;
-	gboolean has_filtered_rows = sheet->has_filtered_rows;
 	gboolean edit_object = scg != NULL &&
 		(scg->selected_objects != NULL || wbcg->new_object != NULL);
 	gboolean has_print_area;
 
-	if (!has_filtered_rows) {
-		GSList *ptr = sheet->filters;
-		for (;ptr != NULL ; ptr = ptr->next)
-			if (((GnmFilter *)ptr->data)->is_active) {
-				has_filtered_rows = TRUE;
-				break;
-			}
-	}
-
 	if (MS_INSERT_COLS & flags)
 		wbc_gtk_set_action_sensitivity (wbcg, "InsertColumns",
 			sv->enable_insert_cols);
@@ -1555,7 +1545,7 @@ wbcg_menu_state_update (WorkbookControl *wbc, int flags)
 	if (MS_CONSOLIDATE & flags)
 		wbc_gtk_set_action_sensitivity (wbcg, "DataConsolidate", !has_guru);
 	if (MS_FILTER_STATE_CHANGED & flags)
-		wbc_gtk_set_action_sensitivity (wbcg, "DataFilterShowAll", has_filtered_rows);
+		wbc_gtk_set_action_sensitivity (wbcg, "DataFilterShowAll", sheet->has_filtered_rows);
 	if (MS_SHOW_PRINTAREA & flags) {
 		GnmRange *print_area = sheet_get_nominal_printarea (sheet);
 		has_print_area = (print_area != NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]