diff --git a/ChangeLog b/ChangeLog index 90161989fa..14708b725d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2001-04-20 Dave Peticolas + + * src/guile/gnc-helpers.c: remove cruft. work on converting + Query objects to and from a scheme representation (unfinished) + + * src/guile/gnc.gwp: wrap more of the Query enums + + * src/engine/Query.c (xaccQueryAddAccountGUIDMatch): new func + + * src/scm/options.scm: add a query option type + + * src/scm/report/report-list.scm: don't bother hiding tax report + 2001-04-19 Bill Gribble * src/gnome/top-level.c: add call to skeleton "welcome" report diff --git a/src/engine/Account.c b/src/engine/Account.c index 28586973f0..7df0517aad 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -2070,7 +2070,6 @@ xaccAccountGetPriceSrc(Account *acc) void xaccAccountSetQuoteTZ(Account *acc, const char *tz) { - if(!acc) return; if(!tz) return; @@ -2080,8 +2079,8 @@ xaccAccountSetQuoteTZ(Account *acc, const char *tz) if((t == STOCK) || (t == MUTUAL)) { kvp_frame_set_slot_nc(acc->kvp_data, - "old-quote-tz", - kvp_value_new_string(tz)); + "old-quote-tz", + kvp_value_new_string(tz)); mark_account (acc); } } diff --git a/src/engine/Query.c b/src/engine/Query.c index f234a29b9a..49af875942 100644 --- a/src/engine/Query.c +++ b/src/engine/Query.c @@ -36,6 +36,7 @@ #include "gnc-numeric.h" #include "Account.h" #include "BackendP.h" +#include "GNCId.h" #include "Group.h" #include "Query.h" #include "Transaction.h" @@ -313,9 +314,9 @@ free_query_term(QueryTerm *qt) g_list_free (qt->data.acct.accounts); qt->data.acct.accounts = NULL; - for (node = qt->data.acct.account_guids; node; node = node->next) { - g_free (node->data); - } + for (node = qt->data.acct.account_guids; node; node = node->next) + xaccGUIDFree (node->data); + g_list_free (qt->data.acct.account_guids); qt->data.acct.account_guids = NULL; break; @@ -353,7 +354,7 @@ copy_query_term(QueryTerm * qt) { for (node = nqt->data.acct.account_guids; node; node = node->next) { GUID *old = node->data; - GUID *new = g_new (GUID, 1); + GUID *new = xaccGUIDMalloc (); *new = *old; node->data = new; @@ -901,7 +902,7 @@ account_list_to_guid_list (GList *accounts) if (!account) continue; - guid = g_new (GUID, 1); + guid = xaccGUIDMalloc (); *guid = *xaccAccountGetGUID (account); guids = g_list_prepend (guids, guid); @@ -910,6 +911,29 @@ account_list_to_guid_list (GList *accounts) return g_list_reverse (guids); } +static GList * +copy_guid_list (GList *guids) +{ + GList *new_guids = NULL; + GList *node; + + for (node = guids; node; node = node->next) + { + GUID *guid = node->data; + GUID *new_guid; + + if (!guid) + continue; + + new_guid = xaccGUIDMalloc (); + *new_guid = *guid; + + new_guids = g_list_prepend (new_guids, new_guid); + } + + return g_list_reverse (new_guids); +} + static GList * guid_list_to_account_list (GList *guids) { @@ -1320,6 +1344,41 @@ xaccQueryAddAccountMatch(Query * q, GList * accounts, acct_match_t how, xaccFreeQuery(qr); } +/******************************************************************** + * xaccQueryAddAccountGUIDMatch + * Add an account filter to an existing query. + ********************************************************************/ + +void +xaccQueryAddAccountGUIDMatch(Query * q, GList * account_guids, + acct_match_t how, QueryOp op) +{ + Query * qs = xaccMallocQuery(); + QueryTerm * qt = g_new0(QueryTerm, 1); + Query * qr; + + qt->p = & xaccAccountMatchPredicate; + qt->data.type = PD_ACCOUNT; + qt->data.base.term_type = PR_ACCOUNT; + qt->data.base.sense = 1; + qt->data.acct.how = how; + qt->data.acct.accounts = NULL; + qt->data.acct.account_guids = copy_guid_list (account_guids); + + xaccInitQuery(qs, qt); + xaccQuerySetGroup(qs, q->acct_group); + + if(xaccQueryHasTerms(q)) { + qr = xaccQueryMerge(q, qs, op); + } + else { + qr = xaccQueryMerge(q, qs, QUERY_OR); + } + xaccQuerySwapTerms(q, qr); + + xaccFreeQuery(qs); + xaccFreeQuery(qr); +} /******************************************************************** * xaccQueryAddSingleAccountMatch diff --git a/src/engine/Query.h b/src/engine/Query.h index 04003f1cfe..a9515741e6 100644 --- a/src/engine/Query.h +++ b/src/engine/Query.h @@ -258,6 +258,8 @@ void xaccQueryPrint(Query *q); void xaccQueryAddAccountMatch(Query * q, GList * accounts, acct_match_t how, QueryOp op); +void xaccQueryAddAccountGUIDMatch(Query * q, GList * account_guids, + acct_match_t how, QueryOp op); void xaccQueryAddSingleAccountMatch(Query * q, Account * acct, QueryOp op); diff --git a/src/scm/options.scm b/src/scm/options.scm index 9c09da52a0..0626b6160d 100644 --- a/src/scm/options.scm +++ b/src/scm/options.scm @@ -664,6 +664,29 @@ (lambda (x) (list #t x)) #f #f #f #f))) + +(define (gnc:make-query-option + section + name + default-value) + (let* ((value (if (list? default-value) + default-value + (gnc:query->scm default-value))) + (value->string (lambda () + (string-append "'" (gnc:value->string value))))) + (gnc:make-option + section name "" 'query #f + (lambda () value) + (lambda (x) (set! value (if (list? x) x (gnc:query->scm x))) + (display value) (newline)) + (lambda () (if (list? default-value) + default-value + (gnc:query->scm default-value))) + (gnc:restore-form-generator value->string) + (lambda (x) (list #t x)) + #f #f #f #f))) + + ;; Color options store rgba values in a list. ;; The option-data is a list, whose first element ;; is the range of possible rgba values and whose diff --git a/src/scm/report/register.scm b/src/scm/report/register.scm index d21f75ccb6..e07cdda3c5 100644 --- a/src/scm/report/register.scm +++ b/src/scm/report/register.scm @@ -233,6 +233,9 @@ (define (gnc:register-reg-option new-option) (gnc:register-option gnc:*report-options* new-option)) + (gnc:register-reg-option + (gnc:make-query-option "__reg" "query-new" #f)) + (gnc:register-reg-option (gnc:make-internal-option "__reg" "query" #f)) (gnc:register-reg-option @@ -649,6 +652,7 @@ (let* ((options (gnc:make-report-options "Register")) (invoice-op (gnc:lookup-option options "Invoice" "Make an invoice")) (query-op (gnc:lookup-option options "__reg" "query")) + (query-new-op (gnc:lookup-option options "__reg" "query-new")) (journal-op (gnc:lookup-option options "__reg" "journal")) (double-op (gnc:lookup-option options "__reg" "double")) (title-op (gnc:lookup-option options "General" "Title")) @@ -663,6 +667,7 @@ (gnc:option-set-value invoice-op invoice?) (gnc:option-set-value query-op query) + (gnc:option-set-value query-new-op query) (gnc:option-set-value journal-op journal?) (gnc:option-set-value double-op double?) (gnc:option-set-value title-op title) diff --git a/src/scm/report/report-list.scm b/src/scm/report/report-list.scm index 403eb29e4a..8d315e9655 100644 --- a/src/scm/report/report-list.scm +++ b/src/scm/report/report-list.scm @@ -18,12 +18,7 @@ (gnc:depend "report/portfolio.scm") (gnc:depend "report/register.scm") (gnc:depend "report/iframe-url.scm") - -(let ((locale (setlocale LC_MESSAGES))) - (if (or (equal? locale "C") - (equal? locale "en") - (equal? locale "en_US")) - (gnc:depend "report/taxtxf.scm"))) +(gnc:depend "report/taxtxf.scm") (gnc:depend "report/transaction-report.scm") ;; style sheets