[Gnucash-changes] r13468 - gnucash/trunk/src/engine - Generate REMOVE events when a Split is removed from a Transaction.

Chris Shoemaker chris at cvs.gnucash.org
Fri Mar 3 22:21:35 EST 2006


Author: chris
Date: 2006-03-03 22:21:34 -0500 (Fri, 03 Mar 2006)
New Revision: 13468
Trac: http://svn.gnucash.org/trac/changeset/13468

Added:
   gnucash/trunk/src/engine/gnc-event.h
Modified:
   gnucash/trunk/src/engine/Makefile.am
   gnucash/trunk/src/engine/Transaction.c
Log:
   Generate REMOVE events when a Split is removed from a Transaction.
   Pass the *old* parent transaction (since the Split may be moving into 
   a new transaction) and the old index of the Split in the old Transaction's
   list of Splits.


Modified: gnucash/trunk/src/engine/Makefile.am
===================================================================
--- gnucash/trunk/src/engine/Makefile.am	2006-03-04 03:04:46 UTC (rev 13467)
+++ gnucash/trunk/src/engine/Makefile.am	2006-03-04 03:21:34 UTC (rev 13468)
@@ -75,6 +75,7 @@
   gnc-budget.h \
   gnc-commodity.h \
   gnc-engine.h \
+  gnc-event.h \
   gnc-filepath-utils.h \
   gnc-hooks.h \
   gnc-pricedb.h \

Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c	2006-03-04 03:04:46 UTC (rev 13467)
+++ gnucash/trunk/src/engine/Transaction.c	2006-03-04 03:21:34 UTC (rev 13468)
@@ -46,6 +46,7 @@
 #include "gnc-engine.h"
 #include "gnc-lot-p.h"
 #include "gnc-lot.h"
+#include "gnc-event.h"
 
 
 /* Notes about xaccTransBeginEdit(), xaccTransCommitEdit(), and
@@ -954,15 +955,18 @@
         if ((s->parent != trans) || s->inst.do_free) {
             /* Existing split either moved to another transaction or
                was destroyed, drop from list */
+            GncEventData ed;
+            ed.parent = trans;
+            ed.idx = g_list_index(trans->splits, s);
             trans->splits = g_list_remove(trans->splits, s);
-            //gnc_engine_gen_event(&trans->inst, QOF_EVENT_REMOVE);
+            qof_event_gen(&s->inst.entity, QOF_EVENT_REMOVE, &ed);
         }
 
         if (s->parent == trans) {
             /* Split was either destroyed or just changed */
-            //if (s->inst.do_free)
-            //    gnc_engine_gen_event(&trans->inst, QOF_EVENT_REMOVE);
-            //else gnc_engine_gen_event(&trans->inst, QOF_EVENT_MODIFY);
+            if (s->inst.do_free)
+                qof_event_gen(&s->inst.entity, QOF_EVENT_DESTROY, NULL);
+            else qof_event_gen(&s->inst.entity, QOF_EVENT_MODIFY, NULL);
             xaccSplitCommitEdit(s);
         }
     }

Added: gnucash/trunk/src/engine/gnc-event.h
===================================================================
--- gnucash/trunk/src/engine/gnc-event.h	2006-03-04 03:04:46 UTC (rev 13467)
+++ gnucash/trunk/src/engine/gnc-event.h	2006-03-04 03:21:34 UTC (rev 13468)
@@ -0,0 +1,34 @@
+/********************************************************************
+ * gnc-event.h  -- engine-level events for Gnucash                  *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+ ********************************************************************/
+
+#ifndef GNC_EVENT_H
+#define GNC_EVENT_H
+
+#include <glib.h>
+
+typedef struct {
+    gpointer parent;
+    gint idx;
+} GncEventData;
+
+
+#endif



More information about the gnucash-changes mailing list