change name of account group subroutine

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2333 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 2000-05-15 22:11:19 +00:00
parent 2590d21bcc
commit 3927fe149b
8 changed files with 120 additions and 21 deletions

View File

@ -171,7 +171,7 @@ gncFileQuerySave (void)
* up the file-selection dialog, we don't blow em out of the water;
* instead, give them another chance to say "no" to the verify box.
*/
while ( xaccAccountGroupNotSaved (grp) )
while ( xaccGroupNotSaved (grp) )
{
GNCVerifyResult result;
@ -383,7 +383,7 @@ gncFileSave (void)
/* going down -- abandon ship */
if (uh_oh) return;
xaccAccountGroupMarkSaved (topgroup);
xaccGroupMarkSaved (topgroup);
}
/* ======================================================== */

View File

@ -100,6 +100,7 @@ xaccInitAccount (Account * acc)
acc->changed = 0;
acc->open = 0;
acc->mark = 0;
}
/********************************************************************\
@ -193,6 +194,7 @@ xaccFreeAccount( Account *acc )
acc->changed = 0;
acc->open = 0;
acc->mark = 0;
_free(acc);
}
@ -269,6 +271,68 @@ xaccGetAccountFlags (Account *acc)
return acc->flags;
}
/********************************************************************\
\********************************************************************/
short
xaccAccountGetMark (Account *acc)
{
if (!acc) return 0;
return acc->mark;
}
void
xaccAccountSetMark (Account *acc, short m)
{
if (!acc) return;
acc->mark = m;
}
void
xaccClearMark (Account *acc, short val)
{
AccountGroup *topgrp;
if (!acc) return;
topgrp = xaccGetAccountRoot (acc);
if (topgrp) {
int i, nacc = topgrp->numAcc;
for (i=0; i<nacc; i++) {
xaccClearMarkDown (topgrp->account[i], val);
}
} else {
xaccClearMarkDown (acc, val);
}
}
void
xaccClearMarkDown (Account *acc, short val)
{
AccountGroup *chillin;
if (!acc) return;
acc->mark = val;
chillin = acc->children;
if (chillin) {
int i, nacc = chillin->numAcc;
for (i=0; i<nacc; i++) {
xaccClearMarkDown (chillin->account[i], val);
}
}
}
void
xaccClearMarkDownGr (AccountGroup *grp, short val)
{
int i, nacc;
if (!grp) return;
nacc = grp->numAcc;
for (i=0; i<nacc; i++) {
xaccClearMarkDown (grp->account[i], val);
}
}
/********************************************************************\
\********************************************************************/

View File

@ -64,6 +64,11 @@ const GUID * xaccAccountGetGUID (Account *account);
Account * xaccAccountLookup (const GUID *guid);
int xaccGetAccountID (Account *);
/* AccountFlags is currently not used for anything.
* If you need to add a bitflag, this may not be a bad
* way to go. This flag *is* stored in the file-file DB.
*/
char xaccGetAccountFlags (Account *);
/*
@ -182,4 +187,21 @@ gncBoolean xaccAccountsHaveCommonCurrency(Account *account_1,
* Returns false if either is NULL. */
gncBoolean xaccAccountHasAncestor (Account *, Account * ancestor);
/* Get and Set a mark on the account. The meaning of this mark is
* completely undefined. Its presented here as a utility for the
* programmer, to use as desired. Handy for performing customer traversals
* over the account tree. The mark is *not* stored in the database/file
* format. When accounts are newly created, the mark is set to zero.
*
* The xaccClearMark will find the topmost group, and clear the mark in
* the entire group tree.
* The xaccClearMarkDown will clear the mark inly in this and in
* sub-accounts.
*/
short xaccAccountGetMark (Account *acc);
void xaccAccountSetMark (Account *acc, short mark);
void xaccClearMark (Account *, short val);
void xaccClearMarkDown (Account *, short val);
void xaccClearMarkDownGr (AccountGroup *, short val);
#endif /* __XACC_ACCOUNT_H__ */

View File

@ -117,6 +117,10 @@ struct _account {
* various housekeeping operations by the engine.
*/
int id; /* unique account id, internally assigned */
/* the 'flags' field is currently unused. If you need some
* persistant flags, this is it. It *is* stored in the flat-file DB.
*/
char flags;
/* protected data, cached parameters */
@ -132,13 +136,18 @@ struct _account {
Split **splits; /* ptr to array of ptrs to splits */
/* The "changed" flag is used to invalidate cached values in this structure.
* currently, the balances and the cost basis are cached.
* Currently, the balances and the cost basis are cached.
*/
short changed;
/* the "open" flag indicates if the account has been
/* The "open" flag indicates if the account has been
* opened for editing. */
short open;
/* The "mark" flag can be used by the user to mark this account
* in any way desired. Handy for specialty traversals of the
* account tree. */
short mark;
};
/* bitfields for the changed flag */

View File

@ -350,7 +350,7 @@ xaccReadAccountGroup( int fd )
/* mark the newly read group as saved, since the act of putting
* it together will have caused it to be marked up as not-saved.
*/
xaccAccountGroupMarkSaved (grp);
xaccGroupMarkSaved (grp);
/* auto-number the accounts, if they are not already numbered */
xaccGroupDepthAutoCode (grp);

View File

@ -112,7 +112,7 @@ xaccFreeAccountGroup( AccountGroup *grp )
\********************************************************************/
void
xaccAccountGroupMarkSaved (AccountGroup *grp)
xaccGroupMarkSaved (AccountGroup *grp)
{
int i;
@ -120,7 +120,7 @@ xaccAccountGroupMarkSaved (AccountGroup *grp)
grp->saved = GNC_T;
for (i=0; i<grp->numAcc; i++) {
xaccAccountGroupMarkSaved (grp->account[i]->children);
xaccGroupMarkSaved (grp->account[i]->children);
}
}
@ -128,7 +128,7 @@ xaccAccountGroupMarkSaved (AccountGroup *grp)
\********************************************************************/
void
xaccAccountGroupMarkNotSaved (AccountGroup *grp)
xaccGroupMarkNotSaved (AccountGroup *grp)
{
if (!grp) return;
grp->saved = GNC_F;
@ -136,8 +136,9 @@ xaccAccountGroupMarkNotSaved (AccountGroup *grp)
/********************************************************************\
\********************************************************************/
int
xaccAccountGroupNotSaved (AccountGroup *grp)
xaccGroupNotSaved (AccountGroup *grp)
{
int not_saved;
int i;
@ -146,7 +147,7 @@ xaccAccountGroupNotSaved (AccountGroup *grp)
if (GNC_F == grp->saved) return 1;
for (i=0; i<grp->numAcc; i++) {
not_saved = xaccAccountGroupNotSaved (grp->account[i]->children);
not_saved = xaccGroupNotSaved (grp->account[i]->children);
if (not_saved) return 1;
}
return 0;
@ -154,6 +155,7 @@ xaccAccountGroupNotSaved (AccountGroup *grp)
/********************************************************************\
\********************************************************************/
const GUID *
xaccGroupGetGUID (AccountGroup *group)
{
@ -165,7 +167,9 @@ xaccGroupGetGUID (AccountGroup *group)
/********************************************************************\
\********************************************************************/
void xaccGroupSetGUID (AccountGroup *group, GUID *guid)
void
xaccGroupSetGUID (AccountGroup *group, GUID *guid)
{
if (!group || !guid) return;

View File

@ -59,20 +59,20 @@ void xaccConcatGroups (AccountGroup *to, AccountGroup *from);
void xaccMergeAccounts (AccountGroup *grp);
/*
* The xaccAccountGroupNotSaved() subroutine will return
* The xaccGroupNotSaved() subroutine will return
* a non-zero value if any account in the group or in
* any subgroup hasn't been saved.
*
* The xaccAccountGroupMarkSaved() subroutine will mark
* The xaccGroupMarkSaved() subroutine will mark
* the entire group as having been saved, including
* all of the child accounts.
*
* The xaccAccountGroupMarkNotSaved() subroutine will mark
* The xaccGroupMarkNotSaved() subroutine will mark
* the given group as not having been saved.
*/
int xaccAccountGroupNotSaved (AccountGroup *grp);
void xaccAccountGroupMarkSaved (AccountGroup *grp);
void xaccAccountGroupMarkNotSaved (AccountGroup *grp);
int xaccGroupNotSaved (AccountGroup *grp);
void xaccGroupMarkSaved (AccountGroup *grp);
void xaccGroupMarkNotSaved (AccountGroup *grp);
/*
* The xaccRemoveAccount() subroutine will remove the indicated

View File

@ -243,10 +243,10 @@ xaccConfigGetForceDoubleEntry (void)
/********************************************************************\
\********************************************************************/
#define MARK_SPLIT(split) { \
Account *acc = (Account *) ((split)->acc); \
if (acc) acc->changed |= ACC_INVALIDATE_ALL; \
if (acc) xaccAccountGroupMarkNotSaved(acc->parent); \
#define MARK_SPLIT(split) { \
Account *acc = (Account *) ((split)->acc); \
if (acc) acc->changed |= ACC_INVALIDATE_ALL; \
if (acc) xaccGroupMarkNotSaved(acc->parent); \
}
static void