mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge Bob Fewell's 'cutpaste' into stable.
This commit is contained in:
commit
e4d2443cf4
@ -71,11 +71,12 @@ typedef struct
|
||||
FloatingSplit *fs;
|
||||
FloatingTxn *ft;
|
||||
};
|
||||
CursorClass cursor_class;
|
||||
GncGUID leader_guid;
|
||||
gint anchor_split_index;
|
||||
} ft_fs_store;
|
||||
|
||||
static ft_fs_store copied_item = { 0, { NULL } };
|
||||
static CursorClass copied_class = CURSOR_CLASS_NONE;
|
||||
static GncGUID copied_leader_guid;
|
||||
|
||||
/** static prototypes *****************************************************/
|
||||
|
||||
@ -98,8 +99,10 @@ clear_copied_item()
|
||||
gnc_float_txn_free (copied_item.ft);
|
||||
copied_item.ftype = 0;
|
||||
copied_item.fs = NULL;
|
||||
copied_class = CURSOR_CLASS_NONE;
|
||||
copied_leader_guid = *guid_null();
|
||||
copied_item.ft = NULL;
|
||||
copied_item.cursor_class = CURSOR_CLASS_NONE;
|
||||
copied_item.leader_guid = *guid_null();
|
||||
copied_item.anchor_split_index = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -785,6 +788,9 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
|
||||
return;
|
||||
}
|
||||
|
||||
/* unprotect the old object, if any */
|
||||
clear_copied_item();
|
||||
|
||||
/* Ok, we are now ready to make the copy. */
|
||||
|
||||
if (cursor_class == CURSOR_CLASS_SPLIT)
|
||||
@ -798,7 +804,7 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
|
||||
gnc_split_register_save_to_copy_buffer (reg, NULL, new_fs,
|
||||
use_cut_semantics);
|
||||
|
||||
copied_leader_guid = *guid_null ();
|
||||
copied_item.leader_guid = *guid_null ();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -823,7 +829,8 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
|
||||
use_cut_semantics);
|
||||
}
|
||||
|
||||
copied_leader_guid = info->default_account;
|
||||
copied_item.leader_guid = info->default_account;
|
||||
copied_item.anchor_split_index = xaccTransGetSplitIndex (trans, split);
|
||||
}
|
||||
}
|
||||
|
||||
@ -834,9 +841,6 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
|
||||
return;
|
||||
}
|
||||
|
||||
/* unprotect the old object, if any */
|
||||
clear_copied_item();
|
||||
|
||||
if (new_fs)
|
||||
{
|
||||
copied_item.fs = new_fs;
|
||||
@ -848,7 +852,7 @@ gnc_split_register_copy_current_internal (SplitRegister* reg,
|
||||
copied_item.ftype = GNC_TYPE_TRANSACTION;
|
||||
}
|
||||
|
||||
copied_class = cursor_class;
|
||||
copied_item.cursor_class = cursor_class;
|
||||
gnc_hook_add_dangler (HOOK_BOOK_CLOSED, clear_copied_item, NULL, NULL);
|
||||
LEAVE ("%s %s", use_cut_semantics ? "cut" : "copied",
|
||||
cursor_class == CURSOR_CLASS_SPLIT ? "split" : "transaction");
|
||||
@ -916,7 +920,7 @@ gnc_split_register_paste_current (SplitRegister* reg)
|
||||
|
||||
ENTER ("reg=%p", reg);
|
||||
|
||||
if (copied_class == CURSOR_CLASS_NONE)
|
||||
if (copied_item.cursor_class == CURSOR_CLASS_NONE)
|
||||
{
|
||||
LEAVE ("no copied cursor class");
|
||||
return;
|
||||
@ -964,7 +968,7 @@ gnc_split_register_paste_current (SplitRegister* reg)
|
||||
"you navigate to a register that shows another "
|
||||
"side of this same transaction.");
|
||||
|
||||
if (copied_class == CURSOR_CLASS_TRANS)
|
||||
if (copied_item.cursor_class == CURSOR_CLASS_TRANS)
|
||||
{
|
||||
/* An entire transaction was copied, but we're just on a split. */
|
||||
LEAVE ("can't copy trans to split");
|
||||
@ -1025,7 +1029,7 @@ gnc_split_register_paste_current (SplitRegister* reg)
|
||||
int split_index;
|
||||
int num_splits;
|
||||
|
||||
if (copied_class == CURSOR_CLASS_SPLIT)
|
||||
if (copied_item.cursor_class == CURSOR_CLASS_SPLIT)
|
||||
{
|
||||
LEAVE ("can't copy split to transaction");
|
||||
return;
|
||||
@ -1062,7 +1066,7 @@ gnc_split_register_paste_current (SplitRegister* reg)
|
||||
split_index = xaccTransGetSplitIndex (trans, split);
|
||||
trans_split_index = xaccTransGetSplitIndex (trans, trans_split);
|
||||
|
||||
copied_leader = xaccAccountLookup (&copied_leader_guid,
|
||||
copied_leader = xaccAccountLookup (&copied_item.leader_guid,
|
||||
gnc_get_current_book ());
|
||||
default_account = gnc_split_register_get_default_account (reg);
|
||||
if (copied_leader && default_account)
|
||||
@ -1081,7 +1085,11 @@ gnc_split_register_paste_current (SplitRegister* reg)
|
||||
if (trans == blank_trans)
|
||||
{
|
||||
/* In pasting, the blank split is deleted. Pick a new one. */
|
||||
blank_split = xaccTransGetSplit (trans, 0);
|
||||
gint anchor_split_index = copied_item.anchor_split_index;
|
||||
if (anchor_split_index > num_splits)
|
||||
anchor_split_index = 0;
|
||||
|
||||
blank_split = xaccTransGetSplit (trans, anchor_split_index);
|
||||
info->blank_split_guid = *xaccSplitGetGUID (blank_split);
|
||||
info->blank_split_edited = TRUE;
|
||||
info->auto_complete = FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user