1 /* 2 * gnc-tree-model-account.h -- GtkTreeModel implementation to 3 * display accounts in a GtkTreeView. 4 * 5 * Copyright (C) 2003 Jan Arne Petersen <jpetersen@uni-bonn.de> 6 * Copyright (C) 2003 David Hampton <hampton@employees.org> 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License as 10 * published by the Free Software Foundation; either version 2 of 11 * the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, contact: 20 * 21 * Free Software Foundation Voice: +1-617-542-5942 22 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 23 * Boston, MA 02110-1301, USA gnu@gnu.org 24 */ 25 26 /** @addtogroup GUI 27 @{ */ 28 /** @addtogroup GuiTreeModel GnuCash Tree Model 29 @{ */ 30 /** @file gnc-tree-model-account.h 31 @brief GtkTreeModel implementation for gnucash account tree. 32 @author Jan Arne Petersen <jpetersen@uni-bonn.de> 33 @author David Hampton <hampton@employees.org> 34 */ 35 36 #ifndef __GNC_TREE_MODEL_ACCOUNT_H 37 #define __GNC_TREE_MODEL_ACCOUNT_H 38 39 #include <gtk/gtk.h> 40 #include "gnc-tree-model.h" 41 42 #include "Account.h" 43 44 G_BEGIN_DECLS 45 46 /* type macros */ 47 #define GNC_TYPE_TREE_MODEL_ACCOUNT (gnc_tree_model_account_get_type ()) 48 #define GNC_TREE_MODEL_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_MODEL_ACCOUNT, GncTreeModelAccount)) 49 #define GNC_TREE_MODEL_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_MODEL_ACCOUNT, GncTreeModelAccountClass)) 50 #define GNC_IS_TREE_MODEL_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_MODEL_ACCOUNT)) 51 #define GNC_IS_TREE_MODEL_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_MODEL_ACCOUNT)) 52 #define GNC_TREE_MODEL_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_MODEL_ACCOUNT, GncTreeModelAccountClass)) 53 #define GNC_TREE_MODEL_ACCOUNT_NAME "GncTreeModelAccount" 54 55 56 typedef enum 57 { 58 GNC_TREE_MODEL_ACCOUNT_COL_NAME, 59 GNC_TREE_MODEL_ACCOUNT_COL_TYPE, 60 GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY, 61 GNC_TREE_MODEL_ACCOUNT_COL_CODE, 62 GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION, 63 GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM, 64 GNC_TREE_MODEL_ACCOUNT_COL_PRESENT, 65 GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT, 66 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE, 67 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT, 68 GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_PERIOD, 69 GNC_TREE_MODEL_ACCOUNT_COL_CLEARED, 70 GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT, 71 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED, 72 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT, 73 GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE, 74 GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN, 75 GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT, 76 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL, 77 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT, 78 GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_PERIOD, 79 GNC_TREE_MODEL_ACCOUNT_COL_NOTES, 80 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO, 81 GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO_SUB_ACCT, 82 GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN, 83 GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER, 84 GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE, 85 86 GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE = GNC_TREE_MODEL_ACCOUNT_COL_OPENING_BALANCE, 87 88 /* internal hidden columns */ 89 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT, 90 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT, 91 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE, 92 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD, 93 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED, 94 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED, 95 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN, 96 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL, 97 GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL_PERIOD, 98 99 GNC_TREE_MODEL_ACCOUNT_NUM_COLUMNS 100 } GncTreeModelAccountColumn; 101 102 /* typedefs & structures */ 103 104 /** The instance data structure for an account tree model. */ 105 typedef struct 106 { 107 GncTreeModel gnc_tree_model; /**< The parent object data. */ 108 int stamp; /**< The state of the model. Any state 109 * change increments this number. */ 110 } GncTreeModelAccount; 111 112 113 /** The class data structure for an account tree model. */ 114 typedef struct 115 { 116 GncTreeModelClass gnc_tree_model;/**< The parent object data. */ 117 } GncTreeModelAccountClass; 118 119 120 121 /** Get the type of an account tree plugin. 122 * 123 * @return A GType. 124 */ 125 GType gnc_tree_model_account_get_type (void); 126 127 /** Clear the tree model account cached values. 128 * 129 * @param model A pointer to the account tree model. 130 */ 131 void gnc_tree_model_account_clear_cache (GncTreeModelAccount *model); 132 133 /** @name Account Tree Model Constructors 134 @{ */ 135 136 /** Create a new GtkTreeModel for manipulating gnucash accounts. 137 * 138 * @param root The account group to put at the top level of the tree 139 * hierarchy. */ 140 GtkTreeModel *gnc_tree_model_account_new (Account *root); 141 /** @} */ 142 143 144 /** @name Account Tree Model Get/Set Functions 145 @{ */ 146 147 /** Convert a model/iter pair to a gnucash account. This routine should 148 * only be called from an account tree view filter function. The 149 * model and iter values will be provided as part of the call to the 150 * filter. 151 * 152 * @param model A pointer to the account tree model. 153 * 154 * @param iter A gtk_tree_iter corresponding to a single account in 155 * the model. 156 * 157 * @return A pointer to the corresponding account. 158 */ 159 Account *gnc_tree_model_account_get_account (GncTreeModelAccount *model, 160 GtkTreeIter *iter); 161 162 163 /** Convert a model/account pair into a gtk_tree_model_iter. This 164 * routine should only be called from the file 165 * gnc-tree-view-account.c. 166 * 167 * @internal 168 * 169 * @param model The model that an account belongs to. 170 * 171 * @param account The account to convert. 172 * 173 * @param iter A pointer to an iter. This iter will be rewritten to 174 * contain the results of the query. 175 * 176 * @return TRUE if the account was found and the iter filled 177 * in. FALSE otherwise. 178 */ 179 gboolean gnc_tree_model_account_get_iter_from_account (GncTreeModelAccount *model, 180 Account *account, 181 GtkTreeIter *iter); 182 183 184 /** Convert a model/account pair into a gtk_tree_model_path. This 185 * routine should only be called from the file 186 * gnc-tree-view-account.c. 187 * 188 * @internal 189 * 190 * @param model The model that an account belongs to. 191 * 192 * @param account The account to convert. 193 * 194 * @return A pointer to a path describing the account. It is the 195 * responsibility of the caller to free this path when done. 196 */ 197 GtkTreePath *gnc_tree_model_account_get_path_from_account (GncTreeModelAccount *model, 198 Account *account); 199 /** @} */ 200 201 G_END_DECLS 202 203 #endif /* __GNC_TREE_MODEL_ACCOUNT_H */ 204 205 /** @} */ 206 /** @} */ 207