mask.* Aggiunta creazione campi albero dinamica
maskfld.* Migliorata gestione resizing campi e procedura di "Gestione" multirec.* Resa indipendente dalle dimensione degli array C git-svn-id: svn://10.65.10.50/trunk@6579 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
ebdec7ba39
commit
2eb4a2460d
@ -302,7 +302,7 @@ TOperable_field& TMask::focus_field() const
|
|||||||
{
|
{
|
||||||
if (is_open())
|
if (is_open())
|
||||||
{
|
{
|
||||||
const short focus = get_focus_id(win());
|
const short focus = low_get_focus_id(win());
|
||||||
if (focus > 0 )
|
if (focus > 0 )
|
||||||
((TMask *)this)->_focus = id2pos(focus);
|
((TMask *)this)->_focus = id2pos(focus);
|
||||||
}
|
}
|
||||||
@ -1718,6 +1718,21 @@ TMemo_field& TMask::add_memo(
|
|||||||
return *f;
|
return *f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TTree_field& TMask::add_tree (
|
||||||
|
short id, // @parm Numero identificatore del campo da aggiungere
|
||||||
|
int page, // @parm Pagina nel quale aggiungere il campo
|
||||||
|
int x, // @parm Coordinata x (in caratteri)
|
||||||
|
int y, // @parm Coordinata y (in caratteri)
|
||||||
|
int dx, // @parm Larghezza del campo sulla maschera
|
||||||
|
int dy, // @parm Altezza del campo sulla maschera
|
||||||
|
const char* flags)// @parm Flag di controllo del campo (default "")
|
||||||
|
{
|
||||||
|
TTree_field* f = new TTree_field(this);
|
||||||
|
f->construct(id, "", x, y, dy, _pagewin[page], flags, dx);
|
||||||
|
add_field(f);
|
||||||
|
return *f;
|
||||||
|
}
|
||||||
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
|
|
||||||
// @mfunc Salva i valori dei campi della maschera sul file di salvataggio
|
// @mfunc Salva i valori dei campi della maschera sul file di salvataggio
|
||||||
|
@ -203,6 +203,8 @@ public:
|
|||||||
TZoom_field& add_zoom (short id, int page, const char* prompt, int x, int y, int dim, const char* flags = "", int width = 0);
|
TZoom_field& add_zoom (short id, int page, const char* prompt, int x, int y, int dim, const char* flags = "", int width = 0);
|
||||||
// @cmember Aggiunge runtime un campo lista alla maschera
|
// @cmember Aggiunge runtime un campo lista alla maschera
|
||||||
TList_field& add_list (short id, int page, const char* prompt, int x, int y, int dim, const char* flags = "", const char* codes = NULL, const char* items = NULL);
|
TList_field& add_list (short id, int page, const char* prompt, int x, int y, int dim, const char* flags = "", const char* codes = NULL, const char* items = NULL);
|
||||||
|
// @cmember Aggiunge runtime un campo albero
|
||||||
|
TTree_field& add_tree (short id, int page, int x, int y, int dx, int dy, const char* flags = "");
|
||||||
|
|
||||||
// @cmember Ritorna il numero di campi della maschera
|
// @cmember Ritorna il numero di campi della maschera
|
||||||
int fields() const
|
int fields() const
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
#include <applicat.h>
|
|
||||||
#include <colors.h>
|
#include <colors.h>
|
||||||
#include <controls.h>
|
#include <controls.h>
|
||||||
#include <defmask.h>
|
|
||||||
#include <execp.h>
|
#include <execp.h>
|
||||||
#include <mailbox.h>
|
|
||||||
#include <mask.h>
|
#include <mask.h>
|
||||||
#include <prefix.h>
|
#include <prefix.h>
|
||||||
#include <relation.h>
|
#include <relation.h>
|
||||||
#include <sheet.h>
|
#include <sheet.h>
|
||||||
#include <tabutil.h>
|
#include <tabutil.h>
|
||||||
|
#include <text.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
#include <utility.h>
|
#include <utility.h>
|
||||||
#include <validate.h>
|
#include <validate.h>
|
||||||
#include <xvtility.h>
|
#include <xvtility.h>
|
||||||
#include <text.h>
|
|
||||||
|
|
||||||
|
|
||||||
// @doc INTERNAL
|
// @doc INTERNAL
|
||||||
@ -179,8 +176,6 @@ void TMask_field::set_focus() const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @doc INTERNAL
|
// @doc INTERNAL
|
||||||
|
|
||||||
// Certified 100%
|
// Certified 100%
|
||||||
@ -941,11 +936,9 @@ void TOperable_field::highlight() const
|
|||||||
|
|
||||||
bool TOperable_field::handler(KEY k)
|
bool TOperable_field::handler(KEY k)
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok = TRUE;
|
||||||
if (_handler)
|
if (_handler)
|
||||||
ok = _handler(*this, k);
|
ok = _handler(*this, k);
|
||||||
else
|
|
||||||
ok = TRUE;
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2149,32 +2142,32 @@ bool TBrowse::do_link(bool insert)
|
|||||||
if (_insert[0] == 'M')
|
if (_insert[0] == 'M')
|
||||||
{
|
{
|
||||||
TString nm(_insert.mid(1));
|
TString nm(_insert.mid(1));
|
||||||
// if (nm.compare("batb", 4, TRUE) == 0) // Programma gestione tabelle
|
|
||||||
if (nm.compare("tb", 2, TRUE) == 0) // Programma gestione tabelle
|
if (nm.compare("tb", 2, TRUE) == 0) // Programma gestione tabelle
|
||||||
{
|
{
|
||||||
// app = format("ba3 -0 %s", (const char*)nm.mid(4));
|
|
||||||
const char* module = ((TTable&)_cursor->file()).module();
|
const char* module = ((TTable&)_cursor->file()).module();
|
||||||
TString prg("ba3 -0");
|
app = "ba3 -0 ";
|
||||||
if (strcmp(module,"ba")!=0)
|
if (stricmp(module,"ba") !=0 )
|
||||||
{
|
{
|
||||||
TConfig c(CONFIG_STUDIO);
|
TConfig c(CONFIG_STUDIO);
|
||||||
prg = c.get("TabPrg",module);
|
app = c.get("TabPrg",module);
|
||||||
if (prg.empty())
|
if (app.empty())
|
||||||
prg = "ba3 -0";
|
app = "ba3 -0 ";
|
||||||
}
|
}
|
||||||
|
nm.ltrim(2);
|
||||||
// Obbligatorio usare la format globale
|
app << nm;
|
||||||
app.format("%s %s", (const char*)prg,(const char*)nm.mid(2));
|
|
||||||
}
|
|
||||||
else // Programma generico di browse/edit
|
|
||||||
// Obbligatorio usare la format globale
|
|
||||||
app = format("ba3 -3 %s %d", (const char*)nm, _cursor->file().num());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
app = &_insert[1];
|
// Programma generico di browse/edit (caduto in disuso)
|
||||||
|
app = "ba3 -3 ";
|
||||||
|
app << nm << ' ' << _cursor->file().num();
|
||||||
}
|
}
|
||||||
if (app.find('#') != -1)
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
app = _insert.mid(1);
|
||||||
|
}
|
||||||
|
if (app.find('#') >= 0)
|
||||||
{
|
{
|
||||||
TString w(app);
|
TString w(app);
|
||||||
app = "";
|
app = "";
|
||||||
@ -2195,67 +2188,66 @@ bool TBrowse::do_link(bool insert)
|
|||||||
app << *f;
|
app << *f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TMailbox mail;
|
|
||||||
|
TFilename msg; msg.temp("msg");
|
||||||
|
app << " /i" << msg;
|
||||||
|
|
||||||
if (insert)
|
if (insert)
|
||||||
{
|
{
|
||||||
TMessage msg(app, MSG_AI, "");
|
TConfig ini(msg, "Transaction");
|
||||||
mail.send(msg);
|
ini.set("Action", "RUN");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TToken_string body;
|
TConfig ini(msg, "Transaction");
|
||||||
|
ini.set("Action", "MODIFY");
|
||||||
|
|
||||||
|
TString paragraph; paragraph << _cursor->file().num();
|
||||||
|
ini.set_paragraph(paragraph);
|
||||||
|
|
||||||
body.add(_cursor->key());
|
|
||||||
_inp_fn.restart();
|
_inp_fn.restart();
|
||||||
for (const char* i = _inp_id.get(0); i; i = _inp_id.get())
|
for (const char* i = _inp_id.get(0); i; i = _inp_id.get())
|
||||||
{
|
{
|
||||||
TString inp_id(i);
|
TString inp_id(i);
|
||||||
TString16 field_name(_inp_fn.get());
|
TString s(_inp_fn.get());
|
||||||
TString s(field_name);
|
|
||||||
const int pos = s.find(",");
|
const int pos = s.find(",");
|
||||||
|
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
s.cut(pos);
|
s.cut(pos);
|
||||||
|
|
||||||
s << "=";
|
|
||||||
if (inp_id[0] == '"')
|
if (inp_id[0] == '"')
|
||||||
{
|
{
|
||||||
inp_id.ltrim(1);
|
inp_id.ltrim(1);
|
||||||
inp_id.rtrim(1);
|
inp_id.rtrim(1);
|
||||||
s << inp_id;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const short id = field().atodlg(inp_id);
|
TFieldref fldref(s, 0);
|
||||||
const TEditable_field & f = field(id);
|
inp_id = fldref.read(*_cursor->relation());
|
||||||
|
|
||||||
TFieldref fldref(field_name, 0);
|
|
||||||
s << fldref.read(*_cursor->relation());
|
|
||||||
}
|
}
|
||||||
body.add(s);
|
ini.set(s, inp_id);
|
||||||
}
|
}
|
||||||
TMessage msg(app, MSG_ED, body);
|
|
||||||
mail.send(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TExternal_app a(app);
|
TExternal_app a(app);
|
||||||
int err = a.run();
|
int err = a.run();
|
||||||
field().mask().set_focus();
|
field().mask().set_focus();
|
||||||
|
|
||||||
if (err == 0 && mail.check())
|
if (msg.not_empty())
|
||||||
{
|
{
|
||||||
TMessage* rcv = mail.next_s(insert ? MSG_AI : MSG_LN);
|
TConfig ini(msg, "Transaction");
|
||||||
if (rcv != NULL)
|
_rec = ini.get_long("Record");
|
||||||
_rec = atol(rcv->body());
|
if (_rec >= 0)
|
||||||
if (_rec > 0)
|
|
||||||
{
|
{
|
||||||
_cursor->file().readat(_rec);
|
_cursor->file().readat(_rec);
|
||||||
ok = _cursor->ok();
|
ok = _cursor->ok();
|
||||||
if (ok) do_output();
|
if (ok)
|
||||||
|
do_output();
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
else yesnofatal_box("Selezione da programma esterno errata");
|
else
|
||||||
|
yesnofatal_box("Selezione da programma esterno errata");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
::remove(msg);
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
@ -2438,11 +2430,6 @@ bool TBrowse::check(CheckTime t)
|
|||||||
const int ne = do_input(TRUE);
|
const int ne = do_input(TRUE);
|
||||||
if (ne || chk == CHECK_REQUIRED)
|
if (ne || chk == CHECK_REQUIRED)
|
||||||
{
|
{
|
||||||
/* Guy: vecchio modo
|
|
||||||
_cursor->setkey();
|
|
||||||
_cursor->file().read(_isequal);
|
|
||||||
passed = _cursor->ok();
|
|
||||||
*/
|
|
||||||
passed = _cursor->test() == NOERR;
|
passed = _cursor->test() == NOERR;
|
||||||
|
|
||||||
if (t != FINAL_CHECK)
|
if (t != FINAL_CHECK)
|
||||||
@ -2768,6 +2755,12 @@ bool TEdit_field::parse_item(TScanner& scanner)
|
|||||||
return TEditable_field::parse_item(scanner);
|
return TEditable_field::parse_item(scanner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filtro magico sulle ditte esistenti
|
||||||
|
HIDDEN bool firm_filter(const TRelation* rel)
|
||||||
|
{
|
||||||
|
const long firm = rel->curr().get_long("CODDITTA");
|
||||||
|
return prefix().exist(firm);
|
||||||
|
}
|
||||||
|
|
||||||
void TEdit_field::create(WINDOW parent)
|
void TEdit_field::create(WINDOW parent)
|
||||||
{
|
{
|
||||||
@ -2786,6 +2779,17 @@ void TEdit_field::create(WINDOW parent)
|
|||||||
|
|
||||||
if (_browse && !enabled_default())
|
if (_browse && !enabled_default())
|
||||||
((TField_control*)_ctl)->show_button(FALSE);
|
((TField_control*)_ctl)->show_button(FALSE);
|
||||||
|
|
||||||
|
if (_browse && validate_func() == 24)
|
||||||
|
{
|
||||||
|
TCursor* cursor = browse()->cursor();
|
||||||
|
if (cursor)
|
||||||
|
{
|
||||||
|
const int logicnum = cursor->file().num();
|
||||||
|
if (logicnum == LF_NDITTE)
|
||||||
|
cursor->set_filterfunction(firm_filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TEdit_field::reformat(const char* str) const
|
const char* TEdit_field::reformat(const char* str) const
|
||||||
@ -3388,7 +3392,9 @@ void TReal_field::create(WINDOW w)
|
|||||||
TEdit_field::create(w);
|
TEdit_field::create(w);
|
||||||
|
|
||||||
if (_flags.firm)
|
if (_flags.firm)
|
||||||
TMask_field::set(main_app().get_firm());
|
{
|
||||||
|
TMask_field::set(prefix().get_codditta());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if (automagic())
|
if (automagic())
|
||||||
TMask_field::set(TDate(TODAY).year());
|
TMask_field::set(TDate(TODAY).year());
|
||||||
@ -3467,7 +3473,7 @@ bool TReal_field::on_key(KEY key)
|
|||||||
{
|
{
|
||||||
const long f = atol(n);
|
const long f = atol(n);
|
||||||
if (f > 0 && prefix().exist(f))
|
if (f > 0 && prefix().exist(f))
|
||||||
main_app().set_firm(f);
|
prefix().set_codditta(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_window_data(raw2win(n));
|
set_window_data(raw2win(n));
|
||||||
@ -4228,9 +4234,9 @@ extern "C"
|
|||||||
void TField_window::update()
|
void TField_window::update()
|
||||||
{
|
{
|
||||||
const WINDOW me = win();
|
const WINDOW me = win();
|
||||||
const WINDOW pa = parent();
|
|
||||||
if (CAMPI_SCAVATI)
|
if (CAMPI_SCAVATI)
|
||||||
{
|
{
|
||||||
|
const WINDOW pa = parent();
|
||||||
RCT rct; xvt_vobj_get_outer_rect(me, &rct);
|
RCT rct; xvt_vobj_get_outer_rect(me, &rct);
|
||||||
rct.left -= 2; rct.top -= 2; rct.right += 2; rct.bottom += 2;
|
rct.left -= 2; rct.top -= 2; rct.right += 2; rct.bottom += 2;
|
||||||
xi_draw_3d_rect(pa, &rct, TRUE, 2,
|
xi_draw_3d_rect(pa, &rct, TRUE, 2,
|
||||||
@ -4275,6 +4281,31 @@ void TWindowed_field::show(bool on)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TWindowed_field::highlight() const
|
||||||
|
{
|
||||||
|
if (_win && active())
|
||||||
|
{
|
||||||
|
WINDOW w = _win->win();
|
||||||
|
xvt_scr_set_focus_vobj(w);
|
||||||
|
xvt_vobj_raise(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RCT& TWindowed_field::get_rect(RCT& r) const
|
||||||
|
{
|
||||||
|
if (_win)
|
||||||
|
xvt_vobj_get_outer_rect(_win->win(), &r);
|
||||||
|
else
|
||||||
|
xvt_rect_set_empty(&r);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TWindowed_field::set_rect(const RCT&)
|
||||||
|
{
|
||||||
|
CHECK(NULL, "Can't resize windowed field by now!");
|
||||||
|
}
|
||||||
|
|
||||||
void TWindowed_field::parse_head(TScanner& scanner)
|
void TWindowed_field::parse_head(TScanner& scanner)
|
||||||
{
|
{
|
||||||
_ctl_data._width = scanner.integer();
|
_ctl_data._width = scanner.integer();
|
||||||
|
@ -150,8 +150,8 @@ public:
|
|||||||
// @cmember Ritorna la finestra padre
|
// @cmember Ritorna la finestra padre
|
||||||
virtual WINDOW parent() const;
|
virtual WINDOW parent() const;
|
||||||
|
|
||||||
RCT& get_rect(RCT& r) const;
|
virtual RCT& get_rect(RCT& r) const;
|
||||||
void set_rect(const RCT& r);
|
virtual void set_rect(const RCT& r);
|
||||||
|
|
||||||
// @cmember Ritorna l'identificatore del controllo
|
// @cmember Ritorna l'identificatore del controllo
|
||||||
virtual short dlg() const;
|
virtual short dlg() const;
|
||||||
@ -1442,6 +1442,7 @@ class TWindowed_field : public TOperable_field
|
|||||||
protected: // TMask_field
|
protected: // TMask_field
|
||||||
virtual void parse_head(TScanner& scanner);
|
virtual void parse_head(TScanner& scanner);
|
||||||
virtual void create(WINDOW parent);
|
virtual void create(WINDOW parent);
|
||||||
|
virtual void highlight() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual TField_window* create_window(int x, int y, int dx, int dy,
|
virtual TField_window* create_window(int x, int y, int dx, int dy,
|
||||||
@ -1452,6 +1453,8 @@ public: // TMask_field
|
|||||||
virtual WINDOW parent() const { return win().parent(); }
|
virtual WINDOW parent() const { return win().parent(); }
|
||||||
virtual void enable(bool on = TRUE);
|
virtual void enable(bool on = TRUE);
|
||||||
virtual void show(bool on = TRUE);
|
virtual void show(bool on = TRUE);
|
||||||
|
virtual RCT& get_rect(RCT& r) const;
|
||||||
|
virtual void set_rect(const RCT& r);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TField_window& win() const { CHECK(_win, "NULL Window in field"); return *_win; }
|
TField_window& win() const { CHECK(_win, "NULL Window in field"); return *_win; }
|
||||||
@ -1477,6 +1480,7 @@ public:
|
|||||||
|
|
||||||
void hide_leaves(bool yes = TRUE);
|
void hide_leaves(bool yes = TRUE);
|
||||||
void show_leaves(bool yes = TRUE) { hide_leaves(!yes); }
|
void show_leaves(bool yes = TRUE) { hide_leaves(!yes); }
|
||||||
|
bool select_current();
|
||||||
|
|
||||||
TTree_field(TMask* m) : TWindowed_field(m) { }
|
TTree_field(TMask* m) : TWindowed_field(m) { }
|
||||||
virtual ~TTree_field() { }
|
virtual ~TTree_field() { }
|
||||||
|
@ -27,7 +27,7 @@ void TMultiple_rectype::load_rows_file(int logicnum)
|
|||||||
_files.add( r, index);
|
_files.add( r, index);
|
||||||
}
|
}
|
||||||
((TRecord_array &)_files[index]).read(rec); // rilegge
|
((TRecord_array &)_files[index]).read(rec); // rilegge
|
||||||
_changed[index]=FALSE;
|
_changed.reset(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TMultiple_rectype::find(int logicnum, const char * fieldname, const char * s, int from, bool reverse) const
|
int TMultiple_rectype::find(int logicnum, const char * fieldname, const char * s, int from, bool reverse) const
|
||||||
@ -70,7 +70,7 @@ int TMultiple_rectype::write_rewrite(TBaseisamfile & f, bool re) const
|
|||||||
|
|
||||||
if (re)
|
if (re)
|
||||||
{
|
{
|
||||||
for (int i = _nfiles - 1; err == NOERR && i >= 0 ; i--)
|
for (int i = _files.last(); err == NOERR && i >= 0 ; i = _files.pred(i))
|
||||||
{
|
{
|
||||||
TRecord_array * r = (TRecord_array *) _files.objptr(i);
|
TRecord_array * r = (TRecord_array *) _files.objptr(i);
|
||||||
if (r && !_changed[i])
|
if (r && !_changed[i])
|
||||||
@ -109,7 +109,7 @@ int TMultiple_rectype::write_rewrite(TBaseisamfile & f, bool re) const
|
|||||||
if (err != NOERR)
|
if (err != NOERR)
|
||||||
err = TRectype::rewrite(f);
|
err = TRectype::rewrite(f);
|
||||||
}
|
}
|
||||||
for (int i = _nfiles - 1; err == NOERR && i >= 0 ; i--)
|
for (int i = _files.last(); err == NOERR && i >= 0 ; i = _files.pred(i))
|
||||||
{
|
{
|
||||||
TRecord_array * r = (TRecord_array *)_files.objptr(i);
|
TRecord_array * r = (TRecord_array *)_files.objptr(i);
|
||||||
if (r && !_changed[i])
|
if (r && !_changed[i])
|
||||||
@ -129,10 +129,10 @@ void TMultiple_rectype::remove_body(int logicnum)
|
|||||||
|
|
||||||
int TMultiple_rectype::log2ind(int logicnum) const
|
int TMultiple_rectype::log2ind(int logicnum) const
|
||||||
{
|
{
|
||||||
if (logicnum == 0)
|
if (logicnum <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
for (int i = _nfiles - 1; i >= 0 ; i--)
|
for (int i = _logicnums.last(); i >= 0 ; i--)
|
||||||
if (_logicnums[i] == logicnum)
|
if (lognum(i) == logicnum)
|
||||||
return i;
|
return i;
|
||||||
NFCHECK("Can't find file %d in multiple record", logicnum);
|
NFCHECK("Can't find file %d in multiple record", logicnum);
|
||||||
return 0;
|
return 0;
|
||||||
@ -143,23 +143,18 @@ TRecord_array & TMultiple_rectype::body(int logicnum) const
|
|||||||
const int index = log2ind(logicnum);
|
const int index = log2ind(logicnum);
|
||||||
|
|
||||||
if (_files.objptr(index) == NULL || _changed[index])
|
if (_files.objptr(index) == NULL || _changed[index])
|
||||||
((TMultiple_rectype *) this)->load_rows_file(_logicnums[index]);
|
((TMultiple_rectype*) this)->load_rows_file(lognum(index));
|
||||||
return (TRecord_array&) _files[index];
|
return (TRecord_array&) _files[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMultiple_rectype::renum_key()
|
void TMultiple_rectype::renum_key()
|
||||||
{
|
{
|
||||||
for (int i = _nfiles - 1; i >= 0 ; i--)
|
for (int i = _files.last(); i >= 0 ; i = _files.pred(i))
|
||||||
{
|
{
|
||||||
const int logicnum = _logicnums[i];
|
TRecord_array& b = (TRecord_array&)_files[i];
|
||||||
TRecord_array * b = (TRecord_array *) _files.objptr(i);
|
TRectype* rec = new TRectype(b.key());
|
||||||
if (b)
|
|
||||||
{
|
|
||||||
TRectype * rec = new TRectype(b->key());
|
|
||||||
|
|
||||||
set_body_key(*rec);
|
set_body_key(*rec);
|
||||||
b->set_key(rec); // Aggiorna righe
|
b.set_key(rec); // Aggiorna righe
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,17 +179,14 @@ void TMultiple_rectype::zero(char c)
|
|||||||
{
|
{
|
||||||
reset_fields(*this);
|
reset_fields(*this);
|
||||||
TAuto_variable_rectype::zero(c);
|
TAuto_variable_rectype::zero(c);
|
||||||
for (int i = _nfiles - 1; i >= 0 ; i--)
|
for (int i = _files.last(); i >= 0 ; i = _files.pred(i))
|
||||||
if (_files.objptr(i) != NULL)
|
|
||||||
((TRecord_array &)_files[i]).destroy_rows();
|
((TRecord_array &)_files[i]).destroy_rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TMultiple_rectype::readat(TBaseisamfile& f, TRecnotype nrec, word lockop)
|
int TMultiple_rectype::readat(TBaseisamfile& f, TRecnotype nrec, word lockop)
|
||||||
{
|
{
|
||||||
int err = NOERR;
|
|
||||||
|
|
||||||
_nuovo = FALSE;
|
_nuovo = FALSE;
|
||||||
err = TRectype::readat(f, nrec, lockop);
|
int err = TRectype::readat(f, nrec, lockop);
|
||||||
synchronize_bodies();
|
synchronize_bodies();
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -224,16 +216,16 @@ int TMultiple_rectype::read(TBaseisamfile & f, word op, word lockop)
|
|||||||
|
|
||||||
void TMultiple_rectype::synchronize_bodies()
|
void TMultiple_rectype::synchronize_bodies()
|
||||||
{
|
{
|
||||||
for (int i = _nfiles - 1; i >= 0 ; i--)
|
for (int i = _logicnums.last(); i >= 0 ; i--)
|
||||||
{
|
{
|
||||||
if (_nuovo)
|
if (_nuovo)
|
||||||
{
|
{
|
||||||
TRecord_array * b = (TRecord_array *) _files.objptr(i);
|
TRecord_array * b = (TRecord_array *) _files.objptr(i);
|
||||||
if (b != NULL)
|
if (b != NULL)
|
||||||
{
|
{
|
||||||
_changed[i] = FALSE;
|
_changed.reset(i);
|
||||||
b->destroy_rows();
|
b->destroy_rows();
|
||||||
TRectype * r = new_body_record(_logicnums[i]);
|
TRectype * r = new_body_record(lognum(i));
|
||||||
set_body_key(*r);
|
set_body_key(*r);
|
||||||
b->set_key(r);
|
b->set_key(r);
|
||||||
}
|
}
|
||||||
@ -241,10 +233,10 @@ void TMultiple_rectype::synchronize_bodies()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (_autoload[i])
|
if (_autoload[i])
|
||||||
load_rows_file(_logicnums[i]);
|
load_rows_file(lognum(i));
|
||||||
else
|
else
|
||||||
if (_files.objptr(i) != NULL)
|
if (_files.objptr(i) != NULL)
|
||||||
_changed[i] = TRUE;
|
_changed.set(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -254,16 +246,14 @@ TMultiple_rectype & TMultiple_rectype::copy(const TMultiple_rectype& r)
|
|||||||
{
|
{
|
||||||
// copia..
|
// copia..
|
||||||
TAuto_variable_rectype::operator=((TAuto_variable_rectype&)r);
|
TAuto_variable_rectype::operator=((TAuto_variable_rectype&)r);
|
||||||
_files = r._files;
|
|
||||||
_nuovo = r._nuovo;
|
_nuovo = r._nuovo;
|
||||||
_nfiles=r._nfiles; // file delle righe
|
_files = r._files;
|
||||||
for (int i = _nfiles - 1; i >= 0; i--)
|
_logicnums = r._logicnums;
|
||||||
{
|
_changed = r._changed;
|
||||||
_logicnums[i] = r._logicnums[i];
|
_autoload = r._autoload;
|
||||||
_changed[i] = r._changed[i];
|
|
||||||
_autoload[i] = r._autoload[i];
|
|
||||||
}
|
|
||||||
_numfields = r._numfields;
|
_numfields = r._numfields;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,9 +272,9 @@ int TMultiple_rectype::remove(TBaseisamfile & f) const
|
|||||||
{
|
{
|
||||||
int err = NOERR;
|
int err = NOERR;
|
||||||
|
|
||||||
for (int i = _nfiles - 1; err == NOERR && i >= 0 ; i--)
|
for (int i = _files.last(); err == NOERR && i >= 0 ; i = _files.pred(i))
|
||||||
{
|
{
|
||||||
TRecord_array & r = body(_logicnums[i]);
|
TRecord_array & r = body(lognum(i));
|
||||||
err = r.remove();
|
err = r.remove();
|
||||||
}
|
}
|
||||||
if (err == NOERR)
|
if (err == NOERR)
|
||||||
@ -294,14 +284,14 @@ int TMultiple_rectype::remove(TBaseisamfile & f) const
|
|||||||
|
|
||||||
// @doc INTERNAL
|
// @doc INTERNAL
|
||||||
TMultiple_rectype::TMultiple_rectype(int hfn)
|
TMultiple_rectype::TMultiple_rectype(int hfn)
|
||||||
: TAuto_variable_rectype(hfn), _nuovo(TRUE), _nfiles(0)
|
: TAuto_variable_rectype(hfn), _nuovo(TRUE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMultiple_rectype::enable_autoload(int logicnum,bool on)
|
void TMultiple_rectype::enable_autoload(int logicnum,bool on)
|
||||||
{
|
{
|
||||||
const int index = log2ind(logicnum);
|
const int index = log2ind(logicnum);
|
||||||
_autoload[index] = on;
|
_autoload.set(index, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRectype & TMultiple_rectype::insert_row(int row, int logicnum)
|
TRectype & TMultiple_rectype::insert_row(int row, int logicnum)
|
||||||
@ -332,20 +322,18 @@ bool TMultiple_rectype::autoload_enabled(int logicnum)
|
|||||||
// @cmember Aggiunge il corpo lgicnum
|
// @cmember Aggiunge il corpo lgicnum
|
||||||
void TMultiple_rectype::add_file(int logicnum, const char* numfield)
|
void TMultiple_rectype::add_file(int logicnum, const char* numfield)
|
||||||
{
|
{
|
||||||
CHECK(_nfiles < maxfiles, "Too many files added");
|
_logicnums.add_long(logicnum);
|
||||||
_logicnums[_nfiles] = logicnum;
|
_numfields.add(numfield);
|
||||||
_autoload[_nfiles] = FALSE;
|
|
||||||
_numfields.add(numfield, _nfiles++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TMultiple_rectype::TMultiple_rectype(const TBaseisamfile* file)
|
TMultiple_rectype::TMultiple_rectype(const TBaseisamfile* file)
|
||||||
:TAuto_variable_rectype(file), _nuovo(TRUE), _nfiles(0)
|
:TAuto_variable_rectype(file), _nuovo(TRUE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ cmember costruttore dal record
|
// @ cmember costruttore dal record
|
||||||
TMultiple_rectype::TMultiple_rectype(const TRectype & rec)
|
TMultiple_rectype::TMultiple_rectype(const TRectype & rec)
|
||||||
:TAuto_variable_rectype(rec), _nuovo(TRUE), _nfiles(0)
|
:TAuto_variable_rectype(rec), _nuovo(TRUE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
#ifndef __MULTIREC_H
|
#ifndef __MULTIREC_H
|
||||||
#define __MULTIREC_H
|
#define __MULTIREC_H
|
||||||
|
|
||||||
#ifndef __RELATION_H
|
|
||||||
#include <relation.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef __RECARRAY_H
|
#ifndef __RECARRAY_H
|
||||||
#include <recarray.h>
|
#include <recarray.h>
|
||||||
#endif
|
#endif
|
||||||
@ -20,22 +16,20 @@ class TMultiple_rectype ;
|
|||||||
//
|
//
|
||||||
class TMultiple_rectype : public TAuto_variable_rectype
|
class TMultiple_rectype : public TAuto_variable_rectype
|
||||||
{
|
{
|
||||||
enum { maxfiles = 20};
|
|
||||||
// @cmember Array di TRecord array per le righe
|
// @cmember Array di TRecord array per le righe
|
||||||
TArray _files; //
|
TArray _files; //
|
||||||
// @cmember flag indicatore di record nuovo
|
// @cmember flag indicatore di record nuovo
|
||||||
bool _nuovo;
|
bool _nuovo;
|
||||||
// @cmember numero di file righe
|
|
||||||
short _nfiles;
|
|
||||||
// @cmember file delle righe
|
// @cmember file delle righe
|
||||||
int _logicnums[maxfiles];
|
TPointer_array _logicnums;
|
||||||
// @cmember Indicazione di record array non più corrispondente alla testata
|
// @cmember Indicazione di record array non più corrispondente alla testata
|
||||||
bool _changed[maxfiles];
|
TBit_array _changed;
|
||||||
// @cmember Indicazione autoload
|
// @cmember Indicazione autoload
|
||||||
bool _autoload[maxfiles];
|
TBit_array _autoload;
|
||||||
// @cmember Array di nomi di campo "numeratore" delle righe
|
// @cmember Array di nomi di campo "numeratore" delle righe
|
||||||
TString_array _numfields;
|
TString_array _numfields;
|
||||||
|
|
||||||
|
int lognum(int index) const { return _logicnums.get_int(index); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const TArray & files() const { return _files;}
|
const TArray & files() const { return _files;}
|
||||||
@ -50,7 +44,7 @@ protected:
|
|||||||
// @cmember renumera le chiavi di tutti i corpi in base alla testata
|
// @cmember renumera le chiavi di tutti i corpi in base alla testata
|
||||||
virtual void renum_key();
|
virtual void renum_key();
|
||||||
// @cmember Genera il record del corpo
|
// @cmember Genera il record del corpo
|
||||||
virtual TRectype * new_body_record(int logicnum = 0) { return new TRectype(logicnum ? logicnum : _logicnums[0]); }
|
virtual TRectype * new_body_record(int logicnum = 0) { return new TRectype(logicnum ? logicnum : lognum(0)); }
|
||||||
// @cmember Crea e carica il record array del corpo
|
// @cmember Crea e carica il record array del corpo
|
||||||
virtual void load_rows_file(int logicnum);
|
virtual void load_rows_file(int logicnum);
|
||||||
// @cmember Ritorna l'indice di <p _files> del numero logico passato
|
// @cmember Ritorna l'indice di <p _files> del numero logico passato
|
||||||
@ -80,7 +74,6 @@ public:
|
|||||||
// @cmember restituisce il record di testata
|
// @cmember restituisce il record di testata
|
||||||
TAuto_variable_rectype& head() { return *this; } // Ritorna la testata del documento
|
TAuto_variable_rectype& head() { return *this; } // Ritorna la testata del documento
|
||||||
|
|
||||||
|
|
||||||
// @cmember restituisce il record array del corpo
|
// @cmember restituisce il record array del corpo
|
||||||
TRecord_array & body(int logicnum = 0) const;
|
TRecord_array & body(int logicnum = 0) const;
|
||||||
// @cmember restituisce il numero di record nel corpo
|
// @cmember restituisce il numero di record nel corpo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user