diff --git a/src/register/ledger-core/split-register-load.c b/src/register/ledger-core/split-register-load.c index b11f6e8aa2..99f9ec8e6b 100644 --- a/src/register/ledger-core/split-register-load.c +++ b/src/register/ledger-core/split-register-load.c @@ -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 (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 (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++; + } } 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); diff --git a/src/register/register-core/table-allgui.c b/src/register/register-core/table-allgui.c index f74e5ac3d0..04107093e6 100644 --- a/src/register/register-core/table-allgui.c +++ b/src/register/register-core/table-allgui.c @@ -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) diff --git a/src/register/register-core/table-allgui.h b/src/register/register-core/table-allgui.h index 4168f3e499..8db190ec26 100644 --- a/src/register/register-core/table-allgui.h +++ b/src/register/register-core/table-allgui.h @@ -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); diff --git a/src/register/register-gnome/gnucash-item-edit.c b/src/register/register-gnome/gnucash-item-edit.c index 198c5128ed..b41d1f6d8b 100644 --- a/src/register/register-gnome/gnucash-item-edit.c +++ b/src/register/register-gnome/gnucash-item-edit.c @@ -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;