diff --git a/src/SplitLedger.c b/src/SplitLedger.c index acb6baaa2e..b1a5259159 100644 --- a/src/SplitLedger.c +++ b/src/SplitLedger.c @@ -338,23 +338,39 @@ printf ("save split is %p \n", split); * display, we just reparent the indicated split, its it, * and that's that. For a two-line display, we want to reparent * the "other" split, but only if there is one ... + * XFRM is the straight split, MXFRM is the mirrored split. */ if (MOD_XFRM & changed) { - Account *old_acc=NULL, *new_acc=NULL; Split *split_to_modify = NULL; - if ((REG_MULTI_LINE == style) || - (REG_SINGLE_DYNAMIC == style) || - (REG_DOUBLE_DYNAMIC == style)) - { - split_to_modify = split; - } else { - split_to_modify = xaccGetOtherSplit(split); - } + split_to_modify = split; /* split to modify may be null if its a mutli-split transaction, * and a single-line or two-line display. Then do nothing */ if (split_to_modify) { + Account *old_acc=NULL, *new_acc=NULL; + + /* do some reparenting. Insertion into new account will automatically + * delete from the old account */ + old_acc = xaccSplitGetAccount (split_to_modify); + new_acc = xaccGetAccountByName (trans, reg->xfrmCell->cell.value); + xaccAccountInsertSplit (new_acc, split_to_modify); + + /* make sure any open windows of the old account get redrawn */ + xaccAccountDisplayRefresh (old_acc); + } + } + + if (MOD_MXFRM & changed) { + Split *split_to_modify = NULL; + + split_to_modify = xaccGetOtherSplit(split); + + /* split to modify may be null if its a mutli-split transaction, + * and a single-line or two-line display. Then do nothing */ + if (split_to_modify) { + Account *old_acc=NULL, *new_acc=NULL; + /* do some reparenting. Insertion into new account will automatically * delete from the old account */ old_acc = xaccSplitGetAccount (split_to_modify); @@ -446,6 +462,7 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit) xaccSetComboCellValue (reg->actionCell, ""); xaccSetBasicCellValue (reg->memoCell, ""); xaccSetComboCellValue (reg->xfrmCell, ""); + xaccSetComboCellValue (reg->mxfrmCell, ""); xaccSetDebCredCellValue (reg->debitCell, reg->creditCell, 0.0); xaccSetDebCredCellValue (reg->ndebitCell, @@ -489,21 +506,18 @@ xaccSRLoadTransEntry (SplitRegister *reg, Split *split, int do_commit) * For a multi-line display, show the account for each member split. * For a one or two-line display, show the other account, but only * if there are exactly two splits. + * xfrm is the "straight" display, "mxfrm" is the "mirrored" display. */ - if ((REG_MULTI_LINE == style) || - (REG_SINGLE_DYNAMIC == style) || - (REG_DOUBLE_DYNAMIC == style)) + accname = xaccAccountGetName (xaccSplitGetAccount (split)); + xaccSetComboCellValue (reg->xfrmCell, accname); { - accname = xaccAccountGetName (xaccSplitGetAccount (split)); - xaccSetComboCellValue (reg->xfrmCell, accname); - } else { Split *s = xaccGetOtherSplit (split); if (s) { accname = xaccAccountGetName (xaccSplitGetAccount (s)); } else { accname = SPLIT_STR; } - xaccSetComboCellValue (reg->xfrmCell, accname); + xaccSetComboCellValue (reg->mxfrmCell, accname); } xaccSetBasicCellValue (reg->memoCell, xaccSplitGetMemo (split)); diff --git a/src/register/splitreg.c b/src/register/splitreg.c index cc7c5b8464..6e7ba0345a 100644 --- a/src/register/splitreg.c +++ b/src/register/splitreg.c @@ -60,11 +60,15 @@ #define NCRED_CELL 14 #define NDEBT_CELL 15 +/* MXFRM is the "mirrored" transfer-from account */ +#define MXFRM_CELL 16 + #define DATE_CELL_WIDTH 11 #define NUM_CELL_WIDTH 7 #define ACTN_CELL_WIDTH 7 #define XFRM_CELL_WIDTH 14 +#define MXFRM_CELL_WIDTH 14 #define XTO_CELL_WIDTH 14 #define DESC_CELL_WIDTH 29 #define MEMO_CELL_WIDTH 29 @@ -102,6 +106,7 @@ configLabels (SplitRegister *reg) LABEL (NUM, NUM_STR); LABEL (ACTN, NUM_STR); LABEL (XFRM, XFRM_STR); + LABEL (MXFRM, XFRM_STR); LABEL (XTO, XFTO_STR); LABEL (DESC, DESC_STR); LABEL (MEMO, DESC_STR); @@ -238,7 +243,7 @@ configLayout (SplitRegister *reg) curs = reg->single_cursor; FANCY (DATE, date, 0, 0); BASIC (NUM, num, 1, 0); - FANCY (XFRM, xfrm, 2, 0); + FANCY (MXFRM, mxfrm, 2, 0); FANCY (DESC, desc, 3, 0); BASIC (RECN, recn, 4, 0); FANCY (DEBT, debit, 5, 0); @@ -255,7 +260,7 @@ configLayout (SplitRegister *reg) FANCY (BALN, balance, 7, 0); FANCY (ACTN, action, 1, 1); - FANCY (XFRM, xfrm, 2, 1); + FANCY (MXFRM, mxfrm, 2, 1); BASIC (MEMO, memo, 3, 1); curs = reg->trans_cursor; @@ -282,7 +287,7 @@ configLayout (SplitRegister *reg) curs = reg->single_cursor; FANCY (DATE, date, 0, 0); BASIC (NUM, num, 1, 0); - FANCY (XFRM, xfrm, 2, 0); + FANCY (MXFRM, mxfrm, 2, 0); FANCY (DESC, desc, 3, 0); BASIC (RECN, recn, 4, 0); FANCY (DEBT, debit, 5, 0); @@ -306,7 +311,7 @@ configLayout (SplitRegister *reg) FANCY (BALN, balance, 10, 0); FANCY (ACTN, action, 1, 1); - FANCY (XFRM, xfrm, 2, 1); + FANCY (MXFRM, mxfrm, 2, 1); BASIC (MEMO, memo, 3, 1); /* only the transaction cursor gets used */ @@ -539,6 +544,7 @@ xaccInitSplitRegister (SplitRegister *reg, int type) HDR (NUM); HDR (ACTN); HDR (XFRM); + HDR (MXFRM); HDR (XTO); HDR (DESC); HDR (MEMO); @@ -565,6 +571,7 @@ xaccInitSplitRegister (SplitRegister *reg, int type) NEW (balance, Price); NEW (xfrm, Combo); + NEW (mxfrm, Combo); NEW (xto, Combo); NEW (action, Combo); NEW (memo, Text); @@ -743,6 +750,7 @@ xaccDestroySplitRegister (SplitRegister *reg) xaccDestroyComboCell (reg->actionCell); xaccDestroyComboCell (reg->xfrmCell); + xaccDestroyComboCell (reg->mxfrmCell); xaccDestroyComboCell (reg->xtoCell); xaccDestroyBasicCell (reg->memoCell); xaccDestroyPriceCell (reg->creditCell); @@ -762,6 +770,7 @@ xaccDestroySplitRegister (SplitRegister *reg) reg->actionCell = NULL; reg->xfrmCell = NULL; + reg->mxfrmCell = NULL; reg->xtoCell = NULL; reg->memoCell = NULL; reg->creditCell = NULL; @@ -785,19 +794,20 @@ xaccSplitRegisterGetChangeFlag (SplitRegister *reg) unsigned int changed = 0; /* be careful to use bitwise ands and ors to assemble bit flag */ - changed |= MOD_DATE & reg->dateCell->cell.changed; - changed |= MOD_NUM & reg->numCell->changed; - changed |= MOD_DESC & reg->descCell->cell.changed; - changed |= MOD_RECN & reg->recnCell->changed; + changed |= MOD_DATE & reg->dateCell->cell.changed; + changed |= MOD_NUM & reg->numCell->changed; + changed |= MOD_DESC & reg->descCell->cell.changed; + changed |= MOD_RECN & reg->recnCell->changed; - changed |= MOD_ACTN & reg->actionCell->cell.changed; - changed |= MOD_XFRM & reg->xfrmCell->cell.changed; - changed |= MOD_XTO & reg->xtoCell->cell.changed; - changed |= MOD_MEMO & reg->memoCell->changed; - changed |= MOD_AMNT & reg->creditCell->cell.changed; - changed |= MOD_AMNT & reg->debitCell->cell.changed; - changed |= MOD_PRIC & reg->priceCell->cell.changed; - changed |= MOD_VALU & reg->valueCell->cell.changed; + changed |= MOD_ACTN & reg->actionCell->cell.changed; + changed |= MOD_XFRM & reg->xfrmCell->cell.changed; + changed |= MOD_MXFRM & reg->mxfrmCell->cell.changed; + changed |= MOD_XTO & reg->xtoCell->cell.changed; + changed |= MOD_MEMO & reg->memoCell->changed; + changed |= MOD_AMNT & reg->creditCell->cell.changed; + changed |= MOD_AMNT & reg->debitCell->cell.changed; + changed |= MOD_PRIC & reg->priceCell->cell.changed; + changed |= MOD_VALU & reg->valueCell->cell.changed; changed |= MOD_NAMNT & reg->ncreditCell->cell.changed; changed |= MOD_NAMNT & reg->ndebitCell->cell.changed; diff --git a/src/register/splitreg.h b/src/register/splitreg.h index b745a1b3b8..ca1a4e542c 100644 --- a/src/register/splitreg.h +++ b/src/register/splitreg.h @@ -96,14 +96,15 @@ #define MOD_ACTN 0x0010 #define MOD_XFRM 0x0020 -#define MOD_XTO 0x0040 -#define MOD_MEMO 0x0080 -#define MOD_AMNT 0x0100 -#define MOD_NAMNT 0x0200 -#define MOD_PRIC 0x0400 -#define MOD_VALU 0x0800 -#define MOD_NEW 0x1000 -#define MOD_ALL 0x1fff +#define MOD_MXFRM 0x0040 +#define MOD_XTO 0x0080 +#define MOD_MEMO 0x0100 +#define MOD_AMNT 0x0200 +#define MOD_NAMNT 0x0400 +#define MOD_PRIC 0x0800 +#define MOD_VALU 0x1000 +#define MOD_NEW 0x2000 +#define MOD_ALL 0x3fff /* The value of NUM_CELLS should be larger than the number of * cells defined in the structure below! @@ -133,6 +134,7 @@ struct _SplitRegister { ComboCell * actionCell; ComboCell * xfrmCell; + ComboCell * mxfrmCell; ComboCell * xtoCell; BasicCell * memoCell; PriceCell * creditCell;