r22827 - gnucash/trunk/src - Register rewrite Update

Geert Janssens gjanssens at code.gnucash.org
Mon Mar 11 14:08:09 EDT 2013


Author: gjanssens
Date: 2013-03-11 14:08:08 -0400 (Mon, 11 Mar 2013)
New Revision: 22827
Trac: http://svn.gnucash.org/trac/changeset/22827

Modified:
   gnucash/trunk/src/engine/Transaction.c
   gnucash/trunk/src/engine/Transaction.h
   gnucash/trunk/src/engine/engine-helpers.c
   gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.c
   gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.h
   gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.h
   gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c
   gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.h
   gnucash/trunk/src/gnome/gnc-plugin-page-register2.c
   gnucash/trunk/src/gnome/gnc-split-reg2.c
   gnucash/trunk/src/gnome/gnc-split-reg2.h
   gnucash/trunk/src/gnome/gtkbuilder/gnc-plugin-page-register2.glade
   gnucash/trunk/src/gnome/ui/gnc-plugin-page-register2-ui.xml
   gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.c
   gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.h
Log:
Register rewrite Update

This update is mainly to do with the change to using a tree model sort and model filter. The existing sort option has been removed and replaced with the model sort which saves the order to gconf. The filter option is still used but uses the model filter instead of the query and still saves to kvp entries in each register. There are also some changes to the cut, copy and paste of transactions along with the transaction auto complete.

Author: Robert Fewell

Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/engine/Transaction.c	2013-03-11 18:08:08 UTC (rev 22827)
@@ -631,7 +631,7 @@
 void
 xaccTransCopyOnto(const Transaction *from_trans, Transaction *to_trans)
 {
-    xaccTransCopyFromClipBoard(from_trans, to_trans, NULL, NULL);
+    xaccTransCopyFromClipBoard(from_trans, to_trans, NULL, NULL, TRUE);
 }
 
 /********************************************************************\
@@ -643,16 +643,18 @@
  *  'from_acc' need not be a valid account. It may be an already freed
  *   Account. Therefore, it must not be dereferenced at all.
  *
- *   Neither 'from_trans', nor 'from_acc', nor any of 'from's splits may be modified
- *   in any way.
+ *   Neither 'from_trans', nor 'from_acc', nor any of 'from's splits may
+ *   be modified in any way.
  *
+ *   'no_date' if TRUE will not copy the date posted.
+ *
  *   The 'to_trans' transaction will end up with valid copies of from's
  *   splits.  In addition, the copies of any of from's splits that were
  *   in from_acc (or at least claimed to be) will end up in to_acc.
 \********************************************************************/
 void
 xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
-                           const Account *from_acc, Account *to_acc)
+                           const Account *from_acc, Account *to_acc, gboolean no_date)
 {
     Timespec ts = {0,0};
     gboolean change_accounts = FALSE;
@@ -670,8 +672,11 @@
     xaccTransSetDescription(to_trans, xaccTransGetDescription(from_trans));
     xaccTransSetNum(to_trans, xaccTransGetNum(from_trans));
     xaccTransSetNotes(to_trans, xaccTransGetNotes(from_trans));
-    xaccTransGetDatePostedTS(from_trans, &ts);
-    xaccTransSetDatePostedTS(to_trans, &ts);
+    if(!no_date)
+    {
+        xaccTransGetDatePostedTS(from_trans, &ts);
+        xaccTransSetDatePostedTS(to_trans, &ts);
+    }
 
     /* Each new split will be parented to 'to' */
     for (node = from_trans->splits; node; node = node->next)
@@ -1109,7 +1114,7 @@
     trans_curr = xaccTransGetCurrency (trans);
     if (gnc_commodity_equal (trans_curr, split_com))
     {
-        if (rate) 
+        if (rate)
             *rate = gnc_numeric_create (1, 1);
         return TRUE;
     }

Modified: gnucash/trunk/src/engine/Transaction.h
===================================================================
--- gnucash/trunk/src/engine/Transaction.h	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/engine/Transaction.h	2013-03-11 18:08:08 UTC (rev 22827)
@@ -244,12 +244,14 @@
  *   Neither 'from_trans', nor 'from_acc', nor any of 'from's splits may be modified
  *   in any way.
  *
+ *   'no_date' if TRUE will not copy the date posted.
+ *
  *   The 'to_trans' transaction will end up with valid copies of from's
  *   splits.  In addition, the copies of any of from's splits that were
  *   in from_acc (or at least claimed to be) will end up in to_acc.
  */
 void xaccTransCopyFromClipBoard(const Transaction *from_trans, Transaction *to_trans,
-                           const Account *from_acc, Account *to_acc);
+                           const Account *from_acc, Account *to_acc, gboolean no_date);
 
 /*################## Added for Reg2 #################*/
 

Modified: gnucash/trunk/src/engine/engine-helpers.c
===================================================================
--- gnucash/trunk/src/engine/engine-helpers.c	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/engine/engine-helpers.c	2013-03-11 18:08:08 UTC (rev 22827)
@@ -169,6 +169,7 @@
         if (num_action && action)
             xaccTransSetNum (trans, action);
     }
+
     if (split)
     {
         if (!num_action && action)

Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register2.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register2.c	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register2.c	2013-03-11 18:08:08 UTC (rev 22827)
@@ -53,7 +53,7 @@
 
 #include "dialog-account.h"
 #include "dialog-find-transactions.h"
-/*#include "dialog-print-check.h" */
+//#include "dialog-print-check.h"
 #include "dialog-transfer.h"
 #include "dialog-utils.h"
 #include "assistant-stock-split.h"
@@ -106,14 +106,6 @@
 
 static void gnc_plugin_page_register2_summarybar_position_changed (GConfEntry *entry, gpointer user_data);
 
-/* Callbacks for the "Sort By" dialog */
-void gnc_plugin_page_register2_sort_button_cb (GtkToggleButton *button, GncPluginPageRegister2 *page);
-void gnc_plugin_page_register2_sort_response_cb (GtkDialog *dialog, gint response, GncPluginPageRegister2 *plugin_page);
-void gnc_plugin_page_register2_sort_order_save_cb (GtkToggleButton *button, GncPluginPageRegister2 *page);
-
-static gchar *gnc_plugin_page_register2_get_sort_order (GncPluginPage *plugin_page);
-void gnc_plugin_page_register2_set_sort_order (GncPluginPage *plugin_page, const gchar *sort_order);
-
 /* Callbacks for the "Filter By" dialog */
 void gnc_plugin_page_register2_filter_select_range_cb (GtkRadioButton *button, GncPluginPageRegister2 *page);
 void gnc_plugin_page_register2_filter_start_cb (GtkWidget *radio, GncPluginPageRegister2 *page);
@@ -128,8 +120,8 @@
 static gchar *gnc_plugin_page_register2_get_filter (GncPluginPage *plugin_page);
 void gnc_plugin_page_register2_set_filter (GncPluginPage *plugin_page, const gchar *filter);
 
-static void gnc_ppr_update_status_query (GncPluginPageRegister2 *page, gboolean refresh_page);
-static void gnc_ppr_update_date_query (GncPluginPageRegister2 *page, gboolean refresh_page);
+static void gnc_ppr_update_status_filter (GncPluginPageRegister2 *page, gboolean refresh_page);
+static void gnc_ppr_update_date_filter (GncPluginPageRegister2 *page, gboolean refresh_page);
 
 /* Command callbacks */
 static void gnc_plugin_page_register2_cmd_print_check (GtkAction *action, GncPluginPageRegister2 *plugin_page);
@@ -145,7 +137,6 @@
 static void gnc_plugin_page_register2_cmd_unvoid_transaction (GtkAction *action, GncPluginPageRegister2 *plugin_page);
 static void gnc_plugin_page_register2_cmd_reverse_transaction (GtkAction *action, GncPluginPageRegister2 *plugin_page);
 static void gnc_plugin_page_register2_cmd_shift_transaction_forward (GtkAction *action, GncPluginPageRegister2 *plugin_page);
-static void gnc_plugin_page_register2_cmd_view_sort_by (GtkAction *action, GncPluginPageRegister2 *plugin_page);
 static void gnc_plugin_page_register2_cmd_view_filter_by (GtkAction *action, GncPluginPageRegister2 *plugin_page);
 static void gnc_plugin_page_register2_cmd_style_changed (GtkAction *action, GtkRadioAction *current, GncPluginPageRegister2 *plugin_page);
 static void gnc_plugin_page_register2_cmd_style_double_line (GtkToggleAction *action, GncPluginPageRegister2 *plugin_page);
@@ -284,10 +275,6 @@
     /* View menu */
 
     {
-        "ViewSortByAction", NULL, N_("_Sort By..."), NULL, NULL,
-        G_CALLBACK (gnc_plugin_page_register2_cmd_view_sort_by)
-    },
-    {
         "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL,
         G_CALLBACK (gnc_plugin_page_register2_cmd_view_filter_by)
     },
@@ -466,7 +453,6 @@
 
 #define CLEARED_VALUE "cleared_value"
 #define DEFAULT_FILTER "0x001f"
-#define DEFAULT_SORT_ORDER "BY_STANDARD"
 
 /************************************************************/
 /*                      Data Structures                     */
@@ -489,14 +475,6 @@
     struct
     {
         GtkWidget *dialog;
-        SortType original_sort_type;
-        gboolean original_save_order;
-        gboolean save_order;
-    } sd;
-
-    struct
-    {
-        GtkWidget *dialog;
         GtkWidget *table;
         GtkWidget *start_date_choose;
         GtkWidget *start_date_today;
@@ -948,22 +926,8 @@
     ledger_type = gnc_ledger_display2_type (priv->ledger);
 
 
-    if (ledger_type == LD2_SINGLE || ledger_type == LD2_SUBACCOUNT)
+    if (ledger_type == LD2_SINGLE || ledger_type == LD2_SUBACCOUNT || ledger_type == LD2_GL)
     {
-        /* Set the sort order for the split register and status of save order button */
-        priv->sd.save_order = FALSE;
-        order = gnc_plugin_page_register2_get_sort_order (plugin_page);
-
-        PINFO("Loaded Sort order is %s", order);
-
-        gnc_split_reg2_set_sort_type (priv->gsr, SortTypefromString (order));
-
-        if (order && (g_strcmp0 (order, DEFAULT_SORT_ORDER) != 0))
-            priv->sd.save_order = TRUE;
-
-        priv->sd.original_save_order = priv->sd.save_order;
-        g_free(order);
-
         /* Set the filter for the split register and status of save filter button */
         priv->fd.save_filter = FALSE;
 
@@ -1000,9 +964,9 @@
         priv->fd.original_save_filter = priv->fd.save_filter;
         g_strfreev (filter);
 
-        /* Update Query with Filter Status and Dates */
-        gnc_ppr_update_status_query (page, FALSE);
-        gnc_ppr_update_date_query (page, FALSE);
+        /* Update the filter with Status and Dates */
+        gnc_ppr_update_status_filter (page, FALSE);
+        gnc_ppr_update_date_filter (page, FALSE);
     }
 
     gnc_ledger_display2_refresh (priv->ledger);
@@ -1084,7 +1048,10 @@
                                 gnc_plugin_page_register2_summarybar_position_changed, page);
 
     if (priv->widget == NULL)
+    {
+        LEAVE(" ");
         return;
+    }
 
     if (priv->component_manager_id)
     {
@@ -1098,12 +1065,6 @@
         priv->event_handler_id = 0;
     }
 
-    if (priv->sd.dialog)
-    {
-        gtk_widget_destroy (priv->sd.dialog);
-        memset(&priv->sd, 0, sizeof(priv->sd));
-    }
-
     if (priv->fd.dialog)
     {
         gtk_widget_destroy (priv->fd.dialog);
@@ -1583,53 +1544,6 @@
 }
 
 static gchar *
-gnc_plugin_page_register2_get_sort_order (GncPluginPage *plugin_page)
-{
-    GncPluginPageRegister2Private *priv;
-    GNCLedgerDisplay2Type ledger_type;
-    GNCLedgerDisplay2 *ld;
-    Account *leader;
-    const char* sort_order;
-
-    g_return_val_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page), _("unknown"));
-
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
-    ld = priv->ledger;
-    ledger_type = gnc_ledger_display2_type (ld);
-    leader = gnc_ledger_display2_leader (ld);
-    sort_order = NULL;
-
-    if ((ledger_type == LD2_SINGLE) || (ledger_type == LD2_SUBACCOUNT))
-        sort_order = xaccAccountGetSortOrder (leader);
-
-    return g_strdup(sort_order ? sort_order : DEFAULT_SORT_ORDER);
-}
-
-void
-gnc_plugin_page_register2_set_sort_order (GncPluginPage *plugin_page, const gchar *sort_order )
-{
-    GncPluginPageRegister2Private *priv;
-    GNCLedgerDisplay2Type ledger_type;
-    GNCLedgerDisplay2 *ld;
-    Account *leader;
-
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
-    ld = priv->ledger;
-    ledger_type = gnc_ledger_display2_type (ld);
-    leader = gnc_ledger_display2_leader (ld);
-
-    if (leader != NULL)
-    {
-        if (!sort_order || (g_strcmp0 (sort_order, DEFAULT_SORT_ORDER) == 0))
-            xaccAccountSetSortOrder (leader, NULL);
-        else
-            xaccAccountSetSortOrder (leader, sort_order);
-    }
-
-    return;
-}
-
-static gchar *
 gnc_plugin_page_register2_get_long_name (GncPluginPage *plugin_page)
 {
     GncPluginPageRegister2Private *priv;
@@ -1698,222 +1612,57 @@
 /*#################################################################################*/
 
 /************************************************************/
-/*                     "Sort By" Dialog                     */
-/************************************************************/
-
-/** This function is called when the "Sort By..." dialog is closed.
- *  If the dialog was closed by any method other than clicking the OK
- *  button, the original sorting order will be restored.
- *
- *  @param dialog A pointer to the dialog box.
- *
- *  @param response A numerical value indicating why the dialog box was closed.
- *
- *  @param page A pointer to the GncPluginPageRegister2 associated with
- *  this dialog box.
- */
-void
-gnc_plugin_page_register2_sort_response_cb (GtkDialog *dialog,
-        gint response,
-        GncPluginPageRegister2 *page)
-{
-    GncPluginPageRegister2Private *priv;
-    GncPluginPage *plugin_page;
-    SortType type;
-    const gchar *order;
-
-    g_return_if_fail(GTK_IS_DIALOG(dialog));
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
-
-    ENTER(" ");
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    plugin_page = GNC_PLUGIN_PAGE(page);
-
-    if (response != GTK_RESPONSE_OK)
-    {
-        /* Restore the original sort order */
-        gnc_split_reg2_set_sort_type(priv->gsr, priv->sd.original_sort_type);
-        priv->sd.save_order = priv->sd.original_save_order;
-    }
-    else
-    {
-        priv->sd.original_save_order = priv->sd.save_order;
-
-        if (priv->sd.save_order)
-        {
-            type = gnc_split_reg2_get_sort_type(priv->gsr);
-            order = SortTypeasString(type);
-            gnc_plugin_page_register2_set_sort_order (plugin_page, order);
-        }
-    }
-    priv->sd.dialog = NULL;
-    gtk_widget_destroy(GTK_WIDGET(dialog));
-    LEAVE(" ");
-}
-
-
-/** This function is called when a radio button in the "Sort By..."
- *  dialog is clicked.
- *
- *  @param button The button that was toggled.
- *
- *  @param page A pointer to the GncPluginPageRegister2 associated with
- *  this dialog box.
- */
-void
-gnc_plugin_page_register2_sort_button_cb (GtkToggleButton *button,
-        GncPluginPageRegister2 *page)
-{
-    GncPluginPageRegister2Private *priv;
-    const gchar *name;
-    SortType type;
-
-    g_return_if_fail(GTK_IS_TOGGLE_BUTTON(button));
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
-
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    name = gtk_buildable_get_name(GTK_BUILDABLE(button));
-    ENTER("button %s(%p), page %p", name, button, page);
-    type = SortTypefromString(name);
-    gnc_split_reg2_set_sort_type(priv->gsr, type);
-    LEAVE(" ");
-}
-
-
-/** This function is called whenever the save sort order is checked
- *  or unchecked which allows saving of the sort order.
- *
- *  @param button The toggle button that was changed.
- *
- *  @param page A pointer to the GncPluginPageRegister2 that is
- *  associated with this sort order dialog.
- */
-void
-gnc_plugin_page_register2_sort_order_save_cb (GtkToggleButton *button,
-        GncPluginPageRegister2 *page)
-{
-    GncPluginPageRegister2Private *priv;
-
-    g_return_if_fail(GTK_IS_CHECK_BUTTON(button));
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
-
-    ENTER("Save toggle button (%p), plugin_page %p", button, page);
-
-    /* Compute the new save sort order */
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-
-    if (gtk_toggle_button_get_active(button))
-        priv->sd.save_order = TRUE;
-    else
-        priv->sd.save_order = FALSE;
-    LEAVE(" ");
-}
-
-/*#################################################################################*/
-/*#################################################################################*/
-
-/************************************************************/
 /*                    "Filter By" Dialog                    */
 /************************************************************/
 
 /** This function updates the "cleared match" term of the register
- *  query.  It unconditionally removes any old "cleared match" query
- *  term, then adds back a new query term if needed.  There seems to
- *  be a bug in the current g2 register code such that when the number
- *  of entries in the register doesn't fill up the window, the blank
- *  space at the end of the window isn't correctly redrawn.  This
- *  function works around that problem, but a root cause analysis
- *  should probably be done.
+ *  filter.
  *
  *  @param page A pointer to the GncPluginPageRegister2 that is
  *  associated with this filter dialog.
  */
 static void
-gnc_ppr_update_status_query (GncPluginPageRegister2 *page, gboolean refresh_page)
+gnc_ppr_update_status_filter (GncPluginPageRegister2 *page, gboolean refresh_page)
 {
     GncPluginPageRegister2Private *priv;
-    GSList *param_list;
-    Query *query;
+    GncTreeModelSplitReg *model;
 
-    ENTER(" ");
+    g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
+
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    query = gnc_ledger_display2_get_query (priv->ledger );
-    if (!query)
-    {
-        LEAVE("no query found");
-        return;
-    }
+    model = gnc_ledger_display2_get_split_model_register (priv->ledger);
 
-    /* Remove the old status match */
-    param_list = qof_query_build_param_list (SPLIT_RECONCILE, NULL);
-    if (param_list)
-    {
-        qof_query_purge_terms (query, param_list);
-        g_slist_free(param_list);
-    }
+    model->filter_cleared_match = priv->fd.cleared_match;
 
-    /* Install the new status match */
-    if (priv->fd.cleared_match != CLEARED_ALL)
-        xaccQueryAddClearedMatch(query, priv->fd.cleared_match, QOF_QUERY_AND);
+    if (refresh_page)
+        gnc_ledger_display2_refilter (priv->ledger);
 
-    if(refresh_page)
-        gnc_ledger_display2_refresh (priv->ledger);
     LEAVE(" ");
 }
 
 /** This function updates the "date posted" term of the register
- *  query.  It unconditionally removes any old "date posted" query
- *  term, then adds back a new query term if needed.  There seems to
- *  be a bug in the current g2 register code such that when the number
- *  of entries in the register doesn't fill up the window, the blank
- *  space at the end of the window isn't correctly redrawn.  This
- *  function works around that problem, but a root cause analysis
- *  should probably be done.
+ *  filter.
  *
  *  @param page A pointer to the GncPluginPageRegister2 that is
  *  associated with this filter dialog.
  */
 static void
-gnc_ppr_update_date_query (GncPluginPageRegister2 *page, gboolean refresh_page)
+gnc_ppr_update_date_filter (GncPluginPageRegister2 *page, gboolean refresh_page)
 {
     GncPluginPageRegister2Private *priv;
-    GSList *param_list;
-    Query *query;
+    GncTreeModelSplitReg *model;
 
-    ENTER(" ");
+    g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (page));
+
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    if (!priv->ledger)
-    {
-        LEAVE("no ledger");
-        return;
-    }
+    model = gnc_ledger_display2_get_split_model_register (priv->ledger);
 
-    query = gnc_ledger_display2_get_query( priv->ledger );
-    if (!query)
-    {
-        LEAVE("no query");
-        return;
-    }
+    model->filter_start_time = priv->fd.start_time;
+    model->filter_end_time = priv->fd.end_time;
 
-    /* Delete any existing old date spec. */
-    param_list = qof_query_build_param_list(SPLIT_TRANS, TRANS_DATE_POSTED, NULL);
-    if (param_list)
-    {
-        qof_query_purge_terms (query, param_list);
-        g_slist_free(param_list);
-    }
+    if (refresh_page)
+        gnc_ledger_display2_refilter (priv->ledger);
 
-    if (priv->fd.start_time || priv->fd.end_time)
-    {
-        /* Build a new spec */
-        xaccQueryAddDateMatchTT(query,
-                                priv->fd.start_time != 0, priv->fd.start_time,
-                                priv->fd.end_time != 0,   priv->fd.end_time,
-                                QOF_QUERY_AND);
-    }
-
-    if(refresh_page)
-        gnc_ledger_display2_refresh (priv->ledger);
     LEAVE(" ");
 }
 
@@ -1991,13 +1740,13 @@
         priv->fd.cleared_match |= value;
     else
         priv->fd.cleared_match &= ~value;
-    gnc_ppr_update_status_query(page, TRUE);
+    gnc_ppr_update_status_filter(page, TRUE);
     LEAVE(" ");
 }
 
 /** This function is called whenever the "select all" status button is
  *  clicked.  It updates all of the checkbox widgets, then updates the
- *  query on the register.
+ *  filter on the register.
  *
  *  @param button The button that was clicked.
  *
@@ -2029,7 +1778,7 @@
     /* Set the requested status */
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
     priv->fd.cleared_match = CLEARED_ALL;
-    gnc_ppr_update_status_query(page, TRUE);
+    gnc_ppr_update_status_filter(page, TRUE);
     LEAVE(" ");
 }
 
@@ -2090,11 +1839,11 @@
 }
 
 /** This function is called when the "select range" radio button
- *  changes state.  Since there are only two choices in this radio
- *  group, this one signal can be used to handle all cases.  This
+ *  changes state. Since there are only two choices in this radio
+ *  group, this one signal can be used to handle all cases. This
  *  function is responsible for setting the sensitivity of the table
  *  of widgets underneath the "select range" choice, and updating the
- *  time limitation on the register query.  This is handled by a
+ *  time limitation on the register filter. This is handled by a
  *  helper function when the radio button is selected (as potentially
  *  all the widgets in the table need to be inspected), and is trivial
  *  for the other case.
@@ -2127,13 +1876,13 @@
         priv->fd.start_time = 0;
         priv->fd.end_time = 0;
     }
-    gnc_ppr_update_date_query(page, TRUE);
+    gnc_ppr_update_date_filter(page, TRUE);
     LEAVE(" ");
 }
 
 /** This function is called when one of the start date entry widgets
- *  is updated.  It simply calls common routines to determine the
- *  start/end times and update the register query.
+ *  is updated. It simply calls common routines to determine the
+ *  start/end times and update the register filter.
  *
  *  @param unused A pointer to a GncDateEntry widgets, but it could be
  *  any widget.
@@ -2149,22 +1898,22 @@
 
     ENTER("(widget %s(%p), page %p)", gtk_buildable_get_name(GTK_BUILDABLE(unused)), unused, page);
     get_filter_times(page);
-    gnc_ppr_update_date_query(page, TRUE);
+    gnc_ppr_update_date_filter(page, TRUE);
     LEAVE(" ");
 }
 
 /** This function is called when one of the start date radio buttons
- *  is selected.  It updates the sensitivity of the date entry widget,
+ *  is selected. It updates the sensitivity of the date entry widget,
  *  then calls a common routine to determine the start/end times and
- *  update the register query.
+ *  update the register filter.
  *
  *  *Note: This function is actually called twice for each new radio
- *  button selection.  The first time call is to uncheck the old
- *  button, and the second time to check the new button.  This does
+ *  button selection. The first time call is to uncheck the old
+ *  button, and the second time to check the new button. This does
  *  make a kind of sense, as radio buttons are nothing more than
  *  linked toggle buttons where only one can be active.
  *
- *  @param radio The button whose state is changing.  This will be
+ *  @param radio The button whose state is changing. This will be
  *  the previously selected button the first of the pair of calls to
  *  this function, and will be the newly selected button the second
  *  time.
@@ -2195,22 +1944,22 @@
     active = ( g_strcmp0(name, g_strdup("start_date_choose")) == 0 ? 1 : 0 );
     gtk_widget_set_sensitive(priv->fd.start_date, active);
     get_filter_times(page);
-    gnc_ppr_update_date_query(page, TRUE);
+    gnc_ppr_update_date_filter(page, TRUE);
     LEAVE(" ");
 }
 
 /** This function is called when one of the end date radio buttons is
- *  selected.  It updates the sensitivity of the date entry widget,
+ *  selected. It updates the sensitivity of the date entry widget,
  *  then calls a common routine to determine the start/end times and
- *  update the register query.
+ *  update the register filter.
  *
  *  *Note: This function is actually called twice for each new radio
- *  button selection.  The first time call is to uncheck the old
- *  button, and the second time to check the new button.  This does
+ *  button selection. The first time call is to uncheck the old
+ *  button, and the second time to check the new button. This does
  *  make a kind of sense, as radio buttons are nothing more than
  *  linked toggle buttons where only one can be active.
  *
- *  @param radio The button whose state is changing.  This will be
+ *  @param radio The button whose state is changing. This will be
  *  the previously selected button the first of the pair of calls to
  *  this function, and will be the newly selected button the second
  *  time.
@@ -2241,7 +1990,7 @@
     active = ( g_strcmp0(name, g_strdup("end_date_choose")) == 0 ? 1 : 0 );
     gtk_widget_set_sensitive(priv->fd.end_date, active);
     get_filter_times(page);
-    gnc_ppr_update_date_query(page, TRUE);
+    gnc_ppr_update_date_filter(page, TRUE);
     LEAVE(" ");
 }
 
@@ -2303,11 +2052,11 @@
     {
         /* Remove the old status match */
         priv->fd.cleared_match = priv->fd.original_cleared_match;
-        gnc_ppr_update_status_query(page, FALSE);
+        gnc_ppr_update_status_filter(page, FALSE);
         priv->fd.start_time = priv->fd.original_start_time;
         priv->fd.end_time = priv->fd.original_end_time;
         priv->fd.save_filter = priv->fd.original_save_filter;
-        gnc_ppr_update_date_query(page, FALSE);
+        gnc_ppr_update_date_filter(page, FALSE);
         gnc_ledger_display2_refresh (priv->ledger);
     }
     else
@@ -2319,23 +2068,23 @@
             gchar* filter;
             filter = g_strdup_printf("0x%04x", priv->fd.cleared_match);
 
-            if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->fd.start_date_choose)) && priv->fd.start_time != 0 )
+            if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.start_date_choose)) && priv->fd.start_time != 0 )
             {
-                gchar *timeval = gnc_plugin_page_register2_filter_time2dmy(priv->fd.start_time);
-                filter = g_strconcat ( filter, ",", timeval, NULL);
+                gchar *timeval = gnc_plugin_page_register2_filter_time2dmy (priv->fd.start_time);
+                filter = g_strconcat (filter, ",", timeval, NULL);
                 g_free (timeval);
             }
             else
-                filter = g_strconcat ( filter, ",0", NULL);
+                filter = g_strconcat (filter, ",0", NULL);
 
-            if ( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(priv->fd.end_date_choose)) && priv->fd.end_time != 0 )
+            if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->fd.end_date_choose)) && priv->fd.end_time != 0 )
             {
-                gchar *timeval = gnc_plugin_page_register2_filter_time2dmy(priv->fd.end_time);
-                filter = g_strconcat ( filter, ",", timeval, NULL);
+                gchar *timeval = gnc_plugin_page_register2_filter_time2dmy (priv->fd.end_time);
+                filter = g_strconcat (filter, ",", timeval, NULL);
                 g_free (timeval);
             }
             else
-                filter = g_strconcat ( filter, ",0", NULL);
+                filter = g_strconcat (filter, ",0", NULL);
 
             PINFO("The filter to save is %s", filter);
 
@@ -2356,7 +2105,7 @@
 /************************************************************/
 
 static char *
-gnc_reg_get_name (GNCLedgerDisplay2 *ledger, gboolean for_window)
+gnc_reg_get_name (GNCLedgerDisplay2 *ledger, gboolean for_window) // this works
 {
     Account *leader;
     GncTreeModelSplitReg *model;
@@ -2423,9 +2172,10 @@
 }
 
 static int
-report_helper (GNCLedgerDisplay2 *ledger, Split *split, Query *query)
+report_helper (GNCLedgerDisplay2 *ledger, Split *split, Query *query) //this works
 {
-    SplitRegister *reg = gnc_ledger_display2_get_split_register (ledger);
+    GncTreeViewSplitReg *view;
+    GncTreeModelSplitReg *model;
     Account *account;
     char *str;
     const char *tmp;
@@ -2436,14 +2186,16 @@
 
     args = SCM_EOL;
 
+    view = gnc_ledger_display2_get_split_view_register (ledger);
+    model = gnc_ledger_display2_get_split_model_register (ledger);
+
     func = scm_c_eval_string ("gnc:register-report-create");
     g_return_val_if_fail (scm_is_procedure (func), -1);
+    tmp = gnc_tree_view_split_reg_get_credit_debit_string (view, TRUE);
 
-    tmp = gnc_split_register_get_credit_string (reg);
     arg = scm_from_locale_string (tmp ? tmp : _("Credit"));
     args = scm_cons (arg, args);
-
-    tmp = gnc_split_register_get_debit_string (reg);
+    tmp = gnc_tree_view_split_reg_get_credit_debit_string (view, FALSE);
     arg = scm_from_locale_string (tmp ? tmp : _("Debit"));
     args = scm_cons (arg, args);
 
@@ -2452,14 +2204,14 @@
     args = scm_cons (arg, args);
     g_free (str);
 
-    arg = SCM_BOOL (reg->use_double_line);
+    arg = SCM_BOOL (model->use_double_line);
     args = scm_cons (arg, args);
 
-    arg = SCM_BOOL (reg->type == GENERAL_LEDGER || reg->type == INCOME_LEDGER
-                                                || reg->type == SEARCH_LEDGER);
+    arg = SCM_BOOL (model->type == GENERAL_LEDGER2 || model->type == INCOME_LEDGER2
+                                                   || model->type == SEARCH_LEDGER2);
     args = scm_cons (arg, args);
 
-    arg = SCM_BOOL (reg->style == REG_STYLE_JOURNAL);
+    arg = SCM_BOOL (model->style == REG2_STYLE_JOURNAL);
     args = scm_cons (arg, args);
 
     if (!query)
@@ -2515,49 +2267,56 @@
 
 static void
 gnc_plugin_page_register2_cmd_print_check (GtkAction *action,
-        GncPluginPageRegister2 *plugin_page) //FIXME
+        GncPluginPageRegister2 *plugin_page) //FIXME Should work but not tested
 {
     GncPluginPageRegister2Private *priv;
-    SplitRegister * reg;
+    GncTreeViewSplitReg *view;
+    GncTreeModelSplitReg *model;
     Split         * split;
     Transaction   * trans;
     GList         * splits = NULL, *item;
     GNCLedgerDisplay2Type ledger_type;
 
     ENTER("(action %p, plugin_page %p)", action, plugin_page);
-#ifdef SKIP
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
 
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
-    reg = gnc_ledger_display2_get_split_register (priv->ledger);
-    ledger_type = gnc_ledger_display2_type(priv->ledger);
+    g_return_if_fail (GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
+
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    model = gnc_ledger_display2_get_split_model_register (priv->ledger);
+    ledger_type = gnc_ledger_display2_type (priv->ledger);
+
+//FIXME  'gnc_ui_print_check_dialog_create' uses 'GncPluginPageRegister' so this will need to wait
+//        for when we change the type back or I add a new function to dialog-print-check using
+//        'GncPluginPageRegister2'
+#ifdef skip
     if (ledger_type == LD2_SINGLE || ledger_type == LD2_SUBACCOUNT)
     {
-        split    = gnc_split_register_get_current_split(reg);
-        trans    = xaccSplitGetParent(split);
+        split = gnc_tree_view_split_reg_get_current_split (view);
+        trans = xaccSplitGetParent (split);
 
         if (split && trans)
         {
-            splits = g_list_append(splits, split);
-            gnc_ui_print_check_dialog_create(plugin_page, splits);
-            g_list_free(splits);
+            splits = g_list_append (splits, split);
+            gnc_ui_print_check_dialog_create (plugin_page, splits);
+            g_list_free (splits);
         }
     }
-    else if (ledger_type == LD2_GL && reg->type == SEARCH_LEDGER)
+    else if (ledger_type == LD2_GL && model->type == SEARCH_LEDGER2)
     {
         Account *common_acct = NULL, *account;
-        splits = qof_query_run(gnc_ledger_display2_get_query(priv->ledger));
+        splits = qof_query_run (gnc_ledger_display2_get_query (priv->ledger));
         /* Make sure each split is from the same account */
-        for (item = splits; item; item = g_list_next(item))
+        for (item = splits; item; item = g_list_next (item))
         {
             split = (Split *) item->data;
             if (common_acct == NULL)
             {
-                common_acct = xaccSplitGetAccount(split);
+                common_acct = xaccSplitGetAccount (split);
             }
             else
             {
-                if (xaccSplitGetAccount(split) != common_acct)
+                if (xaccSplitGetAccount (split) != common_acct)
                 {
                     GtkWidget *dialog, *window;
                     gint response;
@@ -2566,18 +2325,18 @@
                         _("This search result contains splits from more than one account. "
                           "Do you want to print the checks even though they are not all "
                           "from the same account?");
-                    window = gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(plugin_page));
-                    dialog = gtk_message_dialog_new(GTK_WINDOW(window),
+                    window = gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page));
+                    dialog = gtk_message_dialog_new (GTK_WINDOW (window),
                                                     GTK_DIALOG_DESTROY_WITH_PARENT,
                                                     GTK_MESSAGE_WARNING,
                                                     GTK_BUTTONS_CANCEL,
                                                     "%s", title);
-                    gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
+                    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                             "%s", message);
-                    gtk_dialog_add_button(GTK_DIALOG(dialog), _("_Print checks"),
+                    gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Print checks"),
                                           GTK_RESPONSE_YES);
-                    response = gnc_dialog_run(GTK_DIALOG(dialog), "print_multi_acct_checks");
-                    gtk_widget_destroy(dialog);
+                    response = gnc_dialog_run (GTK_DIALOG (dialog), "print_multi_acct_checks");
+                    gtk_widget_destroy (dialog);
                     if (response != GTK_RESPONSE_YES)
                     {
                         LEAVE("Multiple accounts");
@@ -2587,11 +2346,11 @@
                 }
             }
         }
-        gnc_ui_print_check_dialog_create(plugin_page, splits);
+        gnc_ui_print_check_dialog_create (plugin_page, splits);
     }
     else
     {
-        gnc_error_dialog(gnc_plugin_page_get_window(GNC_PLUGIN_PAGE(plugin_page)), "%s",
+        gnc_error_dialog (gnc_plugin_page_get_window (GNC_PLUGIN_PAGE (plugin_page)), "%s",
                          _("You can only print checks from a bank account register or search results."));
         LEAVE("Unsupported ledger type");
         return;
@@ -2677,7 +2436,7 @@
 
 static void
 gnc_plugin_page_register2_cmd_edit_account (GtkAction *action,
-        GncPluginPageRegister2 *page)
+        GncPluginPageRegister2 *page) //this works
 {
     Account *account;
 
@@ -2692,7 +2451,7 @@
 
 static void
 gnc_plugin_page_register2_cmd_find_transactions (GtkAction *action,
-        GncPluginPageRegister2 *page)
+        GncPluginPageRegister2 *page) //FIXME see below
 {
     GncPluginPageRegister2Private *priv;
 
@@ -2774,17 +2533,27 @@
     view = gnc_ledger_display2_get_split_view_register (priv->ledger);
     trans = gnc_tree_view_split_reg_get_current_trans (view);
     if (trans == NULL)
+    {
+        LEAVE("trans is NULL");
         return;
+    }
     if (xaccTransHasSplitsInState (trans, VREC))
+    {
+        LEAVE("trans has split in VREC state");
         return;
+    }
     if (xaccTransHasReconciledSplits (trans) || xaccTransHasSplitsInState (trans, CREC))
     {
         gnc_error_dialog (NULL, "%s", _("You cannot void a transaction with reconciled or cleared splits."));
+        LEAVE("trans with reconciled splits");
         return;
     }
 
     if (!gnc_plugin_page_register2_finish_pending (GNC_PLUGIN_PAGE (page)))
+    {
+        LEAVE("finish pending");
         return;
+    }
 
     builder = gtk_builder_new();
     gnc_builder_add_from_file  (builder , "gnc-plugin-page-register2.glade", "Void Transaction");
@@ -2803,6 +2572,7 @@
     /* All done. Get rid of it. */
     gtk_widget_destroy (dialog);
     g_object_unref (G_OBJECT(builder));
+    LEAVE(" ");
 }
 
 static void
@@ -2821,7 +2591,10 @@
     view = gnc_ledger_display2_get_split_view_register (priv->ledger);
     trans = gnc_tree_view_split_reg_get_current_trans (view);
     if (!xaccTransHasSplitsInState (trans, VREC))
+    {
+        LEAVE("trans has split in VREC state");
         return;
+    }
     gnc_tree_control_split_reg_unvoid_current_trans (view);
     LEAVE(" ");
 }
@@ -2861,7 +2634,10 @@
     view = gnc_ledger_display2_get_split_view_register (priv->ledger);
     trans = gnc_tree_view_split_reg_get_current_trans (view);
     if (trans == NULL)
+    {
+        LEAVE("trans is NULL");
         return;
+    }
 
     qof_event_suspend();
 
@@ -2877,72 +2653,17 @@
 /*#################################################################################*/
 
 static void
-gnc_plugin_page_register2_cmd_view_sort_by (GtkAction *action,
-        GncPluginPageRegister2 *page)
-{
-    GncPluginPageRegister2Private *priv;
-    GtkWidget *dialog, *button;
-    GtkBuilder *builder;
-    SortType sort;
-    const gchar *name;
-    gchar *title;
-
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(page));
-    ENTER("(action %p, page %p)", action, page);
-
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(page);
-    if (priv->sd.dialog)
-    {
-        gtk_window_present(GTK_WINDOW(priv->sd.dialog));
-        LEAVE("existing dialog");
-        return;
-    }
-
-    /* Create the dialog */
-
-    builder = gtk_builder_new();
-    gnc_builder_add_from_file  (builder, "gnc-plugin-page-register2.glade", "Sort By");
-    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Sort By"));
-    priv->sd.dialog = dialog;
-    gtk_window_set_transient_for(GTK_WINDOW(dialog),
-                                 gnc_window_get_gtk_window(GNC_WINDOW(GNC_PLUGIN_PAGE(page)->window)));
-    /* Translations: The %s is the name of the plugin page */
-    title = g_strdup_printf(_("Sort %s by..."),
-                            gnc_plugin_page_get_page_name(GNC_PLUGIN_PAGE(page)));
-    gtk_window_set_title(GTK_WINDOW(dialog), title);
-    g_free(title);
-
-    /* Set the button for the current sort order */
-    sort = gnc_split_reg2_get_sort_type(priv->gsr);
-    name = SortTypeasString(sort);
-    button = GTK_WIDGET(gtk_builder_get_object (builder, name));
-    DEBUG("current sort %d, button %s(%p)", sort, name, button);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
-    priv->sd.original_sort_type = sort;
-
-    button = GTK_WIDGET(gtk_builder_get_object (builder, "sort_save"));
-    if (priv->sd.save_order == TRUE)
-        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
-
-    /* Wire it up */
-    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, page);
-
-    /* Show it */
-    gtk_widget_show(dialog);
-    g_object_unref(G_OBJECT(builder));
-    LEAVE(" ");
-}
-
-static void
 gnc_plugin_page_register2_cmd_view_filter_by (GtkAction *action,
-        GncPluginPageRegister2 *page)
+        GncPluginPageRegister2 *page) //this works
 {
     GncPluginPageRegister2Private *priv;
+    GNCLedgerDisplay2Type ledger_type;
     GtkWidget *dialog, *toggle, *button, *start_date, *end_date, *table, *hbox;
     time64 start_time, end_time, time_val;
     GtkBuilder *builder;
     gboolean sensitive, value;
     Query *query;
+    GList *split_list;
     gchar *title;
     int i;
 
@@ -2985,16 +2706,22 @@
     if (priv->fd.save_filter == TRUE)
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
 
+    // General Ledgers can not save filters so disable button.
+    ledger_type = gnc_ledger_display2_type (priv->ledger);
+    if (ledger_type == LD2_GL)
+       gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
 
     /* Set the date info */
     button = GTK_WIDGET(gtk_builder_get_object (builder, "filter_show_range"));
     query = gnc_ledger_display2_get_query (priv->ledger);
-    xaccQueryGetDateMatchTT(query, &start_time, &end_time);
-    priv->fd.original_start_time = start_time;
-    priv->fd.start_time = start_time;
-    priv->fd.original_end_time = end_time;
-    priv->fd.end_time = end_time;
+    // Lets update the query but do not free the resulting list as it belongs to query.
+    split_list = qof_query_run (query);
 
+    priv->fd.original_start_time = priv->fd.start_time;
+    start_time = priv->fd.start_time;
+    priv->fd.original_end_time = priv->fd.end_time;
+    end_time = priv->fd.end_time;
+
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), start_time || end_time);
     table = GTK_WIDGET(gtk_builder_get_object (builder, "select_range_table"));
     priv->fd.table = table;
@@ -3143,7 +2870,7 @@
 
 static void
 gnc_plugin_page_register2_cmd_transfer (GtkAction *action,
-                                       GncPluginPageRegister2 *page)
+                                       GncPluginPageRegister2 *page) //this works
 {
     Account *account;
     GncWindow *gnc_window;
@@ -3162,7 +2889,7 @@
 
 static void
 gnc_plugin_page_register2_cmd_reconcile (GtkAction *action,
-                                        GncPluginPageRegister2 *page)
+                                        GncPluginPageRegister2 *page) // this works
 {
     Account *account;
     GtkWindow *window;
@@ -3182,7 +2909,7 @@
 
 static void
 gnc_plugin_page_register2_cmd_autoclear (GtkAction *action,
-                                        GncPluginPageRegister2 *page)
+                                        GncPluginPageRegister2 *page) //FIXME What is this?
 {
     Account *account;
     GtkWindow *window;
@@ -3202,7 +2929,7 @@
 
 static void
 gnc_plugin_page_register2_cmd_stock_split (GtkAction *action,
-        GncPluginPageRegister2 *page)
+        GncPluginPageRegister2 *page) // this works
 {
     Account *account;
 
@@ -3217,7 +2944,7 @@
 
 static void
 gnc_plugin_page_register2_cmd_lots (GtkAction *action,
-                                   GncPluginPageRegister2 *page)
+                                   GncPluginPageRegister2 *page) // this works
 {
     Account *account;
 
@@ -3472,7 +3199,7 @@
 
 static void
 gnc_plugin_page_register2_cmd_schedule (GtkAction *action,
-                                       GncPluginPageRegister2 *plugin_page)
+                                       GncPluginPageRegister2 *plugin_page) //FIXME Not setup
 {
     GncPluginPageRegister2Private *priv;
 
@@ -3481,34 +3208,34 @@
     g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
 
     priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
-    gsr2_default_schedule_handler(priv->gsr, NULL);
+//    gsr2_default_schedule_handler(priv->gsr, NULL);
     LEAVE(" ");
 }
 
 static void
 gnc_plugin_page_register2_cmd_scrub_current (GtkAction *action,
-        GncPluginPageRegister2 *plugin_page)
+        GncPluginPageRegister2 *plugin_page) // this works
 {
     GncPluginPageRegister2Private *priv;
+    GncTreeViewSplitReg *view;
     Query *query;
     Account *root;
     Transaction *trans;
-    SplitRegister *reg;
 
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
+    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
 
     ENTER("(action %p, plugin_page %p)", action, plugin_page);
 
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
-    query = gnc_ledger_display2_get_query( priv->ledger );
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
+    query = gnc_ledger_display2_get_query (priv->ledger);
     if (query == NULL)
     {
         LEAVE("no query found");
         return;
     }
 
-    reg = gnc_ledger_display2_get_split_register(priv->ledger);
-    trans = gnc_split_register_get_current_trans(reg);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
+    trans = gnc_tree_view_split_reg_get_current_trans (view);
     if (trans == NULL)
     {
         LEAVE("no trans found");
@@ -3516,16 +3243,16 @@
     }
 
     gnc_suspend_gui_refresh();
-    root = gnc_get_current_root_account();
-    xaccTransScrubOrphans(trans);
-    xaccTransScrubImbalance(trans, root, NULL);
-    gnc_resume_gui_refresh();
+    root = gnc_get_current_root_account ();
+    xaccTransScrubOrphans (trans);
+    xaccTransScrubImbalance (trans, root, NULL);
+    gnc_resume_gui_refresh ();
     LEAVE(" ");
 }
 
 static void
 gnc_plugin_page_register2_cmd_scrub_all (GtkAction *action,
-                                        GncPluginPageRegister2 *plugin_page)
+                                        GncPluginPageRegister2 *plugin_page) // this works
 {
     GncPluginPageRegister2Private *priv;
     Query *query;
@@ -3564,7 +3291,7 @@
 
 static void
 gnc_plugin_page_register2_cmd_account_report (GtkAction *action,
-        GncPluginPageRegister2 *plugin_page)
+        GncPluginPageRegister2 *plugin_page) // this works
 {
     GncPluginPageRegister2Private *priv;
     GncMainWindow *window;
@@ -3584,26 +3311,28 @@
 
 static void
 gnc_plugin_page_register2_cmd_transaction_report (GtkAction *action,
-        GncPluginPageRegister2 *plugin_page)
+        GncPluginPageRegister2 *plugin_page) // this works
 {
     GncPluginPageRegister2Private *priv;
     GncMainWindow *window;
-    SplitRegister *reg;
+    GncTreeViewSplitReg *view;
     Split *split;
     Query *query;
     int id;
 
-
     ENTER("(action %p, plugin_page %p)", action, plugin_page);
 
-    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2(plugin_page));
+    g_return_if_fail(GNC_IS_PLUGIN_PAGE_REGISTER2 (plugin_page));
 
-    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE(plugin_page);
-    reg = gnc_ledger_display2_get_split_register (priv->ledger);
+    priv = GNC_PLUGIN_PAGE_REGISTER2_GET_PRIVATE (plugin_page);
+    view = gnc_ledger_display2_get_split_view_register (priv->ledger);
 
-    split = gnc_split_register_get_current_split (reg);
+    split = gnc_tree_view_split_reg_get_current_split (view);
     if (!split)
+    {
+        LEAVE("split is NULL");
         return;
+    }
 
     query = qof_query_create_for(GNC_ID_SPLIT);
 

Modified: gnucash/trunk/src/gnome/gnc-split-reg2.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-split-reg2.c	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome/gnc-split-reg2.c	2013-03-11 18:08:08 UTC (rev 22827)
@@ -119,27 +119,12 @@
 void gnc_split_reg2_double_line_cb (GtkWidget *w, gpointer data);
 
 
-void gnc_split_reg2_sort_standard_cb (GtkWidget *w, gpointer data);
-void gnc_split_reg2_sort_date_cb (GtkWidget *w, gpointer data);
-void gnc_split_reg2_sort_date_entered_cb (GtkWidget *w, gpointer data);
-void gnc_split_reg2_sort_date_reconciled_cb (GtkWidget *w, gpointer data);
-void gnc_split_reg2_sort_num_cb (GtkWidget *w, gpointer data);
-void gnc_split_reg2_sort_amount_cb (GtkWidget *w, gpointer data);
-void gnc_split_reg2_sort_memo_cb (GtkWidget *w, gpointer data);
-void gnc_split_reg2_sort_desc_cb (GtkWidget *w, gpointer data);
-void gnc_split_reg2_sort_action_cb (GtkWidget *w, gpointer data);
-void gnc_split_reg2_sort_notes_cb (GtkWidget *w, gpointer data);
-
 void gnc_split_reg2_destroy_cb (GtkWidget *widget, gpointer data);
 
 static void gnc_split_reg2_class_init (GNCSplitReg2Class *class);
 static void gnc_split_reg2_init (GNCSplitReg2 *gsr);
 static void gnc_split_reg2_init2 (GNCSplitReg2 *gsr);
 
-#ifdef SKIP
-FROM_STRING_FUNC (SortType, ENUM_LIST_SORTTYPE)
-AS_STRING_FUNC (SortType, ENUM_LIST_SORTTYPE)
-#endif
 
 GType
 gnc_split_reg2_get_type( void )
@@ -264,7 +249,6 @@
 static void
 gnc_split_reg2_init( GNCSplitReg2 *gsr )
 {
-    gsr->sort_type = BY_STANDARD;
     gsr->width = -1;
     gsr->height = -1;
     gsr->numRows = 10;
@@ -941,150 +925,6 @@
 }
 
 static void
-gnc_split_reg2_sort (GNCSplitReg2 *gsr, SortType sort_code)
-{
-    Query *query = gnc_ledger_display2_get_query (gsr->ledger);
-    gboolean show_present_divider = FALSE;
-    GSList *p1 = NULL, *p2 = NULL, *p3 = NULL, *standard;
-    GncTreeModelSplitReg *model;
-
-    if (gsr->sort_type == sort_code)
-        return;
-
-    standard = g_slist_prepend (NULL, QUERY_DEFAULT_SORT);
-
-    switch (sort_code)
-    {
-    case BY_STANDARD:
-        p1 = standard;
-        show_present_divider = TRUE;
-        break;
-    case BY_DATE:
-        p1 = g_slist_prepend (p1, TRANS_DATE_POSTED);
-        p1 = g_slist_prepend (p1, SPLIT_TRANS);
-        p2 = standard;
-        show_present_divider = TRUE;
-        break;
-    case BY_DATE_ENTERED:
-        p1 = g_slist_prepend (p1, TRANS_DATE_ENTERED);
-        p1 = g_slist_prepend (p1, SPLIT_TRANS);
-        p2 = standard;
-        break;
-    case BY_DATE_RECONCILED:
-        p1 = g_slist_prepend (p1, SPLIT_RECONCILE);
-        p2 = g_slist_prepend (p2, SPLIT_DATE_RECONCILED);
-        p3 = standard;
-        break;
-    case BY_NUM:
-        p1 = g_slist_prepend (p1, TRANS_NUM);
-        p1 = g_slist_prepend (p1, SPLIT_TRANS);
-        p2 = standard;
-        break;
-    case BY_AMOUNT:
-        p1 = g_slist_prepend (p1, SPLIT_VALUE);
-        p2 = standard;
-        break;
-    case BY_MEMO:
-        p1 = g_slist_prepend (p1, SPLIT_MEMO);
-        p2 = standard;
-        break;
-    case BY_DESC:
-        p1 = g_slist_prepend (p1, TRANS_DESCRIPTION);
-        p1 = g_slist_prepend (p1, SPLIT_TRANS);
-        p2 = standard;
-        break;
-    case BY_ACTION:
-        p1 = g_slist_prepend (p1, SPLIT_ACTION);
-        p2 = standard;
-        break;
-    case BY_NOTES:
-        p1 = g_slist_prepend (p1, TRANS_NOTES);
-        p1 = g_slist_prepend (p1, SPLIT_TRANS);
-        p2 = standard;
-        break;
-    default:
-        g_slist_free (standard);
-        g_return_if_fail (FALSE);
-        break;
-    }
-
-    qof_query_set_sort_order (query, p1, p2, p3);
-    model = gnc_ledger_display2_get_split_model_register (gsr->ledger);
-    gsr->sort_type = sort_code;
-    gnc_ledger_display2_refresh (gsr->ledger);
-}
-
-void
-gnc_split_reg2_sort_standard_cb (GtkWidget *w, gpointer data)
-{
-    GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort (gsr, BY_STANDARD);
-}
-
-void
-gnc_split_reg2_sort_date_cb (GtkWidget *w, gpointer data)
-{
-    GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort (gsr, BY_DATE);
-}
-
-void
-gnc_split_reg2_sort_date_entered_cb (GtkWidget *w, gpointer data)
-{
-    GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort (gsr, BY_DATE_ENTERED);
-}
-
-void
-gnc_split_reg2_sort_date_reconciled_cb (GtkWidget *w, gpointer data)
-{
-    GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort (gsr, BY_DATE_RECONCILED);
-}
-
-void
-gnc_split_reg2_sort_num_cb (GtkWidget *w, gpointer data)
-{
-    GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort (gsr, BY_NUM);
-}
-
-void
-gnc_split_reg2_sort_amount_cb (GtkWidget *w, gpointer data)
-{
-    GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort (gsr, BY_AMOUNT);
-}
-
-void
-gnc_split_reg2_sort_memo_cb (GtkWidget *w, gpointer data)
-{
-    GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort (gsr, BY_MEMO);
-}
-
-void
-gnc_split_reg2_sort_desc_cb (GtkWidget *w, gpointer data)
-{
-    GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort (gsr, BY_DESC);
-}
-
-void
-gnc_split_reg2_sort_action_cb (GtkWidget *w, gpointer data)
-{
-    GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort (gsr, BY_ACTION);
-}
-
-void
-gnc_split_reg2_sort_notes_cb (GtkWidget *w, gpointer data)
-{
-    GNCSplitReg2 *gsr = data;
-    gnc_split_reg2_sort (gsr, BY_NOTES);
-}
-
-static void
 gnc_split_reg2_record (GNCSplitReg2 *gsr)
 {
 /*FIXME*/
@@ -1387,19 +1227,6 @@
     return gnc_ledger_display2_get_split_view_register (gsr->ledger);
 }
 
-SortType
-gnc_split_reg2_get_sort_type (GNCSplitReg2 *gsr)
-{
-    g_assert (gsr);
-    return gsr->sort_type;
-}
-
-void
-gnc_split_reg2_set_sort_type (GNCSplitReg2 *gsr, SortType t)
-{
-    gnc_split_reg2_sort (gsr, t);
-}
-
 GtkWidget*
 gnc_split_reg2_get_summarybar (GNCSplitReg2 *gsr)
 {

Modified: gnucash/trunk/src/gnome/gnc-split-reg2.h
===================================================================
--- gnucash/trunk/src/gnome/gnc-split-reg2.h	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome/gnc-split-reg2.h	2013-03-11 18:08:08 UTC (rev 22827)
@@ -60,7 +60,6 @@
     GtkWidget *edit_menu;
     GtkWidget *view_menu;
     GtkWidget *style_submenu;
-    GtkWidget *sort_submenu;
     GtkWidget *action_menu;
 
     GtkWidget *double_line_check;
@@ -86,8 +85,6 @@
 
     gint numRows;
 
-    guint sort_type;
-
     gboolean read_only;
 };
 
@@ -108,7 +105,6 @@
 {
     SCHEDULE,
     SPLIT,
-    SORT_ORDER_SUBMENU,
     STYLE_SUBMENU,
 } GNC_SPLIT_REG2_ITEM;
 #endif
@@ -116,32 +112,7 @@
 /*FIXME Note sure about this == Coming from original gnc-split-reg.h */
 typedef GNC_SPLIT_REG_ITEM GNC_SPLIT_REG2_ITEM;
 
-/*FIXME Note sure about this == Coming from original gnc-split-reg.h */
-#ifdef skip
-/* Easy way to pass the sort-type
- * Note that this is STUPID -- we should be using parameter lists,
- * but this provides a simple case statement internally.  This should
- * probably not actually be exposed in the external interface....
- */
-#define ENUM_LIST_SORTTYPE(_) \
-  _(BY_NONE,) \
-  _(BY_STANDARD,) \
-  _(BY_DATE,) \
-  _(BY_DATE_ENTERED,) \
-  _(BY_DATE_RECONCILED,) \
-  _(BY_NUM,) \
-  _(BY_AMOUNT,) \
-  _(BY_MEMO,) \
-  _(BY_DESC,) \
-  _(BY_ACTION,) \
-  _(BY_NOTES,)
 
-DEFINE_ENUM(SortType, ENUM_LIST_SORTTYPE)
-AS_STRING_DEC(SortType, ENUM_LIST_SORTTYPE)
-FROM_STRING_DEC(SortType, ENUM_LIST_SORTTYPE)
-#endif
-
-
 /**
  * GTK-related; gets an identifier for the class of GNCSplitRegs.
  **/
@@ -170,12 +141,6 @@
 GtkWidget *gsr2_create_summary_bar (GNCSplitReg2 *gsr );
 
 /**
- * Gets/sets the sort-type of the GNCSplitReg.
- **/
-SortType gnc_split_reg2_get_sort_type (GNCSplitReg2 *gsr );
-void gnc_split_reg2_set_sort_type (GNCSplitReg2 *gsr, SortType t );
-
-/**
  * Gets/sets the style of the GNCSplitReg.
  **/
 void gnc_split_reg2_change_style (GNCSplitReg2 *gsr, SplitRegisterStyle2 style);

Modified: gnucash/trunk/src/gnome/gtkbuilder/gnc-plugin-page-register2.glade
===================================================================
--- gnucash/trunk/src/gnome/gtkbuilder/gnc-plugin-page-register2.glade	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome/gtkbuilder/gnc-plugin-page-register2.glade	2013-03-11 18:08:08 UTC (rev 22827)
@@ -745,338 +745,6 @@
       <action-widget response="-5">okbutton4</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkDialog" id="Sort By">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="border_width">6</property>
-    <property name="title" translatable="yes">Sort register by...</property>
-    <property name="resizable">False</property>
-    <property name="window_position">center-on-parent</property>
-    <property name="type_hint">dialog</property>
-    <signal name="response" handler="gnc_plugin_page_register2_sort_response_cb" swapped="no"/>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox17">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="spacing">6</property>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area19">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="cancelbutton2">
-                <property name="label">gtk-cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="okbutton2">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkVBox" id="vbox101">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="border_width">12</property>
-            <child>
-              <object class="GtkRadioButton" id="BY_STANDARD">
-                <property name="label" translatable="yes">_Standard Order</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Keep normal account order</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <signal name="toggled" handler="gnc_plugin_page_register2_sort_button_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkHSeparator" id="hseparator2">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="BY_DATE">
-                <property name="label" translatable="yes">_Date</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Sort by date</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <property name="group">BY_STANDARD</property>
-                <signal name="toggled" handler="gnc_plugin_page_register2_sort_button_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="BY_DATE_ENTERED">
-                <property name="label" translatable="yes">Date of _Entry</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Sort by the date of entry</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <property name="group">BY_STANDARD</property>
-                <signal name="toggled" handler="gnc_plugin_page_register2_sort_button_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">3</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="BY_DATE_RECONCILED">
-                <property name="label" translatable="yes">S_tatement Date</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Sort by the statement date (unreconciled items last)</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <property name="group">BY_STANDARD</property>
-                <signal name="toggled" handler="gnc_plugin_page_register2_sort_button_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="BY_NUM">
-                <property name="label" translatable="yes">Num_ber</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Sort by number</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <property name="group">BY_STANDARD</property>
-                <signal name="toggled" handler="gnc_plugin_page_register2_sort_button_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">5</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="BY_AMOUNT">
-                <property name="label" translatable="yes">Amo_unt</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Sort by amount</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <property name="group">BY_STANDARD</property>
-                <signal name="toggled" handler="gnc_plugin_page_register2_sort_button_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">6</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="BY_MEMO">
-                <property name="label" translatable="yes">_Memo</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Sort by memo</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <property name="group">BY_STANDARD</property>
-                <signal name="toggled" handler="gnc_plugin_page_register2_sort_button_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">7</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="BY_DESC">
-                <property name="label" translatable="yes">Descri_ption</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Sort by description</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <property name="group">BY_STANDARD</property>
-                <signal name="toggled" handler="gnc_plugin_page_register2_sort_button_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">8</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="BY_ACTION">
-                <property name="label" translatable="yes">_Action</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Sort by action field</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <property name="group">BY_STANDARD</property>
-                <signal name="toggled" handler="gnc_plugin_page_register2_sort_button_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">9</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRadioButton" id="BY_NOTES">
-                <property name="label" translatable="yes">_Notes</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip_text" translatable="yes">Sort by notes field</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <property name="group">BY_STANDARD</property>
-                <signal name="toggled" handler="gnc_plugin_page_register2_sort_button_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">10</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkHSeparator" id="hseparator1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">11</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">True</property>
-                <property name="position">12</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkHBox" id="hbox1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <child>
-                  <object class="GtkCheckButton" id="sort_save">
-                    <property name="label" translatable="yes">Sa_ve Sort Order</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="use_underline">True</property>
-                    <property name="xalign">1</property>
-                    <property name="draw_indicator">True</property>
-                    <signal name="toggled" handler="gnc_plugin_page_register2_sort_order_save_cb" swapped="no"/>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="padding">6</property>
-                    <property name="pack_type">end</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="expand">True</property>
-                <property name="fill">False</property>
-                <property name="position">14</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">2</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-6">cancelbutton2</action-widget>
-      <action-widget response="-5">okbutton2</action-widget>
-    </action-widgets>
-  </object>
   <object class="GtkDialog" id="Void Transaction">
     <property name="visible">True</property>
     <property name="can_focus">False</property>

Modified: gnucash/trunk/src/gnome/ui/gnc-plugin-page-register2-ui.xml
===================================================================
--- gnucash/trunk/src/gnome/ui/gnc-plugin-page-register2-ui.xml	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome/ui/gnc-plugin-page-register2-ui.xml	2013-03-11 18:08:08 UTC (rev 22827)
@@ -82,7 +82,6 @@
 
   <popup name="MainPopup"                    action="FakeToplevel">
     <placeholder name="PopupPlaceholder1">
-      <menuitem name="ViewSortBy"              action="ViewSortByAction"/>
       <menuitem name="ViewFilterBy"            action="ViewFilterByAction"/>
     </placeholder>
     <placeholder name="PopupPlaceholder2">

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.c	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.c	2013-03-11 18:08:08 UTC (rev 22827)
@@ -48,8 +48,6 @@
 /** Static Globals *******************************************************/
 static QofLogModule log_module = GNC_MOD_LEDGER;
 
-static gboolean gtc_scroll_to_cell (GncTreeViewSplitReg *view);
-static GncTreeModelSplitReg *gtc_get_model_split_reg_from_view (GncTreeViewSplitReg *view);
 
 static SCM copied_item = SCM_UNDEFINED;
 
@@ -92,71 +90,8 @@
 
 
 /*************************************************************************/
-//FIXME For convienience, these functions are duplicates, needs changing
 
-static GncTreeModelSplitReg *
-gtc_get_model_split_reg_from_view (GncTreeViewSplitReg *view)
-{
-    GtkTreeModelSort *s_model = GTK_TREE_MODEL_SORT(
-        gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
-    return GNC_TREE_MODEL_SPLIT_REG (gtk_tree_model_sort_get_model (s_model));
-}
 
-
-/* Scroll the view to show selected row based on sort direction */
-static gboolean
-gtc_scroll_to_cell (GncTreeViewSplitReg *view)
-{
-    GncTreeModelSplitReg *model;
-    GtkTreePath *mpath, *spath;
-
-    model = gtc_get_model_split_reg_from_view (view);
-
-    mpath = gnc_tree_view_split_reg_get_current_path (view);
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
-
-    if (view->sort_direction == 1)
-        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), spath, NULL, TRUE, 0.0, 0.0);
-    else
-    {
-        if (model->use_double_line)
-        {
-            gtk_tree_path_down (spath); // move to the second row of transaction
-            gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), spath, NULL, TRUE, 1.0, 0.0);
-            gtk_tree_path_up (spath); // back to first row of transaction
-        }
-        else
-            gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), spath, NULL, TRUE, 1.0, 0.0);
-    }
-    gtk_tree_path_free (mpath);
-    gtk_tree_path_free (spath);
-    return (FALSE);
-}
-
-
-/* Returns a Split that matches the current Account */
-static Split *
-gtc_get_this_split (GncTreeViewSplitReg *view, Transaction *trans)
-{
-    GncTreeModelSplitReg *model;
-    int i;
-    Split *split = NULL;
-    Account *anchor;
-
-    model = gtc_get_model_split_reg_from_view (view);
-
-    anchor = gnc_tree_model_split_reg_get_anchor (model);
-
-    for (i = 0; (split = xaccTransGetSplit (trans, i)); i++) {
-        if (anchor == xaccSplitGetAccount (split))
-            return split;
-    }
-    return NULL;
-}
-
-
-/*********************************************************************************/
-
 /* Read only dialoue */
 static gboolean
 gtc_is_trans_readonly_and_warn (const Transaction *trans)
@@ -206,7 +141,6 @@
 void
 gnc_tree_control_split_reg_cancel_edit (GncTreeViewSplitReg *view, gboolean reg_closing)
 {
-//g_print("gnc_tree_control_split_reg_cancel_edit\n");
     /* Make sure we have stopped editing */
     gnc_tree_view_split_reg_finish_edit (view);
 
@@ -231,7 +165,7 @@
     const char *message;
     gnc_commodity *txn_com;
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     trans = gnc_tree_view_split_reg_get_current_trans (view);
     expanded = gnc_tree_view_split_reg_trans_expanded (view, NULL);
@@ -392,18 +326,19 @@
     GncTreeModelSplitReg *model;
     GtkTreePath *mpath, *spath;
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, NULL);
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
 
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
+
     gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath);
 
     gtk_tree_path_free (spath);
     gtk_tree_path_free (mpath);
 
     /* scroll when view idle */
-    g_idle_add ((GSourceFunc)gtc_scroll_to_cell, view );
+    g_idle_add ((GSourceFunc)gnc_tree_view_split_reg_scroll_to_cell, view );
 }
 
 
@@ -414,11 +349,14 @@
     GncTreeModelSplitReg *model;
     GtkTreePath *mpath, *spath;
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, split, NULL);
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
 
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
+
+    gnc_tree_view_split_reg_expand_trans (view, xaccSplitGetParent (split));
+
     gnc_tree_view_split_reg_set_current_path (view, spath);
 
     gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath);
@@ -427,7 +365,7 @@
     gtk_tree_path_free (mpath);
 
     /* scroll when view idle */
-    g_idle_add ((GSourceFunc)gtc_scroll_to_cell, view );
+    g_idle_add ((GSourceFunc)gnc_tree_view_split_reg_scroll_to_cell, view );
 }
 
 
@@ -437,7 +375,7 @@
 {
     GncTreeModelSplitReg *model;
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     return gnc_tree_model_split_get_blank_trans (model);
 }
@@ -448,25 +386,28 @@
 gnc_tree_control_split_reg_get_current_trans_split (GncTreeViewSplitReg *view)
 {
     GncTreeModelSplitReg *model;
-    GtkTreePath *path;
-    GtkTreeIter iter;
+    GtkTreePath *mpath;
+    GtkTreeIter m_iter;
     Split *split = NULL;
     Transaction *trans = NULL;
+    Account *anchor;
     gboolean is_trow1, is_trow2, is_split, is_blank;
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
-    path = gnc_tree_view_split_reg_get_current_path (view);
+    mpath = gnc_tree_view_split_reg_get_current_path (view);
 
-    gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+    gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &m_iter, mpath);
 
     gnc_tree_model_split_reg_get_split_and_trans (
-            GNC_TREE_MODEL_SPLIT_REG (model), &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
+            GNC_TREE_MODEL_SPLIT_REG (model), &m_iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
 
-    split = gtc_get_this_split (view, trans);
+    anchor = gnc_tree_model_split_reg_get_anchor (model);
 
-    gtk_tree_path_free (path);
+    split = xaccTransFindSplitByAccount (trans, anchor);
 
+    gtk_tree_path_free (mpath);
+
     return split;
 }
 
@@ -477,7 +418,7 @@
 {
     GncTreeModelSplitReg *model;
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     return gnc_tree_model_split_get_blank_split (model);
 }
@@ -489,35 +430,35 @@
 {
     GncTreeModelSplitReg *model;
     GtkTreePath *mpath, *spath;
-    GtkTreePath *new_path;
+    GtkTreePath *new_spath;
     gint *indices;
 
     ENTER("Move relative, view is %p, relative is %d", view, relative);
 
 //FIXME Do we need to do some checks on relative maybe  -1,0,1 ??
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     mpath = gnc_tree_view_split_reg_get_current_path (view);
 
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
 
     indices = gtk_tree_path_get_indices (spath);
 
-    new_path = gtk_tree_path_new_from_indices (indices[0] + (relative * view->sort_direction), -1);
+    new_spath = gtk_tree_path_new_from_indices (indices[0] + (relative * view->sort_direction), -1);
 
-    gnc_tree_view_split_reg_set_current_path (view, new_path);
+    gnc_tree_view_split_reg_set_current_path (view, new_spath);
 
     gnc_tree_view_split_reg_block_selection (view, TRUE);
     gtk_tree_selection_unselect_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath);
     gnc_tree_view_split_reg_block_selection (view, FALSE);
-    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), new_path);
+    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), new_spath);
 
-    LEAVE("new_path is %s", gtk_tree_path_to_string (new_path));
+    LEAVE("new_spath is %s", gtk_tree_path_to_string (new_spath));
 
-    gtk_tree_path_free (new_path);
+    gtk_tree_path_free (new_spath);
+    gtk_tree_path_free (mpath);
     gtk_tree_path_free (spath);
-    gtk_tree_path_free (mpath);
 }
 
 
@@ -530,7 +471,7 @@
 
     ENTER("view=%p, next_transaction=%s", view, next_transaction ? "TRUE" : "FALSE");
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     goto_blank = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER,
                                     "enter_moves_to_end", NULL);
@@ -812,22 +753,31 @@
         return;
     }
 
-    xaccTransBeginEdit (trans);
+#ifdef skip
 
+//FIXME Test for trans in edit....
+
     gnc_tree_view_split_reg_set_dirty_trans (view, trans);
 
+    xaccTransBeginEdit (trans);
+
     new_trans = xaccTransReverse (trans);
 
+    xaccTransBeginEdit (new_trans);
+
     /* Clear transaction level info */
     xaccTransSetDatePostedSecs (new_trans, gnc_time (NULL));
     xaccTransSetDateEnteredSecs (new_trans, gnc_time (NULL));
 
+    xaccTransCommitEdit (new_trans);
     xaccTransCommitEdit (trans);
 
     gnc_tree_view_split_reg_set_dirty_trans (view, NULL);
 
     /* Now jump to new trans */
-    gnc_tree_control_split_reg_jump_to_split (view, xaccTransGetSplit (new_trans, 0));
+//    gnc_tree_control_split_reg_jump_to_split (view, xaccTransGetSplit (new_trans, 0));
+
+#endif
 }
 
 
@@ -845,14 +795,14 @@
 
     ENTER("");
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     blank_split = gnc_tree_control_split_reg_get_blank_split (view);
     split = gnc_tree_view_split_reg_get_current_split (view);
     trans_split = gnc_tree_control_split_reg_get_current_trans_split (view);
     trans = gnc_tree_view_split_reg_get_current_trans (view);
     depth = gnc_tree_view_reg_get_selected_row_depth (view);
-
+#ifdef skip
     /* This shouldn't happen, but be paranoid. */
     if (trans == NULL)
     {
@@ -861,7 +811,10 @@
     }
 
     if (gtc_is_trans_readonly_and_warn (trans))
+    {
+        LEAVE("read only transaction");
         return FALSE;
+    }
 
     /* Make sure we have stopped editing */
     gnc_tree_view_split_reg_finish_edit (view);
@@ -946,6 +899,7 @@
             gnc_error_dialog (window, "%s",
                          _("This is the split anchoring this transaction to the register."
                            " You can not duplicate it from this register window."));
+            LEAVE("split anchoring this transaction");
             return FALSE;
         }
     }
@@ -1003,6 +957,7 @@
                 gtk_widget_destroy (dialog);
 
                 g_date_free (readonly_threshold);
+                LEAVE("entered date older than read-only threshold");
                 return FALSE;
             }
             g_date_free (readonly_threshold);
@@ -1017,9 +972,10 @@
         xaccTransCommitEdit (new_trans);
     }
 
+
     /* Refresh the GUI. */
     gnc_resume_gui_refresh ();
-
+#endif
     LEAVE(" ");
     return TRUE;
 }
@@ -1054,7 +1010,7 @@
     if (reg_closing)
         view->reg_closing = TRUE;
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     blank_split = gnc_tree_control_split_reg_get_blank_split (view);
     pending_trans = gnc_tree_view_split_reg_get_dirty_trans (view);
@@ -1128,7 +1084,7 @@
                     LEAVE("save cancelled");
                     return TRUE;
                 }
-
+                LEAVE("return to transaction");
                 return FALSE;
             }
 
@@ -1204,10 +1160,10 @@
         xaccSplitSetReconcile (split, rec);
 
         LEAVE("mark split unreconciled");
-        return FALSE;
+        return TRUE;
     }
     LEAVE("Canceled split unreconciled");
-    return TRUE;
+    return FALSE;
 }
 
 
@@ -1224,8 +1180,10 @@
 
     /* This assumes we reset the flag whenever we change splits. */
     if (view->change_allowed)
+    {
+        LEAVE("change allowed is set");
         return TRUE;
-
+    }
     depth = gnc_tree_view_reg_get_selected_row_depth (view);
 
     if (depth == SPLIT3)
@@ -1234,7 +1192,10 @@
         split = gnc_tree_control_split_reg_get_current_trans_split (view);
 
     if (!split)
+    {
+        LEAVE("No split");
         return TRUE;
+    }
 
     trans = xaccSplitGetParent (split);
 
@@ -1278,9 +1239,13 @@
         gtk_widget_destroy (dialog);
 
         if (response != GTK_RESPONSE_YES)
+        {
+            LEAVE("cancel reconciled split");
             return FALSE;
+        }
     }
     view->change_allowed = TRUE;
+    LEAVE(" ");
     return TRUE;
 }
 
@@ -1301,7 +1266,7 @@
 
     g_return_if_fail (GNC_IS_TREE_VIEW_SPLIT_REG (view));
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     from_trans = gnc_tree_view_split_reg_get_current_trans (view);
     if (!from_trans)
@@ -1327,40 +1292,50 @@
     gnc_tree_view_split_reg_delete_current_trans (view);
 }
 
+/* Return the split account for which ancestor is it's parent */
+static Account *
+gtc_trans_get_account_for_splits_ancestor (const Transaction *trans, const Account *ancestor)
+{
+    GList *node;
+
+    for (node = xaccTransGetSplitList (trans); node; node = node->next)
+    {
+        Split *split = node->data;
+        Account *split_acc = xaccSplitGetAccount(split);
+
+        if (!xaccTransStillHasSplit(trans, split))
+            continue;
+
+        if (ancestor && xaccAccountHasAncestor(split_acc, ancestor))
+            return split_acc;
+    }
+    return NULL;
+}
+
 void
 gnc_tree_control_split_reg_copy_trans (GncTreeViewSplitReg *view)
 {
     GncTreeModelSplitReg *model;
     Transaction *from_trans;
+    Account *from_acc, *anchor;
 
     g_return_if_fail (GNC_IS_TREE_VIEW_SPLIT_REG (view));
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     from_trans = gnc_tree_view_split_reg_get_current_trans (view);
     if (!from_trans)
         return;
 
-    //FIXME You can not copy from a sub account register, is this too simplistic
-    //      May be we should search for anchor as a parent of splits to identify
-    //      the correct anchor for this transaction ?
-    if (gnc_tree_model_split_reg_get_sub_account (model))
-    {
-        GtkWidget *window;
+    anchor = gnc_tree_model_split_reg_get_anchor (model);
 
-        window = gnc_tree_view_split_reg_get_parent (view);
-        gnc_error_dialog (window, "%s",
-                         _("You can not copy from a sub account register."));
-        return;
-    }
+    clipboard_acct = gtc_trans_get_account_for_splits_ancestor (from_trans, anchor);
 
     xaccTransBeginEdit (clipboard_trans);
     if (clipboard_trans)
         xaccTransDestroy (clipboard_trans);
 
     clipboard_trans = xaccTransCopyToClipBoard (from_trans);
-
-    clipboard_acct = gnc_tree_model_split_reg_get_anchor (model);
 }
 
 void
@@ -1372,7 +1347,7 @@
 
     g_return_if_fail (GNC_IS_TREE_VIEW_SPLIT_REG (view));
 
-    model = gtc_get_model_split_reg_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
     anchor_acct = gnc_tree_model_split_reg_get_anchor (model);
 
     to_trans = gnc_tree_view_split_reg_get_current_trans (view);
@@ -1406,7 +1381,7 @@
     // Remove the blank split
     gnc_tree_model_split_reg_set_blank_split_parent (model, to_trans, TRUE);
 
-    xaccTransCopyFromClipBoard (clipboard_trans, to_trans, clipboard_acct, anchor_acct);
+    xaccTransCopyFromClipBoard (clipboard_trans, to_trans, clipboard_acct, anchor_acct, FALSE);
 
     // Add the blank split back
     gnc_tree_model_split_reg_set_blank_split_parent (model, to_trans, FALSE);
@@ -1415,7 +1390,48 @@
     g_signal_emit_by_name (model, "refresh_view", NULL);
 }
 
+void
+gnc_tree_control_auto_complete (GncTreeViewSplitReg *view, Transaction *trans,  const gchar *new_text)
+{
+    GncTreeModelSplitReg *model;
+    Transaction          *btrans, *dirty_trans;
+    GtkListStore         *desc_list;
+    GtkTreeIter           iter;
+    gboolean              valid;
 
+    g_return_if_fail (GNC_IS_TREE_VIEW_SPLIT_REG (view));
+    DEBUG("auto_complete - trans %p and description '%s'", trans, new_text);
+
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
+
+    btrans = gnc_tree_model_split_get_blank_trans (model);
+
+    // if we are not looking at the blank trans, return.
+    if (trans != btrans)
+       return;
+
+    desc_list = gnc_tree_model_split_reg_get_description_list (model);
+
+    valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (desc_list), &iter);
+    while (valid)
+    {
+        Transaction *trans_from;
+        gchar *text;
+        // Walk through the list, reading each row
+        gtk_tree_model_get (GTK_TREE_MODEL (desc_list), &iter, 0, &text, 1, &trans_from, -1);
+
+        if (g_strcmp0 (text, new_text) == 0)
+        {
+            xaccTransCopyOnto (trans_from, trans);
+            g_free(text);
+            break;
+        }
+        g_free(text);
+
+        valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (desc_list), &iter);
+    }
+}
+
 /*****************************************************************************
  *                             Sort Functions                                *
  *****************************************************************************/
@@ -1449,49 +1465,67 @@
     gnc_gconf_set_int (gconf_section, "sort_depth", view->sort_depth, NULL);
 
     LEAVE("sort_col %d, sort_direction is %d  sort_depth is %d", view->sort_col, view->sort_direction, view->sort_depth );
+}
 
+
+static GtkTreeModel *
+gtc_sort_cb_filter_iters (GtkTreeModel *f_model,
+                       GtkTreeIter *f_iter_a,
+                       GtkTreeIter *f_iter_b,
+                       GtkTreeIter *iter_a,
+                       GtkTreeIter *iter_b)
+{
+    GtkTreeModel *model;
+
+    model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (f_model));
+    gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model), iter_a, f_iter_a);
+    gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model), iter_b, f_iter_b);
+    return model;
 }
 
 
 /* Sort function for Date column */
 gint
-gnc_tree_control_split_reg_sort_by_date (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+gnc_tree_control_split_reg_sort_by_date (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
                   gpointer user_data)
 {
-    GncTreeModelSplitReg *model  = GNC_TREE_MODEL_SPLIT_REG (tm);
+    GncTreeModelSplitReg *model;
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
-    GList *tnode;
-    Transaction *transa, *transb;
+    GtkTreeIter *ma = gtk_tree_iter_copy (fa);
+    GtkTreeIter *mb = gtk_tree_iter_copy (fb);
+    GList *tnodea, *tnodeb;
     int depth;
     time64 i, j;
     int retval;
 
-    if (gnc_tree_model_split_reg_is_blank_trans (model, a)) return 1;
-    if (gnc_tree_model_split_reg_is_blank_trans (model, b)) return -1;
+    model = GNC_TREE_MODEL_SPLIT_REG (gtc_sort_cb_filter_iters (fm, fa, fb, ma, mb));
 
-    tnode = a->user_data2;
-    transa = tnode->data;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, ma)) return 1;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, mb)) return -1;
 
-    tnode = b->user_data2;
-    transb = tnode->data;
+    tnodea = ma->user_data2;
+    tnodeb = mb->user_data2;
 
     depth = view->sort_depth;
 
+    gtk_tree_iter_free (ma);
+    gtk_tree_iter_free (mb);
+
     switch (depth) {
         case 1: // Date Posted
-        retval = xaccTransOrder (transa, transb);
+        retval = xaccTransOrder (tnodea->data, tnodeb->data);
         if (retval)
            return retval;
 
         break;
         case 2: // Date Entered
-        i = xaccTransGetDateEntered (transa);
-        j = xaccTransGetDateEntered (transb);
+        i = xaccTransGetDateEntered (tnodea->data);
+        j = xaccTransGetDateEntered (tnodeb->data);
 
         if ((gint)(i - j) == 0)
         {
-            i = xaccTransGetDate (transb);
-            j = xaccTransGetDate (transa);
+            i = xaccTransGetDate (tnodeb->data);
+            j = xaccTransGetDate (tnodea->data);
         }
 
         return (gint)(i - j);
@@ -1503,35 +1537,38 @@
 
 /* Sort function for Number / Action column */
 gint
-gnc_tree_control_split_reg_sort_by_numact (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+gnc_tree_control_split_reg_sort_by_numact (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
                   gpointer user_data)
 {
-    GncTreeModelSplitReg *model  = GNC_TREE_MODEL_SPLIT_REG (tm);
+    GncTreeModelSplitReg *model;
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
-    GList *tnode;
-    Transaction *transa, *transb;
+    GtkTreeIter *ma = gtk_tree_iter_copy (fa);
+    GtkTreeIter *mb = gtk_tree_iter_copy (fb);
+    GList *tnodea, *tnodeb;
     Account *anchor;
     int depth;
     time64 i, j;
     int na, nb, retval;
     const char *ca, *cb;
 
-    if (gnc_tree_model_split_reg_is_blank_trans (model, a)) return 1;
-    if (gnc_tree_model_split_reg_is_blank_trans (model, b)) return -1;
+    model = GNC_TREE_MODEL_SPLIT_REG (gtc_sort_cb_filter_iters (fm, fa, fb, ma, mb));
 
-    tnode = a->user_data2;
-    transa = tnode->data;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, ma)) return 1;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, mb)) return -1;
 
-    tnode = b->user_data2;
-    transb = tnode->data;
+    tnodea = ma->user_data2;
+    tnodeb = mb->user_data2;
 
     depth = view->sort_depth;
 
+    gtk_tree_iter_free (ma);
+    gtk_tree_iter_free (mb);
+
     switch (depth) {
         case 1: // Number
 
-        na = atoi (xaccTransGetNum (transa));
-        nb = atoi (xaccTransGetNum (transb));
+        na = atoi (xaccTransGetNum (tnodea->data));
+        nb = atoi (xaccTransGetNum (tnodeb->data));
 
         if (na < nb) return -1;
         if (na > nb) return +1;
@@ -1544,10 +1581,10 @@
 
         if (anchor != NULL)
         {
-            ca = xaccSplitGetAction (xaccTransFindSplitByAccount (transa, anchor))
-               ? xaccSplitGetAction (xaccTransFindSplitByAccount (transa, anchor)) : "";
-            cb = xaccSplitGetAction (xaccTransFindSplitByAccount (transb, anchor))
-               ? xaccSplitGetAction (xaccTransFindSplitByAccount (transb, anchor)) : "";
+            ca = xaccSplitGetAction (xaccTransFindSplitByAccount (tnodea->data, anchor))
+               ? xaccSplitGetAction (xaccTransFindSplitByAccount (tnodea->data, anchor)) : "";
+            cb = xaccSplitGetAction (xaccTransFindSplitByAccount (tnodeb->data, anchor))
+               ? xaccSplitGetAction (xaccTransFindSplitByAccount (tnodeb->data, anchor)) : "";
         }
         else
             ca = cb = "Text";
@@ -1563,33 +1600,36 @@
 
 /* Sort function for 'Description / Notes / Memo' column */
 gint
-gnc_tree_control_split_reg_sort_by_dnm (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+gnc_tree_control_split_reg_sort_by_dnm (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
                   gpointer user_data)
 {
-    GncTreeModelSplitReg *model  = GNC_TREE_MODEL_SPLIT_REG (tm);
+    GncTreeModelSplitReg *model;
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
-    Transaction *transa, *transb;
+    GtkTreeIter *ma = gtk_tree_iter_copy (fa);
+    GtkTreeIter *mb = gtk_tree_iter_copy (fb);
+    GList *tnodea, *tnodeb;
     Account *anchor;
-    GList *tnode;
     const char *ca, *cb;
     int depth;
     int retval;
 
-    if (gnc_tree_model_split_reg_is_blank_trans (model, a)) return 1;
-    if (gnc_tree_model_split_reg_is_blank_trans (model, b)) return -1;
+    model = GNC_TREE_MODEL_SPLIT_REG (gtc_sort_cb_filter_iters (fm, fa, fb, ma, mb));
 
-    tnode = a->user_data2;
-    transa = tnode->data;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, ma)) return 1;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, mb)) return -1;
 
-    tnode = b->user_data2;
-    transb = tnode->data;
+    tnodea = ma->user_data2;
+    tnodeb = mb->user_data2;
 
     depth = view->sort_depth;
 
+    gtk_tree_iter_free (ma);
+    gtk_tree_iter_free (mb);
+
     switch (depth) {
         case 1: // Description
-        ca = xaccTransGetDescription (transa) ? xaccTransGetDescription (transa) : "";
-        cb = xaccTransGetDescription (transb) ? xaccTransGetDescription (transb) : "";
+        ca = xaccTransGetDescription (tnodea->data) ? xaccTransGetDescription (tnodea->data) : "";
+        cb = xaccTransGetDescription (tnodeb->data) ? xaccTransGetDescription (tnodeb->data) : "";
 
         retval = g_utf8_collate (ca, cb);
         if (retval)
@@ -1597,8 +1637,8 @@
 
         break;
         case 2: // Notes
-        ca = xaccTransGetNotes (transa) ? xaccTransGetNotes (transa) : "";
-        cb = xaccTransGetNotes (transb) ? xaccTransGetNotes (transb) : "";
+        ca = xaccTransGetNotes (tnodea->data) ? xaccTransGetNotes (tnodea->data) : "";
+        cb = xaccTransGetNotes (tnodeb->data) ? xaccTransGetNotes (tnodeb->data) : "";
 
         retval = g_utf8_collate (ca, cb);
         if (retval)
@@ -1610,10 +1650,10 @@
 
         if (anchor != NULL)
         {
-            ca = xaccSplitGetMemo (xaccTransFindSplitByAccount (transa, anchor))
-               ? xaccSplitGetMemo (xaccTransFindSplitByAccount (transa, anchor)) : "";
-            cb = xaccSplitGetMemo (xaccTransFindSplitByAccount (transb, anchor))
-               ? xaccSplitGetMemo (xaccTransFindSplitByAccount (transb, anchor)) : "";
+            ca = xaccSplitGetMemo (xaccTransFindSplitByAccount (tnodea->data, anchor))
+               ? xaccSplitGetMemo (xaccTransFindSplitByAccount (tnodea->data, anchor)) : "";
+            cb = xaccSplitGetMemo (xaccTransFindSplitByAccount (tnodeb->data, anchor))
+               ? xaccSplitGetMemo (xaccTransFindSplitByAccount (tnodeb->data, anchor)) : "";
         }
         else
             ca = cb = "Text";
@@ -1630,38 +1670,39 @@
 
 /* Sort function for Reconcile column */
 gint
-gnc_tree_control_split_reg_sort_by_recn (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+gnc_tree_control_split_reg_sort_by_recn (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
                   gpointer user_data)
 {
-    GncTreeModelSplitReg *model  = GNC_TREE_MODEL_SPLIT_REG (tm);
+    GncTreeModelSplitReg *model;
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
-    GList *tnode;
-    Transaction *transa, *transb;
-
+    GtkTreeIter *ma = gtk_tree_iter_copy (fa);
+    GtkTreeIter *mb = gtk_tree_iter_copy (fb);
+    GList *tnodea, *tnodeb;
     Account *anchor;
     int depth;
-
     int na = 0, nb = 0, retval;
 
-    if (gnc_tree_model_split_reg_is_blank_trans (model, a)) return 1;
-    if (gnc_tree_model_split_reg_is_blank_trans (model, b)) return -1;
+    model = GNC_TREE_MODEL_SPLIT_REG (gtc_sort_cb_filter_iters (fm, fa, fb, ma, mb));
 
-    tnode = a->user_data2;
-    transa = tnode->data;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, ma)) return 1;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, mb)) return -1;
 
-    tnode = b->user_data2;
-    transb = tnode->data;
+    tnodea = ma->user_data2;
+    tnodeb = mb->user_data2;
 
     depth = view->sort_depth;
 
+    gtk_tree_iter_free (ma);
+    gtk_tree_iter_free (mb);
+
     anchor = gnc_tree_model_split_reg_get_anchor (model);
 
     if (anchor != NULL)
     {
         Split *splita, *splitb;
 
-        splita = xaccTransFindSplitByAccount (transa, anchor);
-        splitb = xaccTransFindSplitByAccount (transb, anchor);
+        splita = xaccTransFindSplitByAccount (tnodea->data, anchor);
+        splitb = xaccTransFindSplitByAccount (tnodeb->data, anchor);
 
         switch (xaccSplitGetReconcile (splita))
         {
@@ -1710,9 +1751,136 @@
         if (na < nb) return -1;
         if (na > nb) return +1;
 
-        retval = xaccTransOrder (transa, transb);
+        retval = xaccTransOrder (tnodea->data, tnodeb->data);
         if (retval)
            return retval;
     }
     return 0;
 }
+
+
+/* Sort function for transfer column */
+gint
+gnc_tree_control_split_reg_sort_by_account (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
+                  gpointer user_data)
+{
+    GncTreeModelSplitReg *model;
+    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
+    GtkTreeIter *ma = gtk_tree_iter_copy (fa);
+    GtkTreeIter *mb = gtk_tree_iter_copy (fb);
+    GList *tnodea, *tnodeb;
+    Account *anchor, *accounta, *accountb;
+    Split *splita, *splitb;
+    const char *ca, *cb;
+    int depth;
+    int retval;
+
+    model = GNC_TREE_MODEL_SPLIT_REG (gtc_sort_cb_filter_iters (fm, fa, fb, ma, mb));
+
+    if (gnc_tree_model_split_reg_is_blank_trans (model, ma)) return 1;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, mb)) return -1;
+
+    tnodea = ma->user_data2;
+    tnodeb = mb->user_data2;
+
+    depth = view->sort_depth;
+
+    gtk_tree_iter_free (ma);
+    gtk_tree_iter_free (mb);
+
+    anchor = gnc_tree_model_split_reg_get_anchor (model);
+
+    switch (depth) {
+        case 1: // Account Transfer
+        if (xaccTransCountSplits (tnodea->data) > 2) return 1;
+        if (xaccTransCountSplits (tnodeb->data) > 2) return -1;
+
+        if (anchor != NULL) // Registers and sub accounts.
+        {
+            // Get the split parent who has anchor as a parent, think of sub accounts.
+            accounta = gtc_trans_get_account_for_splits_ancestor (tnodea->data, anchor);
+            accountb = gtc_trans_get_account_for_splits_ancestor (tnodeb->data, anchor);
+
+            // Get the other split parent account.
+            splita = xaccSplitGetOtherSplit (xaccTransFindSplitByAccount(tnodea->data, accounta));
+            splitb = xaccSplitGetOtherSplit (xaccTransFindSplitByAccount(tnodeb->data, accountb));
+        }
+        else // General Ledger
+        {
+            // Get the first split in the transaction.
+            splita = xaccTransGetSplit (tnodea->data, 0);
+            splitb = xaccTransGetSplit (tnodeb->data, 0);
+        }
+
+        // Sort on split accounts.
+        retval = xaccAccountOrder (xaccSplitGetAccount (splita), xaccSplitGetAccount (splitb));
+        if (retval)
+            return retval;
+        break;
+
+        case 2: // Void Reason
+            ca = xaccTransGetVoidReason (tnodea->data) ? xaccTransGetVoidReason (tnodea->data) : "";
+            cb = xaccTransGetVoidReason (tnodeb->data) ? xaccTransGetVoidReason (tnodeb->data) : "";
+
+            retval = g_utf8_collate (ca, cb);
+            if (retval)
+               return retval;
+        break;
+    }
+    return 0;
+}
+
+
+/* Sort function for debit / credit column */
+gint
+gnc_tree_control_split_reg_sort_by_value (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
+                  gpointer user_data)
+{
+    GncTreeModelSplitReg *model;
+    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
+    GtkTreeIter *ma = gtk_tree_iter_copy (fa);
+    GtkTreeIter *mb = gtk_tree_iter_copy (fb);
+    GList *tnodea, *tnodeb;
+    Account *anchor, *accounta, *accountb;
+    int depth;
+    int na = 0, nb = 0, retval;
+    gnc_numeric numa, numb;
+
+    model = GNC_TREE_MODEL_SPLIT_REG (gtc_sort_cb_filter_iters (fm, fa, fb, ma, mb));
+
+    if (gnc_tree_model_split_reg_is_blank_trans (model, ma)) return 1;
+    if (gnc_tree_model_split_reg_is_blank_trans (model, mb)) return -1;
+
+    tnodea = ma->user_data2;
+    tnodeb = mb->user_data2;
+
+    depth = view->sort_depth;
+
+    gtk_tree_iter_free (ma);
+    gtk_tree_iter_free (mb);
+
+    anchor = gnc_tree_model_split_reg_get_anchor (model);
+
+    if (anchor != NULL) // Registers and sub accounts.
+    {
+        // Get the split parent who has anchor as a parent, think of sub accounts.
+        accounta = gtc_trans_get_account_for_splits_ancestor (tnodea->data, anchor);
+        accountb = gtc_trans_get_account_for_splits_ancestor (tnodeb->data, anchor);
+    }
+    else // General ledger
+    {
+        // Get the account of the first split.
+        accounta = xaccSplitGetAccount (xaccTransGetSplit (tnodea->data, 0));
+        accountb = xaccSplitGetAccount (xaccTransGetSplit (tnodeb->data, 0));
+    }
+
+    // Get the value based on accounts.
+    numa = xaccTransGetAccountValue (tnodea->data, accounta);
+    numb = xaccTransGetAccountValue (tnodeb->data, accountb);
+
+    retval = gnc_numeric_compare (numa, numb);
+    if (retval)
+        return retval;
+
+    return 0;
+}

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.h	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-control-split-reg.h	2013-03-11 18:08:08 UTC (rev 22827)
@@ -82,27 +82,38 @@
 /* Paste transaction from clipboard */
 void gnc_tree_control_split_reg_paste_trans (GncTreeViewSplitReg *view);
 
+/* Copy the last transaction with given description to the blank transaction */
+void gnc_tree_control_auto_complete (GncTreeViewSplitReg *view, Transaction *trans,  const gchar *new_text);
+
 /*****************************************************************************/
 
 /* Sort changed callback */
 void gnc_tree_control_split_reg_sort_changed_cb (GtkTreeSortable *sortable, gpointer user_data);
 
 /* Sort by date */
-gint gnc_tree_control_split_reg_sort_by_date (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
+gint gnc_tree_control_split_reg_sort_by_date (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
                        gpointer user_data);
 
 /* Sort by Description / Notes / Memo */
-gint gnc_tree_control_split_reg_sort_by_dnm (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
+gint gnc_tree_control_split_reg_sort_by_dnm (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
                        gpointer user_data);
 
 /* Sort function for Number / Action column */
-gint gnc_tree_control_split_reg_sort_by_numact (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+gint gnc_tree_control_split_reg_sort_by_numact (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
                   gpointer user_data);
 
 /* Sort function for Reconcile column */
-gint gnc_tree_control_split_reg_sort_by_recn (GtkTreeModel *tm, GtkTreeIter *a, GtkTreeIter *b,
+gint gnc_tree_control_split_reg_sort_by_recn (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
                   gpointer user_data);
 
+/* Sort function for transfer column */
+gint gnc_tree_control_split_reg_sort_by_account (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
+                  gpointer user_data);
+
+/* Sort function for debit / credit column */
+gint gnc_tree_control_split_reg_sort_by_value (GtkTreeModel *fm, GtkTreeIter *fa, GtkTreeIter *fb,
+                  gpointer user_data);
+
 /*****************************************************************************/
 
 G_END_DECLS

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.c	2013-03-11 18:08:08 UTC (rev 22827)
@@ -51,7 +51,8 @@
 {
     REFRESH_VIEW,
     REFRESH_STATUS_BAR,
-    TRANS_DELETE,
+    SELECTION_MOVE_DELETE,
+    SELECTION_MOVE_FILTER,
     LAST_SIGNAL
 };
 
@@ -126,8 +127,9 @@
     GtkListStore *description_list;  // description field autocomplete list
     GtkListStore *notes_list;        // notes field autocomplete list
     GtkListStore *memo_list;         // memo field autocomplete list
-    GtkListStore *num_list;          // number list combo list
+    GtkListStore *num_list;          // number combo list
     GtkListStore *numact_list;       // number / action combo list
+    GtkListStore *account_list;      // Account combo list
 
     gint event_handler_id;
 };
@@ -305,20 +307,32 @@
                      g_cclosure_marshal_VOID__VOID,
                      G_TYPE_NONE, 0);
 
-    gnc_tree_model_split_reg_signals[TRANS_DELETE] =
-        g_signal_new("trans_delete",
+    gnc_tree_model_split_reg_signals[SELECTION_MOVE_DELETE] =
+        g_signal_new("selection_move_delete",
                      G_TYPE_FROM_CLASS (o_class),
                      G_SIGNAL_RUN_FIRST,
-                     G_STRUCT_OFFSET (GncTreeModelSplitRegClass, trans_delete),
+                     G_STRUCT_OFFSET (GncTreeModelSplitRegClass, selection_move_delete),
                      NULL, NULL,
                      g_cclosure_marshal_VOID__POINTER,
                      G_TYPE_NONE,
                      1,
                      G_TYPE_POINTER);
 
+    gnc_tree_model_split_reg_signals[SELECTION_MOVE_FILTER] =
+        g_signal_new("selection_move_filter",
+                     G_TYPE_FROM_CLASS (o_class),
+                     G_SIGNAL_RUN_FIRST,
+                     G_STRUCT_OFFSET (GncTreeModelSplitRegClass, selection_move_filter),
+                     NULL, NULL,
+                     g_cclosure_marshal_VOID__POINTER,
+                     G_TYPE_NONE,
+                     1,
+                     G_TYPE_POINTER);
+
     klass->refresh_view = NULL;
     klass->refresh_status_bar = NULL;
-    klass->trans_delete = NULL;
+    klass->selection_move_delete = NULL;
+    klass->selection_move_filter = NULL;
 }
 
 
@@ -471,11 +485,12 @@
     model->read_only = FALSE;
 
     /* Create the ListStores for the auto completion / combo's */
-    priv->description_list = gtk_list_store_new (1, G_TYPE_STRING);
+    priv->description_list = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
     priv->notes_list = gtk_list_store_new (1, G_TYPE_STRING);
     priv->memo_list = gtk_list_store_new (1, G_TYPE_STRING);
     priv->num_list = gtk_list_store_new (1, G_TYPE_STRING);
     priv->numact_list = gtk_list_store_new (1, G_TYPE_STRING);
+    priv->account_list = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER );
 
     priv->event_handler_id = qof_event_register_handler
                              ((QofEventHandler)gnc_tree_model_split_reg_event_handler, model);
@@ -737,9 +752,12 @@
     case GNC_TREE_MODEL_SPLIT_REG_COL_DESCNOTES:
     case GNC_TREE_MODEL_SPLIT_REG_COL_TRANSVOID:
     case GNC_TREE_MODEL_SPLIT_REG_COL_RECN:
+    case GNC_TREE_MODEL_SPLIT_REG_COL_DEBIT:
+    case GNC_TREE_MODEL_SPLIT_REG_COL_CREDIT:
         return G_TYPE_STRING;
 
     case GNC_TREE_MODEL_SPLIT_REG_COL_RO:
+    case GNC_TREE_MODEL_SPLIT_REG_COL_VIS:
         return G_TYPE_BOOLEAN;
 
     default:
@@ -917,6 +935,101 @@
 }
 
 
+/* Return the split account for which ancestor is it's parent */
+static Account *
+gtm_trans_get_account_for_splits_ancestor (const Transaction *trans, const Account *ancestor)
+{
+    GList *node;
+
+    for (node = xaccTransGetSplitList (trans); node; node = node->next)
+    {
+        Split *split = node->data;
+        Account *split_acc = xaccSplitGetAccount(split);
+
+        if (!xaccTransStillHasSplit(trans, split))
+            continue;
+
+        if (ancestor && xaccAccountHasAncestor(split_acc, ancestor))
+            return split_acc;
+    }
+    return NULL;
+}
+
+
+/* Return FALSE if this row should not be shown */
+static gboolean
+gnc_tree_model_split_reg_get_vis (GncTreeModelSplitReg *model, Transaction *trans, gboolean trow1)
+{
+    GList *tnode, *tnode_last = NULL;
+    gboolean return_value = FALSE;
+    char chars[6];
+    int i = 0;
+    time64 date_posted;
+    Account *account;
+
+    tnode = g_list_find (model->priv->tlist, trans); // row trans
+    tnode_last = g_list_last (model->priv->tlist); // Blank trans
+
+    if (tnode == tnode_last) // Blank trans is always visable.
+       return TRUE;
+
+    // Get the posted date
+    date_posted = xaccTransGetDate (trans);
+
+    // Test for posted date earlier than start date.
+    if ((date_posted < model->filter_start_time) && trow1 == TRUE)
+    {
+        g_signal_emit_by_name (model, "selection_move_filter", trans);
+        return FALSE;
+    }
+
+    // Test for posted date later than end date.
+    if ((model->filter_end_time > 0) && (date_posted > model->filter_end_time) && trow1 == TRUE)
+    {
+        g_signal_emit_by_name (model, "selection_move_filter", trans);
+        return FALSE;
+    }
+
+    // Test for default status flag.
+    if (model->filter_cleared_match == CLEARED_ALL)
+        return TRUE;
+
+    // Test for sub account register, if so, check split accounts against ancestor
+    if (model->priv->display_subacc)
+        account = gtm_trans_get_account_for_splits_ancestor (trans, model->priv->anchor);
+    else
+        account = model->priv->anchor;
+
+     // Test for the status field.
+    if (model->filter_cleared_match & CLEARED_CLEARED)
+        chars[i++] = CREC;
+    if (model->filter_cleared_match & CLEARED_RECONCILED)
+        chars[i++] = YREC;
+    if (model->filter_cleared_match & CLEARED_FROZEN)
+        chars[i++] = FREC;
+    if (model->filter_cleared_match & CLEARED_NO)
+        chars[i++] = NREC;
+    if (model->filter_cleared_match & CLEARED_VOIDED)
+        chars[i++] = VREC;
+    chars[i] = '\0';
+
+    // Loop through splits checking state.
+    for (i = 0; i < 5; i++)
+    {
+        if (xaccTransHasSplitsInStateByAccount (trans, chars[i], account))
+        {
+            return_value = TRUE;
+            break;
+        }
+    }
+
+    if (return_value == FALSE && trow1 == TRUE)
+        g_signal_emit_by_name (model, "selection_move_filter", trans);
+
+    return return_value;
+}
+
+
 /* Return TRUE if this row should be marked read only */
 gboolean
 gnc_tree_model_split_reg_get_read_only (GncTreeModelSplitReg *model, Transaction *trans)
@@ -935,10 +1048,6 @@
     if (model->read_only) // register is read only
         return TRUE;
 
-    /* This may be wrong but I thought it was mentioned on news list that you should not change these */
-    if (model->type == RECEIVABLE_REGISTER2 || model->type == PAYABLE_REGISTER2)
-        return TRUE;
-
     /* Voided Transaction. */
     if (xaccTransHasSplitsInState (trans, VREC))
         return TRUE;
@@ -961,49 +1070,49 @@
 
     gchar *cell_color = NULL;
 
-    if(!model->use_theme_colors)
+    if (!model->use_theme_colors)
     {
-        if(model->use_double_line)
+        if (model->use_double_line)
         {
-            if(model->alt_colors_by_txn)
+            if (model->alt_colors_by_txn)
             {
-                if(num % 2 == 0)
+                if (num % 2 == 0)
                 {
-                    if(is_trow1 || is_trow2)
+                    if (is_trow1 || is_trow2)
                         cell_color = (gchar*)GREENROW;
                 }
                 else 
                 {
-                    if(is_trow1 || is_trow2)
+                    if (is_trow1 || is_trow2)
                         cell_color = (gchar*)TANROW;
                 }
             }
             else
             {
-                if(is_trow1)
+                if (is_trow1)
                     cell_color = (gchar*)GREENROW;
-                else if(is_trow2)
+                else if (is_trow2)
                     cell_color = (gchar*)TANROW;
             }
         }
         else
         {
-            if(num % 2 == 0)
+            if (num % 2 == 0)
             {
-                if(is_trow1)
+                if (is_trow1)
                     cell_color = (gchar*)GREENROW;
-                else if(is_trow2)
+                else if (is_trow2)
                     cell_color = (gchar*)TANROW;
             }
             else
             {
-                if(is_trow1)
+                if (is_trow1)
                     cell_color = (gchar*)TANROW;
-                else if(is_trow2)
+                else if (is_trow2)
                     cell_color = (gchar*)GREENROW;
             }
         }
-        if(is_split)
+        if (is_split)
             cell_color = (gchar*)SPLITROW;
     }
     else
@@ -1022,8 +1131,6 @@
     /* Initializes and sets value to that at column. When done with value,
        g_value_unset() needs to be called to free any allocated memory. */
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
-    GtkTreePath *path;
-    Transaction *trans;
     const GncGUID *guid;
     GList *tnode;
     gint depth, *indices;
@@ -1033,18 +1140,13 @@
     ENTER("model %p, iter %s, col %d", tree_model, iter_to_string (iter), column);
 
     tnode = (GList *) iter->user_data2;
-    trans = (Transaction *) tnode->data;
 
     g_value_init (value, gnc_tree_model_split_reg_get_column_type (tree_model, column));
 
-    path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
-
-    indices = gtk_tree_path_get_indices (path);
-
     switch (column)
     {
     case GNC_TREE_MODEL_SPLIT_REG_COL_GUID:
-        guid = qof_entity_get_guid (QOF_INSTANCE (trans));
+        guid = qof_entity_get_guid (QOF_INSTANCE (tnode->data));
         g_value_set_pointer (value, (gpointer) guid);
         break;
 
@@ -1066,15 +1168,23 @@
     case GNC_TREE_MODEL_SPLIT_REG_COL_RECN:
         break;
 
+    case GNC_TREE_MODEL_SPLIT_REG_COL_DEBIT:
+        break;
+
+    case GNC_TREE_MODEL_SPLIT_REG_COL_CREDIT:
+        break;
+
     case GNC_TREE_MODEL_SPLIT_REG_COL_RO:
-            g_value_set_boolean (value, gnc_tree_model_split_reg_get_read_only (model, trans));
+            g_value_set_boolean (value, gnc_tree_model_split_reg_get_read_only (model, tnode->data));
         break;
 
+    case GNC_TREE_MODEL_SPLIT_REG_COL_VIS:
+            g_value_set_boolean (value, gnc_tree_model_split_reg_get_vis (model, tnode->data, IS_TROW1(iter)));
+        break;
+
     default:
         g_assert_not_reached ();
     }
-
-    gtk_tree_path_free (path);
     LEAVE(" ");
 }
 
@@ -1086,7 +1196,6 @@
        If there is no next iter, FALSE is returned and iter is set to be
        invalid */
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
-    Transaction *trans;
     Split *split;
     SplitList *slist;
     GList *tnode = NULL, *snode = NULL;
@@ -1175,13 +1284,12 @@
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
     GList *tnode = NULL, *snode = NULL;
     gint flags = 0;
-    Transaction *trans;
     Split *split;
     SplitList *slist;
 
     g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (tree_model), FALSE);
     ENTER("model %p, iter %p , parent %s",
-          tree_model, iter, (parent_iter ? iter_to_string(parent_iter) : "(null)"));
+          tree_model, iter, (parent_iter ? iter_to_string (parent_iter) : "(null)"));
 
     if (!parent_iter)
     {
@@ -1326,7 +1434,6 @@
     /* Returns the number of children that iter has. As a special case,
        if iter is NULL, then the number of toplevel nodes is returned.  */
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
-    Transaction *trans;
     GList *tnode;
     int i;
 
@@ -1348,8 +1455,7 @@
     if (IS_TROW2 (iter))
     {
         tnode = iter->user_data2;
-        trans = tnode->data;
-        i = xaccTransCountSplits (trans);
+        i = xaccTransCountSplits (tnode->data);
         if (tnode == model->priv->bsplit_parent_node)
             i++;
     }
@@ -1367,7 +1473,6 @@
 {
     /* Sets iter to be the n'th child of parent, using the given index. 0 > */
     GncTreeModelSplitReg *model = GNC_TREE_MODEL_SPLIT_REG (tree_model);
-    Transaction *trans;
     Split *split;
     SplitList *slist;
     GList *tnode, *snode;
@@ -1416,14 +1521,13 @@
     snode = NULL;
 
     tnode = parent_iter->user_data2;
-    trans = tnode->data;
 
     if (IS_TROW1 (parent_iter) && IS_BLANK (parent_iter))
     {
         flags |= BLANK;
     }
 
-    if (IS_TROW2 (parent_iter) && (n > xaccTransCountSplits (trans)))
+    if (IS_TROW2 (parent_iter) && (n > xaccTransCountSplits (tnode->data)))
     {
         goto fail;
     }
@@ -1433,7 +1537,7 @@
         {
             snode = NULL;
         }
-        else if ((tnode == model->priv->bsplit_parent_node) && (xaccTransCountSplits (trans) == n))
+        else if ((tnode == model->priv->bsplit_parent_node) && (xaccTransCountSplits (tnode->data) == n))
         {
             flags = SPLIT | BLANK;
             snode = model->priv->bsplit_node;
@@ -1441,8 +1545,8 @@
         else
         {
             flags = SPLIT;
-            slist = xaccTransGetSplitList (trans);
-            split = xaccTransGetSplit (trans, n);
+            slist = xaccTransGetSplitList (tnode->data);
+            split = xaccTransGetSplit (tnode->data, n);
             snode = g_list_find (slist, split);
         }
     }
@@ -1789,6 +1893,7 @@
     GtkTreePath *path;
 //    g_assert(VALID_ITER (model, iter));
 
+    ENTER(" ");
     path = gnc_tree_model_split_reg_get_path (GTK_TREE_MODEL (model), iter);
     if (!path)
         PERR ("Null path");
@@ -1802,6 +1907,7 @@
         PERR ("Tried to change with invalid iter.");
 
     gtk_tree_path_free (path);
+    LEAVE(" ");
 }
 
 
@@ -1899,7 +2005,7 @@
     else
         tnode = g_list_find (priv->tlist, trans);
 
-    ENTER("set blank split parent bsplit %p and trans %p and remove_only is %d", priv->bsplit, trans, remove_only);
+    ENTER("set blank split %p parent to trans %p and remove_only is %d", priv->bsplit, trans, remove_only);
 
     bs_parent_node = priv->bsplit_parent_node;
 
@@ -1912,6 +2018,7 @@
             iter = gtm_make_iter (model, SPLIT | BLANK, bs_parent_node, priv->bsplit_node);
             gtm_delete_row_at (model, &iter);
             priv->bsplit_parent_node = NULL;
+
         }
         if (remove_only == FALSE)
         {
@@ -1962,7 +2069,6 @@
 gnc_tree_model_split_reg_commit_blank_split (GncTreeModelSplitReg *model)
 {
     Split *bsplit;
-    Transaction *trans;
     GList *tnode, *snode;
     GtkTreeIter iter;
 
@@ -1972,39 +2078,38 @@
     bsplit = model->priv->bsplit;
 
     if (!tnode || !tnode->data) {
-        PERR("blank split has no trans");
+        LEAVE("blank split has no trans");
         return;
     }
 
-    trans = tnode->data;
-    if (xaccTransGetSplitIndex (trans, bsplit) == -1) {
-        PINFO("blank split has been removed from this trans");
+    if (xaccTransGetSplitIndex (tnode->data, bsplit) == -1) {
+        LEAVE("blank split has been removed from this trans");
         return;
     }
 
-    snode = g_list_find (xaccTransGetSplitList (trans), bsplit);
+    snode = g_list_find (xaccTransGetSplitList (tnode->data), bsplit);
     if (!snode) {
-        PERR("Failed to turn blank split into real split");
+        LEAVE("Failed to turn blank split into real split");
         return;
     }
 
     /* If we haven't set an amount yet, and there's an imbalance, use that. */
     if (gnc_numeric_zero_p (xaccSplitGetAmount (bsplit)))
     {
-        gnc_numeric imbal = gnc_numeric_neg (xaccTransGetImbalanceValue (trans));
+        gnc_numeric imbal = gnc_numeric_neg (xaccTransGetImbalanceValue (tnode->data));
         if (!gnc_numeric_zero_p (imbal))
         {
             gnc_numeric amount, rate;
             Account *acct = xaccSplitGetAccount (bsplit);
             xaccSplitSetValue (bsplit, imbal);
 
-            if (gnc_commodity_equal (xaccAccountGetCommodity (acct), xaccTransGetCurrency (trans)))
+            if (gnc_commodity_equal (xaccAccountGetCommodity (acct), xaccTransGetCurrency (tnode->data)))
             {
                 amount = imbal;
             }
             else
             {
-                rate = xaccTransGetAccountConvRate (trans, acct);
+                rate = xaccTransGetAccountConvRate (tnode->data, acct);
                 amount = gnc_numeric_mul (imbal, rate, xaccAccountGetCommoditySCU (acct), GNC_HOW_RND_ROUND);
             }
             if (gnc_numeric_check (amount) == GNC_ERROR_OK)
@@ -2082,32 +2187,39 @@
 GtkListStore *
 gnc_tree_model_split_reg_get_description_list (GncTreeModelSplitReg *model)
 {
-    g_return_val_if_fail(GNC_IS_TREE_MODEL_SPLIT_REG(model), NULL);
+    g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model), NULL);
     return model->priv->description_list;
 }
 
 GtkListStore *
 gnc_tree_model_split_reg_get_notes_list (GncTreeModelSplitReg *model)
 {
-    g_return_val_if_fail(GNC_IS_TREE_MODEL_SPLIT_REG(model), NULL);
+    g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model), NULL);
     return model->priv->notes_list;
 }
 
 GtkListStore *
 gnc_tree_model_split_reg_get_memo_list (GncTreeModelSplitReg *model)
 {
-    g_return_val_if_fail(GNC_IS_TREE_MODEL_SPLIT_REG(model), NULL);
+    g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model), NULL);
     return model->priv->memo_list;
 }
 
 GtkListStore *
 gnc_tree_model_split_reg_get_numact_list (GncTreeModelSplitReg *model)
 {
-    g_return_val_if_fail(GNC_IS_TREE_MODEL_SPLIT_REG(model), NULL);
+    g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model), NULL);
     return model->priv->numact_list;
 }
 
+GtkListStore *
+gnc_tree_model_split_reg_get_acct_list (GncTreeModelSplitReg *model)
+{
+    g_return_val_if_fail (GNC_IS_TREE_MODEL_SPLIT_REG (model), NULL);
+    return model->priv->account_list;
+}
 
+
 /* Return TRUE if string already exists in the list */
 static gboolean
 gtm_check_for_duplicates (GtkListStore *liststore, const gchar *string)
@@ -2141,44 +2253,45 @@
 {
     GncTreeModelSplitRegPrivate *priv;
     GtkTreeIter d_iter, n_iter, m_iter, num_iter;
-    GList *tlist, *tnode, *slist, *snode;
+    GList *tlist_cpy, *tnode, *slist, *snode;
     int cnt, nSplits;
 
     ENTER(" ");
 
     priv = model->priv;
-    tlist = priv->tlist;
 
+    // Copy the tlist, put it in date order and reverse it.
+    tlist_cpy = g_list_copy (priv->tlist);
+    tlist_cpy = g_list_sort (tlist_cpy, (GCompareFunc)xaccTransOrder );
+    tlist_cpy = g_list_reverse (tlist_cpy);
+
     /* Clear the liststores */
     gtk_list_store_clear (priv->description_list);
     gtk_list_store_clear (priv->notes_list);
     gtk_list_store_clear (priv->num_list);
     gtk_list_store_clear (priv->memo_list);
 
-    for (tnode = tlist; tnode; tnode = tnode->next)
+    for (tnode = tlist_cpy; tnode; tnode = tnode->next)
     {
-        Transaction *trans;
         Split       *split;
         const gchar *string;
 
-        trans = tnode->data;
-
-        nSplits = xaccTransCountSplits (trans);
-        slist = xaccTransGetSplitList (trans);
+        nSplits = xaccTransCountSplits (tnode->data);
+        slist = xaccTransGetSplitList (tnode->data);
     
         /* Add to the Description list */
-        string = xaccTransGetDescription (trans);
+        string = xaccTransGetDescription (tnode->data);
         if(g_strcmp0 (string, ""))
         {
             if(gtm_check_for_duplicates (priv->description_list, string) == FALSE)
             {
                 gtk_list_store_append (priv->description_list, &d_iter);
-                gtk_list_store_set (priv->description_list, &d_iter, 0, string , -1);
+                gtk_list_store_set (priv->description_list, &d_iter, 0, string, 1, tnode->data, -1);
             }
         }
 
         /* Add to the Notes list */
-        string = xaccTransGetNotes (trans);
+        string = xaccTransGetNotes (tnode->data);
         if(g_strcmp0 (string, ""))
         {
             if(gtm_check_for_duplicates (priv->notes_list, string) == FALSE)
@@ -2194,7 +2307,7 @@
          * here so not sure if this is correct; won't get the same 'num' entered
          * by user in a register if book option to use split-action for 'num'
          * field is set */
-        string = gnc_get_num_action (trans, NULL);
+        string = gnc_get_num_action (tnode->data, NULL);
         if(g_strcmp0 (string, ""))
         {
             if(gtm_check_for_duplicates (priv->num_list, string) == FALSE)
@@ -2225,6 +2338,8 @@
             snode = snode->next;
          }
     }
+
+    g_list_free (tlist_cpy);
     DEBUG("desc list is %d long", gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->description_list), NULL));
     DEBUG("notes list is %d long", gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->notes_list), NULL));
     DEBUG("memo list is %d long", gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->memo_list), NULL));
@@ -2234,7 +2349,7 @@
 
 /* Update the model with entries for the Action field */
 void
-gnc_tree_model_split_reg_get_action_list (GncTreeModelSplitReg *model)
+gnc_tree_model_split_reg_update_action_list (GncTreeModelSplitReg *model)
 {
     GncTreeModelSplitRegPrivate *priv;
     GtkListStore *store;
@@ -2373,7 +2488,7 @@
 
 /* Update the model with entries for the Number field ... */
 void
-gnc_tree_model_split_reg_get_num_list (GncTreeModelSplitReg *model)
+gnc_tree_model_split_reg_update_num_list (GncTreeModelSplitReg *model)
 {
     GncTreeModelSplitRegPrivate *priv;
     GtkTreeIter iter, num_iter;
@@ -2402,13 +2517,12 @@
 
 
 /* Return the GtkListstore of Accounts */
-GtkListStore *
-gnc_tree_model_split_reg_get_acct_list (GncTreeModelSplitReg *model)
+void
+gnc_tree_model_split_reg_update_account_list (GncTreeModelSplitReg *model)
 {
     GncTreeModelSplitRegPrivate *priv;
     Account *root;
     Account *acc;
-    GtkListStore *store;
     GtkTreeIter iter;
     GList *accts, *ptr;
     gboolean valid;
@@ -2418,8 +2532,8 @@
 
     priv = model->priv;
 
-    /* Store is short name, full name and account pointer */
-    store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER );
+    /* Clear the liststore, Store is short name, full name and account pointer */
+    gtk_list_store_clear (priv->account_list);
 
     root = gnc_book_get_root_account (gnc_get_current_book());
 /*FIXME This does not look sorted to me, need to look at this */
@@ -2433,15 +2547,12 @@
         {
             fname = gnc_account_get_full_name (acc);
             name = xaccAccountGetName (acc);
-            gtk_list_store_append (store, &iter);
-            gtk_list_store_set (store, &iter, 0, name, 1, fname, 2, acc, -1);
+            gtk_list_store_append (priv->account_list, &iter);
+            gtk_list_store_set (priv->account_list, &iter, 0, name, 1, fname, 2, acc, -1);
             g_free (fname);
         }
     }
-
     g_list_free (accts);
-
-    return store;
 }
 
 
@@ -2609,7 +2720,7 @@
             else if (get_iter (model, trans, NULL, &iter1, &iter2))
             {
                 DEBUG("destroy trans %p (%s)", trans, name);
-                g_signal_emit_by_name (model, "trans_delete", trans);
+                g_signal_emit_by_name (model, "selection_move_delete", trans);
                 gtm_delete_trans (model, trans);
                 g_signal_emit_by_name (model, "refresh_view", NULL);
             }

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.h	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-split-reg.h	2013-03-11 18:08:08 UTC (rev 22827)
@@ -93,13 +93,16 @@
     GNC_TREE_MODEL_SPLIT_REG_COL_DESCNOTES, //4
     GNC_TREE_MODEL_SPLIT_REG_COL_TRANSVOID, //5
     GNC_TREE_MODEL_SPLIT_REG_COL_RECN,      //6
+    GNC_TREE_MODEL_SPLIT_REG_COL_DEBIT,     //7
+    GNC_TREE_MODEL_SPLIT_REG_COL_CREDIT,    //8
 
-    GNC_TREE_MODEL_SPLIT_REG_COL_LAST_VISIBLE = GNC_TREE_MODEL_SPLIT_REG_COL_RECN, //6
+    GNC_TREE_MODEL_SPLIT_REG_COL_LAST_VISIBLE = GNC_TREE_MODEL_SPLIT_REG_COL_CREDIT, //8
 
     /* internal hidden columns */
-    GNC_TREE_MODEL_SPLIT_REG_COL_RO,        //7
+    GNC_TREE_MODEL_SPLIT_REG_COL_RO,        //9
+    GNC_TREE_MODEL_SPLIT_REG_COL_VIS,       //10
 
-    GNC_TREE_MODEL_SPLIT_REG_NUM_COLUMNS    //8
+    GNC_TREE_MODEL_SPLIT_REG_NUM_COLUMNS    //11
 } GncTreeModelSplitRegColumn;
 
 /* typedefs & structures */
@@ -125,7 +128,11 @@
 
     gboolean                     read_only;             /**< register is read only */
 
+    cleared_match_t              filter_cleared_match;  // Status for Filter.
+    time64                       filter_start_time;     // Start time for Filter.
+    time64                       filter_end_time;       // End time for Filter.
 
+
 }GncTreeModelSplitReg;
 
 
@@ -142,8 +149,12 @@
 
     /* This signal is emitted before a transaction delete, the pointer has
        the transaction */
-    void (*trans_delete) (GncTreeModelSplitReg *model, gpointer item);
+    void (*selection_move_delete) (GncTreeModelSplitReg *model, gpointer item);
 
+    /* This signal is emitted before a refilter, the pointer has
+       the transaction */
+    void (*selection_move_filter) (GncTreeModelSplitReg *model, gpointer item);
+
 } GncTreeModelSplitRegClass;
 
 
@@ -201,10 +212,12 @@
 
 GtkListStore * gnc_tree_model_split_reg_get_acct_list (GncTreeModelSplitReg *model);
 
-void gnc_tree_model_split_reg_get_num_list (GncTreeModelSplitReg *model);
+void gnc_tree_model_split_reg_update_num_list (GncTreeModelSplitReg *model);
 
-void gnc_tree_model_split_reg_get_action_list (GncTreeModelSplitReg *model);
+void gnc_tree_model_split_reg_update_action_list (GncTreeModelSplitReg *model);
 
+void gnc_tree_model_split_reg_update_account_list (GncTreeModelSplitReg *model);
+
 void gnc_tree_model_split_reg_update_completion (GncTreeModelSplitReg *model);
 
 

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.c	2013-03-11 18:08:08 UTC (rev 22827)
@@ -64,11 +64,11 @@
 
 static guint gnc_tree_view_split_reg_signals[LAST_SIGNAL] = {0};
 
-static void cdf (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model,
-				GtkTreeIter *iter, gpointer user_data);
+static void cdf (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *s_model,
+				GtkTreeIter *s_iter, gpointer user_data);
 
 static void control_cdf (GtkTreeViewColumn *col, GtkCellRenderer *renderer,
-                                 GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data);
+                                 GtkTreeModel *s_model, GtkTreeIter *s_iter, gpointer user_data);
 
 static void gtv_split_reg_edited_cb (GtkCellRendererText *cell, const gchar *path_string,
                           	const gchar *new_text, gpointer _model);
@@ -83,9 +83,6 @@
 static void gtv_get_editable_start_editing_cb (GtkCellRenderer *cr, GtkCellEditable *editable,
    				const gchar *path, gpointer user_data);
 
-static void get_editable_start_editing_recn_cb (GtkCellRenderer *cr, GtkCellEditable *editable,
-   				const gchar *path, gpointer user_data);
-
 static void gtv_split_reg_editing_canceled_cb (GtkCellRenderer *cr, gpointer user_data);
 
 static void gtv_split_reg_match_selected_cb (GtkEntryCompletion *widget, GtkTreeModel *model,
@@ -94,18 +91,20 @@
 static void gtv_split_reg_changed_cb (GtkCellRendererCombo *widget, gchar *path_string,
                         GtkTreeIter *iter, gpointer user_data); //FIXME This may not be needed
 
-static void gtv_split_reg_trans_delete_cb (GncTreeModelSplitReg *model, gpointer item, gpointer user_data);
+static void gtv_split_reg_selection_move_delete_cb (GncTreeModelSplitReg *model, gpointer item, gpointer user_data);
 
+static void gtv_split_reg_selection_move_filter_cb (GncTreeModelSplitReg *model, gpointer item, gpointer user_data);
+
 static gboolean gtv_split_reg_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data);
 
+static gboolean gtv_split_reg_button_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data);
+
 static gboolean gtv_split_reg_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, gpointer user_data);
 
 static void gtv_split_reg_motion_cb (GtkTreeSelection *sel, gpointer user_data);
 
 static void gtv_split_reg_refresh_cb (GncTreeModelSplitReg *model, gpointer user_data);
 
-static gboolean gtv_scroll_to_cell (GncTreeViewSplitReg *view);
-
 static void gtv_split_reg_double_click_cb (GtkTreeView *treeview,
                                              GtkTreePath       *path,
                                              GtkTreeViewColumn *column,
@@ -113,6 +112,8 @@
 
 
 
+
+
 static gboolean transaction_changed_confirm (GncTreeViewSplitReg *view, Transaction *new_trans);
 
 typedef enum {
@@ -142,6 +143,7 @@
     gchar *pref_name;
     gchar *sizer;
     int visibility_model_col;
+    int always_visible_col;
     void (*edited_cb)(GtkCellRendererText *, const gchar *,
                       const gchar *, gpointer);
     void (*editing_started_cb)(GtkCellRenderer *, GtkCellEditable *,
@@ -153,91 +155,94 @@
 static ColDef all_tree_view_split_reg_columns[] = {
     {COL_DATE, GNC_TREE_MODEL_SPLIT_REG_COL_DATE,
      "Date", "date", "00/00/0000xxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 1,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
      gnc_tree_control_split_reg_sort_by_date},
 
     {COL_DUEDATE, GNC_TREE_MODEL_SPLIT_REG_COL_DUEDATE,
      "Due Date", "duedate", "00/00/0000xxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 1,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_NUMACT, GNC_TREE_MODEL_SPLIT_REG_COL_NUMACT,
      "Num / Act / Act", "numact", "0000xxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 0,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
      gnc_tree_control_split_reg_sort_by_numact},
 
     {COL_DESCNOTES, GNC_TREE_MODEL_SPLIT_REG_COL_DESCNOTES,
      "Description / Notes / Memo", "descnotes", "xxxxxxxxxxxxxxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 1,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
      gnc_tree_control_split_reg_sort_by_dnm},
 
-    {COL_TRANSVOID, -1,
+    {COL_TRANSVOID, GNC_TREE_MODEL_SPLIT_REG_COL_TRANSVOID,
      "Transfer / Void", "transvoid", "xxxxxxxxxxxxxxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 1,
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
+     gnc_tree_control_split_reg_sort_by_account},
 
     {COL_RECN, GNC_TREE_MODEL_SPLIT_REG_COL_RECN,
-     "R", "recn", "x",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     "R", "recn", "xxx",
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 0,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
      gnc_tree_control_split_reg_sort_by_recn},
 
     {COL_TYPE, -1,
      "Type", "type", "x",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 0,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_VALUE, -1,
      "Value", "value", "xxxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 0,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_AMOUNT, -1,
      "Amount", "amount", "xxxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 0,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_AMTVAL, -1,
      "Amount / Value", "amtval", "xxxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 1,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_RATE, -1,
      "Rate", "rate", "xxxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 0,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
     {COL_PRICE, -1,
      "Price", "price", "xxxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 1,
      gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
 
-    {COL_DEBIT, -1,
-     "Debit", "debit", "xxxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
+    {COL_DEBIT, GNC_TREE_MODEL_SPLIT_REG_COL_DEBIT,
+     "Debit", "debit", "xxxxxxxxxx",
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 1,
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
+     gnc_tree_control_split_reg_sort_by_value},
 
-    {COL_CREDIT, -1,
-     "Credit", "credit", "xxxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb, NULL},
+    {COL_CREDIT, GNC_TREE_MODEL_SPLIT_REG_COL_CREDIT,
+     "Credit", "credit", "xxxxxxxxxx",
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 1,
+     gtv_split_reg_edited_cb, gtv_get_editable_start_editing_cb,
+     gnc_tree_control_split_reg_sort_by_value},
 
     {COL_BALANCE, -1,
      "Balance", "balance", "xxxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 0,
      NULL, NULL, NULL},
 
     {COL_STATUS, -1,
      " ", "status", "x",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 1,
      NULL, NULL, NULL},
 
     {COL_COMM, -1,
      "Commodity", "commodity", "xxxxxxx",
-     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS, 0,
      NULL, NULL, NULL},
 };
 
@@ -263,6 +268,7 @@
     gboolean             acct_short_names;    // Use account short names
     gboolean             double_line;         // Use double line mode
     gboolean             expanded;            // Are we expanded to splits
+    gboolean             auto_complete;       // Whether auto complete has run
 
 };
 
@@ -356,20 +362,94 @@
 
     klass->update_signal = NULL;
     klass->help_signal = NULL;
-
 }
 
+/*****************************************************************************/
 
 /* Return the tree model from the tree view */
-static GncTreeModelSplitReg *
-get_split_reg_model_from_view (GncTreeViewSplitReg *view)
+GncTreeModelSplitReg *
+gnc_tree_view_split_reg_get_model_from_view (GncTreeViewSplitReg *view)
 {
-    GtkTreeModelSort *s_model = GTK_TREE_MODEL_SORT(
-        gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
-    return GNC_TREE_MODEL_SPLIT_REG (gtk_tree_model_sort_get_model (s_model));
+    GtkTreeModelSort *s_model = GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
+    GtkTreeModelFilter *f_model = GTK_TREE_MODEL_FILTER (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model)));
+
+    return GNC_TREE_MODEL_SPLIT_REG (gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (f_model)));
 }
 
 
+/* Get the model iter from the view path string */
+static gboolean
+gtv_get_model_iter_from_view_string (GncTreeViewSplitReg *view,
+                                const gchar *path_string, GtkTreeIter *iter)
+{
+    GtkTreeModel *f_model, *s_model;
+    GtkTreeIter f_iter, s_iter;
+
+    s_model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+    f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
+
+    if (!gtk_tree_model_get_iter_from_string (s_model, &s_iter, path_string))
+    {
+        iter = NULL;
+        return FALSE;
+    }
+
+    gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model), &f_iter, &s_iter);
+    gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model), iter, &f_iter);
+    return TRUE;
+}
+
+
+/* Get the model iter from the selection */
+static gboolean
+gtv_get_model_iter_from_selection (GncTreeViewSplitReg *view,
+                              GtkTreeSelection *sel, GtkTreeIter *iter)
+{
+    GtkTreeModel *f_model, *s_model;
+    GtkTreeIter f_iter, s_iter;
+
+    if (gtk_tree_selection_get_selected (sel, &s_model, &s_iter))
+    {
+        f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
+        gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model), &f_iter, &s_iter);
+        gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model), iter, &f_iter);
+        return TRUE;
+    }
+    return FALSE;
+}
+
+
+/* Get sort model path from the model path */
+GtkTreePath *
+gnc_tree_view_split_reg_get_sort_path_from_model_path (GncTreeViewSplitReg *view, GtkTreePath *mpath)
+{
+    GtkTreeModel *f_model, *s_model;
+    GtkTreePath *fpath;
+
+    s_model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+    f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
+
+    fpath = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_FILTER (f_model), mpath);
+
+    return gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model), fpath);
+}
+
+
+/* Forces the entire split register tree to be re-evaluated for visibility. */
+void
+gnc_tree_view_split_reg_refilter (GncTreeViewSplitReg *view)
+{
+    GtkTreeModel *f_model, *s_model;
+
+    g_return_if_fail(GNC_IS_TREE_VIEW_SPLIT_REG(view));
+
+    s_model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+    f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
+    gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (f_model));
+}
+
+/*****************************************************************************/
+
 static void
 gnc_tree_view_split_reg_init (GncTreeViewSplitReg *view)
 {
@@ -381,6 +461,7 @@
     view->reg_closing = FALSE;
     view->priv->fo_handler_id = 0;
     view->sort_depth = 1;
+    view->priv->auto_complete = FALSE;
 
     view->priv->acct_short_names = gnc_gconf_get_bool (GCONF_GENERAL_REGISTER, "show_leaf_account_names", NULL);
 }
@@ -395,13 +476,14 @@
     gnc_leave_return_if_fail (object != NULL);
     gnc_leave_return_if_fail (GNC_IS_TREE_VIEW_SPLIT_REG (object));
 
-    ENTER("split reg view %p", object);
-
     view = GNC_TREE_VIEW_SPLIT_REG (object);
     priv = GNC_TREE_VIEW_SPLIT_REG_GET_PRIVATE (view);
 
     if (priv->disposed)
         return;
+
+    ENTER("split reg view %p", object);
+
     priv->disposed = TRUE;
 
     if(view->priv->current_ref != NULL)
@@ -450,7 +532,7 @@
 
 //g_print("gnc_tree_view_split_reg_refresh_from_gconf\n");
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     model->use_theme_colors = gnc_gconf_get_bool(GCONF_GENERAL_REGISTER,
                               "use_theme_colors", NULL);
@@ -520,7 +602,7 @@
         {
         static ViewCol col_list[] = {
         COL_DATE, COL_NUMACT, COL_DESCNOTES, COL_TRANSVOID, COL_RECN,
-        COL_STATUS, COL_COMM, COL_AMTVAL, COL_PRICE, COL_DEBIT, COL_CREDIT, COL_BALANCE, -1};
+        COL_STATUS, COL_AMTVAL, COL_PRICE, COL_DEBIT, COL_CREDIT, COL_BALANCE, -1};
         return col_list;
         }
         break;
@@ -564,7 +646,7 @@
     int i = 0;
 
     GncTreeModelSplitReg *model;
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     while (col_list && col_list[i] != -1) {
         GList *renderers;
@@ -609,7 +691,8 @@
                 def.modelcol, def.visibility_model_col, def.sort_fn);
         } 
 
-        g_object_set_data (G_OBJECT (col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
+        g_object_set_data (G_OBJECT (col), DEFAULT_VISIBLE, GINT_TO_POINTER (1));
+        g_object_set_data (G_OBJECT (col), ALWAYS_VISIBLE, GINT_TO_POINTER (def.always_visible_col));
 
         renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col));
         g_assert (g_list_length (renderers) == 1);
@@ -652,11 +735,6 @@
     }
     gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), GTK_SELECTION_BROWSE);
 
-    // Default the sorting to date.
-    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(gtk_tree_view_get_model (GTK_TREE_VIEW (view))),
-                                         GNC_TREE_MODEL_SPLIT_REG_COL_DATE,
-                                         GTK_SORT_ASCENDING);
-
     // Connect a call back to update the sort settings.
     g_signal_connect (GTK_TREE_SORTABLE (gtk_tree_view_get_model (GTK_TREE_VIEW (view))),
         "sort-column-changed", G_CALLBACK (gnc_tree_control_split_reg_sort_changed_cb), view);
@@ -666,18 +744,24 @@
 
     g_signal_connect(gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), "changed", G_CALLBACK (gtv_split_reg_motion_cb), view);
 
-    //Add a data-edited property to keep track of transaction edits
+    //Add a data-edited property to keep track of transaction edits.
     g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (FALSE));
 
-    // This is used to move the selected item if the selected transaction is deleted
-    g_signal_connect (G_OBJECT (model), "trans_delete", G_CALLBACK (gtv_split_reg_trans_delete_cb), view);
+    // This is used to move the selected item if the selected transaction is deleted.
+    g_signal_connect (G_OBJECT (model), "selection_move_delete", G_CALLBACK (gtv_split_reg_selection_move_delete_cb), view);
 
-    // This will refresh the view
+    // This is used to move the selected item when we refilter.
+    g_signal_connect (G_OBJECT (model), "selection_move_filter", G_CALLBACK (gtv_split_reg_selection_move_filter_cb), view);
+
+    // This will refresh the view.
     g_signal_connect (G_OBJECT (model), "refresh_view", G_CALLBACK (gtv_split_reg_refresh_cb), view);
 
     // This should be for key navigation, tabbing...
-    g_signal_connect_after (G_OBJECT (view), "key-press-event", G_CALLBACK (gtv_split_reg_key_press_cb), NULL);
+    g_signal_connect (G_OBJECT (view), "key-press-event", G_CALLBACK (gtv_split_reg_key_press_cb), NULL);
 
+    // This should be for mouse buttons...
+    g_signal_connect (G_OBJECT (view), "button_press_event", G_CALLBACK (gtv_split_reg_button_cb), NULL);
+
     return view;
 }
 
@@ -688,34 +772,78 @@
 {
     GncTreeViewSplitRegPrivate *priv;
     GncTreeModelSplitReg *model;
+    GtkTreeModel *f_model, *s_model;
     GtkTreePath *mpath, *spath;
     gint total_num = 0;
 
     ENTER(" ");
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
+
+    s_model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+    f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
+
     priv = view->priv;
 
     total_num = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (model), NULL);
 
     mpath = gtk_tree_row_reference_get_path (view->priv->current_ref);
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
 
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
+
     priv->expanded = FALSE;
 
     {
         if (model->style == REG2_STYLE_JOURNAL)
         {
-            gtk_tree_view_expand_all (GTK_TREE_VIEW (view));
+/* FIXME We need all this with a filter model, not sure if this is a mistake
+   in the model or a timing issue or a bug but with gtk_tree_view_expand_all
+   it crashes if the blank split is not on the blank transaction. */
 
+            GtkTreePath *path;
+            gint *indices;
+            gint index = 0;
+
+            path = gtk_tree_path_new_first ();
+            indices = gtk_tree_path_get_indices (mpath);
+
+            while (index < total_num)
+            {
+                if (view->sort_direction == 1)
+                {
+                    if (index != total_num -1)
+                        gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, TRUE); // all rows a part from last
+                    else if (indices[0] != total_num -1)
+                        gtk_tree_view_expand_to_path (GTK_TREE_VIEW (view), path); // selection not on balnk trans
+                    else
+                        gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, TRUE); // selection on blank trans
+                }
+                else
+                {
+                    if (index > 0)
+                        gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, TRUE); // all rows apart from first
+                    else if (indices[0] != total_num -1)
+                        gtk_tree_view_expand_to_path (GTK_TREE_VIEW (view), path); // selection not on blank trans
+                    else
+                        gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, TRUE); // selection on blank trans
+                }
+
+                gtk_tree_path_next (path); //Next Transaction
+
+                index = index + 1;
+            }
+            gtk_tree_path_free (path);
+
+//FIXME this worked without the filter model -   gtk_tree_view_expand_all (GTK_TREE_VIEW (view));
+
             priv->expanded = TRUE;
 
             /* This updates the plugin page gui */
             if (view->moved_cb)
                 (view->moved_cb)(view, view->moved_cb_data);
 
-            LEAVE("journal foramt");
+            LEAVE("journal format");
             return (FALSE);
         }
 
@@ -789,10 +917,10 @@
 GncTreeViewSplitReg*
 gnc_tree_view_split_reg_new_with_model (GncTreeModelSplitReg *model)
 {
-    GtkTreeModel *s_model;
+    GtkTreeModel        *s_model, *f_model;
     GncTreeViewSplitReg *view;
-    GtkCellRenderer *cr;
-    GtkTreeViewColumn *col;
+    GtkCellRenderer     *cr;
+    GtkTreeViewColumn   *col;
     GtkTreeSelection    *selection;
 
     gtk_rc_parse_string (rc_string);
@@ -800,9 +928,15 @@
     view = g_object_new (gnc_tree_view_split_reg_get_type(), NULL);
     g_object_set (view, "name", "split_reg_tree", NULL);
 
-    s_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (model));
+    // Setup the filter model
+    f_model = gtk_tree_model_filter_new (GTK_TREE_MODEL (model), NULL);
     // do not do this - g_object_unref (G_OBJECT (model));
 
+    // Setup the sort model
+    s_model = gtk_tree_model_sort_new_with_model (f_model);
+    g_object_unref(G_OBJECT(f_model));
+
+    // Connect model to tree view
     gnc_tree_view_set_model (GNC_TREE_VIEW (view), s_model);
     g_object_unref (G_OBJECT (s_model));
 
@@ -815,6 +949,15 @@
 
     gnc_tree_view_split_reg_set_cols (view, gnc_tree_view_split_reg_get_colummn_list (model));
 
+    // Filtering function.
+    gtk_tree_model_filter_set_visible_column (GTK_TREE_MODEL_FILTER (f_model),
+                                              GNC_TREE_MODEL_SPLIT_REG_COL_VIS);
+
+    // Default the sorting to date.
+    gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (s_model),
+                                          GNC_TREE_MODEL_SPLIT_REG_COL_DATE,
+                                          GTK_SORT_ASCENDING);
+
     /* Set default visibilities */
     gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), TRUE);
 
@@ -864,7 +1007,7 @@
 
     ENTER(" ");
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     /* Set the default start position to end of list */
     if (view->priv->current_trans == NULL)
@@ -880,7 +1023,7 @@
 
     new_mpath = gtk_tree_path_new_from_indices (indices[0], -1);
 
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), new_mpath);
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, new_mpath);
 
     DEBUG("default_selection mpath is %s, spath is %s, new path is %s", gtk_tree_path_to_string (mpath),
                                     gtk_tree_path_to_string (spath), gtk_tree_path_to_string (new_mpath));
@@ -896,15 +1039,21 @@
 
     gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath);
 
+    /* Set cursor to new spath */
+    gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), spath, NULL, FALSE);
+
     gtk_tree_path_free (mpath);
     gtk_tree_path_free (spath);
     gtk_tree_path_free (new_mpath);
 
+    /* Refilter the tree view register */
+    gnc_tree_view_split_reg_refilter (view);
+
     /* Set the view format */
     g_idle_add ((GSourceFunc)gnc_tree_view_split_reg_set_format, view);
 
     /* scroll window to show selection when view is idle */
-    g_idle_add ((GSourceFunc)gtv_scroll_to_cell, view );
+    g_idle_add ((GSourceFunc)gnc_tree_view_split_reg_scroll_to_cell, view );
 
     LEAVE(" ");
 }
@@ -916,7 +1065,7 @@
 {
     GncTreeModelSplitReg *model;
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     model->read_only = read_only;
 }
@@ -1231,10 +1380,16 @@
 static Split *
 get_this_split (GncTreeViewSplitReg *view, Transaction *trans)
 {
+    GncTreeModelSplitReg *model;
     int i;
     Split *split = NULL;
     Account *anchor = view->priv->anchor;
 
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
+
+    if (xaccTransCountSplits (trans) == 0)
+        return gnc_tree_model_split_get_blank_split (model);
+
     for (i = 0; (split = xaccTransGetSplit (trans, i)); i++) {
         if (anchor == xaccSplitGetAccount (split))
             return split;
@@ -1423,6 +1578,7 @@
             recalc_value = TRUE;
             break;
         default: /* Cancel */
+            LEAVE(" " );
             return;
         }
     }
@@ -1653,43 +1809,6 @@
 }
 
 
-/* Get the model iter from the view path string */
-static gboolean
-get_model_iter_from_view_string (GncTreeViewSplitReg *view,
-                                const gchar *path_string, GtkTreeIter *iter)
-{
-    GtkTreeModelSort *s_model;
-    GtkTreeIter s_iter;
-
-    s_model = GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view)));
-    if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (s_model), &s_iter, path_string))
-    {
-        iter = NULL;
-        return FALSE;
-    }
-
-    gtk_tree_model_sort_convert_iter_to_child_iter (s_model, iter, &s_iter);
-    return TRUE;
-}
-
-
-/* Get the model iter from the selection */
-static gboolean
-get_model_iter_from_selection (GncTreeViewSplitReg *view,
-                              GtkTreeSelection *sel, GtkTreeIter *iter)
-{
-    GtkTreeModel *s_model;
-    GtkTreeIter s_iter;
-
-    if (gtk_tree_selection_get_selected (sel, &s_model, &s_iter))
-    {
-        gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model), iter, &s_iter);
-        return TRUE;
-    }
-    return FALSE;
-}
-
-
 /* Only allow changes to values if we have valid split accounts */
 static gboolean
 have_account (GncTreeViewSplitReg *view, RowDepth depth, gboolean expanded, Transaction *trans, Split *split)
@@ -1724,7 +1843,8 @@
 {
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
     GncTreeModelSplitReg *model;
-    GtkTreeIter iter;
+    GtkTreeIter m_iter, f_iter;
+    GtkTreeModel *f_model;
     GtkTreePath *mpath, *spath;
     Transaction *trans;
     Split *split;
@@ -1735,18 +1855,21 @@
 
     ENTER("");
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
-    gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model), &iter, s_iter);
+    f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
 
+    gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model), &f_iter, s_iter);
+    gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model), &m_iter, &f_iter);
+
     g_return_if_fail (gnc_tree_model_split_reg_get_split_and_trans (
-                         GNC_TREE_MODEL_SPLIT_REG (model), &iter,
+                         GNC_TREE_MODEL_SPLIT_REG (model), &m_iter,
                           &is_trow1, &is_trow2, &is_split, &is_blank,
                           &split, &trans));
 
-    mpath = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
+    mpath = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &m_iter);
 
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
 
     indices = gtk_tree_path_get_indices (spath);
 
@@ -1770,8 +1893,10 @@
 {
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
     GncTreeModelSplitReg *model;
-    GtkTreeIter iter;
-    GtkTreePath *path, *mpath, *spath;
+    GtkTreeIter m_iter, f_iter;
+    GtkTreeModel *f_model;
+    GtkTreePath *mpath, *spath;
+    GtkTreePath *path;
     ViewCol viewcol;
     Transaction *trans;
     Split *split;
@@ -1792,20 +1917,23 @@
 
     ENTER("");
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
-    gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model), &iter, s_iter);
+    f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
 
+    gtk_tree_model_sort_convert_iter_to_child_iter (GTK_TREE_MODEL_SORT (s_model), &f_iter, s_iter);
+    gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (f_model), &m_iter, &f_iter);
+
     viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "view_column"));
 
     g_return_if_fail (gnc_tree_model_split_reg_get_split_and_trans (
-                         GNC_TREE_MODEL_SPLIT_REG (model), &iter,
+                         GNC_TREE_MODEL_SPLIT_REG (model), &m_iter,
                           &is_trow1, &is_trow2, &is_split, &is_blank,
                           &split, &trans));
 
-    mpath = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
+    mpath = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &m_iter);
 
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
 
     depth = gtk_tree_path_get_depth (spath);
 
@@ -1820,7 +1948,7 @@
     g_object_set (cell, "cell-background", row_color, (gchar*)NULL);
 
     /* Get the read only model setting */
-    gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, GNC_TREE_MODEL_SPLIT_REG_COL_RO, &read_only, -1);
+    gtk_tree_model_get (GTK_TREE_MODEL (model), &m_iter, GNC_TREE_MODEL_SPLIT_REG_COL_RO, &read_only, -1);
 
     /* Are we being edited in other register */
     if (xaccTransIsOpen (trans) && (view->priv->dirty_trans != trans))
@@ -1833,7 +1961,7 @@
     if (is_trow1 || is_trow2)
     {
         num_of_splits = xaccTransCountSplits (trans);
-        path = gtk_tree_model_get_path (s_model, s_iter);
+        path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &m_iter);
         if (is_trow1)
             gtk_tree_path_down (path); /* Move the path down to trow2 */
         expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path);
@@ -1932,21 +2060,28 @@
         if (is_trow1)
             /* Get per book option */
             s = gnc_get_num_action (trans, get_this_split (view, trans));
-        else if (is_trow2 && (qof_book_use_split_action_for_num_field (gnc_get_current_book())))
+
+        else if (is_trow2 && expanded)
+        {
             /* Get per book option */
-            s = gnc_get_action_num (trans, get_this_split (view, trans));
-        else if (is_trow2 && !expanded && (!qof_book_use_split_action_for_num_field (gnc_get_current_book())))
+            if (qof_book_use_split_action_for_num_field (gnc_get_current_book()))
+                s = gnc_get_action_num (trans, get_this_split (view, trans));
+            else
+                s = "";
+            editable = FALSE;
+        }
+        else if (is_trow2 && !expanded)
+        {
             /* Get per book option */
-            s = gnc_get_action_num (trans, get_this_split (view, trans));
+            if (get_this_split (view, trans) != NULL) // Blank split of blank trans is not child of trans yet.
+               s = gnc_get_action_num (trans, get_this_split (view, trans));
+            else
+               s = "";
+        }
         else if (is_split)
             /* Get split-action with gnc_get_num_action which is the same as
              * xaccSplitGetAction with these arguments */
             s = gnc_get_num_action (NULL, split);
-        else
-        {
-            s = "";
-            editable = FALSE;
-        }
 
         editable = (read_only == TRUE) ? FALSE : editable;
 
@@ -2459,7 +2594,7 @@
 //g_print("\n\nstart_edit\n");
 /*FIXME Not sure if this is required, leave for now ? */
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     gtv_get_editable_start_editing_cb (cr, editable, path_string, user_data);
 /*    g_signal_connect(G_OBJECT(editable), "editing-done", (GCallback) editing_done_cb, view); */
@@ -2652,10 +2787,10 @@
 
 
 /* Explain: GtkEntry has a cursor that blinks upon
-   g_timeout_dispatch().  It complains if it blinks after the GtkEntry
-   loses focus.  So, we can't pop up any dialogs while the blinking
-   cursor is around.  The solution is to force the editing to be
-   finished before raising the dialog.  That finalizes the
+   g_timeout_dispatch(). It complains if it blinks after the GtkEntry
+   loses focus. So, we can't pop up any dialogs while the blinking
+   cursor is around. The solution is to force the editing to be
+   finished before raising the dialog. That finalizes the
    gtkcelleditable. */
 static void
 gtv_finish_edit (GncTreeViewSplitReg *view)
@@ -2685,13 +2820,31 @@
 }
 
 
+/* This is used in g_idle_add to cancel an edit */
+static gboolean
+gtv_idle_cancel_edit (GtkCellRenderer *cr)
+{
+    GtkCellEditable *ce;
+
+    gtk_cell_renderer_stop_editing (cr, TRUE);
+
+    ce = GTK_CELL_EDITABLE (g_object_get_data (G_OBJECT (cr), "cell-editable"));
+    gtk_cell_editable_editing_done (ce);
+    gtk_cell_editable_remove_widget (ce);
+
+   return FALSE;
+}
+
+
 /* Returns TRUE if dialog was canceled or discarded.
    Does nothing if 'new_trans' is the dirty trans. */
 static gboolean
 transaction_changed_confirm (GncTreeViewSplitReg *view,
                             Transaction *new_trans)
 {
-    GtkWidget *dialog, *window;
+    GtkWidget            *dialog, *window;
+    GncTreeModelSplitReg *model;
+    Split                *split;
     gint response;
     const char *title = _("Save the changed transaction?");
     const char *message = _(
@@ -2701,6 +2854,8 @@
     if (!view->priv->dirty_trans || view->priv->dirty_trans == new_trans)
         return FALSE;
 
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
+
     window = gnc_tree_view_split_reg_get_parent (view);
     dialog = gtk_message_dialog_new (GTK_WINDOW (window),
                                     GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -2726,19 +2881,17 @@
             gtk_tree_row_reference_free (view->priv->edit_ref);
             view->priv->edit_ref = NULL;
         }
+        split = gnc_tree_model_split_get_blank_split (model);
+        xaccSplitReinit (split); // Clear the blank split
         view->priv->dirty_trans = NULL;
         view->change_allowed = FALSE;
+        view->priv->auto_complete = FALSE;
         return FALSE;
         break;
 
     case GTK_RESPONSE_REJECT:
         if (view->priv->dirty_trans && xaccTransIsOpen (view->priv->dirty_trans))
         {
-            GncTreeModelSplitReg *model;
-            Split                *split;
-
-            model = get_split_reg_model_from_view (view);
-
             // Remove the split before rollback.
             gnc_tree_model_split_reg_set_blank_split_parent (model, view->priv->dirty_trans, TRUE);
 
@@ -2752,6 +2905,7 @@
             split = gnc_tree_model_split_get_blank_split (model);
             xaccSplitReinit (split); // Clear the blank split
             view->change_allowed = FALSE;
+            view->priv->auto_complete = FALSE;
         }
         return TRUE;
         break;
@@ -2768,6 +2922,47 @@
 }
 
 
+/* Return the credit and debit titles of those columns */
+const char *
+gnc_tree_view_split_reg_get_credit_debit_string (GncTreeViewSplitReg *view, gboolean credit)
+{
+    GtkCellRenderer *cr;
+    GList *renderers;
+    GList *columns;
+    GList  *column;
+    gint i;
+    const char *title = NULL;
+
+    columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (view));
+
+    for ( column = columns, i = 1; column; column = g_list_next (column), i++)
+    {
+        GtkTreeViewColumn *tvc;
+        ViewCol viewcol;
+
+        tvc = column->data;
+
+        /*  We only have one renderer per cell now */
+        renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (tvc));
+        g_assert (g_list_length (renderers) == 1);
+        cr = g_list_nth_data (renderers, 0);
+        g_list_free (renderers);
+
+        viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(cr), "view_column"));
+
+        DEBUG("viewcol is %d", viewcol);
+
+        if (viewcol == COL_CREDIT && credit)
+            title = gtk_tree_view_column_get_title (tvc);
+
+        if (viewcol == COL_DEBIT && !credit)
+            title = gtk_tree_view_column_get_title (tvc);
+    }
+    g_list_free (columns);
+    return title;
+}
+
+
 /*####################################################################
           ^^^^^    edit function call backs      ^^^^^
           vvvvvv   gtv function call backs       vvvvv
@@ -2785,7 +2980,7 @@
 
     ENTER("title depth is %d and sort_depth %d, sort_col is %d", depth, view->sort_depth, view->sort_col);
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
     columns = gtk_tree_view_get_columns (GTK_TREE_VIEW (view));
 
     for ( column = columns, i = 1; column; column = g_list_next (column), i++)
@@ -2934,6 +3129,12 @@
                 break;
 
             default:
+                /* Display arrows if we are sorting on this row */
+                if (view->sort_depth == depth && view->sort_col == viewcol)
+                    gtk_tree_view_column_set_sort_indicator (tvc, TRUE);
+                else
+                    gtk_tree_view_column_set_sort_indicator (tvc, FALSE);
+
                 if(depth == TRANS1)
                     gtk_tree_view_column_set_title (tvc, _("Accounts"));
                 else if (depth == TRANS2)
@@ -3205,7 +3406,7 @@
 
     ENTER("Help Viewcol is %d and depth is %d", viewcol, depth);
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     switch(viewcol)
     {
@@ -3440,12 +3641,12 @@
     if (view->priv->expanded == FALSE)
         return FALSE;
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     bsplit = gnc_tree_model_split_get_blank_split (model);
     bpath =  gnc_tree_model_split_reg_get_path_to_split_and_trans (model, bsplit, NULL);
 
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), bpath);
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, bpath);
 
     gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath);
 
@@ -3464,7 +3665,7 @@
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (treeview);
     GncTreeModelSplitReg *model;
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     /* this works on non editable cells like void, balance */
 
@@ -3482,24 +3683,43 @@
 }
 
 
-/* Call back for when a Transaction is deleted so we can move selection out of way */
+
+/* Call back for when a change to a filter requires the selection to get out of the way */
 static void
-gtv_split_reg_trans_delete_cb (GncTreeModelSplitReg *model, gpointer item, gpointer user_data)
+gtv_split_reg_selection_move_filter_cb (GncTreeModelSplitReg *model, gpointer item, gpointer user_data)
 {
     GncTreeViewSplitReg *view = user_data;
     Transaction *trans = item;
 
-    DEBUG("gtv_split_reg_trans_delete_cb view %p model %p trans %p ", view, model, trans);
+    DEBUG("gtv_split_reg_selection_move_filter_cb view %p model %p trans %p", view, model, trans);
 
-    DEBUG("gtv_split_reg_trans_delete_cb current_trans %p trans %p", view->priv->current_trans, trans);
+    DEBUG("gtv_split_reg_selection_move_filter_cb current_trans %p trans %p", view->priv->current_trans, trans);
 
-    /* if same, lets get out of the way so move */
+    /* if same, lets get out of the way, so move */
     if (trans == view->priv->current_trans)
+        gnc_tree_control_split_reg_jump_to_blank (view);
+}
+
+
+/* Call back for when a change to a Transaction requires the selection to get out of the way */
+static void
+gtv_split_reg_selection_move_delete_cb (GncTreeModelSplitReg *model, gpointer item, gpointer user_data)
+{
+    GncTreeViewSplitReg *view = user_data;
+    Transaction *trans = item;
+
+    DEBUG("gtv_split_reg_selection_move_delete_cb view %p model %p trans %p", view, model, trans);
+
+    DEBUG("gtv_split_reg_selection_move_delete_cb current_trans %p trans %p", view->priv->current_trans, trans);
+
+    /* if same, lets get out of the way, so move */
+    if (trans == view->priv->current_trans)
         gnc_tree_control_split_reg_goto_rel_trans_row (view, 1);
+
 }
 
 
-/* Call back for focus out evnt so we can finish edit */
+/* Call back for focus out event so we can finish edit */
 static gboolean
 gtv_split_reg_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, gpointer user_data)
 {
@@ -3511,105 +3731,175 @@
 }
 
 
-/* For handling keynav */
+/* Reconcile column tests */
 static gboolean
-gtv_split_reg_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+gtv_split_reg_recn_tests (GncTreeViewSplitReg *view, GtkTreeViewColumn *column)
 {
-    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (widget);
-    GtkTreeViewColumn *col;
-    ViewCol viewcol;
     GtkCellRenderer *cell;
     GList *renderers;
-    GtkTreePath *path = NULL;
-    gint *indices_ed, *indices_now;
+    ViewCol viewcol;
 
-    gboolean tabbed = FALSE;
+    ENTER(" ");
 
-    gint editable = 0;
+    renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
+    g_assert (g_list_length (renderers) == 1);
+    cell = g_list_nth_data (renderers, 0);
+    g_list_free (renderers);
 
-//FIXME ????
-//g_print("\ngtvt_key_press_cb\n");
+    viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "view_column"));
 
-    if (event->type != GDK_KEY_PRESS)
-        return TRUE;
+    /* Test for change of RECN COLUMN setting from reconciled */
+    if (viewcol == COL_RECN)
+    {
+        /* Are we trying to change the reconcile setting */
+        if (!gnc_tree_control_split_reg_recn_change (view))
+        {
+            LEAVE("Not allowed to change reconciled transaction");
+            return TRUE;
+        }
+    }
 
-    switch (event->keyval)
+    /* Ask, are we allowed to change reconciled values other than 'description / notes / memo'
+       which we can change always */
+    if (viewcol != COL_DESCNOTES && viewcol != COL_RECN)
     {
-    case GDK_Tab:
-    case GDK_ISO_Left_Tab:
-    case GDK_KP_Tab:
-        tabbed = TRUE;
-        break;
-
-    case GDK_Return:
-    case GDK_KP_Enter:
-        break;
-    default: 
-	return TRUE;
+        if (!gnc_tree_control_split_reg_recn_test (view))
+        {
+            LEAVE("Not allowed to edit reconciled transaction");
+            return TRUE;
+        }
     }
+    LEAVE(" ");
+    return FALSE;
+}
 
 
-    gtk_tree_view_get_cursor (GTK_TREE_VIEW (view), &path, &col);
+/* This is the callback for the mouse click on a selected row */
+static gboolean
+gtv_split_reg_button_cb (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
+{
+    GncTreeViewSplitReg  *view = GNC_TREE_VIEW_SPLIT_REG (widget);
+    GncTreeModelSplitReg *model;
+    GtkTreePath          *spath;
+    GtkTreeViewColumn    *col;
+    ViewCol viewcol;
 
-    if (!path)
-        return TRUE;
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
-    gnc_tree_view_split_reg_finish_edit (view);
+    if (event->button == 1 && event->type == GDK_BUTTON_PRESS)
+    {
+        // Make sure we have stoped editing.
+        gnc_tree_view_split_reg_finish_edit (view);
 
+        /* Get tree path for row that was clicked, true is row exists */
+        if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (view), (gint) event->x, (gint) event->y,
+                                             &spath, &col, NULL, NULL))
+        {
+            // Are we on a selected row.
+            if (gtk_tree_selection_path_is_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (view)), spath))
+            {
+                /* Set cursor to column */
+                gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), spath, col, FALSE);
 
+                // Reconcile tests
+                if (gtv_split_reg_recn_tests (view, col))
+                {
+                    gtk_tree_path_free (spath);
+                    return TRUE;
+                }
+            }
+        }
+        gtk_tree_path_free (spath);
+    }
+    return FALSE;
+}
 
-if (tabbed == TRUE)
+
+/* For handling keynav */
+static gboolean
+gtv_split_reg_key_press_cb (GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 {
+    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (widget);
+    GtkTreeViewColumn *col;
+    GtkTreePath *spath;
 
+//g_print("\ngtvt_key_press_cb\n");
 
-/*FIXME This does not work, editable does not reflect status, why ????? */
+    gtk_tree_view_get_cursor (GTK_TREE_VIEW (view), &spath, &col);
 
-//    while (editable == 0) // lets step over non editable columns
-//    {
+//g_print("column title is %s and path is %s\n", gtk_tree_view_column_get_title (col), gtk_tree_path_to_string (spath));
 
-        /* Step to the next column, we may wrap */
-        gnc_tree_view_keynav (GNC_TREE_VIEW (view), &col, path, event); // returns path and column
+    if (event->type != GDK_KEY_PRESS)
+        return FALSE;
 
-//        if (!path || !gnc_tree_view_path_is_valid (GNC_TREE_VIEW (view), path)) // We have stepped off the end
-//             break;
+    switch (event->keyval)
+    {
+    case GDK_KEY_space:
+    case GDK_KEY_Return:
+    case GDK_KEY_KP_Enter:
 
-        renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col)); //FIXME I am only looking at one renderer per cell.
-        g_assert (g_list_length (renderers) == 1);
-        cell = g_list_nth_data (renderers, 0);
-        g_list_free (renderers);
+        if (!spath)
+            return TRUE;
 
-        viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "view_column"));
+        // Do the reconcile tests.
+        if (!gtv_split_reg_recn_tests (view, col))
+        {
+            /* Set cursor to new column, open for editing */
+            gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), spath, col, TRUE);
+        }
 
-        g_object_get (G_OBJECT (cell), "editable", &editable, NULL);
+        gtk_tree_path_free (spath);
+        return TRUE;
+        break;
 
-//g_print("key nav - Path is '%s' and viewcol is %d and editable is %d and cell pointer is %p\n", gtk_tree_path_to_string (path),
-//                   viewcol, editable, cell);
 
+    case GDK_KEY_Tab:
+    case GDK_KEY_ISO_Left_Tab:
+    case GDK_KEY_KP_Tab:
 
+        gtk_tree_view_get_cursor (GTK_TREE_VIEW (view), &spath, &col);
 
-//    }
-}
+        if (!spath)
+            return TRUE;
 
+        // Make sure we have stoped editing.
+        gnc_tree_view_split_reg_finish_edit (view);
 
-    if (!path || !gnc_tree_view_path_is_valid (GNC_TREE_VIEW (view), path)) // We have stepped off the end
-    {
-        /* no need to restore cursor because we won't move. */
-        //Only ask for confirmation if data was edited
-        if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT(view), "data-edited")))
+        /* Step to the next column, we may wrap */
+        gnc_tree_view_keynav (GNC_TREE_VIEW (view), &col, spath, event); // returns path and column
+
+        // Do the reconcile tests.
+        if (gtv_split_reg_recn_tests (view, col))
         {
-       	    transaction_changed_confirm (GNC_TREE_VIEW_SPLIT_REG (view), NULL);
-            g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (FALSE));
+            gtk_tree_path_free (spath);
+            return TRUE;
         }
-    }
-    else
-        /* Set cursor to new column, open for editing */
-        gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), path, col, TRUE);
 
-//g_print( "end of key nav\n");
+        /* Have we stepped off the end */
+        if (!spath || !gnc_tree_view_path_is_valid (GNC_TREE_VIEW (view), spath)) // We have stepped off the end
+        {
+            /* no need to restore cursor because we won't move. */
+            //Only ask for confirmation if data was edited
+            if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT(view), "data-edited")))
+            {
+	        transaction_changed_confirm (GNC_TREE_VIEW_SPLIT_REG (view), NULL);
+                g_object_set_data (G_OBJECT (view), "data-edited", GINT_TO_POINTER (FALSE));
+            }
+        }
+        else
+        {
+            /* Set cursor to new column, open for editing */
+            gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), spath, col, TRUE);
+        }
 
-    gtk_tree_path_free (path);
+        gtk_tree_path_free (spath);
+        return TRUE;
+        break;
 
-    return TRUE;
+//g_print( "end of key nav\n");
+    default:
+	return FALSE;
+    }
 }
 
 
@@ -3619,18 +3909,21 @@
 {
     GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
     GncTreeModelSplitReg *model;
+    GtkTreeModel *f_model, *s_model;
+    GtkTreePath *mpath, *spath;
     Split *split = NULL;
     Transaction *trans = NULL;
     Transaction *old_trans;
     gboolean is_trow1, is_trow2, is_split, is_blank;
     RowDepth depth = 0;
-    GtkTreeIter iter;
-    GtkTreePath *mpath;
-    GtkTreePath *spath;
+    GtkTreeIter m_iter;
 
+
 //g_print ("\n** gtv_split_reg_motion_cb start\n");
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
+    s_model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+    f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
 
 //g_print("Motion - ** model is %p and view is %p dirty_trans is %p **\n", model, view, view->priv->dirty_trans);
 //g_print("Motion - ** o_trans is %p o_split is %p o_depth %d **\n", view->priv->current_trans, view->priv->current_split, view->priv->current_depth);
@@ -3639,12 +3932,11 @@
     view->help_text = " ";
     g_signal_emit_by_name (view, "help_signal", NULL);
 
-    if (get_model_iter_from_selection (view, sel, &iter))
+    if (gtv_get_model_iter_from_selection (view, sel, &m_iter))
     {
-        mpath = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
+        mpath = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &m_iter);
+        spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
 
-        spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
-
 //g_print ("Motion - mpath is %s spath is %s\n\n", gtk_tree_path_to_string (mpath), gtk_tree_path_to_string (spath));
 
 //g_print("Motion - current_ref is valid %d edit_ref is %d\n", gtk_tree_row_reference_valid (view->priv->current_ref),
@@ -3677,7 +3969,7 @@
     //g_print("Motion - Edit path is '%s'\n", gtk_tree_path_to_string (gtk_tree_row_reference_get_path (view->priv->edit_ref)));
 
         gnc_tree_model_split_reg_get_split_and_trans (
-                GNC_TREE_MODEL_SPLIT_REG (model), &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
+                GNC_TREE_MODEL_SPLIT_REG (model), &m_iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
 
 //g_print("Motion - get model split %p, trans %p, is_split %d, is_blank %d\n", split, trans, is_split, is_blank);
 
@@ -3767,13 +4059,14 @@
     GncTreeViewSplitReg  *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
     GncTreeModelSplitReg *model;
     GtkCellEditable      *editable;
-    GtkTreeIter           iter;
+    GtkTreeIter           m_iter;
     Split                *split;
     Transaction          *trans;
     gboolean              is_trow1, is_trow2, is_split, is_blank;
     ViewCol               viewcol;
     char                 *error_loc = NULL;
     Account              *anchor = view->priv->anchor;
+    const char           *bsplit_action = NULL;
 
     editable = g_object_get_data (G_OBJECT (cell), "cell-editable");
 
@@ -3787,18 +4080,25 @@
     }
     view->priv->fo_handler_id = 0;
 
+    /* Make sure we set focus to the tree view after cell editing */
+    gtk_widget_grab_focus (GTK_WIDGET (view));
+
     if (g_strcmp0 (g_object_get_data (G_OBJECT (cell), "current-string"), new_text) == 0) // No change, return
         return;
 
-    g_return_if_fail (get_model_iter_from_view_string (view, path_string, &iter));
+    g_return_if_fail (gtv_get_model_iter_from_view_string (view, path_string, &m_iter));
 
     viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "view_column"));
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
     g_return_if_fail (model);
 
+    //FIXME this may be a hack, blank split is not part of blank trans when entering
+    // action field in two line mode..
+    bsplit_action = xaccSplitGetAction (gnc_tree_model_split_get_blank_split (model));
+
     gnc_tree_model_split_reg_get_split_and_trans (
-        model, &iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
+        model, &m_iter, &is_trow1, &is_trow2, &is_split, &is_blank, &split, &trans);
 
     switch (viewcol) {
     case COL_DATE:
@@ -3814,6 +4114,7 @@
             }
             else
             {
+                //FIXME should we default to todays date ????
                 PERR("invalid date `%s`", new_text);
             }
         }
@@ -3846,8 +4147,15 @@
         /* Column is DESCRIPTION / NOTES / MEMO */
         gtv_begin_edit (view, NULL, trans);
         if (is_trow1)
+        {
             xaccTransSetDescription (trans, new_text);
-
+            // This will potentially fill in the rest of the transaction.
+            if (view->priv->auto_complete == FALSE)
+            {
+                gnc_tree_control_auto_complete (view, trans, new_text);
+                view->priv->auto_complete = TRUE;
+            }
+        }
         if (is_trow2)
             xaccTransSetNotes (trans, new_text);
 
@@ -3939,6 +4247,9 @@
                     if (!gnc_commodity_equiv (xaccAccountGetCommodity (old_acct), xaccAccountGetCommodity (acct)))
                         force = TRUE;
                 }
+                //FIXME see above...
+                if (bsplit_action != NULL)
+                    xaccSplitSetAction (split, bsplit_action);
             }
             else
             {
@@ -4022,7 +4333,7 @@
             if (is_blank)
             {
                 /*FIXME May be this should be a signal - Promote the blank split to a real split */
-                g_idle_add ((GSourceFunc)gnc_tree_model_split_reg_commit_blank_split, get_split_reg_model_from_view (view));
+                g_idle_add ((GSourceFunc)gnc_tree_model_split_reg_commit_blank_split, gnc_tree_view_split_reg_get_model_from_view (view));
             }
 
             // In transaction mode, two splits only, set up the other split.
@@ -4122,64 +4433,66 @@
 gtv_get_editable_start_editing_cb (GtkCellRenderer *cr, GtkCellEditable *editable,
                               const gchar *path_string, gpointer user_data)
 {
-    GncTreeViewSplitReg *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
+    GncTreeViewSplitReg  *view = GNC_TREE_VIEW_SPLIT_REG (user_data);
     GncTreeModelSplitReg *model;
-    GtkTreeModel     *smodel;
-    GtkTreePath *path, *mpath;
-    ViewCol viewcol;
+    GtkTreeModel         *f_model, *s_model;
+    GtkTreePath          *spath, *mpath, *fpath;
+    ViewCol               viewcol;
 
     GtkListStore *description_list;
     GtkListStore *memo_list;
     GtkListStore *notes_list;
-    GtkListStore *acct_list;
+    GtkListStore *account_list;
 
     GtkEntryCompletion *completion = gtk_entry_completion_new();
     RowDepth depth;
 
     ENTER("ngtv_get_editable_start_editing_cb Path string is '%s'\n", path_string);
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
-    smodel = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+    s_model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+    f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
 
     /* Description / Notes / Memo / Accounts Completion Lists */
     description_list = gnc_tree_model_split_reg_get_description_list (model);
     notes_list = gnc_tree_model_split_reg_get_notes_list (model);
     memo_list = gnc_tree_model_split_reg_get_memo_list (model);
-    acct_list = gnc_tree_model_split_reg_get_acct_list (model);
+    account_list = gnc_tree_model_split_reg_get_acct_list (model);
 
     // Use depth to determine if it is a split or transaction
-    path = gtk_tree_path_new_from_string (path_string);
-    depth = gtk_tree_path_get_depth (path);
+    spath = gtk_tree_path_new_from_string (path_string);
+    depth = gtk_tree_path_get_depth (spath);
 
     viewcol = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(cr), "view_column"));
 
     DEBUG("editable Depth is %u and ViewCol is %d", depth, viewcol);
 
+    g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
+
     /* DATE COLUMN */
     if (viewcol == COL_DATE)
     {
-        g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
-
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data (G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (GTK_ENTRY (GNC_POPUP_ENTRY (editable)->entry))));
 
         g_signal_connect (G_OBJECT (editable), "remove-widget", (GCallback) remove_edit_date, view);
 
         DEBUG("Current String date is '%s'", g_strdup (gtk_entry_get_text (GTK_ENTRY (GNC_POPUP_ENTRY (editable)->entry))));
-
     }
 
-
     /* TRANSFER / VOID COLUMN */
     else if (viewcol == COL_TRANSVOID)
     {
         GtkEntry *entry;
 
+        // Update the Account list combo.
+        gnc_tree_model_split_reg_update_account_list (model);
+
         entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (editable)));
 
         gtk_entry_set_completion (GTK_ENTRY (entry), completion);
-        gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (acct_list));
+        gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (account_list));
 
         /* This sets which text column to use, 0 for short names, 1 for long */
         if (view->priv->acct_short_names)
@@ -4194,8 +4507,6 @@
 //??        g_signal_connect(G_OBJECT(completion), "match-selected", (GCallback) gtv_split_reg_match_selected_cb, view);
         g_object_unref (completion);
 
-        g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
-
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data(G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (entry)));
 
@@ -4205,7 +4516,6 @@
         DEBUG("Current String tv is '%s'", g_strdup(gtk_entry_get_text (entry)));
     }
 
-
     /* NUMBER / ACTION COLUMN */
     else if (viewcol == COL_NUMACT)
     {
@@ -4214,18 +4524,16 @@
         GtkTreeIter iter;
 
         if (depth == TRANS1)
-            gnc_tree_model_split_reg_get_num_list (model);
+            gnc_tree_model_split_reg_update_num_list (model);
 
         else if (depth == TRANS2)
-            gnc_tree_model_split_reg_get_action_list (model);
+            gnc_tree_model_split_reg_update_action_list (model);
 
         else if (depth == SPLIT3)
-            gnc_tree_model_split_reg_get_action_list (model);
+            gnc_tree_model_split_reg_update_action_list (model);
 
         entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (editable)));
 
-        g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
-
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data (G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (entry)));
 
@@ -4235,10 +4543,12 @@
         DEBUG("Current String na is '%s'", g_strdup (gtk_entry_get_text (entry)));
     }
 
-
     /* DESCRIPTION / NOTES / MEMO COLUMN */
     else if (viewcol == COL_DESCNOTES)
     {
+        // Update the auto completion lists.
+        gnc_tree_model_split_reg_update_completion (model);
+
         //Data used for completion is set based on if editing split or not
         if (depth == TRANS1)
         {
@@ -4268,8 +4578,6 @@
 
         g_object_unref (completion);
 
-        g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
-
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data (G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (GTK_ENTRY(editable))));
 
@@ -4280,7 +4588,6 @@
         DEBUG("Current String dnm is '%s'", g_strdup (gtk_entry_get_text (GTK_ENTRY(editable))));
     }
 
-
     /* RECN COLUMN */
     else if (viewcol == COL_RECN)
     {
@@ -4288,8 +4595,6 @@
 
         entry = GTK_ENTRY (editable);
 
-         g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
-
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data (G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (entry)));
 
@@ -4303,7 +4608,6 @@
         DEBUG("Current String recn is '%s'", g_strdup (gtk_entry_get_text (entry)));
     }
 
-
     /* THE REST OF THE COLUMNS */
     else
     {
@@ -4311,8 +4615,6 @@
 
         entry = GTK_ENTRY (editable);
 
-        g_object_set_data (G_OBJECT (cr), "cell-editable", editable);
-
         //Copy the string in the GtkEntry for later comparison
         g_object_set_data (G_OBJECT (cr), "current-string", g_strdup (gtk_entry_get_text (entry)));
 
@@ -4324,11 +4626,12 @@
         DEBUG("Current String rest is '%s'", g_strdup (gtk_entry_get_text (entry)));
     }
 
-
     gtv_split_reg_help (view, cr, viewcol, depth);
 
-    mpath = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (smodel), path);
+    fpath = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (s_model), spath);
 
+    mpath = gtk_tree_model_filter_convert_path_to_child_path (GTK_TREE_MODEL_FILTER (f_model), fpath);
+
     if(view->priv->edit_ref != NULL)
     {
         gtk_tree_row_reference_free (view->priv->edit_ref);
@@ -4337,8 +4640,9 @@
     view->priv->edit_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), mpath);
 
     DEBUG("edit_path is %s", gtk_tree_path_to_string (gtk_tree_row_reference_get_path (view->priv->edit_ref)));
-    gtk_tree_path_free (path);
     gtk_tree_path_free (mpath);
+    gtk_tree_path_free (fpath);
+    gtk_tree_path_free (spath);
 
     view->priv->temp_cr = cr;
     view->editing_now = TRUE;
@@ -4348,43 +4652,6 @@
     //Add edit-canceled property to cr so we can distinguish between
     //cancelled and actual changes
     g_object_set_data (G_OBJECT (cr), "edit-canceled", GINT_TO_POINTER (FALSE));
-
-
-    /*******************************************************************/
-    /*            Test function before edit started                    */
-    /*******************************************************************/
-
-    /* Test for change of RECN COLUMN setting from reconciled */
-    if (viewcol == COL_RECN)
-    {
-       /* Are we trying to change the reconcile setting */
-        if (gnc_tree_control_split_reg_recn_change (view))
-        {
-            /* Make sure we have stopped editing */
-            g_idle_add( (GSourceFunc)gtv_idle_finish_edit, view ); //FIXME Not sure if this is ok.
-        }
-        else
-        {
-            /* Make sure we have stopped editing */
-            g_idle_add( (GSourceFunc)gtv_idle_finish_edit, view ); //FIXME Not sure if this is ok.
-        }
-    }
-
-    /* Ask, are we allowed to change reconciled values other than 'description / notes / memo'
-       which we can change always */
-    if (viewcol != COL_DESCNOTES && viewcol != COL_RECN)
-    {
-        if (gnc_tree_control_split_reg_recn_test (view))
-        {
-            ;
-        }
-        else
-        {
-            /* Make sure we have stopped editing */
-            g_idle_add( (GSourceFunc)gtv_idle_finish_edit, view ); //FIXME Not sure if this is ok.
-        }
-    }
-
     LEAVE(" ");
 }
 
@@ -4442,18 +4709,17 @@
 
 
 /* Scroll the view to show selected row based on sort direction */
-static gboolean
-gtv_scroll_to_cell (GncTreeViewSplitReg *view)
+gboolean
+gnc_tree_view_split_reg_scroll_to_cell (GncTreeViewSplitReg *view)
 {
     GncTreeModelSplitReg *model;
     GtkTreePath *mpath, *spath;
 
-    model = get_split_reg_model_from_view (view);
-
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
+//FIXME needs more work...
     mpath = gnc_tree_view_split_reg_get_current_path (view);
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
 
-
     if (view->sort_direction == 1)
         gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (view), spath, NULL, TRUE, 0.0, 0.0);
     else
@@ -4515,7 +4781,7 @@
 {
     GncTreeModelSplitReg *model;
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     if (trans == NULL)
     {
@@ -4555,7 +4821,7 @@
 {
     GncTreeModelSplitReg *model;
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     if(view->priv->current_ref != NULL)
     {
@@ -4691,7 +4957,7 @@
 
     ENTER("gnc_tree_view_split_reg_cancel_edit view is %p and reg_closing is %d", view, reg_closing);
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     if (trans && xaccTransIsOpen (trans))
     {
@@ -4718,6 +4984,8 @@
     }
     /* Reset allow changes for reconciled transctions */
     view->change_allowed = FALSE;
+
+    view->priv->auto_complete = FALSE; // reset auto_complete has run flag
     LEAVE(" ");
 }
 
@@ -4740,7 +5008,7 @@
 gnc_tree_view_split_reg_trans_expanded (GncTreeViewSplitReg *view, Transaction *trans)
 {
     GncTreeModelSplitReg *model;
-    GtkTreePath  *mpath, *spath;
+    GtkTreePath *mpath, *spath;
     gboolean expanded;
 
     /* if trans is NULL use priv->expanded */
@@ -4748,11 +5016,11 @@
         expanded = view->priv->expanded;
     else
     {
-        model = get_split_reg_model_from_view (view);
+        model = gnc_tree_view_split_reg_get_model_from_view (view);
 
         mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, trans);
 
-        spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+        spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
 
         gtk_tree_path_down (spath); /* Move the path down to trow2 */
         expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), spath);
@@ -4769,14 +5037,18 @@
 gnc_tree_view_split_reg_collapse_trans (GncTreeViewSplitReg *view, Transaction *trans)
 {
     GncTreeModelSplitReg *model;
+    GtkTreeModel *f_model, *s_model;
     GtkTreePath *temp_spath, *mpath, *spath;
     gint *indices;
     RowDepth depth;
 
     ENTER("gnc_tree_view_split_reg_collapse_trans and trans is %p", trans);
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
+    s_model = gtk_tree_view_get_model (GTK_TREE_VIEW (view));
+    f_model = gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (s_model));
+
     /* Make sure we have stopped editing */
     gnc_tree_view_split_reg_finish_edit (view);
 
@@ -4786,7 +5058,7 @@
     else
         mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, trans);
 
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
 
     /* Collapse the view back to the transaction */
     indices = gtk_tree_path_get_indices (spath);
@@ -4800,7 +5072,7 @@
     /* if trans is NULL, collapse and update current_ref */
     if (trans == NULL)
     {
-        GtkTreePath *temp_mpath;
+        GtkTreePath *temp_mpath, *temp_fpath;
 
         gnc_tree_view_split_reg_block_selection (view, TRUE);
 
@@ -4820,13 +5092,15 @@
             view->priv->current_ref = NULL;
         }
 
-        temp_mpath = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), temp_spath);
+        temp_fpath = gtk_tree_model_sort_convert_path_to_child_path (GTK_TREE_MODEL_SORT (s_model), temp_spath);
+        temp_mpath = gtk_tree_model_filter_convert_path_to_child_path (GTK_TREE_MODEL_FILTER (f_model), temp_fpath);
 
         view->priv->current_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), temp_mpath);
 
         gnc_tree_view_split_reg_block_selection (view, FALSE);
 
         gtk_tree_path_free (temp_mpath);
+        gtk_tree_path_free (temp_fpath);
     }
     else
         gtk_tree_view_collapse_row (GTK_TREE_VIEW (view), temp_spath);
@@ -4849,7 +5123,7 @@
 
     ENTER("gnc_tree_view_split_reg_expand_trans and trans is %p", trans);
 
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
 
     /* Make sure we have stopped editing */
     gnc_tree_view_split_reg_finish_edit (view);
@@ -4859,7 +5133,7 @@
     else
         mpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, NULL, trans);
 
-    spath = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (gtk_tree_view_get_model (GTK_TREE_VIEW (view))), mpath);
+    spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, mpath);
 
     gtk_tree_view_expand_row (GTK_TREE_VIEW (view), spath, TRUE);
 
@@ -4880,7 +5154,7 @@
 gnc_tree_view_split_reg_get_parent (GncTreeViewSplitReg *view)
 {
     GncTreeModelSplitReg *model;
-    model = get_split_reg_model_from_view (view);
+    model = gnc_tree_view_split_reg_get_model_from_view (view);
     return gnc_tree_model_split_reg_get_parent (model);
 }
 

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.h	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-split-reg.h	2013-03-11 18:08:08 UTC (rev 22827)
@@ -64,6 +64,7 @@
     gboolean                    change_allowed;           // This is set when we allow the reconciled split to change.
     gboolean                    editing_now;              // This is set while editing of a cell.
 
+
 } GncTreeViewSplitReg;
 
 typedef struct
@@ -125,9 +126,20 @@
 
 void gnc_tree_view_split_reg_collapse_trans (GncTreeViewSplitReg *view, Transaction *trans);
 
+const char * gnc_tree_view_split_reg_get_credit_debit_string (GncTreeViewSplitReg *view, gboolean credit);
 
 /*************************************************************************************/
 
+GtkTreePath * gnc_tree_view_split_reg_get_sort_path_from_model_path (GncTreeViewSplitReg *view, GtkTreePath *mpath);
+
+GncTreeModelSplitReg * gnc_tree_view_split_reg_get_model_from_view (GncTreeViewSplitReg *view);
+
+gboolean gnc_tree_view_split_reg_scroll_to_cell (GncTreeViewSplitReg *view);
+
+void gnc_tree_view_split_reg_refilter (GncTreeViewSplitReg *view);
+
+/*************************************************************************************/
+
 void gnc_tree_view_split_reg_delete_current_split (GncTreeViewSplitReg *view);
 
 void gnc_tree_view_split_reg_delete_current_trans (GncTreeViewSplitReg *view);

Modified: gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.c
===================================================================
--- gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.c	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.c	2013-03-11 18:08:08 UTC (rev 22827)
@@ -626,11 +626,11 @@
 {
     GNCLedgerDisplay2 *ld = user_data;
 
-
-    ENTER(" ");
     if (!ld)
         return;
 
+    ENTER(" ");
+
     gnc_unregister_gui_component (ld->component_id);
 
     if (ld->destroy)
@@ -905,6 +905,17 @@
 }
 
 void
+gnc_ledger_display2_refilter (GNCLedgerDisplay2 *ld)
+{
+    ENTER("ld=%p", ld);
+
+    /* Set the default selection start position and refilter */
+    gnc_tree_view_split_reg_default_selection (ld->view);
+
+    LEAVE(" ");
+}
+
+void
 gnc_ledger_display2_refresh (GNCLedgerDisplay2 *ld)
 {
     ENTER("ld=%p", ld);
@@ -974,7 +985,6 @@
     ld->refresh_ok = ok;
 }
 
-
 static void
 gnc_ledger_display2_refresh_cb (GncTreeModelSplitReg *model, gpointer user_data)
 {
@@ -984,7 +994,6 @@
     g_idle_add ((GSourceFunc)gnc_ledger_display2_refresh, ld);
 }
 
-
 void
 gnc_ledger_display2_close (GNCLedgerDisplay2 *ld)
 {

Modified: gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.h
===================================================================
--- gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.h	2013-03-09 10:24:14 UTC (rev 22826)
+++ gnucash/trunk/src/register/ledger-core/gnc-ledger-display2.h	2013-03-11 18:08:08 UTC (rev 22827)
@@ -132,6 +132,9 @@
 void gnc_ledger_display2_refresh (GNCLedgerDisplay2 * ledger_display);
 void gnc_ledger_display2_refresh_by_split_register (GncTreeModelSplitReg *model);
 
+/* Refilter the register */
+void gnc_ledger_display2_refilter (GNCLedgerDisplay2 *ld);
+
 /* close the window */
 void gnc_ledger_display2_close (GNCLedgerDisplay2 * ledger_display);
 



More information about the gnucash-changes mailing list