Load the entire data set into the combocell before enabling sorting.

Saves a tremendous amount of time.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12264 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton 2006-01-05 05:18:52 +00:00
parent 9d49e5aa15
commit 03e9431406
6 changed files with 59 additions and 3 deletions

View File

@ -1,3 +1,15 @@
2006-01-04 David Hampton <hampton@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@asynchronous.org> 2006-01-03 Joshua Sled <jsled@asynchronous.org>
* gnc-sxed-window-ui.xml: Remove unreferenced `TransactionAction`. * gnc-sxed-window-ui.xml: Remove unreferenced `TransactionAction`.

View File

@ -587,15 +587,19 @@ gnc_split_register_load_xfer_cells (SplitRegister *reg, Account *base_account)
cell = (ComboCell *) cell = (ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, XFRM_CELL); 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_clear_menu (cell);
gnc_combo_cell_use_quickfill_cache (cell, qf); gnc_combo_cell_use_quickfill_cache (cell, qf);
xaccGroupForEachAccount (group, load_xfer_cell_cb, cell, TRUE); xaccGroupForEachAccount (group, load_xfer_cell_cb, cell, TRUE);
gnc_combo_cell_set_sort_enabled (cell, TRUE);
cell = (ComboCell *) cell = (ComboCell *)
gnc_table_layout_get_cell (reg->table->layout, MXFRM_CELL); 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_clear_menu (cell);
gnc_combo_cell_use_quickfill_cache (cell, qf); gnc_combo_cell_use_quickfill_cache (cell, qf);
xaccGroupForEachAccount (group, load_xfer_cell_cb, cell, TRUE); xaccGroupForEachAccount (group, load_xfer_cell_cb, cell, TRUE);
gnc_combo_cell_set_sort_enabled (cell, TRUE);
} }
/* ====================== END OF FILE ================================== */ /* ====================== END OF FILE ================================== */

View File

@ -64,6 +64,10 @@ void gnc_combo_cell_add_menu_item (ComboCell *cell, char * menustr);
* ignore the characters normally used to separate account names. */ * ignore the characters normally used to separate account names. */
void gnc_combo_cell_add_account_menu_item (ComboCell *cell, char * menustr); 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 /** Determines whether the cell will accept strings not in the
* menu. Defaults to strict, i.e., only menu items are accepted. */ * menu. Defaults to strict, i.e., only menu items are accepted. */
void gnc_combo_cell_set_strict (ComboCell *cell, gboolean strict); void gnc_combo_cell_set_strict (ComboCell *cell, gboolean strict);

View File

@ -350,6 +350,23 @@ gnc_combo_cell_destroy (BasicCell *bcell)
cell->cell.gui_realize = NULL; 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 void
gnc_combo_cell_clear_menu (ComboCell * cell) gnc_combo_cell_clear_menu (ComboCell * cell)
{ {

View File

@ -82,6 +82,24 @@ gnc_item_list_append (GncItemList *item_list, char *string)
} }
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 typedef struct _findSelectionData
{ {
GncItemList *item_list; GncItemList *item_list;
@ -403,9 +421,8 @@ gnc_item_list_new(GnomeCanvasGroup *parent)
list_store = gtk_list_store_new (1, G_TYPE_STRING); list_store = gtk_list_store_new (1, G_TYPE_STRING);
tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store)); 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), /* Removed code to enable sorting. Enable it after the list is
0, * fully populated by calling gnc_item_list_finished_loading(). */
GTK_SORT_ASCENDING);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); 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)), gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),

View File

@ -65,6 +65,8 @@ void gnc_item_list_clear (GncItemList *item_list);
void gnc_item_list_append (GncItemList *item_list, char *string); 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_select (GncItemList *item_list, const char *string);
void gnc_item_list_show_selected (GncItemList *item_list); void gnc_item_list_show_selected (GncItemList *item_list);