1994-08-12 10:52:49 +00:00
|
|
|
#include <confapp.h>
|
|
|
|
#include <urldefid.h>
|
|
|
|
#include <utility.h>
|
|
|
|
#include <mask.h>
|
|
|
|
#include <relation.h>
|
|
|
|
|
1995-03-01 09:42:22 +00:00
|
|
|
#define comunque
|
|
|
|
|
1994-08-12 10:52:49 +00:00
|
|
|
bool TConfig_application::create()
|
|
|
|
{
|
|
|
|
TApplication::create();
|
|
|
|
|
|
|
|
_last_choice = BAR_ITEM(1);
|
|
|
|
|
|
|
|
// process args
|
|
|
|
TString arg(16);
|
|
|
|
for (int i = 0; i < argc(); i++)
|
|
|
|
{
|
|
|
|
arg = argv(i);
|
|
|
|
if (arg == "-c")
|
1994-09-28 10:36:08 +00:00
|
|
|
_which_config = atoi(argv(++i));
|
1994-08-12 10:52:49 +00:00
|
|
|
else
|
1994-09-28 10:36:08 +00:00
|
|
|
if (arg[0] == '-')
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TString* argp = new TString(arg);
|
|
|
|
_paragraphs.add(argp);
|
|
|
|
}
|
1994-08-12 10:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
user_create();
|
|
|
|
dispatch_e_menu(_last_choice);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TConfig_application::destroy()
|
|
|
|
{
|
|
|
|
bool b = user_destroy();
|
|
|
|
TApplication::destroy();
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TConfig_application::menu(MENU_TAG m)
|
|
|
|
{
|
|
|
|
// funziona da se' fino a 20 voci della menubar
|
|
|
|
if (m >= BAR_ITEM(1) && m <= BAR_ITEM(20))
|
1994-09-28 10:36:08 +00:00
|
|
|
{
|
|
|
|
_last_choice = m;
|
|
|
|
do_config((m - BAR_ITEM(0))/100);
|
|
|
|
}
|
1994-09-19 09:50:07 +00:00
|
|
|
return xvt_test_menu_tag(BAR_ITEM(2));
|
1994-08-12 10:52:49 +00:00
|
|
|
}
|
1994-09-28 10:36:08 +00:00
|
|
|
|
1994-08-12 10:52:49 +00:00
|
|
|
void TConfig_application::do_config(int m)
|
|
|
|
{
|
1995-03-22 09:07:04 +00:00
|
|
|
TString par(name());
|
|
|
|
if (m < _paragraphs.items())
|
|
|
|
par = (TString&)_paragraphs[m];
|
|
|
|
else par.cut(2);
|
|
|
|
|
1994-08-12 10:52:49 +00:00
|
|
|
for (;;)
|
1994-09-28 10:36:08 +00:00
|
|
|
{
|
|
|
|
TConfig cnf(_which_config, par);
|
|
|
|
|
1995-03-22 09:07:04 +00:00
|
|
|
const TFilename maskname(cnf.get("EdMask"));
|
1994-09-28 10:36:08 +00:00
|
|
|
if (!maskname.empty())
|
|
|
|
{
|
|
|
|
TMask m(maskname);
|
|
|
|
|
|
|
|
// carica campi
|
|
|
|
for (int i = 0; i < m.fields(); i++)
|
|
|
|
{
|
|
|
|
TMask_field& f = m.fld(i);
|
|
|
|
const TFieldref* fref = f.field();
|
|
|
|
if (fref != NULL)
|
|
|
|
{
|
|
|
|
const char* fname = fref->name();
|
|
|
|
if (fname != NULL)
|
|
|
|
{
|
|
|
|
TString& oldvl = cnf.get(fname);
|
|
|
|
if (!oldvl.empty())
|
|
|
|
f.set(oldvl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// run mask
|
|
|
|
if (!preprocess_config(m,cnf))
|
|
|
|
break;
|
1994-08-12 10:52:49 +00:00
|
|
|
|
1994-09-28 10:36:08 +00:00
|
|
|
int k = m.run();
|
1995-04-12 15:43:32 +00:00
|
|
|
if (postprocess_config(m,cnf))
|
1994-09-28 10:36:08 +00:00
|
|
|
{
|
1995-03-29 15:17:00 +00:00
|
|
|
bool tosave = k == K_ENTER || k == K_SAVE;
|
|
|
|
|
|
|
|
if (k == K_ENTER || k == K_QUIT)
|
1994-09-28 10:36:08 +00:00
|
|
|
{
|
1995-03-29 15:17:00 +00:00
|
|
|
// aggiusta campi
|
|
|
|
for (i = 0; i < m.fields(); i++)
|
1994-09-28 10:36:08 +00:00
|
|
|
{
|
1995-03-29 15:17:00 +00:00
|
|
|
TMask_field& f = m.fld(i);
|
|
|
|
if (f.dirty())
|
1994-09-28 10:36:08 +00:00
|
|
|
{
|
1995-03-29 15:17:00 +00:00
|
|
|
const TFieldref* fref = f.field();
|
|
|
|
if (fref != NULL)
|
|
|
|
{
|
|
|
|
const char* fname = fref->name();
|
|
|
|
const char* value = f.get();
|
|
|
|
const char* oldvl = cnf.get(fname);
|
|
|
|
|
|
|
|
if (!tosave)
|
|
|
|
tosave = yesno_box("Modifiche non registrate. Salvare?");
|
|
|
|
|
|
|
|
if (!tosave) break;
|
|
|
|
|
|
|
|
if (postprocess_config_changed(par,fname, oldvl,value))
|
|
|
|
cnf.set(fname, value, NULL, TRUE);
|
|
|
|
}
|
1994-09-28 10:36:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1995-03-29 15:17:00 +00:00
|
|
|
else break;
|
|
|
|
}
|
1995-03-01 09:42:22 +00:00
|
|
|
if (k == K_QUIT)
|
|
|
|
break comunque;
|
1994-08-12 10:52:49 +00:00
|
|
|
}
|
1994-09-28 10:36:08 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
warning_box("Nessun parametro da configurare");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
1994-08-12 10:52:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TConfig_application::preprocess_config (TMask& mask, TConfig& config)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TConfig_application::postprocess_config (TMask& mask, TConfig& config)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TConfig_application::postprocess_config_changed(const char* par,
|
1994-09-28 10:36:08 +00:00
|
|
|
const char* var,
|
|
|
|
const char* oldv,
|
|
|
|
const char* newv)
|
1994-08-12 10:52:49 +00:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|