Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : Spostata get_tmp_var dai TISAM_recordset ai TRecordset git-svn-id: svn://10.65.10.50/trunk@13313 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
73ec6ce9d4
commit
92151c5cd5
@ -386,6 +386,23 @@ int TRecordset::find_column(const char* column_name) const
|
||||
return i;
|
||||
}
|
||||
|
||||
TVariant& TRecordset::get_tmp_var() const
|
||||
{
|
||||
static TArray _page; // Variants to be returned by get
|
||||
static int _next_var = 0; // Index of next variant to be returned
|
||||
|
||||
if (_next_var >= 32)
|
||||
_next_var = 0;
|
||||
TVariant* var = (TVariant*)_page.objptr(_next_var);
|
||||
if (var == NULL)
|
||||
{
|
||||
var = new TVariant;
|
||||
_page.add(var, _next_var);
|
||||
}
|
||||
_next_var++;
|
||||
return *var;
|
||||
}
|
||||
|
||||
const TVariant& TRecordset::get(const char* column_name) const
|
||||
{
|
||||
if (*column_name == '#')
|
||||
@ -699,12 +716,22 @@ bool list_custom_files(const char* ext, const char* classe, TString_array& files
|
||||
|
||||
bool select_custom_file(TFilename& path, const char* ext, const char* library)
|
||||
{
|
||||
TArray_sheet sheet(-1, -1, 78, 20, TR("Selezione"), HR("Nome@8|Classe@8|Descrizione@50"));
|
||||
TArray_sheet sheet(-1, -1, 82, 20, TR("Selezione"), HR("Nome@8|Classe@8|Descrizione@50|Custom"));
|
||||
TString_array& files = sheet.rows_array();
|
||||
|
||||
bool ok = list_custom_files(ext, library, files);
|
||||
if (ok)
|
||||
{
|
||||
TFilename path;
|
||||
FOR_EACH_ARRAY_ROW(files, i, row)
|
||||
{
|
||||
path = row->get(0);
|
||||
path.ext(ext);
|
||||
path.custom_path();
|
||||
if (path.find("custom") > 0)
|
||||
row->add("X");
|
||||
}
|
||||
|
||||
ok = sheet.run() == K_ENTER;
|
||||
if (ok)
|
||||
{
|
||||
@ -982,36 +1009,42 @@ bool TSQLite::import(int logicnum)
|
||||
TRelation rel(logicnum);
|
||||
TCursor cur(&rel);
|
||||
const TRecnotype items = cur.items();
|
||||
cur.freeze();
|
||||
const TRectype& curr = rel.curr();
|
||||
|
||||
TString msg;
|
||||
msg << TR("Esportazione tabella") << ' ' << table;
|
||||
msg << ": " << items << ' ' << TR("righe");
|
||||
TProgind pi(items, msg, true, true);
|
||||
|
||||
TFilename tmp; tmp.tempdir(); tmp.add("sql.txt");
|
||||
ofstream txt(tmp, ios::binary);
|
||||
|
||||
for (cur = 0; cur.pos() < items; ++cur)
|
||||
if (items > 0)
|
||||
{
|
||||
esporta(curr, txt);
|
||||
pi.addstatus(1);
|
||||
if (pi.iscancelled())
|
||||
break;
|
||||
cur.freeze();
|
||||
const TRectype& curr = rel.curr();
|
||||
|
||||
TString msg;
|
||||
msg << TR("Esportazione tabella") << ' ' << table;
|
||||
TPerformance_profiler prof(msg);
|
||||
|
||||
msg << ": " << items << ' ' << TR("righe");
|
||||
TProgind pi(items, msg, true, true);
|
||||
|
||||
TFilename tmp; tmp.tempdir(); tmp.add("sql.txt");
|
||||
ofstream txt(tmp, ios::binary);
|
||||
|
||||
for (cur = 0; cur.pos() < items; ++cur)
|
||||
{
|
||||
esporta(curr, txt);
|
||||
pi.addstatus(1);
|
||||
if (pi.iscancelled())
|
||||
break;
|
||||
}
|
||||
|
||||
txt.close();
|
||||
|
||||
msg << '\n' << TR("Importazione tabella") << ' ' << table;
|
||||
msg << ": " << items << ' ' << TR("righe");
|
||||
pi.set_text(msg);
|
||||
|
||||
sql.cut(0) << "COPY " << table << " FROM '" << tmp << "';";
|
||||
if (exec(sql))
|
||||
set_dbf_time(table, last); // Aggiorna ora di ultima modifica
|
||||
|
||||
::remove(tmp);
|
||||
}
|
||||
|
||||
txt.close();
|
||||
|
||||
msg << '\n' << TR("Importazione tabella") << ' ' << table;
|
||||
msg << ": " << items << ' ' << TR("righe");
|
||||
pi.set_text(msg);
|
||||
|
||||
sql.cut(0) << "COPY " << table << " FROM '" << tmp << "';";
|
||||
if (exec(sql))
|
||||
set_dbf_time(table, last); // Aggiorna ora di ultima modifica
|
||||
|
||||
::remove(tmp);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1700,23 +1733,6 @@ TCursor_parser::TCursor_parser(istream& instr, TArray& col)
|
||||
// TISAM_recordset
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
TVariant& TISAM_recordset::get_tmp_var() const
|
||||
{
|
||||
static TArray _page; // Variants to be returned by get
|
||||
static int _next_var = 0; // Index of next variant to be returned
|
||||
|
||||
if (_next_var >= 32)
|
||||
_next_var = 0;
|
||||
TVariant* var = (TVariant*)_page.objptr(_next_var);
|
||||
if (var == NULL)
|
||||
{
|
||||
var = new TVariant;
|
||||
_page.add(var, _next_var);
|
||||
}
|
||||
_next_var++;
|
||||
return *var;
|
||||
}
|
||||
|
||||
const TVariant& TISAM_recordset::get(int logic, const char* fldname) const
|
||||
{
|
||||
const int idx = relation()->log2ind(logic);
|
||||
|
@ -40,6 +40,7 @@ protected:
|
||||
|
||||
void find_and_reset_vars();
|
||||
void parsed_text(TString& sql) const;
|
||||
TVariant& get_tmp_var() const;
|
||||
|
||||
public: // Absolutely needed methods
|
||||
virtual TRecnotype items() const pure;
|
||||
@ -52,7 +53,7 @@ public: // Absolutely needed methods
|
||||
virtual bool move_prev() { return move_to(current_row()-1); }
|
||||
virtual bool move_next() { return move_to(current_row()+1); }
|
||||
virtual bool move_last() { return move_to(items()-1); }
|
||||
virtual bool bof() const { return current_row() <= 0; }
|
||||
virtual bool bof() const { return current_row() == TRecnotype(-1); }
|
||||
virtual bool eof() const { return current_row() >= items(); }
|
||||
|
||||
virtual unsigned int columns() const pure;
|
||||
@ -129,7 +130,6 @@ protected:
|
||||
TRelation* relation() const;
|
||||
|
||||
virtual void reset();
|
||||
TVariant& get_tmp_var() const;
|
||||
virtual const TVariant& get(int logic, const char* field) const;
|
||||
virtual void set_custom_filter(TCursor& cursor) const { }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user