Minor code factoring, line-wraps, control-flow simplifications, etc.

centered around split-register-load.c.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13510 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2006-03-07 03:41:39 +00:00
parent 3ffc0a28a5
commit 15e375ad1c
4 changed files with 29 additions and 41 deletions

View File

@ -100,9 +100,7 @@ gnc_split_register_add_transaction (SplitRegister *reg,
TRUE, start_primary_color, *vcell_loc);
vcell_loc->virt_row++;
{
for (node = xaccTransGetSplitList (trans); node; node = node->next)
{
for (node = xaccTransGetSplitList (trans); node; node = node->next) {
Split *secondary = node->data;
if (!xaccTransStillHasSplit(trans, secondary)) continue;
@ -113,21 +111,20 @@ gnc_split_register_add_transaction (SplitRegister *reg,
xaccSplitGetGUID (secondary),
visible_splits, TRUE, *vcell_loc);
vcell_loc->virt_row++;
}
}
if (!add_blank)
return;
if (add_blank) {
if (find_trans == trans && find_split == NULL &&
find_class == CURSOR_CLASS_SPLIT)
*new_split_row = vcell_loc->virt_row;
/* Add blank transaction split */
gnc_table_set_vcell (reg->table, split_cursor,
xaccSplitGetGUID (NULL), FALSE, TRUE, *vcell_loc);
vcell_loc->virt_row++;
if (find_trans == trans && find_split == NULL &&
find_class == CURSOR_CLASS_SPLIT) {
*new_split_row = vcell_loc->virt_row;
}
/* Add blank transaction split */
gnc_table_set_vcell(reg->table, split_cursor, xaccSplitGetGUID(NULL),
FALSE, TRUE, *vcell_loc);
vcell_loc->virt_row++;
}
}
static gint
@ -230,10 +227,11 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
new_trans = xaccMallocTransaction (gnc_get_current_book ());
xaccTransBeginEdit (new_trans);
xaccTransSetCurrency (new_trans, currency ? currency : gnc_default_currency ());
xaccTransSetCurrency (new_trans,
currency ? currency : gnc_default_currency());
xaccTransSetDateSecs (new_trans, info->last_date_entered);
blank_split = xaccMallocSplit (gnc_get_current_book ());
xaccTransAppendSplit (new_trans, blank_split);
xaccSplitSetParent(blank_split, new_trans);
xaccTransCommitEdit (new_trans);
info->blank_split_guid = *xaccSplitGetGUID (blank_split);
@ -262,15 +260,14 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
find_trans = xaccSplitGetParent (blank_split);
find_split = NULL;
find_trans_split = blank_split;
find_class = info->cursor_hint_cursor_class;
}
else
{
find_trans = info->cursor_hint_trans;
find_split = info->cursor_hint_split;
find_trans_split = info->cursor_hint_trans_split;
find_class = info->cursor_hint_cursor_class;
}
find_class = info->cursor_hint_cursor_class;
save_loc = table->current_cursor_loc;
@ -293,11 +290,7 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
{
VirtualLocation virt_loc;
virt_loc.vcell_loc.virt_row = -1;
virt_loc.vcell_loc.virt_col = -1;
virt_loc.phys_row_offset = -1;
virt_loc.phys_col_offset = -1;
gnc_virtual_location_init(&virt_loc);
gnc_table_move_cursor_gui (table, virt_loc);
}
@ -360,19 +353,17 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
// list we're about to load.
if (pending_trans != NULL)
{
SplitList *splits;
for (splits = xaccTransGetSplitList(pending_trans); splits; splits = splits->next)
for (node = xaccTransGetSplitList(pending_trans); node; node = node->next)
{
Split *pending_split = (Split*)splits->data;
Split *pending_split = (Split*)node->data;
if (!xaccTransStillHasSplit(pending_trans, pending_split)) continue;
if (g_list_find(slist, pending_split) != NULL)
continue;
//printf("pending_split [%s] not found\n", guid_to_string(xaccSplitGetGUID(pending_split)));
if (g_list_find_custom(slist, pending_trans, _find_split_with_parent_txn) != NULL)
if (g_list_find_custom(slist, pending_trans,
_find_split_with_parent_txn) != NULL)
continue;
//printf("transaction [%s] not found\n", guid_to_string(xaccTransGetGUID(pending_trans)));
if (!we_own_slist)
{ // lazy-copy
slist = g_list_copy(slist);
@ -494,9 +485,9 @@ gnc_split_register_load (SplitRegister *reg, GList * slist,
if (dynamic || multi_line || info->trans_expanded)
{
gnc_table_set_virt_cell_cursor
(table, trans_split_loc.vcell_loc,
gnc_split_register_get_active_cursor (reg));
gnc_table_set_virt_cell_cursor(
table, trans_split_loc.vcell_loc,
gnc_split_register_get_active_cursor (reg));
gnc_split_register_set_trans_visible (reg, trans_split_loc.vcell_loc,
TRUE, multi_line);

View File

@ -57,7 +57,6 @@ static QofLogModule log_module = GNC_MOD_REGISTER;
static void gnc_table_init (Table * table);
static void gnc_table_free_data (Table * table);
static void gnc_virtual_cell_construct (gpointer vcell, gpointer user_data);
static void gnc_virtual_location_init (VirtualLocation *vloc);
static void gnc_virtual_cell_destroy (gpointer vcell, gpointer user_data);
static void gnc_table_resize (Table * table, int virt_rows, int virt_cols);
@ -620,7 +619,7 @@ gnc_table_free_data (Table * table)
g_table_resize (table->virt_cells, 0, 0);
}
static void
void
gnc_virtual_location_init (VirtualLocation *vloc)
{
if (vloc == NULL)

View File

@ -47,7 +47,7 @@
* -- there is only one cursor for a given virt row.
* -- there is no overlap; a phys row can only belong to one virt row.
*
* Lets say there are three cursors T(rans),S(plit), and B(lank).
* Lets say there are three cursors T(rans), S(plit), and B(lank).
* Lets say that these are used to 'print' the following table layout:
*
* virt row 1 T
@ -157,6 +157,7 @@ void gnc_table_set_default_gui_handlers (TableGUIHandlers *gui_handlers);
Table * gnc_table_new (TableLayout *layout,
TableModel *model,
TableControl *control);
void gnc_virtual_location_init (VirtualLocation *vloc);
void gnc_table_save_state (Table *table);
void gnc_table_destroy (Table *table);

View File

@ -676,10 +676,7 @@ gnc_item_edit_init (GncItemEdit *item_edit)
item_edit->reset_pos = TRUE;
item_edit->x_offset = 0;
item_edit->virt_loc.vcell_loc.virt_row = -1;
item_edit->virt_loc.vcell_loc.virt_col = -1;
item_edit->virt_loc.phys_row_offset = -1;
item_edit->virt_loc.phys_col_offset = -1;
gnc_virtual_location_init(&item_edit->virt_loc);
#ifdef USE_XIM
item_edit->ic = NULL;