Patch level : 12.0 1198

Files correlati     : cg2.exe ve0.exe

Commento:
aggiunti campi per  memorizzare documenti generici e documenti cartacei da archiviare
This commit is contained in:
Alessandro Bonazzi 2022-10-01 19:20:03 +02:00
parent d812b4735d
commit 3f3a20a8fd
15 changed files with 222 additions and 58 deletions

View File

@ -160,7 +160,7 @@ bool TArray::destroy(
if (index < 0)
{
for (int i = last(); i >= 0; i--)
if (_data[i] != NULL)
if (_data[i] != nullptr)
safe_delete(_data[i]);
_items = _next = 0;
}

View File

@ -55,9 +55,11 @@
#define DLG_EXPORT_PDF 51 /* TAG del bottone Esporta un pdf */
#define DLG_EXPORT_DBF 52 /* TAG del bottone Esporta in dbf */
#define DLG_EXPORT_TEXT 53 /* TAG del bottone Esporta un testo */
#define DLG_OUTPUTD 54 /* TAG del campo <output> direttorio*/
#define DLG_OUTPUTF 55 /* TAG del campo <output> file*/
#define DLG_REPORT 56 /* TAG del campo <report> */
#define DLG_OUTPUTD 54 /* TAG del campo <output> direttorio*/
#define DLG_OUTPUTF 55 /* TAG del campo <output> file*/
#define DLG_REPORT 56 /* TAG del campo <report> */
#define DLG_OGGETTI 57 /* TAG del campo <golem> */
#define DLG_CARTACEI 58 /* TAG del campo <golem da archiviare> */
#define DLG_USER 100 /* TAG del primo controllo definito dall'utente */

View File

@ -103,6 +103,8 @@
#define DOC_TIPODOCSDI "TIPODOCSDI"
#define DOC_NOINVIOSDI "NOINVIOSDI"
#define DOC_SCONTOFATT "SCONTOFATT"
#define DOC_COLL_GOLEM "COLL_GOLEM"
#define DOC_CARTACEI "CARTACEI"
// Virtuali
#define DOC_PLAFOND "PLAFOND"

View File

@ -10,6 +10,7 @@
#include <msksheet.h>
#include <prefix.h>
#include <relation.h>
#include <statbar.h>
#include <treectrl.h>
#include <urldefid.h>
#include <utility.h>
@ -309,24 +310,31 @@ TString& TGolem_field::get_window_data()
void TGolem_field::set_window_data(const char* data)
{
unsigned int icon = 0;
char* pipe = (char*)strchr(data, '|'); //antica porcata
if (pipe)
{
*pipe = '\0'; // Poor man TToken_string
icon = xvt_sys_load_icon(data);
*pipe = '|';
}
TPushbutton_control* btn = (TPushbutton_control*)_ctl;
if (icon)
btn->set_icon(icon);
else
btn->set_bmp(BMP_OLE, 0);
if (_tool) // non si capisce perchè non disegni la nuova bitmap
update_tool();
else
{
unsigned int icon = 0;
char* pipe = (char*)strchr(data, '|'); //antica porcata
RCT rct; btn->get_rect(rct);
xvt_dwin_invalidate_rect(btn->parent(), &rct);
if (pipe)
{
*pipe = '\0'; // Poor man TToken_string
icon = xvt_sys_load_icon(data);
*pipe = '|';
}
TPushbutton_control* btn = (TPushbutton_control*)_ctl;
if (icon)
btn->set_icon(icon);
else
btn->set_bmp(_bmp, 0);
RCT rct; btn->get_rect(rct);
xvt_dwin_invalidate_rect(btn->parent(), &rct);
}
}
bool TGolem_field::is_editable() const
@ -338,17 +346,54 @@ void TGolem_field::parse_head(TScanner& scanner)
if (_ctl_data._width <= 0) _ctl_data._width = 10;
_ctl_data._height = scanner.integer(); // Height
if (_ctl_data._height <= 0) _ctl_data._height = 1;
_ctl_data._bmp_up = BMP_OLE;
}
bool TGolem_field::parse_item(TScanner& scanner)
{
if (scanner.key() == "PI")
{
const short bmp = (short)scanner.integer();
if (_bmp == 0)
_bmp = bmp;
return bmp > 0;
}
return TEditable_field::parse_item(scanner);
}
void TGolem_field::create(WINDOW parent)
{
_ctl = new TPushbutton_control(parent, _ctl_data._dlg,
_ctl_data._x, _ctl_data._y,
_ctl_data._width+2, _ctl_data._height,
_ctl_data._flags, "", // No prompt -> icons olny!
_ctl_data._bmp_up, _ctl_data._bmp_dn);
}
if (_tool)
{
if (_ctl_data._dlg == DLG_OGGETTI)
{
if (_ctl_data._prompt.blank())
_ctl_data._prompt = TR("Oggetti");
if (_bmp <= 0)
_ctl_data._bmp_up = _bmp = TOOL_OLE;
}
else
if (_ctl_data._dlg == DLG_CARTACEI)
{
if (_ctl_data._prompt.blank())
_ctl_data._prompt = TR("Cartacei");
if (_ctl_data._bmp_up <= 0)
_ctl_data._bmp_up = _bmp = TOOL_ARCHIVE;
}
xvt_toolbar_add_control(_toolbar = parent, _dlg = _ctl_data._dlg, TOOL_TOGLBUTN, _ctl_data._prompt, _ctl_data._bmp_up, _ctl_data._width, -1);
}
else
{
if (_bmp == 0)
_bmp = BMP_OLE;
_ctl_data._bmp_up = _bmp;
_ctl = new TPushbutton_control(parent, _ctl_data._dlg,
_ctl_data._x, _ctl_data._y,
_ctl_data._width+2, _ctl_data._height,
_ctl_data._flags, _ctl_data._prompt,
_ctl_data._bmp_up, _ctl_data._bmp_dn);
}
}
bool TGolem_field::autoload(const TRelation& r)
{
@ -401,9 +446,28 @@ bool TGolem_field::autosave(TRelation& r)
if (tobe_stored && new_file.full())
{
char ext[_MAX_EXT];
xvt_fsys_parse_pathname(new_file, NULL, NULL, NULL, ext, NULL);
golem_path << SLASH;
old_file.temp(golem_path, ext);
char fname[_MAX_FNAME];
xvt_fsys_parse_pathname(new_file, NULL, NULL, fname, ext, NULL);
old_file = golem_path;
old_file.add(fname);
old_file.ext(ext);
if (fexist(old_file))
{
int i = 0;
old_file.ext("");
old_file << '_' << today.string(ANSI) << "_000";
old_file.ext(ext);
while (fexist(old_file))
{
old_file.ext("");
old_file.rtrim(1);
old_file << ++i;
old_file.ext(ext);
}
}
fcopy(new_file, old_file);
new_row.add(old_file, 0);
@ -437,8 +501,11 @@ bool TGolem_field::on_key(KEY key)
{
if (*row > ' ')
sheet.row(-1) = row;
}
if (msk->run() == K_ENTER)
}
short key = msk->run();
if (key == K_ENTER)
{
tmp.cut(0);
FOR_EACH_SHEET_ROW(sheet, r, row)
@ -450,6 +517,9 @@ bool TGolem_field::on_key(KEY key)
_selected = sheet.selected();
do_message(0);
}
else
if (key == K_ESC)
update_tool();
}
else
{
@ -467,14 +537,20 @@ bool TGolem_field::on_key(KEY key)
do_message(0);
}
}
delete msk;
}
safe_delete(msk);
}
return ok;
}
TGolem_field::TGolem_field(TMask* m)
: TEditable_field(m), _old_value(80, '\n'), _selected(0)
void TGolem_field::update_tool()
{
const TString & val = get_window_data();
xvt_toolbar_toggle_control(toolbar(), _dlg, val.full());
};
TGolem_field::TGolem_field(TMask* m, bool tool)
: TEditable_field(m), _old_value(80, '\n'), _selected(0), _bmp(0), _tool(tool), _dlg(-1)
{ }
TGolem_field::~TGolem_field()
@ -611,7 +687,7 @@ bool TGolem_window::on_key(KEY k)
}
}
force_update();
}
}
}
return TField_window::on_key(k);

View File

@ -955,6 +955,7 @@ int TBaseisamfile::_write(const TRectype& rec)
{
if (rec.has_memo())
((TRectype&)rec).write_memo(_isam_handle, _recno );
if (_logicnum < LF_EXTERNAL)
rec_cache(_logicnum).notify_change();
xvt_fsys_set_file_time(filename(), nullptr, nullptr, xvt_time_now());
}
@ -1018,7 +1019,10 @@ int TBaseisamfile::_rewrite(const TRectype& rec)
_lasterr = DB_rewrite(fhnd);
xvt_fsys_set_file_time(filename(), nullptr, nullptr, xvt_time_now());
if (_lasterr == NOERR)
rec_cache(_logicnum).notify_change();
{
if (_logicnum < LF_EXTERNAL)
rec_cache(_logicnum).notify_change();
}
else
_lasterr = get_error(_lasterr);
}
@ -1035,7 +1039,7 @@ int TBaseisamfile::_rewrite(const TRectype& rec)
if (changed)
((TRectype&)rec).write_memo(_isam_handle, _recno);
}
if (changed)
if (changed && _logicnum < LF_EXTERNAL)
rec_cache(_logicnum).notify_change();
}
}
@ -1077,7 +1081,7 @@ int TBaseisamfile::rewriteat(const TRectype& rec, TRecnotype nrec)
if (changed)
((TRectype&)rec).write_memo(_isam_handle, _recno);
}
if (changed)
if (changed && _logicnum < LF_EXTERNAL)
rec_cache(_logicnum).notify_change();
}
return _lasterr;
@ -1104,6 +1108,7 @@ int TBaseisamfile::_remove(const TRectype& rec)
{
if (curr().has_memo( ))
curr().init_memo();
if (_logicnum < LF_EXTERNAL)
rec_cache(_logicnum).notify_change();
DB_flush(fhnd);
}
@ -4336,7 +4341,7 @@ bool TRectype::edit(int logicnum, const char* alternate_key_fields, const char*
xvt_fsys_remove_file(ininame);
if (ok && _logicnum < 1000)
if (ok && _logicnum < LF_EXTERNAL)
rec_cache(logicnum).notify_change();
}
return ok;

View File

@ -606,7 +606,7 @@ bool TMask::check_fields()
{
TMask_field& f = fld(i);
const bool on = f.active() || (f.shown() && f.is_sheet());
if (on) // Don't test inactive fields
if (on && !f.is_kind_of(CLASS_GOLEM)) // Don't test inactive fields
{
if (f.parent() != curpage)
{
@ -2527,6 +2527,49 @@ TButton_tool& TMask::add_button_tool(short id, const char* prompt, short bmpup)
// @doc EXTERNAL
// @mfunc Aggiunge runtime un campo golem alla maschera
//
// @rdesc Ritorna l'handle del campo creato
TGolem_field& TMask::add_golem(
short id, // @parm Numero identificatore del campo da aggiungere
int page, // @parm Pagina nel quale aggiungere il campo
const char* prompt, // @parm Prompt del campo
int x, // @parm Coordinata x (in caratteri)
int y, // @parm Coordinata y (in caratteri)
int dx, // @parm Larghezza del campo (in caratteri, default 9)
int dy, // @parm Altezza del campo (in caratteri, default 1)
const char* flags, // @parm Flag di controllo del campo (default "")
short bmpup, // @parm Icona normale
short bmpdn) // @parm Icona premuta
// @xref <mf TMask::add_static> <mf TMask::add_string> <mf TMask::add_number>
// <mf TMask::add_date> <mf TMask::add_radio> <mf TMask::add_memo>
{
TGolem_field* g = new TGolem_field(this);
g->construct(id, prompt, x, y, dy, page_win(page), flags, dx, bmpup, bmpdn);
add_field(g);
return *g;
}
// @doc EXTERNAL
// @mfunc Aggiunge runtime un campo golem alla toolbar
// @rdesc Ritorna l'handle del campo creato
TGolem_field& TMask::add_golem_tool(short id, const char* prompt, const char* flags, short bmpup, short bmpdn)
{
TGolem_field * g = new TGolem_field(this, true);
if (toolbar() == NULL_WIN) // Se non c'e' ancora la toolbar, me l'invento adesso
create_bar(1);
g->construct(id, prompt, 0, 0, 0, toolbar(), flags, 0, bmpup, bmpdn);
add_field(g);
return *g;
}
// @doc EXTERNAL
// @mfunc Salva i valori dei campi della maschera sul file di salvataggio
//
// @rdesc Ritorna il risultato dell'operazione:

View File

@ -239,9 +239,12 @@ public:
TTree_field& add_tree (short id, int page, int x, int y, int dx, int dy, const char* flags = "");
// @cmember Aggiunge runtime un group box alla maschera
TGroup_field& add_groupbox (short id, int page, const char* prompt, int x, int y, int dx = 78, int dy = 3, const char* flags = "");
// @cmember Aggiunge runtime un campo golem alla maschera
TGolem_field& add_golem(short id, int page, const char* prompt, int x, int y, int dx = 9, int dy = 1, const char* flags = "", short bmpup = 0, short bmpdn = 0);
// @cmember Aggiunge runtime un bottone alla toolbar
TButton_tool& add_button_tool(short id, const char* prompt, short bmpup);
// @cmember Aggiunge runtime un campo golem alla toolbar
TGolem_field& add_golem_tool(short id, const char* prompt, const char* flags, short bmpup = 0, short bmpdn = 0);
// @cmember Ritorna il numero di campi della maschera
int fields() const

View File

@ -1351,15 +1351,21 @@ class TGolem_field : public TEditable_field
{
TToken_string _old_value;
int _selected;
int _bmp;
int _dlg;
bool _tool;
WINDOW _toolbar;
protected: // TEditable_field
bool is_kind_of(word cid) const { return cid == CLASS_GOLEM; }
virtual TString& get_window_data();
virtual void set_window_data(const char* data);
const WINDOW toolbar() const { return _toolbar; }
// @cmember Ritorna false in quanto il campo non e' realmente editable
virtual bool is_editable() const;
virtual void parse_head(TScanner& scanner);
bool parse_item(TScanner& scanner);
virtual void create(WINDOW parent);
// @cmember Legge dalla relazione il valore del campo
@ -1370,8 +1376,9 @@ protected: // TEditable_field
public:
virtual bool on_key(KEY k);
int selected() const { return _selected; }
void update_tool();
TGolem_field(TMask* m);
TGolem_field(TMask* m, bool tool = false);
virtual ~TGolem_field();
};

View File

@ -3,7 +3,7 @@
#include <tabmod.h>
// @cmember Richiede la maschera da usare
TMask* TTable_module_application::get_mask(int)
TMask* TTable_module_application::_get_mask(int)
{
CHECK(_msk, "Null mask");
return _msk;

View File

@ -26,7 +26,7 @@ protected:
virtual bool user_create();
virtual bool user_destroy();
virtual bool protected_record(TRectype& rec);
virtual TMask* get_mask(int mode);
virtual TMask* _get_mask(int mode);
virtual void set_mask(TMask * mask);
virtual TRelation* get_relation() const;
virtual void print();

View File

@ -63,6 +63,8 @@
#define MOV_ELABF9 "ELABF9"
#define MOV_IDDOCSDI "IDDOCSDI"
#define MOV_DATADOCSDI "DATADOCSDI"
#define MOV_COLL_GOLEM "COLL_GOLEM"
#define MOV_CARTACEI "CARTACEI"
#define NUMREG_PROVVISORIO 999999L

View File

@ -1019,6 +1019,28 @@ bool TRelation_application::find(word k)
return err == NOERR;
}
TMask * TRelation_application::setup_mask(int mode, TMask * mask)
{
TRelation * rel = get_relation();
if (rel != nullptr && mask != nullptr && (mode == MODE_INS || mode == MODE_MOD))
{
if (rel->lfile().curr().exist("COLL_GOLEM") && mask->find_by_fieldname("COLL_GOLEM") == nullptr)
{
TGolem_field & o = mask->add_golem_tool(DLG_OGGETTI, "", "M");
o.set_field("COLL_GOLEM");
}
if (rel->lfile().curr().exist("CARTACEI") && mask->find_by_fieldname("CARTACEI") == nullptr)
{
TGolem_field & c = mask->add_golem_tool(DLG_CARTACEI, "", "M", BMP_ARCHIVE);
c.set_field("CARTACEI");
}
}
return mask;
}
void TRelation_application::edit_cancel()
{
if (_mask->mode() == MODE_MOD)

View File

@ -170,9 +170,11 @@ protected:
// <mf TRelation_application::get_mask>. Cio' serve per gestire correttamente le applicazioni
// con maschere multiple.
virtual bool changing_mask(int mode) { return false; }
virtual TMask * setup_mask(int mode, TMask * mask);
// @cmember Richiede la maschera da usare
virtual TMask* get_mask(int mode) pure;
virtual TMask* _get_mask(int mode) pure;
// @cmember wrapper che richiede la maschera da usare
virtual TMask* get_mask(int mode) { return setup_mask(mode, _get_mask(mode)); }
// @cmember:(INTERNAL) Annulla la modifica di un record: toglie il lock
void edit_cancel();
// @cmember:(INTERNAL) Salva i contenuti della maschera su file

View File

@ -18,7 +18,7 @@ bool TTable_application::changing_mask(int mode)
{ return false; }
// @cmember Richiede la maschera da usare
TMask* TTable_application::get_mask(int mode)
TMask* TTable_application::_get_mask(int mode)
{
CHECK(_msk, "Null mask");
return _msk;
@ -160,7 +160,7 @@ bool TMultirel_application::changing_mask(int mode)
{ return false; }
// @cmember Richiede la maschera da usare
TMask* TMultirel_application::get_mask(int mode)
TMask* TMultirel_application::_get_mask(int mode)
{
CHECK(_msk, "Null mask");
return _msk;
@ -197,7 +197,7 @@ bool TMultirel_application::find(word k)
{
file().setkey(1);
file().zero();
for (TEditable_field* e = get_mask()->get_key_field(1, true); e; e = get_mask()->get_key_field(1, false))
for (TEditable_field* e = get_mask(MODE_QUERY)->get_key_field(1, true); e; e = get_mask(MODE_QUERY)->get_key_field(1, false))
{
if (e->shown() || e->ghost()) // Ignora campi invisibili non ghost
e->autosave(*get_relation());
@ -215,7 +215,7 @@ void TMultirel_application::init_insert_mode(TMask& m)
TLocalisamfile multi(LF_MULTIREL);
file().curr().zero();
for (TEditable_field* e = get_mask()->get_key_field(1, true); e; e = get_mask()->get_key_field(1, false))
for (TEditable_field* e = get_mask(MODE_QUERY)->get_key_field(1, true); e; e = get_mask(MODE_QUERY)->get_key_field(1, false))
{
if ((!e->in_group(1)) && (e->shown() || e->ghost()))
e->autosave(*get_relation());

View File

@ -34,7 +34,7 @@ protected:
// @cmember Richiede se il record corrente e' protetto (non cancellabile)
virtual bool protected_record(TRectype& rec);
// @cmember Richiede la maschera da usare
virtual TMask* get_mask(int mode = MODE_QUERY);
virtual TMask* _get_mask(int mode = MODE_QUERY);
// @cmember Indica se la futura <mf Tab_application::get_mask> ritornera' una maschera diversa
// dalla corrente.
virtual bool changing_mask(int mode);
@ -93,7 +93,7 @@ protected:
virtual void get_mask_name(TString& tabname) const;
// @cmember Richiede la maschera da usare
virtual TMask* get_mask(int mode = MODE_QUERY);
virtual TMask* _get_mask(int mode);
// @cmember Indica se la futura <mf Tab_application::get_mask> ritornera' una maschera diversa
// dalla corrente.
virtual bool changing_mask(int mode);