mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Implement new-hierarchy-druid placeholder-value merge policy as discussed on -devel.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13297 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3684d8a444
commit
abae418947
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2006-02-19 Joshua Sled <jsled@asynchronous.org>
|
||||
|
||||
* src/app-utils/gnc-account-merge.[ch]: Remove placeholder-difference
|
||||
"ERROR" merge state.
|
||||
|
||||
* src/gnome/druid-hierarchy.c (placeholder_cell_data_func)
|
||||
(on_final_account_prepare): Remove use of default
|
||||
account-tree-model placeholder column, and substitute a column
|
||||
that reflects the post-merge value.
|
||||
|
||||
2006-02-19 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/engine/TransLog.c: use TABS not SPACES for column separators
|
||||
|
@ -12,10 +12,6 @@ determine_account_merge_disposition(Account *existing_acct, Account *new_acct)
|
||||
if (existing_acct == NULL)
|
||||
return GNC_ACCOUNT_MERGE_DISPOSITION_CREATE_NEW;
|
||||
|
||||
if (xaccAccountGetPlaceholder(existing_acct) != xaccAccountGetPlaceholder(new_acct))
|
||||
/* return GNC_ACCOUNT_MERGE_DISPOSITION_ERROR;*/
|
||||
return GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING;
|
||||
|
||||
return GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING;
|
||||
}
|
||||
|
||||
@ -33,40 +29,6 @@ determine_merge_disposition(AccountGroup *existing_root, Account *new_acct)
|
||||
return determine_account_merge_disposition(existing_acct, new_acct);
|
||||
}
|
||||
|
||||
static void
|
||||
_account_merge_error_detection(AccountGroup *existing_grp, AccountGroup *new_grp, GList **error_accum)
|
||||
{
|
||||
AccountList *accts;
|
||||
for (accts = xaccGroupGetAccountList(new_grp); accts; accts = accts->next)
|
||||
{
|
||||
Account *new_acct, *existing_acct;
|
||||
GncAccountMergeDisposition disp;
|
||||
|
||||
new_acct = (Account*)accts->data;
|
||||
existing_acct = xaccGetAccountFromName(existing_grp, xaccAccountGetName(new_acct));
|
||||
disp = determine_account_merge_disposition(existing_acct, new_acct);
|
||||
if (disp == GNC_ACCOUNT_MERGE_DISPOSITION_ERROR)
|
||||
{
|
||||
GncAccountMergeError *err = g_new0(GncAccountMergeError, 1);
|
||||
err->existing_acct = existing_acct;
|
||||
err->new_acct = new_acct;
|
||||
err->disposition = disp;
|
||||
*error_accum = g_list_append(*error_accum, err);
|
||||
}
|
||||
_account_merge_error_detection(xaccAccountGetChildren(existing_acct),
|
||||
xaccAccountGetChildren(new_acct),
|
||||
error_accum);
|
||||
}
|
||||
}
|
||||
|
||||
GList*
|
||||
account_merge_error_detection(AccountGroup *existing_grp, AccountGroup *new_grp)
|
||||
{
|
||||
GList *errors = NULL;
|
||||
_account_merge_error_detection(existing_grp, new_grp, &errors);
|
||||
return errors;
|
||||
}
|
||||
|
||||
void
|
||||
account_group_merge(AccountGroup *existing_grp, AccountGroup *new_grp)
|
||||
{
|
||||
@ -89,9 +51,6 @@ account_group_merge(AccountGroup *existing_grp, AccountGroup *new_grp)
|
||||
existing_named = xaccGetAccountFromName(existing_grp, name);
|
||||
switch (determine_account_merge_disposition(existing_named, new_acct))
|
||||
{
|
||||
case GNC_ACCOUNT_MERGE_DISPOSITION_ERROR:
|
||||
g_assert_not_reached();
|
||||
return;
|
||||
case GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING:
|
||||
/* recurse */
|
||||
account_group_merge(xaccAccountGetChildren(existing_named),
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "Group.h"
|
||||
|
||||
typedef enum {
|
||||
GNC_ACCOUNT_MERGE_DISPOSITION_ERROR,
|
||||
GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING,
|
||||
GNC_ACCOUNT_MERGE_DISPOSITION_CREATE_NEW
|
||||
} GncAccountMergeDisposition;
|
||||
@ -21,9 +20,6 @@ typedef struct _merge_error {
|
||||
GncAccountMergeDisposition determine_account_merge_disposition(Account *existing_acct, Account *new_acct);
|
||||
GncAccountMergeDisposition determine_merge_disposition(AccountGroup *existing_root, Account *new_acct);
|
||||
|
||||
/** @return GList<GncAccountMergeError> **/
|
||||
GList* account_merge_error_detection(AccountGroup *existing_grp, AccountGroup *new_grp);
|
||||
|
||||
void account_group_merge(AccountGroup *existing_grp, AccountGroup *new_grp);
|
||||
|
||||
#endif /* GNC_ACCOUNT_MERGE_H */
|
||||
|
@ -650,6 +650,42 @@ balance_cell_edited (GtkCellRendererText *cell,
|
||||
gnc_engine_gen_event ((QofEntity*)account, GNC_EVENT_MODIFY);
|
||||
}
|
||||
|
||||
static void
|
||||
placeholder_cell_data_func (GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
GtkTreeModel *model,
|
||||
GtkTreeIter *iter,
|
||||
gpointer user_data)
|
||||
{
|
||||
Account *account;
|
||||
gboolean willbe_placeholder = FALSE;
|
||||
GncAccountMergeDisposition disp;
|
||||
|
||||
g_return_if_fail (GTK_TREE_MODEL (model));
|
||||
account = gnc_tree_view_account_get_account_from_iter (model, iter);
|
||||
disp = determine_merge_disposition(gnc_book_get_group(gnc_get_current_book()), account);
|
||||
switch (disp)
|
||||
{
|
||||
case GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING: {
|
||||
/* find the existing account, do whatever it is. */
|
||||
const char sep_char = '.';
|
||||
gchar *full_name;
|
||||
Account *existing_acct;
|
||||
AccountGroup *root_group = gnc_book_get_group(gnc_get_current_book());
|
||||
full_name = xaccAccountGetFullName(account, sep_char);
|
||||
existing_acct = xaccGetAccountFromFullName(root_group, full_name, sep_char);
|
||||
willbe_placeholder = xaccAccountGetPlaceholder(existing_acct);
|
||||
g_free(full_name);
|
||||
} break;
|
||||
case GNC_ACCOUNT_MERGE_DISPOSITION_CREATE_NEW:
|
||||
willbe_placeholder = xaccAccountGetPlaceholder(account);
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_cell_renderer_toggle_set_active(GTK_CELL_RENDERER_TOGGLE(cell), willbe_placeholder);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
use_existing_account_data_func(GtkTreeViewColumn *tree_column,
|
||||
GtkCellRenderer *cell,
|
||||
@ -674,9 +710,6 @@ use_existing_account_data_func(GtkTreeViewColumn *tree_column,
|
||||
disposition = determine_merge_disposition(real_root, new_acct);
|
||||
switch (disposition)
|
||||
{
|
||||
case GNC_ACCOUNT_MERGE_DISPOSITION_ERROR:
|
||||
to_user = "error: placeholders different";
|
||||
break;
|
||||
case GNC_ACCOUNT_MERGE_DISPOSITION_USE_EXISTING:
|
||||
to_user = "yes";
|
||||
break;
|
||||
@ -736,27 +769,47 @@ on_final_account_prepare (GnomeDruidPage *gnomedruidpage,
|
||||
|
||||
gtk_tree_view_set_headers_visible (tree_view, TRUE);
|
||||
gnc_tree_view_configure_columns (GNC_TREE_VIEW(data->final_account_tree),
|
||||
"type", "placeholder", NULL);
|
||||
"type", /*"placeholder", */ NULL);
|
||||
gnc_tree_view_set_show_column_menu (GNC_TREE_VIEW(data->final_account_tree),
|
||||
FALSE);
|
||||
|
||||
selection = gtk_tree_view_get_selection (tree_view);
|
||||
gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_object_set (G_OBJECT (renderer),
|
||||
"xalign", 1.0,
|
||||
(char *)NULL);
|
||||
g_signal_connect (G_OBJECT (renderer), "edited",
|
||||
G_CALLBACK (balance_cell_edited),
|
||||
data);
|
||||
column = gtk_tree_view_column_new_with_attributes (_("Opening Balance"),
|
||||
renderer,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_cell_data_func (column, renderer,
|
||||
balance_cell_data_func,
|
||||
(gpointer)data, NULL);
|
||||
gnc_tree_view_append_column (GNC_TREE_VIEW(tree_view), column);
|
||||
// This is a re-definition of the placeholder that the account-tree model
|
||||
// provides, reflecting the to-be-created state of the account tree
|
||||
// post-merge.
|
||||
{
|
||||
renderer = gtk_cell_renderer_toggle_new();
|
||||
g_object_set(G_OBJECT (renderer),
|
||||
"activatable", FALSE,
|
||||
"sensitive", FALSE,
|
||||
NULL);
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Placeholder"),
|
||||
renderer, NULL);
|
||||
gtk_tree_view_column_set_cell_data_func (column, renderer,
|
||||
placeholder_cell_data_func,
|
||||
(gpointer)data, NULL);
|
||||
gnc_tree_view_append_column (GNC_TREE_VIEW(tree_view), column);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_object_set (G_OBJECT (renderer),
|
||||
"xalign", 1.0,
|
||||
(char *)NULL);
|
||||
g_signal_connect (G_OBJECT (renderer), "edited",
|
||||
G_CALLBACK (balance_cell_edited),
|
||||
data);
|
||||
column = gtk_tree_view_column_new_with_attributes (_("Opening Balance"),
|
||||
renderer,
|
||||
NULL);
|
||||
gtk_tree_view_column_set_cell_data_func (column, renderer,
|
||||
balance_cell_data_func,
|
||||
(gpointer)data, NULL);
|
||||
gnc_tree_view_append_column (GNC_TREE_VIEW(tree_view), column);
|
||||
}
|
||||
|
||||
// only in the case where there *are* existing accounts...
|
||||
if (xaccGroupGetNumSubAccounts(gnc_book_get_group(gnc_get_current_book())) > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user