Continua la saga del dirty flag

git-svn-id: svn://10.65.10.50/trunk@620 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-11-14 13:22:46 +00:00
parent fd2976e280
commit 6964384386
5 changed files with 45 additions and 31 deletions

@ -135,7 +135,6 @@ void TMask::handler(WINDOW win, EVENT* ep)
{
case DLG_OK:
if (test_focus_change()) stop_run(K_AUTO_ENTER); break;
case DLG_BAR :
case DLG_CANCEL :
stop_run(K_ESC); break;
case DLG_QUIT :
@ -322,8 +321,13 @@ int TMask::first_focus(short id)
}
else
{
if (id > 0) _first_focus = id2pos(id);
else tempfirstfocus = id2pos(-id);
if (id > 0)
{
_first_focus = id2pos(id);
tempfirstfocus = 0;
}
else
tempfirstfocus = id2pos(-id);
}
return f;

@ -1,4 +1,4 @@
// $Id: maskfld.cpp,v 1.45 1994-11-14 09:59:59 guy Exp $
// $Id: maskfld.cpp,v 1.46 1994-11-14 13:22:38 guy Exp $
#include <xvt.h>
#include <applicat.h>
@ -374,16 +374,8 @@ word TMask_field::last_key() const
void TMask_field::set_dirty(bool d)
{
#ifdef DBG
if (_flags.dirty == 3)
{
if (d == 0)
{
error_box("Can't reset dirty flag of a bad field: %d", dlg());
return;
}
}
#endif
if (_flags.dirty > TRUE && d == FALSE)
return;
_flags.dirty = d;
set_focusdirty(d);
}

@ -955,14 +955,19 @@ void TSpreadsheet::str2mask(int riga)
f.set(val);
f.enable(!cell_disabled(riga, id-FIRST_FIELD));
if (f.active() || f.ghost())
if (f.dirty() <= TRUE)
{
if (f.has_check()) f.check(STARTING_CHECK);
if (f.active() || f.ghost())
{
if (f.has_check()) f.check(STARTING_CHECK);
f.set_dirty(FALSE);
f.on_hit();
}
f.set_dirty(FALSE);
f.on_hit();
}
f.set_dirty(FALSE);
else
_mask.first_focus(-rid);
rid += 100;
pos = _mask.id2pos(rid);
}
@ -1178,11 +1183,17 @@ bool TSheet_field::on_hit()
}
bool TSheet_field::on_key(KEY k)
{
{
if (k == K_TAB || k == K_ENTER)
{
if (dirty() > TRUE)
return FALSE; // Lo sheet e' inconsistente
return FALSE;
if (k == K_ENTER && dirty())
{
_sheet->str2mask(selected());
const bool ok = sheet_mask().check_fields();
if (!ok) return FALSE;
}
}
return TMask_field::on_key(k);

@ -1 +1 @@
#define VERSION 1.15
#define VERSION 1.16

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.26 1994-11-14 10:00:06 guy Exp $
// $Id: relapp.cpp,v 1.27 1994-11-14 13:22:46 guy Exp $
#include <mailbox.h>
#include <sheet.h>
#include <urldefid.h>
@ -536,10 +536,12 @@ bool TRelation_application::save(bool check_dirty)
if (check_dirty)
{
const char* ms = (mode == MODE_MOD) ? "le modifiche" : "i dati inseriti";
const int dirty = _mask->dirty();
if (mode == MODE_QUERY)
{
const bool cont = !dirty || yesno_box("Annullare i dati inseriti?");
const bool cont = !dirty || yesno_box("Annullare %s?", ms);
return cont;
}
@ -553,13 +555,19 @@ bool TRelation_application::save(bool check_dirty)
return TRUE;
}
if (_mask->field(dirty).dirty() > TRUE) // C'e' un campo errato
const KEY last = _mask->last_key();
const bool annulla = last == K_ESC || last == K_QUIT || last == K_F9;
const bool errore = dirty && _mask->field(dirty).dirty() > TRUE;
KEY k;
if (errore)
{
was_dirty = TRUE;
return FALSE;
if (annulla) k = yesno_box("Annullare %s?", ms);
else k = K_ESC;
}
const KEY k = yesnocancel_box(mode == MODE_MOD ? "Registrare le modifiche?"
: "Registrare i dati inseriti?");
else
k = yesnocancel_box("Registrare %s?", ms);
if (k == K_ESC)
{
was_dirty = TRUE;
@ -572,9 +580,8 @@ bool TRelation_application::save(bool check_dirty)
was_dirty = FALSE;
return TRUE;
}
const KEY last = _mask->last_key();
if (last == K_ESC || last == K_QUIT || last == K_F9)
if (annulla)
{
if (!_mask->check_fields()) // Exit with ESC didn't check values
{