Convert xaccTransGetSplit() and xaccTransCountSplits() to return the

index and count reflective of any in-progress edit.
   Convert some split iterators from directly using the GList of Splits to 
   using xaccTransGetSplit().


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13487 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker
2006-03-05 04:14:38 +00:00
parent 35a8b15f41
commit 84bcf5685b
6 changed files with 53 additions and 50 deletions

View File

@@ -717,8 +717,7 @@ xaccTransGetAccountConvRate(Transaction *txn, Account *acc)
xaccTransGetCurrency(txn)))
return gnc_numeric_create(1, 1);
splits = xaccTransGetSplitList(txn);
for (; splits; splits = splits->next) {
for (splits = txn->splits; splits; splits = splits->next) {
s = splits->data;
if (!xaccTransStillHasSplit(txn, s))
@@ -763,7 +762,7 @@ xaccTransGetAccountBalance (const Transaction *trans,
// Not really the appropriate error value.
g_return_val_if_fail(account && trans, gnc_numeric_error(GNC_ERROR_ARG));
for (node = xaccTransGetSplitList(trans); node; node = node->next)
for (node = trans->splits; node; node = node->next)
{
Split *split = node->data;
@@ -1442,9 +1441,11 @@ xaccTransSetNotes (Transaction *trans, const char *notes)
Split *
xaccTransGetSplit (const Transaction *trans, int i)
{
if (!trans || i < 0) return NULL;
int j = 0;
if (!trans || i < 0) return NULL;
return g_list_nth_data (trans->splits, i);
FOR_EACH_SPLIT(trans, { if (i == j) return s; j++; });
return NULL;
}
SplitList *
@@ -1456,7 +1457,9 @@ xaccTransGetSplitList (const Transaction *trans)
int
xaccTransCountSplits (const Transaction *trans)
{
return trans ? g_list_length (trans->splits) : 0;
gint i = 0;
FOR_EACH_SPLIT(trans, i++);
return i;
}
const char *