GnuCash  4.11-148-gc20d717b33+
gnc-tree-model-split-reg.h
Go to the documentation of this file.
1 /********************************************************************\
2  * gnc-tree-model-split-reg.h -- GtkTreeView implementation to *
3  * display registers in a GtkTreeView. *
4  * *
5  * Copyright (C) 2006-2007 Chris Shoemaker <c.shoemaker@cox.net> *
6  * Copyright (C) 2012 Robert Fewell *
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 
27 
28 #ifndef __GNC_TREE_MODEL_SPLIT_REG_H
29 #define __GNC_TREE_MODEL_SPLIT_REG_H
30 
31 #include <gtk/gtk.h>
32 #include "gnc-tree-model.h"
33 #include "Query.h"
34 
35 
36 G_BEGIN_DECLS
43 /* type macros */
44 #define GNC_TYPE_TREE_MODEL_SPLIT_REG (gnc_tree_model_split_reg_get_type ())
45 #define GNC_TREE_MODEL_SPLIT_REG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_MODEL_SPLIT_REG, GncTreeModelSplitReg))
46 #define GNC_TREE_MODEL_SPLIT_REG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_MODEL_SPLIT_REG, GncTreeModelSplitRegClass))
47 #define GNC_IS_TREE_MODEL_SPLIT_REG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_MODEL_SPLIT_REG))
48 #define GNC_IS_TREE_MODEL_SPLIT_REG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_MODEL_SPLIT_REG))
49 #define GNC_TREE_MODEL_SPLIT_REG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_MODEL_SPLIT_REG, GncTreeModelSplitRegClass))
50 #define GNC_TREE_MODEL_SPLIT_REG_NAME "GncTreeModelSplitReg"
51 
52 
53 /* Define the number of transaction to load */
54 #define NUM_OF_TRANS 30
55 
56 
61 typedef enum
62 {
63  BANK_REGISTER2, //0
64  CASH_REGISTER2, //1
65  ASSET_REGISTER2, //2
66  CREDIT_REGISTER2, //3
67  LIABILITY_REGISTER2, //4
68  INCOME_REGISTER2, //5
69  EXPENSE_REGISTER2, //6
70  EQUITY_REGISTER2, //7
71  STOCK_REGISTER2, //8
72  CURRENCY_REGISTER2, //9
73  RECEIVABLE_REGISTER2, //10
74  PAYABLE_REGISTER2, //11
75  TRADING_REGISTER2, //12
76  NUM_SINGLE_REGISTER_TYPES2, //13
77 
78  GENERAL_JOURNAL2 = NUM_SINGLE_REGISTER_TYPES2, //13
79  INCOME_LEDGER2, //14
80  PORTFOLIO_LEDGER2, //15
81  SEARCH_LEDGER2, //16
82 
83  NUM_REGISTER_TYPES2 //17
85 
86 
88 typedef enum
89 {
90  REG2_STYLE_LEDGER, //0
91  REG2_STYLE_AUTO_LEDGER, //1
92  REG2_STYLE_JOURNAL //2
94 
95 
96 typedef enum
97 {
98  GNC_TREE_MODEL_SPLIT_REG_COL_GUID, //0
99  GNC_TREE_MODEL_SPLIT_REG_COL_DATE, //1
100  GNC_TREE_MODEL_SPLIT_REG_COL_DUEDATE, //2
101  GNC_TREE_MODEL_SPLIT_REG_COL_NUMACT, //3
102  GNC_TREE_MODEL_SPLIT_REG_COL_DESCNOTES, //4
103  GNC_TREE_MODEL_SPLIT_REG_COL_TRANSFERVOID, //5
104  GNC_TREE_MODEL_SPLIT_REG_COL_RECN, //6
105  GNC_TREE_MODEL_SPLIT_REG_COL_DEBIT, //7
106  GNC_TREE_MODEL_SPLIT_REG_COL_CREDIT, //8
107 
108  GNC_TREE_MODEL_SPLIT_REG_COL_LAST_VISIBLE = GNC_TREE_MODEL_SPLIT_REG_COL_CREDIT, //8
109 
110  /* internal hidden columns */
111  GNC_TREE_MODEL_SPLIT_REG_COL_RO, //9
112  GNC_TREE_MODEL_SPLIT_REG_COL_NUM_VIS, //10
113  GNC_TREE_MODEL_SPLIT_REG_COL_ACT_VIS, //11
114 
115  GNC_TREE_MODEL_SPLIT_REG_NUM_COLUMNS //12
116 } GncTreeModelSplitRegColumn;
117 
118 
119 
120 typedef enum
121 {
122  VIEW_HOME, //0
123  VIEW_UP, //1
124  VIEW_PGUP, //2
125  VIEW_GOTO, //3
126  VIEW_PGDOWN, //4
127  VIEW_DOWN, //5
128  VIEW_END, //6
129 } GncTreeModelSplitRegUpdate;
130 
131 
132 /* typedefs & structures */
134 
136 typedef struct
137 {
140  gint stamp;
144  gboolean use_double_line;
146  gboolean is_template;
149  gint sort_depth;
150  gint sort_col;
151  GtkSortType sort_direction;
154  gboolean separator_changed;
155  gboolean alt_colors_by_txn;
158  gboolean read_only;
160  Transaction *current_trans;
161  gint current_row;
166 
167 
169 typedef struct
170 {
173  /* This signal is emitted to refresh the transaction view, the pointer has
174  the transaction */
175  void (*refresh_trans) (GncTreeModelSplitReg *model, gpointer item);
176 
177  /* This signal is emitted to refresh the model */
178  void (*refresh_view) (GncTreeModelSplitReg *model, gpointer user_data);
179 
180  /* This signal is emitted to keep scrollbar in sync */
181  void (*scroll_sync) (GncTreeModelSplitReg *model, gpointer user_data);
182 
183  /* This signal is emitted to refresh the status bar */
184  void (*refresh_status_bar) (GncTreeModelSplitReg *model, gpointer user_data);
185 
186  /* This signal is emitted before a transaction delete, the pointer has
187  the transaction */
188  void (*selection_move_delete) (GncTreeModelSplitReg *model, gpointer item);
189 
191 
192 
194 typedef GtkWidget *(*SRGetParentCallback2) (gpointer user_data);
195 
201 
205  gboolean use_double_line, gboolean is_template, gboolean mismatched_commodities);
206 
208 void gnc_tree_model_split_reg_load (GncTreeModelSplitReg *model, GList * slist, Account *default_account);
209 
212 
215 
218 
221 
223 void gnc_tree_model_split_reg_set_data (GncTreeModelSplitReg *model, gpointer user_data,
224  SRGetParentCallback2 get_parent);
225 
228 
231 
234  SplitRegisterStyle2 newstyle, gboolean use_double_line);
235 
238 
241 
243 void gnc_tree_model_split_reg_set_display (GncTreeModelSplitReg *model, gboolean subacc, gboolean gl);
244 
246 void gnc_tree_model_split_reg_move (GncTreeModelSplitReg *model, GncTreeModelSplitRegUpdate model_update);
247 
248 /* Sync the vertical scrollbar to position in full_tlist. */
249 void gnc_tree_model_split_reg_sync_scrollbar (GncTreeModelSplitReg *model);
250 
253 
255 gboolean gnc_tree_model_split_reg_trans_is_in_view (GncTreeModelSplitReg *model, Transaction *trans);
256 
257 /* These are to do with autocompletion */
258 GtkListStore * gnc_tree_model_split_reg_get_description_list (GncTreeModelSplitReg *model);
259 
260 GtkListStore * gnc_tree_model_split_reg_get_notes_list (GncTreeModelSplitReg *model);
261 
262 GtkListStore * gnc_tree_model_split_reg_get_memo_list (GncTreeModelSplitReg *model);
263 
264 GtkListStore * gnc_tree_model_split_reg_get_action_list (GncTreeModelSplitReg *model);
265 
266 GtkListStore * gnc_tree_model_split_reg_get_acct_list (GncTreeModelSplitReg *model);
267 
268 void gnc_tree_model_split_reg_update_num_list (GncTreeModelSplitReg *model);
269 
270 void gnc_tree_model_split_reg_update_action_list (GncTreeModelSplitReg *model);
271 
272 void gnc_tree_model_split_reg_update_account_list (GncTreeModelSplitReg *model);
273 
274 void gnc_tree_model_split_reg_update_completion (GncTreeModelSplitReg *model);
275 
276 
277 /* Get the split and transaction */
278 gboolean gnc_tree_model_split_reg_get_split_and_trans (
279  GncTreeModelSplitReg *model, GtkTreeIter *iter,
280  gboolean *is_trow1, gboolean *is_trow2, gboolean *is_split,
281  gboolean *is_blank, Split **split, Transaction **trans);
282 
283 /* Return FALSE if failure */
284 gboolean gnc_tree_model_split_reg_set_blank_split_parent (
285  GncTreeModelSplitReg *model, Transaction *trans, gboolean remove_only);
286 
287 /* Return the blank split */
288 Split * gnc_tree_model_split_get_blank_split (GncTreeModelSplitReg *model);
289 
290 /* Return TRUE if blank_split is on trans */
291 gboolean gnc_tree_model_split_reg_is_blank_split_parent (GncTreeModelSplitReg *model, Transaction *trans);
292 
293 /* Return the blank trans */
294 Transaction * gnc_tree_model_split_get_blank_trans (GncTreeModelSplitReg *model);
295 
296 /* If 'trans' is NULL, use split's parent. If 'split' is NULL, just
297  get the transaction iter. */
298 gboolean gnc_tree_model_split_reg_get_iter_from_trans_and_split (
299  GncTreeModelSplitReg *model, Transaction *trans, Split *split,
300  GtkTreeIter *iter1, GtkTreeIter *iter2);
301 
302 /* Return the row color for the view */
303 gchar * gnc_tree_model_split_reg_get_row_color (GncTreeModelSplitReg *model, gboolean is_trow1,
304  gboolean is_trow2, gboolean is_split, gint num);
305 
306 /* Return the tooltip for transaction at position in full_tlist. */
307 gchar * gnc_tree_model_split_reg_get_tooltip (GncTreeModelSplitReg *model, gint position);
308 
309 /* Set the current transaction to that at position in full_tlist */
310 void gnc_tree_model_split_reg_set_current_trans_by_position (GncTreeModelSplitReg *model, gint position);
311 
312 /* Return TRUE if this transaction is read only for the view */
313 gboolean
314 gnc_tree_model_split_reg_get_read_only (GncTreeModelSplitReg *model, Transaction *trans);
315 
316 /* Return TRUE if this is a sub account view */
317 gboolean
318 gnc_tree_model_split_reg_get_sub_account (GncTreeModelSplitReg *model);
319 
320 /* Return the tree path, if split and trans are null, last in list returned */
321 GtkTreePath * gnc_tree_model_split_reg_get_path_to_split_and_trans (
322  GncTreeModelSplitReg *model, Split *split, Transaction *trans);
323 
324 /* Returns TRUE if iter is a blank transaction */
325 gboolean gnc_tree_model_split_reg_is_blank_trans (GncTreeModelSplitReg *model, GtkTreeIter *iter);
326 
327 /* Return the split for which ancestor is it's parent */
328 Split * gnc_tree_model_split_reg_trans_get_split_equal_to_ancestor (const Transaction *trans, const Account *ancestor);
329 
330 /* Dummy Sort function */
331 gint gnc_tree_model_split_reg_sort_iter_compare_func (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data);
332 
333 /*****************************************************************************/
335 G_END_DECLS
336 
337 #endif /* __GNC_TREE_MODEL_SPLIT_REG_H */
void gnc_tree_model_split_reg_config(GncTreeModelSplitReg *model, SplitRegisterType2 newtype, SplitRegisterStyle2 newstyle, gboolean use_double_line)
Set style and type for register.
gint number_of_trans_in_full_tlist
The total number of transactions in full_tlist.
gint position_of_trans_in_full_tlist
The position of current transaction in full_tlist.
GncTreeModel gnc_tree_model
The parent object data.
gboolean use_double_line
FIXME ? As above, whether to use two lines per transaction.
SplitRegisterType2
Register types.
gint current_row
Current row in treeview.
void gnc_tree_model_split_reg_set_display(GncTreeModelSplitReg *model, gboolean subacc, gboolean gl)
Set display general journal and show sub accounts.
gboolean read_only
register is read only
gboolean is_template
Are we using a template.
gint sort_col
This is the column the sort direction is based on.
gboolean use_gnc_color_theme
whether to use the gnucash built-in color theme
The instance data structure for a generic tree model.
SplitRegisterType2 type
FIXME ? This may be the wrong place for these, may be the view ?
GtkSortType sort_direction
This is the direction of sort.
Account * gnc_tree_model_split_reg_get_anchor(GncTreeModelSplitReg *model)
Return the default account for this register model.
gboolean separator_changed
whether the separator has changed
The class data structure for a generic tree model.
GtkTreeModel implementation for a generic gnucash tree.
gboolean alt_colors_by_txn
whether to use alternative colors by transaction
gboolean gnc_tree_model_split_reg_get_template(GncTreeModelSplitReg *model)
Return TRUE if this is a template register.
void gnc_tree_model_split_reg_commit_blank_split(GncTreeModelSplitReg *model)
Commit the blank split.
GncTreeModelSplitReg * gnc_tree_model_split_reg_new(SplitRegisterType2 reg_type, SplitRegisterStyle2 style, gboolean use_double_line, gboolean is_template, gboolean mismatched_commodities)
Create new model and set options for register.
Transaction * current_trans
Current transaction.
gboolean gnc_tree_model_split_reg_trans_is_in_view(GncTreeModelSplitReg *model, Transaction *trans)
Return TRUE if transaction is in the view list.
The class data structure for an account tree model.
gboolean use_accounting_labels
whether to use accounting Labels
void gnc_tree_model_split_reg_move(GncTreeModelSplitReg *model, GncTreeModelSplitRegUpdate model_update)
Change transactions in the tlist based on view movement.
GncTreeModelClass gnc_tree_model
The parent object data.
void gnc_tree_model_split_reg_set_data(GncTreeModelSplitReg *model, gpointer user_data, SRGetParentCallback2 get_parent)
Sets the user data and callback hooks for the register.
SplitRegisterStyle2 style
FIXME ? This may be the wrong place for these, may be the view ?
gint sort_depth
This is the row the sort direction is based on.
gboolean mismatched_commodities
Are there different commodities.
void gnc_tree_model_split_reg_update_query(GncTreeModelSplitReg *model, Query *query)
Update the query for the register.
Account * gnc_tree_model_split_reg_get_template_account(GncTreeModelSplitReg *model)
Returns the template account.
GtkWidget *(* SRGetParentCallback2)(gpointer user_data)
Callback function type - Used to get parent window.
void gnc_tree_model_split_reg_load(GncTreeModelSplitReg *model, GList *slist, Account *default_account)
Load the model from a slist and set default account for register.
The instance private data for the split register tree model.
gint stamp
The state of the model.
SplitRegisterStyle2
Register styles.
Transaction * gnc_tree_model_split_reg_get_first_trans(GncTreeModelSplitReg *model)
Return the first transaction, opposite to blank transaction in the full list.
GType gnc_tree_model_split_reg_get_type(void)
Get the type of split register tree plugin.
void gnc_tree_model_split_reg_set_template_account(GncTreeModelSplitReg *model, Account *template_account)
Sets the template account.
The instance data structure for an account tree model.
GtkWidget * gnc_tree_model_split_reg_get_parent(GncTreeModelSplitReg *model)
Returns the parent Window of the register.
void gnc_tree_model_split_reg_destroy(GncTreeModelSplitReg *model)
Destroy the model.