more sorting futzing around

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1160 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Linas Vepstas 1998-09-13 10:17:15 +00:00
parent 4982b628a0
commit 83ec54d077
2 changed files with 23 additions and 4 deletions

View File

@ -49,6 +49,8 @@ struct _Query {
Timespec earliest;
Timespec latest;
int (*sort_func)(const void*, const void *);
char changed; /* flag, has the query changed? */
Split **split_list;
};
@ -66,6 +68,8 @@ xaccMallocQuery (void)
/* ================================================== */
static int Sort_DATE_NUM_AMT_MEMO_DESC (Split **, Split **);
void
xaccInitQuery (Query *q)
{
@ -82,6 +86,8 @@ xaccInitQuery (Query *q)
/* q->latest.tv_sec = ULONG_MAX; */
q->latest.tv_sec = LONG_MAX;
q->latest.tv_nsec = 0;
q->sort_func = (int (*)(const void*, const void *)) Sort_DATE_NUM_AMT_MEMO_DESC;
}
/* ================================================== */
@ -455,6 +461,14 @@ DECLARE (DESC, MEMO, AMT, NUM,DATE)
/* ================================================== */
void
xaccQuerySetSortOrder (Query *q, int a, ...)
{
}
/* ================================================== */
static void
SortSplits (Query *q, Split **slist)
{
@ -464,9 +478,7 @@ SortSplits (Query *q, Split **slist)
while (slist[nsplits]) nsplits ++;
/* run the sort routine on the array */
qsort (slist, nsplits, sizeof (Split *),
(int(*)(const void*, const void *)) xaccSplitOrder);
qsort (slist, nsplits, sizeof (Split *), q->sort_func);
}

View File

@ -38,7 +38,9 @@ typedef struct _Query Query;
enum {
BY_DATE,
BY_NUM,
BY_AMOUNT
BY_AMOUNT,
BY_MEMO,
BY_DESC
};
Query * xaccMallocQuery (void);
@ -56,6 +58,11 @@ void xaccQueryAddAccount (Query *, Account *acc);
*/
void xaccQuerySetMaxSplits (Query *, int);
/* The xaccQuerySetSortOrder() method sets the sort order that
* should be used on the splits
*/
void xaccQuerySetSortOrder (Query *, int, ...);
/* The xaccQueryGetSplits() method returns a list of splits
* matching the query and sorting criteria previously set up.
*/