-
-static gint ui_repdist_result_get_pos(gint tmpfor, guint from, Transaction *ope)
-{
-gint pos = 0;
-
- switch(tmpfor)
- {
- case BY_REPDIST_CATEGORY:
- {
- Category *catentry = da_cat_get(ope->kcat);
- if(catentry)
- pos = (catentry->flags & GF_SUB) ? catentry->parent : catentry->key;
- }
- break;
- case BY_REPDIST_SUBCATEGORY:
- pos = ope->kcat;
- break;
- case BY_REPDIST_PAYEE:
- pos = ope->kpay;
- break;
- case BY_REPDIST_MONTH:
- pos = DateInPer(from, ope->date);
- break;
- case BY_REPDIST_YEAR:
- pos = DateInYear(from, ope->date);
- break;
- }
- return pos;
-}
-
-
-
-
-static void ui_repdist_detail(GtkWidget *widget, gpointer user_data)
-{
-struct ui_repdist_data *data;
-guint active = GPOINTER_TO_INT(user_data);
-guint tmpfor;
-GList *list;
-GtkTreeModel *model;
-GtkTreeIter iter;
-
- data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
-
- DB( g_print("\n[repdist] detail\n") );
-
- /* clear and detach our model */
- model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_detail));
- gtk_list_store_clear (GTK_LIST_STORE(model));
-
- if(data->detail)
- {
- tmpfor = gtk_combo_box_get_active(GTK_COMBO_BOX(data->CY_by));
-
- g_object_ref(model); /* Make sure the model stays with us after the tree view unrefs it */
- gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_detail), NULL); /* Detach model from view */
-
- /* fill in the model */
- list = g_queue_peek_head_link(data->txn_queue);
- while (list != NULL)
- {
- Transaction *ope = list->data;
-
- if(filter_test(data->filter, ope) == 1)
- {
- guint i, pos = 0;
-
- if( tmpfor != BY_REPDIST_TAG )
- {
- if( (tmpfor == BY_REPDIST_CATEGORY || tmpfor == BY_REPDIST_SUBCATEGORY) && ope->flags & OF_SPLIT )
- {
- guint nbsplit = da_splits_count(ope->splits);
- Split *split;
-
- for(i=0;i<nbsplit;i++)
- {
- split = ope->splits[i];
- switch(tmpfor)
- {
- case BY_REPDIST_CATEGORY:
- {
- Category *catentry = da_cat_get(split->kcat);
- if(catentry)
- pos = (catentry->flags & GF_SUB) ? catentry->parent : catentry->key;
- }
- break;
- case BY_REPDIST_SUBCATEGORY:
- pos = split->kcat;
- break;
- }
-
- if( pos == active )
- {
-
- gtk_list_store_append (GTK_LIST_STORE(model), &iter);
- gtk_list_store_set (GTK_LIST_STORE(model), &iter,
- LST_DSPOPE_DATAS, ope,
- -1);
-
- break;
- }
-
- }
- }
- else
- {
- pos = ui_repdist_result_get_pos(tmpfor, data->filter->mindate, ope);
- if( pos == active )
- {
-
- gtk_list_store_append (GTK_LIST_STORE(model), &iter);
- gtk_list_store_set (GTK_LIST_STORE(model), &iter,
- LST_DSPOPE_DATAS, ope,
- -1);
-
- }
- }
-
- }
- else
- /* the TAG process is particular */
- {
- if(ope->tags != NULL)
- {
- guint32 *tptr = ope->tags;
-
- while(*tptr)
- {
- pos = *tptr - 1;
-
- DB( g_print(" -> storing tag %d %.2f\n", pos, ope->amount) );
-
- if( pos == active )
- {
- gtk_list_store_append (GTK_LIST_STORE(model), &iter);
- gtk_list_store_set (GTK_LIST_STORE(model), &iter,
- LST_DSPOPE_DATAS, ope,
- -1);
-
- }
-
- tptr++;
- }
-
- }
- }
-
-
-
- }
-
- list = g_list_next(list);
- }
-
- /* Re-attach model to view */
- gtk_tree_view_set_model(GTK_TREE_VIEW(data->LV_detail), model);
- g_object_unref(model);
-
- gtk_tree_view_columns_autosize( GTK_TREE_VIEW(data->LV_detail) );
-
- }
-
-}
-
-