git-svn-id: svn://10.65.10.50/branches/R_10_00@22903 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			161 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			161 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#include <applicat.h>
 | 
						|
#include <automask.h>
 | 
						|
#include <utility.h>
 | 
						|
 | 
						|
#include "felib.h"
 | 
						|
#include "fe0100a.h"
 | 
						|
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
// TSomma_spesometro_msk
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
 | 
						|
class TSomma_spesometro_msk : public TAutomask
 | 
						|
{
 | 
						|
protected:
 | 
						|
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						|
  void elabora(const TString_array& a, const TFilename& n) const;
 | 
						|
  
 | 
						|
  bool str2fname(const TString& name, TFilename& n) const;
 | 
						|
  void enable_buttons();
 | 
						|
 | 
						|
public:
 | 
						|
  TSomma_spesometro_msk() : TAutomask("fe0300a") { load_profile(); }
 | 
						|
  ~TSomma_spesometro_msk() { save_profile(); }
 | 
						|
};
 | 
						|
 | 
						|
bool TSomma_spesometro_msk::str2fname(const TString& name, TFilename& n) const
 | 
						|
{
 | 
						|
  if (name.blank() || name.len() < 4)
 | 
						|
    return false;
 | 
						|
 | 
						|
  if (name.full() && name[1] != ':')
 | 
						|
  {
 | 
						|
    n = get(F_OUTFOLDER); 
 | 
						|
    n.add(name);
 | 
						|
  }
 | 
						|
  else
 | 
						|
    n = name;
 | 
						|
  n.replace('/', '\\');
 | 
						|
  return n.exist();
 | 
						|
}
 | 
						|
 | 
						|
void TSomma_spesometro_msk::enable_buttons()
 | 
						|
{
 | 
						|
  const TSheet_field& righe = sfield(F_RIGHE);
 | 
						|
  enable(DLG_ELABORA, !righe.empty());
 | 
						|
 | 
						|
  TFilename n;
 | 
						|
  enable(DLG_PREVIEW, str2fname(get(F_OUTFILE), n));
 | 
						|
}
 | 
						|
 | 
						|
void TSomma_spesometro_msk::elabora(const TString_array& a, const TFilename& n) const
 | 
						|
{
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
bool TSomma_spesometro_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						|
{
 | 
						|
  switch (o.dlg())
 | 
						|
  {
 | 
						|
  case DLG_ELABORA:
 | 
						|
    if (e == fe_button && check_fields())
 | 
						|
    {
 | 
						|
      TFilename n;
 | 
						|
      str2fname(get(F_OUTFILE), n);
 | 
						|
      TSheet_field& righe = sfield(F_RIGHE);
 | 
						|
      TString_array& a = righe.rows_array();
 | 
						|
      if (!a.empty() && n.full())
 | 
						|
      {
 | 
						|
        elabora(a, n);
 | 
						|
        enable_buttons();
 | 
						|
      }
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  case DLG_USER:
 | 
						|
    if (e == fe_button)
 | 
						|
    {
 | 
						|
      TFilename fn;
 | 
						|
      if (str2fname(o.mask().get(101), fn))
 | 
						|
      {
 | 
						|
        TSpesometro_rep rep(fn);
 | 
						|
        rep.preview();
 | 
						|
      }
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  case DLG_PREVIEW:
 | 
						|
    if (e == fe_button)
 | 
						|
    {
 | 
						|
      TFilename fn;
 | 
						|
      if (str2fname(get(F_OUTFILE), fn))
 | 
						|
      {
 | 
						|
        TSpesometro_rep rep(fn);
 | 
						|
        rep.preview();
 | 
						|
      }
 | 
						|
    }
 | 
						|
    break;
 | 
						|
    case F_OUTFOLDER:
 | 
						|
    if ((e == fe_init || e == fe_modify) && !o.empty())
 | 
						|
    {
 | 
						|
      TSheet_field& righe = sfield(F_RIGHE);
 | 
						|
      TFilename dir = o.get(); dir.add("Spe*.txt");
 | 
						|
      TString_array& a = righe.rows_array();
 | 
						|
      a.destroy();
 | 
						|
      list_files(dir, a);
 | 
						|
      TFilename fn;
 | 
						|
      FOR_EACH_ARRAY_ROW(a, r, row)
 | 
						|
      {
 | 
						|
        fn = row->get(0);
 | 
						|
        *row = fn.name();
 | 
						|
        row->add(fsize(fn) / 1800);
 | 
						|
        const time_t t = xvt_fsys_file_attr(fn, XVT_FILE_ATTR_MTIME);
 | 
						|
        if (t > 0)
 | 
						|
        {
 | 
						|
          const struct tm& lt = *localtime(&t);
 | 
						|
          const TDate d(lt.tm_mday, lt.tm_mon+1, 1900+lt.tm_year);
 | 
						|
          row->add(d);
 | 
						|
          TString8 ora; ora.format("%02d:%02d:%02d", lt.tm_hour, lt.tm_min, lt.tm_sec);
 | 
						|
          row->add(ora);
 | 
						|
        }
 | 
						|
      }  
 | 
						|
 | 
						|
      righe.force_update();
 | 
						|
      enable_buttons();
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  case F_RIGHE:
 | 
						|
    if (e == se_query_add || e == se_query_del)
 | 
						|
      return false;
 | 
						|
    break;
 | 
						|
  default: 
 | 
						|
    break;
 | 
						|
  }
 | 
						|
  return true;
 | 
						|
}
 | 
						|
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
// TSomma_spesometro_app
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
 | 
						|
class TSomma_spesometro_app : public TSkeleton_application
 | 
						|
{
 | 
						|
public:
 | 
						|
  virtual void main_loop();
 | 
						|
};
 | 
						|
 | 
						|
void TSomma_spesometro_app::main_loop()
 | 
						|
{
 | 
						|
  TSomma_spesometro_msk msk;
 | 
						|
  msk.run();
 | 
						|
}
 | 
						|
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
// main
 | 
						|
///////////////////////////////////////////////////////////
 | 
						|
 | 
						|
int fe0300(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TSomma_spesometro_app app;
 | 
						|
  app.run(argc, argv, TR("Somma file Spesometro"));
 | 
						|
  return 0;
 | 
						|
}
 |