When using "Jump" with more than two splits, expand the transaction

If there are more than two splits it may not be obvious why a transaction
has been selected in the basic register mode, so expand the transaction to
show the split that's in this register and also to indicate which split was
followed to reach this transaction.
This commit is contained in:
Simon Arlott 2025-01-31 20:50:41 +00:00
parent bdf7c36d7d
commit c23d8cdf5b
No known key found for this signature in database
GPG Key ID: E36B823BEE9CBBE0

View File

@ -4985,6 +4985,8 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
Account* account; Account* account;
Account* leader; Account* leader;
Split* split; Split* split;
Split* other_split;
gboolean multiple_splits;
ENTER ("(action %p, page %p)", simple, page); ENTER ("(action %p, page %p)", simple, page);
@ -5013,6 +5015,9 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
return; return;
} }
other_split = xaccSplitGetOtherSplit (split);
multiple_splits = other_split == NULL;
leader = gnc_ledger_display_leader (priv->ledger); leader = gnc_ledger_display_leader (priv->ledger);
if (account == leader) if (account == leader)
{ {
@ -5040,8 +5045,7 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
return; return;
} }
Split* other_split = xaccSplitGetOtherSplit (split); if (multiple_splits)
if (other_split == NULL)
{ {
other_split = jump_multiple_splits (account, split); other_split = jump_multiple_splits (account, split);
} }
@ -5105,11 +5109,30 @@ gnc_plugin_page_register_cmd_jump (GSimpleAction *simple,
gnc_main_window_open_page (GNC_MAIN_WINDOW (window), new_page); gnc_main_window_open_page (GNC_MAIN_WINDOW (window), new_page);
gsr = gnc_plugin_page_register_get_gsr (new_page); gsr = gnc_plugin_page_register_get_gsr (new_page);
SplitRegister *new_page_reg = gnc_ledger_display_get_split_register (gsr->ledger);
gboolean jump_twice = FALSE;
/* Selecting the split (instead of just the transaction to open the "other"
* account) requires jumping a second time after expanding the transaction,
* in the basic and auto ledger modes.
*/
if (new_page_reg->style != REG_STYLE_JOURNAL)
jump_twice = TRUE;
/* Test for visibility of split */ /* Test for visibility of split */
if (gnc_split_reg_clear_filter_for_split (gsr, split)) if (gnc_split_reg_clear_filter_for_split (gsr, split))
gnc_plugin_page_register_clear_current_filter (GNC_PLUGIN_PAGE(new_page)); gnc_plugin_page_register_clear_current_filter (GNC_PLUGIN_PAGE(new_page));
gnc_split_reg_jump_to_split (gsr, split); gnc_split_reg_jump_to_split (gsr, split);
if (multiple_splits && jump_twice)
{
/* Expand the transaction for the basic and auto ledger to identify the
* split in this register, but only if there are more than two splits.
*/
gnc_split_register_expand_current_trans (new_page_reg, TRUE);
gnc_split_reg_jump_to_split (gsr, split);
}
LEAVE (" "); LEAVE (" ");
} }