mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
add change flag to help with cached values
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@516 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3288c2fe2b
commit
5a36e8771b
@ -22,6 +22,7 @@ void xaccInitBasicCell (BasicCell *cell)
|
|||||||
cell->width = 0;
|
cell->width = 0;
|
||||||
cell->alignment = 0;
|
cell->alignment = 0;
|
||||||
cell->value = 0x0;
|
cell->value = 0x0;
|
||||||
|
cell->changed = 0;
|
||||||
cell->set_value = NULL;
|
cell->set_value = NULL;
|
||||||
cell->enter_cell = NULL;
|
cell->enter_cell = NULL;
|
||||||
cell->modify_verify = NULL;
|
cell->modify_verify = NULL;
|
||||||
|
@ -114,11 +114,12 @@
|
|||||||
|
|
||||||
typedef struct _BasicCell {
|
typedef struct _BasicCell {
|
||||||
|
|
||||||
short width; /* column width, in chars, not pixels */
|
short width; /* column width, in chars, not pixels */
|
||||||
short alignment; /* column text alignment */
|
short alignment; /* column text alignment */
|
||||||
char input_output; /* zero if output-only */
|
char input_output; /* zero if output-only */
|
||||||
|
|
||||||
char * value; /* current value */
|
char * value; /* current value */
|
||||||
|
unsigned int changed; /* 2^32-1 if value modified */
|
||||||
|
|
||||||
/* "virtual", overloaded set-value method */
|
/* "virtual", overloaded set-value method */
|
||||||
void (*set_value) (struct _BasicCell *,
|
void (*set_value) (struct _BasicCell *,
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#define MAX_COLS 8
|
#define MAX_COLS 8
|
||||||
|
|
||||||
/* ================================= */
|
/* ============================================== */
|
||||||
|
|
||||||
BasicRegister * xaccMallocBasicRegister (void)
|
BasicRegister * xaccMallocBasicRegister (void)
|
||||||
{
|
{
|
||||||
@ -51,7 +51,7 @@ BasicRegister * xaccMallocBasicRegister (void)
|
|||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================= */
|
/* ============================================== */
|
||||||
|
|
||||||
void xaccInitBasicRegister (BasicRegister *reg)
|
void xaccInitBasicRegister (BasicRegister *reg)
|
||||||
{
|
{
|
||||||
@ -188,4 +188,28 @@ void xaccInitBasicRegister (BasicRegister *reg)
|
|||||||
reg->table = table;
|
reg->table = table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ============================================== */
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
xaccGetChangeFlag (BasicRegister *reg)
|
||||||
|
{
|
||||||
|
|
||||||
|
unsigned int changed = 0;
|
||||||
|
|
||||||
|
changed |= MOD_DATE && reg->dateCell->cell.changed;
|
||||||
|
changed |= MOD_NUM && reg->numCell->changed;
|
||||||
|
changed |= MOD_DESC && reg->descCell->cell.changed;
|
||||||
|
changed |= MOD_RECN && reg->recnCell->changed;
|
||||||
|
changed |= MOD_AMNT && reg->creditCell->cell.changed;
|
||||||
|
changed |= MOD_AMNT && reg->debitCell->cell.changed;
|
||||||
|
/* changed |= MOD_SHRS && reg->xxxxxxCell->cell.changed; */
|
||||||
|
/* changed |= MOD_PRIC && reg->xxxxxxCell->cell.changed; */
|
||||||
|
changed |= MOD_MEMO && reg->memoCell->changed;
|
||||||
|
changed |= MOD_ACTN && reg->actionCell->cell.changed;
|
||||||
|
changed |= MOD_XFRM && reg->xfrmCell->cell.changed;
|
||||||
|
/* changed |= MOD_XTO && reg->xtoCell->cell.changed; */
|
||||||
|
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
/* ============ END OF FILE ===================== */
|
/* ============ END OF FILE ===================== */
|
||||||
|
@ -15,19 +15,36 @@
|
|||||||
#include "recncell.h"
|
#include "recncell.h"
|
||||||
#include "textcell.h"
|
#include "textcell.h"
|
||||||
|
|
||||||
|
/* modified flags -- indicate how values have been modified */
|
||||||
|
#define MOD_NONE 0x000
|
||||||
|
#define MOD_DATE 0x001
|
||||||
|
#define MOD_NUM 0x002
|
||||||
|
#define MOD_DESC 0x004
|
||||||
|
#define MOD_RECN 0x008
|
||||||
|
#define MOD_AMNT 0x010
|
||||||
|
#define MOD_SHRS 0x020
|
||||||
|
#define MOD_PRIC 0x040
|
||||||
|
#define MOD_MEMO 0x080
|
||||||
|
#define MOD_ACTN 0x100
|
||||||
|
#define MOD_XFRM 0x200
|
||||||
|
#define MOD_XTO 0x400
|
||||||
|
#define MOD_NEW 0x800
|
||||||
|
#define MOD_ALL 0xfff
|
||||||
|
|
||||||
typedef struct _BasicRegister {
|
typedef struct _BasicRegister {
|
||||||
Table * table;
|
Table * table;
|
||||||
CellBlock * cursor;
|
CellBlock * cursor;
|
||||||
CellBlock * header;
|
CellBlock * header;
|
||||||
DateCell * dateCell;
|
DateCell * dateCell;
|
||||||
BasicCell * numCell;
|
BasicCell * numCell;
|
||||||
ComboCell * actionCell;
|
|
||||||
ComboCell * xfrmCell;
|
|
||||||
QuickFillCell * descCell;
|
QuickFillCell * descCell;
|
||||||
BasicCell * memoCell;
|
|
||||||
BasicCell * recnCell;
|
BasicCell * recnCell;
|
||||||
PriceCell * creditCell;
|
PriceCell * creditCell;
|
||||||
PriceCell * debitCell;
|
PriceCell * debitCell;
|
||||||
|
BasicCell * memoCell;
|
||||||
|
ComboCell * actionCell;
|
||||||
|
ComboCell * xfrmCell;
|
||||||
|
|
||||||
PriceCell * balanceCell;
|
PriceCell * balanceCell;
|
||||||
|
|
||||||
} BasicRegister;
|
} BasicRegister;
|
||||||
@ -35,6 +52,8 @@ typedef struct _BasicRegister {
|
|||||||
BasicRegister * xaccMallocBasicRegister (void);
|
BasicRegister * xaccMallocBasicRegister (void);
|
||||||
void xaccInitBasicRegister (BasicRegister *);
|
void xaccInitBasicRegister (BasicRegister *);
|
||||||
|
|
||||||
|
unsigned int xaccGetChangeFlag (BasicRegister *);
|
||||||
|
|
||||||
#endif __XACC_REGISTER_H__
|
#endif __XACC_REGISTER_H__
|
||||||
|
|
||||||
/* ============ END OF FILE ===================== */
|
/* ============ END OF FILE ===================== */
|
||||||
|
@ -354,6 +354,7 @@ void xaccMoveCursor (Table *table, int virt_row, int virt_col)
|
|||||||
if (cell) {
|
if (cell) {
|
||||||
jphys = j + table->current_cursor_col * table->tile_width;
|
jphys = j + table->current_cursor_col * table->tile_width;
|
||||||
xaccSetBasicCellValue (cell, table->entries[iphys][jphys]);
|
xaccSetBasicCellValue (cell, table->entries[iphys][jphys]);
|
||||||
|
cell->changed = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -385,6 +386,7 @@ void xaccMoveCursorGUI (Table *table, int virt_row, int virt_col)
|
|||||||
for (j=0; j<table->tile_width; j++) {
|
for (j=0; j<table->tile_width; j++) {
|
||||||
cell = table->cursor->cells[i][j];
|
cell = table->cursor->cells[i][j];
|
||||||
if (cell) {
|
if (cell) {
|
||||||
|
cell->changed = 0;
|
||||||
if (cell->move) {
|
if (cell->move) {
|
||||||
(cell->move) (cell, -1, -1);
|
(cell->move) (cell, -1, -1);
|
||||||
}
|
}
|
||||||
@ -476,11 +478,6 @@ verifyCursorPosition (Table *table, int phys_row, int phys_col)
|
|||||||
if ((virt_row != table->current_cursor_row) ||
|
if ((virt_row != table->current_cursor_row) ||
|
||||||
(virt_col != table->current_cursor_col)) {
|
(virt_col != table->current_cursor_col)) {
|
||||||
|
|
||||||
printf ("verify cursor bad cur %d %d new %d %d \n",
|
|
||||||
table->current_cursor_row,
|
|
||||||
table->current_cursor_col,
|
|
||||||
virt_row, virt_col);
|
|
||||||
|
|
||||||
/* before leaving, the current virtual position,
|
/* before leaving, the current virtual position,
|
||||||
* commit any edits that have been accumulated
|
* commit any edits that have been accumulated
|
||||||
* in the cursor */
|
* in the cursor */
|
||||||
@ -655,7 +652,7 @@ enterCB (Widget mw, XtPointer cd, XtPointer cb)
|
|||||||
rel_row %= (arr->numRows);
|
rel_row %= (arr->numRows);
|
||||||
rel_col %= (arr->numCols);
|
rel_col %= (arr->numCols);
|
||||||
|
|
||||||
printf ("enter %d %d \n", row, col);
|
printf ("enter %d %d \n", row, col);
|
||||||
|
|
||||||
/* since we are here, there must be a cell handler.
|
/* since we are here, there must be a cell handler.
|
||||||
* therefore, we accept entry into the cell by default,
|
* therefore, we accept entry into the cell by default,
|
||||||
@ -675,6 +672,7 @@ enterCB (Widget mw, XtPointer cd, XtPointer cb)
|
|||||||
if (val != retval) {
|
if (val != retval) {
|
||||||
if (table->entries[row][col]) free (table->entries[row][col]);
|
if (table->entries[row][col]) free (table->entries[row][col]);
|
||||||
table->entries[row][col] = retval;
|
table->entries[row][col] = retval;
|
||||||
|
(arr->cells[rel_row][rel_col])->changed = 0xffffffff;
|
||||||
XbaeMatrixSetCell (mw, row, col, retval);
|
XbaeMatrixSetCell (mw, row, col, retval);
|
||||||
XbaeMatrixRefreshCell (mw, row, col);
|
XbaeMatrixRefreshCell (mw, row, col);
|
||||||
|
|
||||||
@ -752,6 +750,7 @@ modifyCB (Widget mw, XtPointer cd, XtPointer cb)
|
|||||||
/* update data. bounds check done earlier */
|
/* update data. bounds check done earlier */
|
||||||
free (table->entries[row][col]);
|
free (table->entries[row][col]);
|
||||||
table->entries[row][col] = (char *) retval;
|
table->entries[row][col] = (char *) retval;
|
||||||
|
(arr->cells[rel_row][rel_col])->changed = 0xffffffff;
|
||||||
|
|
||||||
/* if the callback modified the display string,
|
/* if the callback modified the display string,
|
||||||
* update the display cell as well */
|
* update the display cell as well */
|
||||||
@ -806,9 +805,9 @@ leaveCB (Widget mw, XtPointer cd, XtPointer cb)
|
|||||||
rel_row %= (arr->numRows);
|
rel_row %= (arr->numRows);
|
||||||
rel_col %= (arr->numCols);
|
rel_col %= (arr->numCols);
|
||||||
|
|
||||||
printf ("leave %d %d \n", row, col);
|
printf ("leave %d %d \n", row, col);
|
||||||
|
|
||||||
/* by default, accept whateve the final roposed edit is */
|
/* by default, accept whatever the final proposed edit is */
|
||||||
cbs->doit = True;
|
cbs->doit = True;
|
||||||
|
|
||||||
/* OK, if there is a callback for this cell, call it */
|
/* OK, if there is a callback for this cell, call it */
|
||||||
@ -820,16 +819,32 @@ leaveCB (Widget mw, XtPointer cd, XtPointer cb)
|
|||||||
retval = leave (arr->cells[rel_row][rel_col], val);
|
retval = leave (arr->cells[rel_row][rel_col], val);
|
||||||
|
|
||||||
newval = (char *) retval;
|
newval = (char *) retval;
|
||||||
if (val == retval) newval = strdup (val);
|
|
||||||
if (NULL == retval) newval = strdup (val);
|
if (NULL == retval) newval = strdup (val);
|
||||||
|
if (val == retval) newval = strdup (val);
|
||||||
|
|
||||||
|
/* if the leave() routine declared a new string, lets use it */
|
||||||
|
if ( retval && (retval != val)) {
|
||||||
|
cbs->value = strdup (retval);
|
||||||
|
}
|
||||||
|
|
||||||
/* save whatever was returned */
|
|
||||||
if (table->entries[row][col]) free (table->entries[row][col]);
|
|
||||||
table->entries[row][col] = newval;
|
|
||||||
cbs->value = strdup (newval);
|
|
||||||
} else {
|
} else {
|
||||||
if (table->entries[row][col]) free (table->entries[row][col]);
|
newval = strdup (cbs->value);
|
||||||
table->entries[row][col] = strdup (cbs->value);
|
}
|
||||||
|
|
||||||
|
/* save whatever was returned; but lets check for
|
||||||
|
* changes to avoid roiling the cells too much */
|
||||||
|
if (table->entries[row][col]) {
|
||||||
|
if (strcmp (table->entries[row][col], newval)) {
|
||||||
|
free (table->entries[row][col]);
|
||||||
|
table->entries[row][col] = newval;
|
||||||
|
(arr->cells[rel_row][rel_col])->changed = 0xffffffff;
|
||||||
|
} else {
|
||||||
|
/* leave() allocated memory, which we will not be using ... */
|
||||||
|
free (newval);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
table->entries[row][col] = newval;
|
||||||
|
(arr->cells[rel_row][rel_col])->changed = 0xffffffff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user