add handling for the "blank split"

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@732 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-03-25 09:27:25 +00:00
parent 0235cba2e3
commit 9a3fb5a691

View File

@ -38,16 +38,38 @@
/* ======================================================== */ /* ======================================================== */
static void static void
LedgerMoveCursor (struct _Table *_table, void * client_data) LedgerMoveCursor (Table *table, void * client_data)
{ {
/* Table * table = (Table *)_table; */
BasicRegister *reg = (BasicRegister *) client_data; BasicRegister *reg = (BasicRegister *) client_data;
xaccSaveRegEntry (reg); xaccSaveRegEntry (reg);
} }
/* ======================================================== */ /* ======================================================== */
Split * xaccGetCurrentSplit (BasicRegister *reg) static void
LedgerDestroy (BasicRegister *reg)
{
/* be sure to destroy the "blank split" */
if (reg->user_hook) {
Split *split;
Transaction * trans;
Account * acc;
split = (Split *) (reg->user_hook);
acc = xaccSplitGetAccount (split);
xaccAccountRemoveSplit (acc, split);
trans = xaccSplitGetParent (split);
xaccFreeTransaction (trans);
reg->user_hook = NULL;
}
}
/* ======================================================== */
Split *
xaccGetCurrentSplit (BasicRegister *reg)
{ {
CellBlock *cursor; CellBlock *cursor;
Split *split; Split *split;
@ -154,8 +176,18 @@ xaccSaveRegEntry (BasicRegister *reg)
} }
printf ("finished saving %s \n", xaccTransGetDescription(trans)); printf ("finished saving %s \n", xaccTransGetDescription(trans));
/* refresh the register windows *only* if something changed */
if (changed) { if (changed) {
/* if the modified split is the "blank split",
* then it is now an official part of the account.
* Set user_hook to null, so that we can be sure of
* getting a new split.
*/
if (split == ((Split *) (reg->user_hook))) {
reg->user_hook = NULL;
}
/* refresh the register windows *only* if something changed */
acc = xaccSplitGetAccount (split); acc = xaccSplitGetAccount (split);
accRefresh (acc); accRefresh (acc);
} }
@ -273,10 +305,16 @@ printf ("load reg of %d entries --------------------------- \n",i);
} }
/* add the "blank split" at the end */ /* add the "blank split" at the end */
trans = xaccMallocTransaction (); if (reg->user_hook) {
xaccTransSetDateToday (trans); split = (Split *) (reg->user_hook);
split = xaccTransGetSourceSplit (trans); } else {
xaccAccountInsertSplit (default_source_acc, split); trans = xaccMallocTransaction ();
xaccTransSetDateToday (trans);
split = xaccTransGetSourceSplit (trans);
xaccAccountInsertSplit (default_source_acc, split);
reg->user_hook = (void *) split;
reg->destroy = LedgerDestroy;
}
phys_row = reg->header->numRows; phys_row = reg->header->numRows;
phys_row += i * (reg->cursor->numRows); phys_row += i * (reg->cursor->numRows);