* 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


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3998 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-04-20 11:02:17 +00:00
parent 7a872533b0
commit 20a1efa349
7 changed files with 110 additions and 14 deletions

View File

@ -1,3 +1,16 @@
2001-04-20 Dave Peticolas <dave@krondo.com>
* 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 <grib@billgribble.com>
* src/gnome/top-level.c: add call to skeleton "welcome" report

View File

@ -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);
}
}

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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)

View File

@ -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