mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Leave the accounts unordered in the engine. Switch the g-wrap
functions that return account lists to use new functions that return sorted lists so that they see no change. Fixes 331855. Also change the default account sorting to sort on utf8 strings. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13624 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
765f18f478
commit
094de8287b
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
||||
2006-03-14 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/gnome-utils/gnc-tree-view-account.c:
|
||||
* src/gnome-utils/gnc-account-sel.c:
|
||||
* src/gnome/druid-stock-split.c:
|
||||
* src/engine/Account.c:
|
||||
* src/engine/gw-engine-spec.scm:
|
||||
* src/engine/Group.[ch]: Leave the accounts unordered in the
|
||||
engine. Switch the g-wrap functions that return account lists to
|
||||
use new functions that return sorted lists so that they see no
|
||||
change. Fixes 331855. Also change the default account sorting to
|
||||
sort on utf8 strings.
|
||||
|
||||
* src/gnome-utils/dialog-account.c: Fix a warning message.
|
||||
|
||||
2006-03-13 Neil Williams <linux@codehelp.co.uk>
|
||||
|
||||
* : Synchronise with external QOF 0.6.3
|
||||
|
@ -335,6 +335,7 @@ static inline void acc_free (QofInstance *inst)
|
||||
void
|
||||
xaccAccountCommitEdit (Account *acc)
|
||||
{
|
||||
g_return_if_fail(acc);
|
||||
if(!qof_commit_edit(&acc->inst)) { return;}
|
||||
|
||||
/* If marked for deletion, get rid of subaccounts first,
|
||||
@ -375,9 +376,6 @@ xaccAccountCommitEdit (Account *acc)
|
||||
else
|
||||
{
|
||||
xaccAccountBringUpToDate(acc);
|
||||
|
||||
/* force re-sort of parent group */
|
||||
xaccGroupInsertAccount(acc->parent, acc);
|
||||
}
|
||||
|
||||
qof_commit_edit_part2(&acc->inst, on_err, on_done, acc_free);
|
||||
@ -1022,7 +1020,15 @@ xaccAccountOrder (const Account **aa, const Account **ab)
|
||||
/* otherwise, sort on accountName strings */
|
||||
da = (*aa)->accountName;
|
||||
db = (*ab)->accountName;
|
||||
SAFE_STRCMP (da, db);
|
||||
if (da && db) {
|
||||
gint result = g_utf8_collate(da, db);
|
||||
if (result)
|
||||
return result;
|
||||
} else if (da) {
|
||||
return -1;
|
||||
} else if (db) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* guarantee a stable sort */
|
||||
return guid_compare (&((*aa)->inst.entity.guid), &((*ab)->inst.entity.guid));
|
||||
|
@ -418,6 +418,50 @@ xaccGroupGetSubAccounts (const AccountGroup *grp)
|
||||
return g_list_reverse (accounts);
|
||||
}
|
||||
|
||||
static int
|
||||
group_sort_helper (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const Account *aa = (const Account *) a;
|
||||
const Account *bb = (const Account *) b;
|
||||
|
||||
/* xaccAccountOrder returns > 1 if aa should come after bb.
|
||||
* This funciton is building a reversed list. */
|
||||
return xaccAccountOrder (&aa, &bb);
|
||||
}
|
||||
|
||||
static void
|
||||
xaccPrependAccountsSorted (const AccountGroup *grp, GList **accounts_p)
|
||||
{
|
||||
GList *node, *tmp_list;
|
||||
|
||||
if (!grp || !accounts_p) return;
|
||||
|
||||
tmp_list = g_list_copy(grp->accounts);
|
||||
tmp_list = g_list_sort(tmp_list, group_sort_helper);
|
||||
|
||||
for (node = tmp_list; node; node = node->next)
|
||||
{
|
||||
Account *account = node->data;
|
||||
|
||||
*accounts_p = g_list_prepend (*accounts_p, account);
|
||||
|
||||
xaccPrependAccountsSorted (account->children, accounts_p);
|
||||
}
|
||||
g_list_free(tmp_list);
|
||||
}
|
||||
|
||||
AccountList *
|
||||
xaccGroupGetSubAccountsSorted (const AccountGroup *grp)
|
||||
{
|
||||
GList *accounts = NULL;
|
||||
|
||||
if (!grp) return NULL;
|
||||
|
||||
xaccPrependAccountsSorted (grp, &accounts);
|
||||
|
||||
return g_list_reverse (accounts);
|
||||
}
|
||||
|
||||
AccountList *
|
||||
xaccGroupGetAccountList (const AccountGroup *grp)
|
||||
{
|
||||
@ -426,6 +470,15 @@ xaccGroupGetAccountList (const AccountGroup *grp)
|
||||
return grp->accounts;
|
||||
}
|
||||
|
||||
GList *
|
||||
xaccGroupGetAccountListSorted (const AccountGroup *grp)
|
||||
{
|
||||
if (!grp) return NULL;
|
||||
|
||||
return g_list_sort(g_list_copy(grp->accounts), group_sort_helper);
|
||||
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* Fetch the root of the tree *
|
||||
\********************************************************************/
|
||||
@ -692,16 +745,6 @@ xaccAccountInsertSubAccount (Account *adult, Account *child)
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
|
||||
static int
|
||||
group_sort_helper (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
const Account *aa = (const Account *) a;
|
||||
const Account *bb = (const Account *) b;
|
||||
|
||||
/* return > 1 if aa should come after bb */
|
||||
return xaccAccountOrder (&aa, &bb);
|
||||
}
|
||||
|
||||
void
|
||||
xaccGroupInsertAccount (AccountGroup *grp, Account *acc)
|
||||
{
|
||||
@ -713,11 +756,7 @@ xaccGroupInsertAccount (AccountGroup *grp, Account *acc)
|
||||
* first. Basically, we can't have accounts being in two places at
|
||||
* once. If old and new parents are the same, reinsertion causes
|
||||
* the sort order to be checked. */
|
||||
if (acc->parent == grp)
|
||||
{
|
||||
grp->accounts = g_list_sort (grp->accounts, group_sort_helper);
|
||||
}
|
||||
else
|
||||
if (acc->parent != grp)
|
||||
{
|
||||
xaccAccountBeginEdit (acc);
|
||||
|
||||
@ -753,8 +792,7 @@ xaccGroupInsertAccount (AccountGroup *grp, Account *acc)
|
||||
/* set back-pointer to the account's parent */
|
||||
acc->parent = grp;
|
||||
|
||||
grp->accounts = g_list_insert_sorted (grp->accounts, acc,
|
||||
group_sort_helper);
|
||||
grp->accounts = g_list_append (grp->accounts, acc);
|
||||
|
||||
/* Gather event data */
|
||||
qof_event_gen (&acc->inst.entity, QOF_EVENT_ADD, NULL);
|
||||
@ -820,8 +858,7 @@ xaccGroupCopyGroup (AccountGroup *to, AccountGroup *from)
|
||||
to_acc = xaccCloneAccount (from_acc, to->book);
|
||||
|
||||
xaccAccountBeginEdit (to_acc);
|
||||
to->accounts = g_list_insert_sorted (to->accounts, to_acc,
|
||||
group_sort_helper);
|
||||
to->accounts = g_list_append (to->accounts, to_acc);
|
||||
|
||||
to_acc->parent = to;
|
||||
to_acc->inst.dirty = TRUE;
|
||||
|
@ -198,12 +198,25 @@ Account * xaccGroupGetAccount (const AccountGroup *group, int index);
|
||||
*/
|
||||
AccountList * xaccGroupGetSubAccounts (const AccountGroup *grp);
|
||||
|
||||
/** The xaccGroupGetSubAccounts() subroutine returns a sorted list of
|
||||
* the accounts, including subaccounts, in the account group. The
|
||||
* returned list should be freed with g_list_free() when no longer
|
||||
* needed.
|
||||
*/
|
||||
AccountList * xaccGroupGetSubAccountsSorted (const AccountGroup *grp);
|
||||
|
||||
/** The xaccGroupGetAccountList() subroutines returns only the immediate
|
||||
* children of the account group. The returned list should *not*
|
||||
* be freed by the caller.
|
||||
*/
|
||||
AccountList * xaccGroupGetAccountList (const AccountGroup *grp);
|
||||
|
||||
/** The xaccGroupGetAccountList() subroutines returns only the
|
||||
* immediate children of the account group. The returned list
|
||||
* should be freed with g_list_free() when no longer needed.
|
||||
*/
|
||||
GList * xaccGroupGetAccountListSorted (const AccountGroup *grp);
|
||||
|
||||
/** The xaccGroupGetRoot() subroutine will find the topmost
|
||||
* (root) group to which this group belongs.
|
||||
*/
|
||||
|
@ -1087,7 +1087,7 @@ group")
|
||||
ws
|
||||
'gnc:group-get-subaccounts
|
||||
'(gw:glist-of <gnc:Account*> caller-owned)
|
||||
"xaccGroupGetSubAccounts"
|
||||
"xaccGroupGetSubAccountsSorted"
|
||||
'((<gnc:AccountGroup*> g))
|
||||
"Return a list containing all of the accounts, including
|
||||
subaccounts, in the account group. The returned array should be freed
|
||||
@ -1096,8 +1096,8 @@ when no longer needed.")
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:group-get-account-list
|
||||
'(gw:glist-of <gnc:Account*> callee-owned)
|
||||
"xaccGroupGetAccountList"
|
||||
'(gw:glist-of <gnc:Account*> caller-owned)
|
||||
"xaccGroupGetAccountListSorted"
|
||||
'((<gnc:AccountGroup*> g))
|
||||
"Return a list containing the immediate children of g.")
|
||||
|
||||
|
@ -195,7 +195,7 @@ gas_populate_list( GNCAccountSel *gas )
|
||||
GTK_EDITABLE(gas->combo->entry), 0, -1 );
|
||||
|
||||
ag = gnc_book_get_group( gnc_get_current_book() );
|
||||
accts = (GList*)xaccGroupGetSubAccounts( ag );
|
||||
accts = (GList*)xaccGroupGetSubAccountsSorted( ag );
|
||||
|
||||
nameList = NULL;
|
||||
atnd.gas = gas;
|
||||
|
@ -615,6 +615,11 @@ gnc_tree_view_account_new_with_group (AccountGroup *group, gboolean show_root)
|
||||
view,
|
||||
NULL);
|
||||
|
||||
/* Default the sorting to account name */
|
||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_NAME,
|
||||
GTK_SORT_ASCENDING);
|
||||
|
||||
gtk_widget_show(GTK_WIDGET(view));
|
||||
LEAVE("%p", view);
|
||||
return GTK_TREE_VIEW(view);
|
||||
|
@ -120,7 +120,7 @@ fill_account_list (StockSplitInfo *info, Account *account)
|
||||
|
||||
gtk_clist_clear (clist);
|
||||
|
||||
accounts = xaccGroupGetSubAccounts (gnc_get_current_group ());
|
||||
accounts = xaccGroupGetSubAccountsSorted (gnc_get_current_group ());
|
||||
for (node = accounts; node; node = node->next)
|
||||
{
|
||||
Account *account = node->data;
|
||||
@ -157,6 +157,7 @@ fill_account_list (StockSplitInfo *info, Account *account)
|
||||
|
||||
rows++;
|
||||
}
|
||||
g_list_free(accounts);
|
||||
|
||||
{
|
||||
gint row = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user