Bug 799047 - AutoComplete Only Considers Visible Transactions

In the past, all transactions were used on the first load of the
register and this is when the autocomplete would be populated, on
subsequent loads it would be a filtered list. With the change to delay
loading, the first load is empty and the autocomplete is now being
populated by the filtered list.

To fix this, make a copy of the original query and compare this query
to the query used for refresh. When different, pass a second list of
splits to the register to populate the autocomplete lists.
This commit is contained in:
Robert Fewell
2024-06-17 13:36:54 +01:00
parent 0f89f88293
commit 0de4ce1106
4 changed files with 55 additions and 11 deletions

View File

@@ -1509,7 +1509,7 @@ schedXact_editor_populate (GncSxEditorDialog *sxed)
if (splitList)
{
splitReg = gnc_ledger_display_get_split_register (sxed->ledger);
gnc_split_register_load (splitReg, splitList, NULL);
gnc_split_register_load (splitReg, splitList, NULL, NULL);
} /* otherwise, use the existing stuff. */
g_list_free (splitList);
}

View File

@@ -59,6 +59,7 @@ struct gnc_ledger_display
GncGUID leader;
Query* query;
Query* pre_filter_query;
GNCLedgerDisplayType ld_type;
@@ -655,6 +656,9 @@ close_handler (gpointer user_data)
qof_query_destroy (ld->query);
ld->query = NULL;
qof_query_destroy (ld->pre_filter_query);
ld->pre_filter_query = NULL;
g_free (ld);
}
@@ -834,6 +838,8 @@ gnc_ledger_display_internal (Account* lead_account, Query* q,
else
gnc_ledger_display_make_query (ld, limit, reg_type);
ld->pre_filter_query = qof_query_copy (ld->query);
ld->component_id = gnc_register_gui_component (klass,
refresh_handler,
close_handler, ld);
@@ -854,7 +860,7 @@ gnc_ledger_display_internal (Account* lead_account, Query* q,
* the query when we're not in focus yet.
*/
ld->loading = TRUE;
gnc_split_register_load (ld->reg, NULL, gnc_ledger_display_leader (ld));
gnc_split_register_load (ld->reg, NULL, NULL, gnc_ledger_display_leader (ld));
ld->loading = FALSE;
return ld;
}
@@ -888,6 +894,7 @@ static void
gnc_ledger_display_refresh_internal (GNCLedgerDisplay* ld)
{
GList* splits;
GList* pre_filter_splits = NULL;
if (ld->loading)
return;
@@ -899,6 +906,9 @@ gnc_ledger_display_refresh_internal (GNCLedgerDisplay* ld)
*/
splits = qof_query_run (ld->query);
if (!qof_query_equal (ld->query, ld->pre_filter_query))
pre_filter_splits = qof_query_run (ld->pre_filter_query);
gnc_ledger_display_set_watches (ld, splits);
if (!gnc_split_register_full_refresh_ok (ld->reg))
@@ -906,7 +916,7 @@ gnc_ledger_display_refresh_internal (GNCLedgerDisplay* ld)
ld->loading = TRUE;
gnc_split_register_load (ld->reg, splits,
gnc_split_register_load (ld->reg, splits, pre_filter_splits,
gnc_ledger_display_leader (ld));
ld->needs_refresh = FALSE;

View File

@@ -256,7 +256,8 @@ _find_split_with_parent_txn (gconstpointer a, gconstpointer b)
return xaccSplitGetParent (split) == txn ? 0 : 1;
}
static void add_quickfill_completions (TableLayout* layout, Transaction* trans,
static void
add_quickfill_completions (TableLayout* layout, Transaction* trans,
Split* split, gboolean has_last_num)
{
gnc_quickfill_cell_add_completion (
@@ -365,9 +366,30 @@ update_info (SRInfo* info, SplitRegister* reg)
info->reg_loaded = TRUE;
}
static void
add_completions_from_pre_filter_slist (TableLayout* layout, GList *pre_filter_slist,
gboolean first_pass, gboolean quickfill_setup,
gboolean has_last_num)
{
GList *node;
for (node = pre_filter_slist; node; node = node->next)
{
Split *split = node->data;
Transaction *trans = xaccSplitGetParent (split);
gnc_completion_cell_add_menu_item (
(CompletionCell*) gnc_table_layout_get_cell (layout, DESC_CELL),
xaccTransGetDescription (trans));
if (!first_pass && !quickfill_setup)
add_quickfill_completions (layout, trans, split, has_last_num);
}
}
void
gnc_split_register_load (SplitRegister* reg, GList* slist,
Account* default_account)
GList* pre_filter_slist, Account* default_account)
{
SRInfo* info;
Transaction* pending_trans;
@@ -635,6 +657,13 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
(CompletionCell*) gnc_table_layout_get_cell (reg->table->layout, DESC_CELL),
table->model->reverse_sort);
if (!info->first_pass && pre_filter_slist)
{
add_completions_from_pre_filter_slist (reg->table->layout, pre_filter_slist,
info->first_pass, info->quickfill_setup,
has_last_num);
}
/* populate the table */
for (node = slist; node; node = node->next)
{
@@ -752,12 +781,15 @@ gnc_split_register_load (SplitRegister* reg, GList* slist,
/* On first load the split list is empty so fill up the quickfill cells
* only on the next load. */
if (!info->first_pass && !info->quickfill_setup)
if (!info->first_pass && !pre_filter_slist && !info->quickfill_setup)
add_quickfill_completions (reg->table->layout, trans, split, has_last_num);
if (!info->first_pass && !pre_filter_slist)
{
gnc_completion_cell_add_menu_item (
(CompletionCell*) gnc_table_layout_get_cell (reg->table->layout, DESC_CELL),
xaccTransGetDescription (trans));
}
if (trans == find_trans)
new_trans_row = vcell_loc.virt_row;

View File

@@ -530,10 +530,12 @@ void gnc_split_register_cancel_cursor_trans_changes (SplitRegister* reg);
*
* @param slist a list of splits
*
* @param pre_filter_slist the list of splits before applying filter
*
* @param default_account an account to provide defaults for the blank split
*/
void gnc_split_register_load (SplitRegister* reg, GList* slist,
Account* default_account);
GList* pre_filter_slist, Account* default_account);
/** Copy the contents of the current cursor to a split. The split and
* transaction that are updated are the ones associated with the