[Gnucash-changes] r12264 - gnucash/trunk - Load the entire data set into the combocell before enabling sorting.

David Hampton hampton at cvs.gnucash.org
Thu Jan 5 00:18:54 EST 2006


Author: hampton
Date: 2006-01-05 00:18:52 -0500 (Thu, 05 Jan 2006)
New Revision: 12264
Trac: http://svn.gnucash.org/trac/changeset/12264

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/register/ledger-core/split-register-load.c
   gnucash/trunk/src/register/register-core/combocell.h
   gnucash/trunk/src/register/register-gnome/combocell-gnome.c
   gnucash/trunk/src/register/register-gnome/gnucash-item-list.c
   gnucash/trunk/src/register/register-gnome/gnucash-item-list.h
Log:
Load the entire data set into the combocell before enabling sorting.
Saves a tremendous amount of time.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-01-05 03:44:11 UTC (rev 12263)
+++ gnucash/trunk/ChangeLog	2006-01-05 05:18:52 UTC (rev 12264)
@@ -1,3 +1,15 @@
+2006-01-04  David Hampton  <hampton at employees.org>
+
+	* src/register/register-gnome/combocell-gnome.c:
+	* src/register/register-gnome/gnucash-item-list.[ch]:
+	* src/register/ledger-core/split-register-load.c:
+	* src/register/register-core/combocell.h: Load the entire data set
+	into the combocell before enabling sorting.  Saves a tremendous
+	amount of time.
+	
+	* src/backend/file/gnc-transaction-xml-v2.c:
+	* lib/libqof/qof/gnc-numeric.c: A couple of performance tweaks.
+
 2006-01-03  Joshua Sled  <jsled at asynchronous.org>
 
 	* gnc-sxed-window-ui.xml: Remove unreferenced `TransactionAction`.

Modified: gnucash/trunk/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-load.c	2006-01-05 03:44:11 UTC (rev 12263)
+++ gnucash/trunk/src/register/ledger-core/split-register-load.c	2006-01-05 05:18:52 UTC (rev 12264)
@@ -587,15 +587,19 @@
 
   cell = (ComboCell *)
     gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL);
+  gnc_combo_cell_set_sort_enabled (cell, FALSE);
   gnc_combo_cell_clear_menu (cell);
   gnc_combo_cell_use_quickfill_cache (cell, qf);
   xaccGroupForEachAccount (group, load_xfer_cell_cb, cell, TRUE);
+  gnc_combo_cell_set_sort_enabled (cell, TRUE);
 
   cell = (ComboCell *)
     gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL);
+  gnc_combo_cell_set_sort_enabled (cell, FALSE);
   gnc_combo_cell_clear_menu (cell);
   gnc_combo_cell_use_quickfill_cache (cell, qf);
   xaccGroupForEachAccount (group, load_xfer_cell_cb, cell, TRUE);
+  gnc_combo_cell_set_sort_enabled (cell, TRUE);
 }
 
 /* ====================== END OF FILE ================================== */

Modified: gnucash/trunk/src/register/register-core/combocell.h
===================================================================
--- gnucash/trunk/src/register/register-core/combocell.h	2006-01-05 03:44:11 UTC (rev 12263)
+++ gnucash/trunk/src/register/register-core/combocell.h	2006-01-05 05:18:52 UTC (rev 12264)
@@ -64,6 +64,10 @@
  *  ignore the characters normally used to separate account names. */
 void         gnc_combo_cell_add_account_menu_item (ComboCell *cell, char * menustr);
 
+/** Enable sorting of the menu item's contents. Loading the item is
+ *  much faster with sorting disabled. */
+void         gnc_combo_cell_set_sort_enabled (ComboCell *cell, gboolean enabled);
+
 /** Determines whether the cell will accept strings not in the
  * menu. Defaults to strict, i.e., only menu items are accepted. */
 void         gnc_combo_cell_set_strict (ComboCell *cell, gboolean strict);

Modified: gnucash/trunk/src/register/register-gnome/combocell-gnome.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/combocell-gnome.c	2006-01-05 03:44:11 UTC (rev 12263)
+++ gnucash/trunk/src/register/register-gnome/combocell-gnome.c	2006-01-05 05:18:52 UTC (rev 12264)
@@ -350,6 +350,23 @@
 	cell->cell.gui_realize = NULL;
 }
 
+void 
+gnc_combo_cell_set_sort_enabled (ComboCell *cell, gboolean enabled)
+{ 
+	PopBox *box;
+
+	if (cell == NULL)
+		return;
+
+	box = cell->cell.gui_private;
+	if (box->item_list == NULL)
+		return;
+
+	block_list_signals (cell);
+	gnc_item_list_set_sort_enabled(box->item_list, enabled);
+	unblock_list_signals (cell);
+}
+
 void
 gnc_combo_cell_clear_menu (ComboCell * cell)
 {

Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-list.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-list.c	2006-01-05 03:44:11 UTC (rev 12263)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-list.c	2006-01-05 05:18:52 UTC (rev 12264)
@@ -82,6 +82,24 @@
 }
 
 
+void
+gnc_item_list_set_sort_enabled(GncItemList *item_list, gboolean enabled)
+{
+	printf("%s: item_list %p, sort enabled %d\n", __FUNCTION__, item_list, enabled);
+	if (enabled) {
+		gtk_tree_sortable_set_sort_column_id
+			(GTK_TREE_SORTABLE (item_list->list_store),
+			 0,
+			 GTK_SORT_ASCENDING);
+	} else {
+		gtk_tree_sortable_set_sort_column_id
+			(GTK_TREE_SORTABLE (item_list->list_store),
+			 GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
+			 GTK_SORT_ASCENDING);
+	}
+}
+
+
 typedef struct _findSelectionData
 {
         GncItemList *item_list;
@@ -403,9 +421,8 @@
 
 	list_store = gtk_list_store_new (1, G_TYPE_STRING);
 	tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store));
-        gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store),
-                                              0,
-                                              GTK_SORT_ASCENDING);
+	/* Removed code to enable sorting. Enable it after the list is
+	 * fully populated by calling gnc_item_list_finished_loading(). */
  
 	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
 	gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),

Modified: gnucash/trunk/src/register/register-gnome/gnucash-item-list.h
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-item-list.h	2006-01-05 03:44:11 UTC (rev 12263)
+++ gnucash/trunk/src/register/register-gnome/gnucash-item-list.h	2006-01-05 05:18:52 UTC (rev 12264)
@@ -65,6 +65,8 @@
 
 void gnc_item_list_append (GncItemList *item_list, char *string);
 
+void gnc_item_list_set_sort_enabled(GncItemList *item_list, gboolean enabled);
+
 void gnc_item_list_select (GncItemList *item_list, const char *string);
 
 void gnc_item_list_show_selected (GncItemList *item_list);



More information about the gnucash-changes mailing list