[Gnucash-changes] r13508 - gnucash/trunk/src/register/ledger-core - Factor out one small piece of the huge gnc_split_register_load() into

Chris Shoemaker chris at cvs.gnucash.org
Mon Mar 6 22:07:42 EST 2006


Author: chris
Date: 2006-03-06 22:07:41 -0500 (Mon, 06 Mar 2006)
New Revision: 13508
Trac: http://svn.gnucash.org/trac/changeset/13508

Modified:
   gnucash/trunk/src/register/ledger-core/split-register-load.c
Log:
   Factor out one small piece of the huge gnc_split_register_load() into 
   new static function add_quickfill_completions().


Modified: gnucash/trunk/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-load.c	2006-03-07 02:42:12 UTC (rev 13507)
+++ gnucash/trunk/src/register/ledger-core/split-register-load.c	2006-03-07 03:07:41 UTC (rev 13508)
@@ -138,6 +138,33 @@
   return xaccSplitGetParent(split) == txn ? 0 : 1;
 }
 
+static void add_quickfill_completions(TableLayout *layout, Transaction *trans, 
+                                      gboolean has_last_num)
+{
+    Split *s;
+    int i = 0;      
+
+    gnc_quickfill_cell_add_completion(
+        (QuickFillCell *) gnc_table_layout_get_cell(layout, DESC_CELL),
+         xaccTransGetDescription(trans));
+    
+    gnc_quickfill_cell_add_completion(
+        (QuickFillCell *) gnc_table_layout_get_cell(layout, NOTES_CELL),
+        xaccTransGetNotes(trans));
+
+    if (!has_last_num)
+        gnc_num_cell_set_last_num(
+            (NumCell *) gnc_table_layout_get_cell(layout, NUM_CELL),
+            xaccTransGetNum(trans));
+    
+    while ((s = xaccTransGetSplit(trans, i)) != NULL) {
+        gnc_quickfill_cell_add_completion(
+            (QuickFillCell *) gnc_table_layout_get_cell(layout, MEMO_CELL), 
+            xaccSplitGetMemo(s));
+        i++;
+    }
+}
+
 void
 gnc_split_register_load (SplitRegister *reg, GList * slist,
                          Account *default_account)
@@ -390,37 +417,8 @@
     /* If this is the first load of the register,
      * fill up the quickfill cells. */
     if (info->first_pass)
-    {
-      Split *s;
-      int i;      
+        add_quickfill_completions(reg->table->layout, trans, has_last_num);
 
-      gnc_quickfill_cell_add_completion
-        ((QuickFillCell *)
-         gnc_table_layout_get_cell (reg->table->layout, DESC_CELL),
-         xaccTransGetDescription (trans));
-
-      gnc_quickfill_cell_add_completion
-        ((QuickFillCell *)
-         gnc_table_layout_get_cell (reg->table->layout, NOTES_CELL),
-         xaccTransGetNotes (trans));
-
-      if (!has_last_num)
-        gnc_num_cell_set_last_num
-          ((NumCell *)
-           gnc_table_layout_get_cell (reg->table->layout, NUM_CELL),
-           xaccTransGetNum (trans));
-
-      i = 0;
-      while ((s = xaccTransGetSplit(trans, i)) != NULL) {
-          QuickFillCell *cell;
-
-          cell = (QuickFillCell *)
-              gnc_table_layout_get_cell (reg->table->layout, MEMO_CELL);
-          gnc_quickfill_cell_add_completion (cell, xaccSplitGetMemo (s));
-          i++;
-      }
-    }
-
     if (trans == find_trans)
       new_trans_row = vcell_loc.virt_row;
 



More information about the gnucash-changes mailing list