mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
first cut for quickfill in cells
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@455 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
daf57a3a43
commit
13654f3607
@ -1,6 +1,7 @@
|
||||
/********************************************************************\
|
||||
* QuickFill.h -- the quickfill tree data structure *
|
||||
* Copyright (C) 1997 Robin D. Clark *
|
||||
* Copyright (C) 1998 Linas Vepstas *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
@ -27,15 +28,11 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "Account.h"
|
||||
#include "date.h"
|
||||
#include "QuickFill.h"
|
||||
#include "util.h"
|
||||
|
||||
/** PROTOTYPES ******************************************************/
|
||||
void qfInsertTransactionRec( QuickFill *qf, Transaction *trans, int depth );
|
||||
|
||||
/** GLOBALS *********************************************************/
|
||||
static void qfInsertTextRec( QuickFill *qf, const char * text, int depth );
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
@ -66,7 +63,7 @@ mallocQuickFill( void )
|
||||
for( i=0; i<QFNUM; i++ )
|
||||
qf->qf[i] = NULL;
|
||||
|
||||
qf->trans = NULL;
|
||||
qf->text = NULL;
|
||||
|
||||
return qf;
|
||||
}
|
||||
@ -104,30 +101,30 @@ getQuickFill( QuickFill *qf, char c )
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
void
|
||||
qfInsertTransaction( QuickFill *qf, Transaction *trans )
|
||||
qfInsertText( QuickFill *qf, const char * text )
|
||||
{
|
||||
qfInsertTransactionRec( qf, trans, 0 );
|
||||
qfInsertTransactionRec( qf, text, 0 );
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
\********************************************************************/
|
||||
void
|
||||
qfInsertTransactionRec( QuickFill *qf, Transaction *trans, int depth )
|
||||
static void
|
||||
qfInsertTextRec( QuickFill *qf, const char *text, int depth )
|
||||
{
|
||||
if( qf != NULL )
|
||||
{
|
||||
if( trans->description )
|
||||
if( text )
|
||||
{
|
||||
if( trans->description[depth] != '\0' )
|
||||
if( text[depth] != '\0' )
|
||||
{
|
||||
int index = CHAR_TO_INDEX( trans->description[depth] );
|
||||
int index = CHAR_TO_INDEX( text[depth] );
|
||||
|
||||
if( qf->qf[index] == NULL )
|
||||
qf->qf[index] = mallocQuickFill();
|
||||
|
||||
qf->qf[index]->trans = trans;
|
||||
qf->qf[index]->text = text;
|
||||
|
||||
qfInsertTransactionRec( qf->qf[index], trans, ++depth );
|
||||
qfInsertTransactionRec( qf->qf[index], text, ++depth );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ LIBCOMBO = ../lib/ComboBox-1.33/libComboBox.a
|
||||
LIBTRANS = ../Account.o ../Data.o ../FileIO.o ../Transaction.o ../date.o
|
||||
######################################################################
|
||||
SRCS = actioncell.c basiccell.c cellblock.c combocell.c \
|
||||
datecell.c pricecell.c \
|
||||
datecell.c pricecell.c QuickFill.c quickfillcell.c \
|
||||
recncell.c register.c table.c textcell.c
|
||||
OBJS = ${SRCS:.c=.o}
|
||||
######################################################################
|
||||
|
41
src/register/quickfillcell.c
Normal file
41
src/register/quickfillcell.c
Normal file
@ -0,0 +1,41 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "basiccell.h"
|
||||
#include "quickfillcell.h"
|
||||
|
||||
/* ================================================ */
|
||||
/* by definition, all text is valid text. So accept
|
||||
* all modifications */
|
||||
|
||||
static const char *
|
||||
quickMV (struct _BasicCell *_cell,
|
||||
const char *oldval,
|
||||
const char *change,
|
||||
const char *newval)
|
||||
{
|
||||
return newval;
|
||||
}
|
||||
|
||||
/* ================================================ */
|
||||
|
||||
QuickFillCell *
|
||||
xaccMallocQuickFillCell (void)
|
||||
{
|
||||
QuickFillCell *cell;
|
||||
cell = xaccMallocQuickFillCell();
|
||||
xaccInitBasicCell (&(cell->cell));
|
||||
|
||||
cell->qf = xaccMallocQuickFill();
|
||||
return cell;
|
||||
}
|
||||
|
||||
/* ================================================ */
|
||||
|
||||
void
|
||||
xaccInitQuickFillCell (QuickFillCell *cell)
|
||||
{
|
||||
cell->cell.modify_verify = quickMV;
|
||||
}
|
||||
|
||||
/* =============== END OF FILE ==================== */
|
31
src/register/quickfillcell.h
Normal file
31
src/register/quickfillcell.h
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
/*
|
||||
* FILE:
|
||||
* quickfillcell.h
|
||||
*
|
||||
* FUNCTION:
|
||||
* implements a text cell with quick-fill capabilities
|
||||
*
|
||||
* HISTORY:
|
||||
* Copyright (c) 1997, 1998 Linas Vepstas
|
||||
*/
|
||||
|
||||
#ifndef __XACC_FILL_CELL_C__
|
||||
#define __XACC_FILL_CELL_C__
|
||||
|
||||
#include "basiccell.h"
|
||||
#include "QuickFill.h"
|
||||
|
||||
typedef struct _QuickFillCell {
|
||||
BasicCell cell;
|
||||
QuickFill *qf;
|
||||
} QuickFillCell;
|
||||
|
||||
/* installs a callback to handle price recording */
|
||||
QuickFillCell * xaccMallocQuickFillCell (void);
|
||||
void xaccInitQuickFillCell (QuickFillCell *);
|
||||
|
||||
|
||||
#endif /* __XACC_FILL_CELL_C__ */
|
||||
|
||||
/* --------------- end of file ---------------------- */
|
Loading…
Reference in New Issue
Block a user