Collapse knowledge of the account tree model layering into one place.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9659 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
David Hampton
2003-11-01 22:40:37 +00:00
parent 44857b6897
commit d671ee581d
5 changed files with 43 additions and 32 deletions

View File

@@ -41,7 +41,6 @@
#include "gnc-engine.h"
#include "gnc-gui-query.h"
#include "gnc-session.h"
#include "gnc-tree-model-account.h"
#include "gnc-tree-view-account.h"
#include "gnc-ui.h"
#include "gnc-ui-util.h"
@@ -1261,20 +1260,16 @@ commodity_changed_cb (GNCGeneralSelect *gsl, gpointer data)
static gboolean
account_commodity_filter (GtkTreeSelection *selection,
GtkTreeModel *filter_model,
GtkTreePath *filter_path,
GtkTreeModel *unused_model,
GtkTreePath *unused_path,
gboolean path_currently_selected,
gpointer user_data)
{
gnc_commodity *commodity;
AccountWindow *aw;
Account *account;
GtkTreeModel *model;
GtkTreePath *path;
GtkTreeIter iter;
g_return_val_if_fail (GTK_IS_TREE_SELECTION (selection), FALSE);
g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (filter_model), FALSE);
aw = user_data;
@@ -1283,17 +1278,7 @@ account_commodity_filter (GtkTreeSelection *selection,
return TRUE;
}
model = egg_tree_model_filter_get_model
(EGG_TREE_MODEL_FILTER(filter_model));
path = egg_tree_model_filter_convert_path_to_child_path
(EGG_TREE_MODEL_FILTER(filter_model), filter_path);
if (!gtk_tree_model_get_iter (model, &iter, path)) {
/* Can't convert path to iter? Bad! */
return FALSE;
}
account = gnc_tree_model_account_get_account (GNC_TREE_MODEL_ACCOUNT (model), &iter);
account = gnc_tree_view_account_get_selected_account (GNC_TREE_VIEW_ACCOUNT (aw->transfer_tree));
if (!account) {
return FALSE;
}

View File

@@ -473,6 +473,28 @@ gnc_tree_view_account_count_children (GncTreeViewAccount *view,
return num_children;
}
Account *
gnc_tree_view_account_get_account_from_column (GtkTreeViewColumn *column,
GtkTreeModel *f_model,
GtkTreeIter *f_iter)
{
GtkTreeModel *model;
GtkTreeIter iter;
Account *account;
g_return_val_if_fail (EGG_IS_TREE_MODEL_FILTER (f_model), NULL);
ENTER("column %p, model %p, iter %p", column, f_model, f_iter);
model = egg_tree_model_filter_get_model(EGG_TREE_MODEL_FILTER(f_model));
egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER(f_model),
&iter,
f_iter);
account = gnc_tree_model_account_get_account (GNC_TREE_MODEL_ACCOUNT(model), &iter);
LEAVE("account %p (%s)", account, xaccAccountGetName (account));
return account;
}
/************************************************************/
/* Account Tree View Filter Functions */
/************************************************************/

View File

@@ -229,6 +229,12 @@ gint gnc_tree_view_account_count_children (GncTreeViewAccount *view,
Account *account);
Account * gnc_tree_view_account_get_account_from_column (GtkTreeViewColumn *column,
GtkTreeModel *f_model,
GtkTreeIter *f_iter);
/** This function returns the account associated with the top level
* pseudo-account. The gnucash engine does not have a single top
* level account (it has a list of top level accounts), but this code

View File

@@ -40,7 +40,6 @@
#include "gnc-event-p.h"
#include "../gnome-utils/gnc-dir.h"
#include "gnc-gui-query.h"
#include "gnc-tree-model-account.h"
#include "gnc-tree-model-example-account.h"
#include "gnc-tree-model-selection.h"
#include "gnc-tree-view-account.h"
@@ -603,27 +602,19 @@ get_selected_account_list (GtkTreeView *tree_view)
static void
balance_cell_data_func (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *filter_model,
GtkTreeIter *filter_iter,
GtkTreeModel *model,
GtkTreeIter *iter,
gpointer user_data)
{
GtkTreeModel *model;
GtkTreeIter iter;
Account *account;
gnc_numeric balance;
const gchar *string;
GNCPrintAmountInfo print_info;
hierarchy_data *data = (hierarchy_data *)user_data;
g_return_if_fail (EGG_IS_TREE_MODEL_FILTER (filter_model));
model =
egg_tree_model_filter_get_model(EGG_TREE_MODEL_FILTER(filter_model));
egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER(filter_model),
&iter,
filter_iter);
account = gnc_tree_model_account_get_account (GNC_TREE_MODEL_ACCOUNT(model), &iter);
g_return_if_fail (GTK_TREE_MODEL (model));
account = gnc_tree_view_account_get_account_from_column (tree_column,
model, iter);
balance = get_final_balance (data->balance_hash, account);
if (gnc_reverse_balance (account))