r22108 - gnucash/trunk/src - Add a second "red" divider line to the register to denote the read-only section for older transactions.

Christian Stimming cstim at code.gnucash.org
Wed Mar 21 18:18:42 EDT 2012


Author: cstim
Date: 2012-03-21 18:18:41 -0400 (Wed, 21 Mar 2012)
New Revision: 22108
Trac: http://svn.gnucash.org/trac/changeset/22108

Modified:
   gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c
   gnucash/trunk/src/register/ledger-core/split-register-load.c
   gnucash/trunk/src/register/register-core/table-model.c
   gnucash/trunk/src/register/register-core/table-model.h
   gnucash/trunk/src/register/register-gnome/gnucash-grid.c
Log:
Add a second "red" divider line to the register to denote the read-only section for older transactions.

Modified: gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c
===================================================================
--- gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c	2012-03-21 22:18:29 UTC (rev 22107)
+++ gnucash/trunk/src/business/business-ledger/gncEntryLedgerLoad.c	2012-03-21 22:18:41 UTC (rev 22108)
@@ -518,6 +518,7 @@
 
     /* get the current time and reset the dividing row */
     present = gnc_timet_get_today_end ();
+    table->model->dividing_row_upper = -1;
     table->model->dividing_row = -1;
     cursor = gnc_table_layout_get_cursor (table->layout, "cursor");
 

Modified: gnucash/trunk/src/register/ledger-core/split-register-load.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/split-register-load.c	2012-03-21 22:18:29 UTC (rev 22107)
+++ gnucash/trunk/src/register/ledger-core/split-register-load.c	2012-03-21 22:18:41 UTC (rev 22108)
@@ -262,11 +262,14 @@
 
     gboolean start_primary_color = TRUE;
     gboolean found_pending = FALSE;
+    gboolean need_divider_upper = FALSE;
+    gboolean found_divider_upper = FALSE;
     gboolean found_divider = FALSE;
     gboolean has_last_num = FALSE;
     gboolean multi_line;
     gboolean dynamic;
     gboolean we_own_slist = FALSE;
+    gboolean use_autofreeze = qof_book_uses_autofreeze(gnc_get_current_book());
 
     VirtualCellLocation vcell_loc;
     VirtualLocation save_loc;
@@ -274,7 +277,7 @@
     int new_trans_split_row = -1;
     int new_trans_row = -1;
     int new_split_row = -1;
-    time_t present;
+    time_t present, autofreeze_time;
 
     g_return_if_fail(reg);
     table = reg->table;
@@ -431,6 +434,11 @@
 
     /* get the current time and reset the dividing row */
     present = gnc_timet_get_today_end ();
+    {
+        GDate *d = qof_book_get_autofreeze_gdate(gnc_get_current_book());
+        autofreeze_time = timespecToTime_t(gdate_to_timespec(*d));
+        g_date_free(d);
+    }
 
     if (info->first_pass)
     {
@@ -473,6 +481,7 @@
             gnc_split_register_recn_cell_confirm, reg);
     }
 
+    table->model->dividing_row_upper = -1;
     table->model->dividing_row = -1;
 
     // Ensure that the transaction and splits being edited are in the split
@@ -529,8 +538,23 @@
         }
 
         if (info->show_present_divider &&
+                use_autofreeze &&
+                !found_divider_upper)
+        {
+            if (xaccTransGetDate (trans) > autofreeze_time)
+            {
+                table->model->dividing_row_upper = vcell_loc.virt_row;
+                found_divider_upper = TRUE;
+            }
+            else
+            {
+                need_divider_upper = TRUE;
+            }
+        }
+
+        if (info->show_present_divider &&
                 !found_divider &&
-                (present < xaccTransGetDate (trans)))
+                (xaccTransGetDate (trans) > present))
         {
             table->model->dividing_row = vcell_loc.virt_row;
             found_divider = TRUE;
@@ -565,6 +589,15 @@
     if (pending_trans == blank_trans)
         found_pending = TRUE;
 
+    /* No upper divider yet? Store it now */
+    if (info->show_present_divider &&
+            use_autofreeze &&
+            !found_divider_upper && need_divider_upper)
+    {
+        table->model->dividing_row_upper = vcell_loc.virt_row;
+        found_divider_upper = TRUE;
+    }
+
     if (blank_trans == find_trans)
         new_trans_row = vcell_loc.virt_row;
 

Modified: gnucash/trunk/src/register/register-core/table-model.c
===================================================================
--- gnucash/trunk/src/register/register-core/table-model.c	2012-03-21 22:18:29 UTC (rev 22107)
+++ gnucash/trunk/src/register/register-core/table-model.c	2012-03-21 22:18:41 UTC (rev 22108)
@@ -141,6 +141,7 @@
     model->save_handlers = gnc_table_model_handler_hash_new ();
 
     model->read_only = FALSE;
+    model->dividing_row_upper = -1;
     model->dividing_row = -1;
 
     return model;

Modified: gnucash/trunk/src/register/register-core/table-model.h
===================================================================
--- gnucash/trunk/src/register/register-core/table-model.h	2012-03-21 22:18:29 UTC (rev 22107)
+++ gnucash/trunk/src/register/register-core/table-model.h	2012-03-21 22:18:41 UTC (rev 22108)
@@ -121,6 +121,9 @@
     /* If positive, denotes a row that marks a boundary that should
      * be visually distinguished. */
     int dividing_row;
+    /* If positive, denotes a row that marks a boundary that should
+     * be visually distinguished, but different from the other. */
+    int dividing_row_upper;
 
     VirtCellDataAllocator cell_data_allocator;
     VirtCellDataDeallocator cell_data_deallocator;

Modified: gnucash/trunk/src/register/register-gnome/gnucash-grid.c
===================================================================
--- gnucash/trunk/src/register/register-gnome/gnucash-grid.c	2012-03-21 22:18:29 UTC (rev 22107)
+++ gnucash/trunk/src/register/register-gnome/gnucash-grid.c	2012-03-21 22:18:41 UTC (rev 22108)
@@ -449,8 +449,37 @@
         gnucash_draw_hatching (drawable, grid->gc,
                                x, y, width, height);
 
-    /* dividing line */
+    /* dividing line upper (red) */
     if ((virt_loc.phys_row_offset == 0) &&
+            (table->model->dividing_row_upper >= 0))
+    {
+        if (virt_loc.vcell_loc.virt_row == table->model->dividing_row_upper)
+        {
+            gdk_gc_set_foreground (grid->gc, &gn_red);
+            gdk_draw_line (drawable, grid->gc, x, y - 1, x + width, y - 1);
+            gdk_draw_line (drawable, grid->gc, x, y,   x + width, y);
+            gdk_draw_line (drawable, grid->gc, x, y + 1, x + width, y + 1);
+        }
+    }
+
+    if ((virt_loc.phys_row_offset == (block->style->nrows - 1)) &&
+            (table->model->dividing_row_upper >= 0))
+    {
+        if (virt_loc.vcell_loc.virt_row ==
+                (table->model->dividing_row_upper - 1))
+        {
+            gdk_gc_set_foreground (grid->gc, &gn_red);
+            gdk_draw_line (drawable, grid->gc, x, y + height - 1,
+                           x + width, y + height - 1);
+            gdk_draw_line (drawable, grid->gc, x, y + height,
+                           x + width, y + height);
+            gdk_draw_line (drawable, grid->gc, x, y + height + 1,
+                           x + width, y + height + 1);
+        }
+    }
+
+    /* dividing line lower (blue) */
+    if ((virt_loc.phys_row_offset == 0) &&
             (table->model->dividing_row >= 0))
     {
         if (virt_loc.vcell_loc.virt_row == table->model->dividing_row)



More information about the gnucash-changes mailing list