mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Improve handling of the account in the account dialog.
* rename xaccAccountTypesCompatibleWith to xaccParentAccountTypesCompatibleWith, typically allow ACCT_TYPE_ROOT as parent but not as child * remove ACCT_TYPE_ROOT from xaccAccountTypesValid * no need to single-case the root account in gnc_common_ok anymore git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15946 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
55c4675868
commit
94364fb33e
@ -3759,7 +3759,7 @@ xaccAccountGetTypeFromStr (const gchar *str)
|
||||
\********************************************************************/
|
||||
|
||||
guint32
|
||||
xaccAccountTypesCompatibleWith (GNCAccountType type)
|
||||
xaccParentAccountTypesCompatibleWith (GNCAccountType type)
|
||||
{
|
||||
switch (type) {
|
||||
case ACCT_TYPE_BANK:
|
||||
@ -3782,15 +3782,18 @@ xaccAccountTypesCompatibleWith (GNCAccountType type)
|
||||
(1 << ACCT_TYPE_CREDIT) |
|
||||
(1 << ACCT_TYPE_LIABILITY) |
|
||||
(1 << ACCT_TYPE_RECEIVABLE) |
|
||||
(1 << ACCT_TYPE_PAYABLE);
|
||||
(1 << ACCT_TYPE_PAYABLE) |
|
||||
(1 << ACCT_TYPE_ROOT);
|
||||
case ACCT_TYPE_INCOME:
|
||||
case ACCT_TYPE_EXPENSE:
|
||||
return
|
||||
(1 << ACCT_TYPE_INCOME) |
|
||||
(1 << ACCT_TYPE_EXPENSE);
|
||||
(1 << ACCT_TYPE_EXPENSE) |
|
||||
(1 << ACCT_TYPE_ROOT);
|
||||
case ACCT_TYPE_EQUITY:
|
||||
return
|
||||
(1 << ACCT_TYPE_EQUITY);
|
||||
(1 << ACCT_TYPE_EQUITY) |
|
||||
(1 << ACCT_TYPE_ROOT);
|
||||
default:
|
||||
PERR("bad account type: %d", type);
|
||||
return 0;
|
||||
@ -3801,7 +3804,7 @@ gboolean
|
||||
xaccAccountTypesCompatible (GNCAccountType parent_type,
|
||||
GNCAccountType child_type)
|
||||
{
|
||||
return ((xaccAccountTypesCompatibleWith (parent_type) &
|
||||
return ((xaccParentAccountTypesCompatibleWith (parent_type) &
|
||||
(1 << child_type))
|
||||
!= 0);
|
||||
}
|
||||
@ -3810,7 +3813,8 @@ guint32
|
||||
xaccAccountTypesValid(void)
|
||||
{
|
||||
guint32 mask = (1 << NUM_ACCOUNT_TYPES) - 1;
|
||||
mask &= ~(1 << ACCT_TYPE_CURRENCY); /* DEPRECATED */
|
||||
mask &= ~((1 << ACCT_TYPE_CURRENCY) | /* DEPRECATED */
|
||||
(1 << ACCT_TYPE_ROOT)); /* ROOT */
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
@ -946,15 +946,16 @@ const char * xaccAccountGetTypeStr (GNCAccountType type);
|
||||
* to the local language. */
|
||||
GNCAccountType xaccAccountGetTypeFromStr (const gchar *str);
|
||||
|
||||
/** Return the bitmask of account types compatible with a given type. */
|
||||
guint32 xaccAccountTypesCompatibleWith (GNCAccountType type);
|
||||
/** Return the bitmask of parent account types compatible with a given type. */
|
||||
guint32 xaccParentAccountTypesCompatibleWith (GNCAccountType type);
|
||||
|
||||
/** Return TRUE if accounts of type parent_type can have accounts
|
||||
* of type child_type as children. */
|
||||
gboolean xaccAccountTypesCompatible (GNCAccountType parent_type,
|
||||
GNCAccountType child_type);
|
||||
|
||||
/* Returns the bitmask of the account type enums that are valid. */
|
||||
/** Returns the bitmask of the account type enums that are valid. Deprecated and
|
||||
* root account types are stripped. */
|
||||
guint32 xaccAccountTypesValid(void);
|
||||
|
||||
|
||||
|
@ -750,8 +750,7 @@ gnc_common_ok (AccountWindow *aw)
|
||||
}
|
||||
|
||||
/* check whether the types of child and parent are compatible */
|
||||
if (!gnc_account_is_root(parent) &&
|
||||
!xaccAccountTypesCompatible (aw->type, xaccAccountGetType (parent))) {
|
||||
if (!xaccAccountTypesCompatible (aw->type, xaccAccountGetType (parent))) {
|
||||
const char *message = _("The selected account type is incompatible with "
|
||||
"the one of the selected parent.");
|
||||
gnc_error_dialog(aw->dialog, message);
|
||||
@ -969,7 +968,7 @@ gnc_account_parent_changed_cb (GtkTreeSelection *selection, gpointer data)
|
||||
types = aw->valid_types;
|
||||
} else {
|
||||
types = aw->valid_types &
|
||||
xaccAccountTypesCompatibleWith (xaccAccountGetType (parent_account));
|
||||
xaccParentAccountTypesCompatibleWith (xaccAccountGetType (parent_account));
|
||||
}
|
||||
|
||||
type_model = gtk_tree_view_get_model (GTK_TREE_VIEW (aw->type_view));
|
||||
|
@ -94,7 +94,7 @@ GType gnc_tree_model_account_types_get_type (void);
|
||||
|
||||
/*************** Method 1 functions ***************/
|
||||
|
||||
/* Returns a GtkTreeModelFilter that wraps the model. Deprecated
|
||||
/* Returns a GtkTreeModelFilter that wraps the model. Deprecated and root
|
||||
account types will be filtered. Caller is responsible for
|
||||
ref/unref. */
|
||||
GtkTreeModel * gnc_tree_model_account_types_valid (void);
|
||||
|
Loading…
Reference in New Issue
Block a user