r15946 - gnucash/trunk/src - Improve handling of the account in the account dialog.

Andreas Köhler andi5 at cvs.gnucash.org
Sat Apr 21 08:01:02 EDT 2007


Author: andi5
Date: 2007-04-21 08:00:56 -0400 (Sat, 21 Apr 2007)
New Revision: 15946
Trac: http://svn.gnucash.org/trac/changeset/15946

Modified:
   gnucash/trunk/src/engine/Account.c
   gnucash/trunk/src/engine/Account.h
   gnucash/trunk/src/gnome-utils/dialog-account.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h
Log:
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


Modified: gnucash/trunk/src/engine/Account.c
===================================================================
--- gnucash/trunk/src/engine/Account.c	2007-04-21 08:59:49 UTC (rev 15945)
+++ gnucash/trunk/src/engine/Account.c	2007-04-21 12:00:56 UTC (rev 15946)
@@ -3759,7 +3759,7 @@
 \********************************************************************/
 
 guint32
-xaccAccountTypesCompatibleWith (GNCAccountType type)
+xaccParentAccountTypesCompatibleWith (GNCAccountType type)
 {
   switch (type) {
   case ACCT_TYPE_BANK:
@@ -3782,15 +3782,18 @@
       (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 @@
 xaccAccountTypesCompatible (GNCAccountType parent_type,
                             GNCAccountType child_type)
 {
-  return ((xaccAccountTypesCompatibleWith (parent_type) &
+  return ((xaccParentAccountTypesCompatibleWith (parent_type) &
            (1 << child_type))
           != 0);
 }
@@ -3810,7 +3813,8 @@
 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;
 }

Modified: gnucash/trunk/src/engine/Account.h
===================================================================
--- gnucash/trunk/src/engine/Account.h	2007-04-21 08:59:49 UTC (rev 15945)
+++ gnucash/trunk/src/engine/Account.h	2007-04-21 12:00:56 UTC (rev 15946)
@@ -946,15 +946,16 @@
  *  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);
 
 

Modified: gnucash/trunk/src/gnome-utils/dialog-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-account.c	2007-04-21 08:59:49 UTC (rev 15945)
+++ gnucash/trunk/src/gnome-utils/dialog-account.c	2007-04-21 12:00:56 UTC (rev 15946)
@@ -750,8 +750,7 @@
   }
 
   /* 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 @@
     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));

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h	2007-04-21 08:59:49 UTC (rev 15945)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h	2007-04-21 12:00:56 UTC (rev 15946)
@@ -94,7 +94,7 @@
 
 /*************** 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);



More information about the gnucash-changes mailing list