Patch level : 12.0 no-patch
Files correlati : Commento : Aggiunte sistemate funzioni freze, unfreeze, frozen, not_frozen nei recordset
This commit is contained in:
parent
3d1fdb90d5
commit
f911ddbd7c
@ -241,7 +241,7 @@ void TMultiple_rectype::renum_key()
|
||||
|
||||
TRectype & TMultiple_rectype::operator =(const TRectype & r)
|
||||
{
|
||||
TRectype::operator=(r);
|
||||
TAuto_variable_rectype::operator=(r);
|
||||
reset_fields(*this);
|
||||
set_fields(*this);
|
||||
return *this;
|
||||
@ -249,7 +249,7 @@ TRectype & TMultiple_rectype::operator =(const TRectype & r)
|
||||
|
||||
TRectype & TMultiple_rectype::operator =(const char * r)
|
||||
{
|
||||
TRectype::operator=(r);
|
||||
TAuto_variable_rectype::operator=(r);
|
||||
reset_fields(*this);
|
||||
set_fields(*this);
|
||||
return *this;
|
||||
@ -432,7 +432,7 @@ void TMultiple_rectype::fill_transaction(TConfig& cfg, int row) const
|
||||
|
||||
// @doc INTERNAL
|
||||
TMultiple_rectype::TMultiple_rectype(int hfn)
|
||||
: TAuto_variable_rectype(hfn), _nuovo(TRUE)
|
||||
: TAuto_variable_rectype(hfn), _nuovo(true)
|
||||
{
|
||||
}
|
||||
|
||||
@ -475,13 +475,13 @@ void TMultiple_rectype::add_file(int logicnum, const char* numfield)
|
||||
}
|
||||
|
||||
TMultiple_rectype::TMultiple_rectype(const TBaseisamfile* file)
|
||||
:TAuto_variable_rectype(file), _nuovo(TRUE)
|
||||
:TAuto_variable_rectype(file), _nuovo(true)
|
||||
{
|
||||
}
|
||||
|
||||
// @ cmember costruttore dal record
|
||||
TMultiple_rectype::TMultiple_rectype(const TRectype & rec)
|
||||
:TAuto_variable_rectype(rec), _nuovo(TRUE)
|
||||
:TAuto_variable_rectype(rec), _nuovo(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
TRecord_array & operator[](int logicnum) { return (TRecord_array &)body(logicnum); }
|
||||
|
||||
// @cmember distrugge una riga del record array del corpo
|
||||
bool destroy_row(int n, bool pack = FALSE, int logicnum = 0) { return body(logicnum).destroy_row(n, pack); }
|
||||
bool destroy_row(int n, bool pack = false, int logicnum = 0) { return body(logicnum).destroy_row(n, pack); }
|
||||
// @cmember distrugge tutte le righe del record array del corpo
|
||||
void destroy_rows(int logicnum = 0) { body(logicnum).destroy_rows(); }
|
||||
|
||||
@ -98,7 +98,7 @@ public:
|
||||
TRectype & new_row(int logicnum = 0);
|
||||
|
||||
// @cmember Abilita il caricamento del corpo <par lognum> insieme alla testata
|
||||
void enable_autoload(int lognum = 0 ,bool on =TRUE);
|
||||
void enable_autoload(int lognum = 0 ,bool on = true);
|
||||
// @cmember Restituisce il flag di caricamento del corpo <par lognum> insieme alla testata
|
||||
bool autoload_enabled(int lognum =0 );
|
||||
|
||||
|
@ -249,7 +249,7 @@ int TODBC_recordset::on_get_rows(int argc, char** values, char** columns)
|
||||
if (!_columns_loaded)
|
||||
on_get_columns(argc, values, columns);
|
||||
|
||||
if (!_freezed && _page.items() >= _pagesize)
|
||||
if (not_frozen() && _page.items() >= _pagesize)
|
||||
return -1;
|
||||
|
||||
if (_cursor_pos++ < _first_row)
|
||||
@ -296,7 +296,7 @@ bool TODBC_recordset::move_to(TRecnotype n)
|
||||
const TRecnotype tot = items();
|
||||
|
||||
_current_row = n;
|
||||
if (_freezed && _loaded)
|
||||
if (frozen() && _loaded)
|
||||
{
|
||||
if (n < 0)
|
||||
_current_row = 0L;
|
||||
@ -312,7 +312,7 @@ bool TODBC_recordset::move_to(TRecnotype n)
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((n < _first_row || n >= _first_row+_page.items()) || _freezed && !_loaded)
|
||||
if ((n < _first_row || n >= _first_row+_page.items()) || frozen() && !_loaded)
|
||||
{
|
||||
TString sql; parsed_text(sql);
|
||||
XVT_ODBC oc = connection();
|
||||
@ -326,7 +326,7 @@ bool TODBC_recordset::move_to(TRecnotype n)
|
||||
sql.cut(semicolon);
|
||||
sql.trim();
|
||||
_page.destroy();
|
||||
if (_freezed)
|
||||
if (frozen())
|
||||
_first_row = 0;
|
||||
else
|
||||
if (n >= _pagesize)
|
||||
@ -339,7 +339,7 @@ bool TODBC_recordset::move_to(TRecnotype n)
|
||||
_cursor_pos = 0;
|
||||
xvt_odbc_execute(oc, sql, query_get_rows, this);
|
||||
|
||||
_loaded = _freezed;
|
||||
_loaded = frozen();
|
||||
if (!_columns_loaded)
|
||||
_columns_loaded = true; // Brutto posto ma necessario
|
||||
}
|
||||
@ -709,15 +709,16 @@ void TODBC_recordset::remove_rec(const TISAM_recordset& dbfset)
|
||||
|
||||
void TODBC_recordset::set(const char* sql)
|
||||
{
|
||||
if (!_freezed || !_loaded || _sql != sql)
|
||||
if (not_frozen() || !_loaded || _sql != sql)
|
||||
reset();
|
||||
_sql = sql;
|
||||
if (_sql.find("SELECT") >= 0 || _sql.find("select") >= 0)
|
||||
find_and_reset_vars();
|
||||
}
|
||||
|
||||
TODBC_recordset::TODBC_recordset(const char* sql, const bool freezed) : _freezed(freezed), _loaded(false)
|
||||
TODBC_recordset::TODBC_recordset(const char* sql, const bool freezed) : _loaded(false)
|
||||
{
|
||||
freeze(freezed);
|
||||
set(sql);
|
||||
}
|
||||
|
||||
@ -749,9 +750,9 @@ bool TDB_recordset::set(const char* sql)
|
||||
bool ok;
|
||||
TString real_query = "";
|
||||
// Posso modificare oppure non posso ma _sql è vuota
|
||||
if (!_freezed || _sql.empty())
|
||||
if (not_frozen() || _sql.empty())
|
||||
{
|
||||
if (_sql.empty() || !_freezed && !_sql.empty())
|
||||
if (_sql.empty() || not_frozen() && !_sql.empty())
|
||||
{
|
||||
// Guardo se la query inizia con la stringa di connessione
|
||||
if (TString(sql).starts_with("CONNECT(", true))
|
||||
@ -778,7 +779,7 @@ bool TDB_recordset::set(const char* sql)
|
||||
}
|
||||
|
||||
// Serve?
|
||||
if (!_freezed || _sql != sql)
|
||||
if (not_frozen() || _sql != sql)
|
||||
reset();
|
||||
|
||||
_sql.cut(0) << real_query;
|
||||
@ -922,7 +923,7 @@ void TDB_recordset::freeze(const bool on)
|
||||
_rec->freeze();
|
||||
else
|
||||
_rec->defrost();
|
||||
_freezed = on;
|
||||
TRecordset::freeze(on);
|
||||
}
|
||||
|
||||
bool TDB_recordset::connect(const char* db, const char* user, const char* pass, const char* tipo_db) const
|
||||
@ -1045,7 +1046,7 @@ const TVariant& TDB_recordset::get(unsigned int column) const
|
||||
{
|
||||
static TVariant field = NULL_VARIANT;
|
||||
static unsigned int last_get = 0;
|
||||
if (!_freezed || column != last_get || field == NULL_VARIANT)
|
||||
if (not_frozen() || column != last_get || field == NULL_VARIANT)
|
||||
{
|
||||
last_get = column;
|
||||
field = _rec->sq_get(column);
|
||||
@ -1087,7 +1088,7 @@ bool TDB_recordset::commit() const
|
||||
return _rec->sq_commit();
|
||||
}
|
||||
|
||||
TDB_recordset::TDB_recordset(const char* sql, const bool freezed) : _freezed(freezed)
|
||||
TDB_recordset::TDB_recordset(const char* sql, const bool freezed)
|
||||
{
|
||||
_current_row = -1;
|
||||
_rec = new SSimple_query();
|
||||
|
@ -595,7 +595,7 @@ bool TRecordset::set_var(const char* name, const TVariant& var, bool create)
|
||||
{
|
||||
bool ok = false;
|
||||
TVariant* old = (TVariant*)_var.objptr(name);
|
||||
if (old != NULL)
|
||||
if (old != nullptr)
|
||||
{
|
||||
*old = var;
|
||||
ok = true;
|
||||
@ -605,6 +605,7 @@ bool TRecordset::set_var(const char* name, const TVariant& var, bool create)
|
||||
if (create)
|
||||
{
|
||||
const TFixed_string n(name);
|
||||
|
||||
if (n.starts_with("#PARENT.") || n.starts_with("#RECORD."))
|
||||
{
|
||||
// Aggiungo solo il nome alla lista: niente valore!
|
||||
@ -645,6 +646,7 @@ void TRecordset::find_and_reset_vars()
|
||||
if (is_var_separator(sql[diesis-1])) // Controllo che ci sia un separatore prima del #
|
||||
{
|
||||
int i = diesis+1;
|
||||
|
||||
for ( ; sql[i] && (isalnum(sql[i]) || strchr("@_.#", sql[i]) != NULL); i++);
|
||||
if (i > diesis+1)
|
||||
{
|
||||
@ -735,12 +737,14 @@ bool TRecordset::ask_variables(bool all)
|
||||
return true;
|
||||
|
||||
const bool ok = variables().items() > 0;
|
||||
|
||||
if (ok) // Se ci sono variabili faccio le sostituzioni
|
||||
{
|
||||
FOR_EACH_ARRAY_ROW(_varnames, i, name)
|
||||
{
|
||||
TVariant var = get_var(*name);
|
||||
if (var.is_null() || all)
|
||||
|
||||
if (var.is_null() || all)
|
||||
{
|
||||
ask_variable(*name, var);
|
||||
if (var.is_null())
|
||||
|
@ -14,6 +14,8 @@
|
||||
#endif
|
||||
|
||||
#define FIELD_NAME(lf, name) TOSTRING(lf) "." name
|
||||
#define SUB_FIELD_NAME(lf, name, from, to ) TOSTRING(lf) "." name "[" TOSTRING(from) "," TOSTRING(to) "]"
|
||||
#define MAIN_SUB_FIELD_NAME(name, from, to ) name "[" TOSTRING(from) "," TOSTRING(to) "]"
|
||||
|
||||
struct TRecordset_column_info : public TObject
|
||||
{
|
||||
@ -64,6 +66,7 @@ class TRecordset : public TObject
|
||||
const TRecordset* _parentset;
|
||||
char _text_separator;
|
||||
bool _disable_variables;
|
||||
bool _frozen;
|
||||
|
||||
protected:
|
||||
virtual bool save_as_html(const char* path);
|
||||
@ -90,7 +93,11 @@ public: // Absolutely needed methods
|
||||
virtual char text_separator() const { return _text_separator;}
|
||||
virtual void set_text_separator(char sep) { _text_separator = sep;}
|
||||
|
||||
virtual void freeze() {}
|
||||
virtual void freeze(bool on = true) { _frozen = on; }
|
||||
virtual void unfreeze() { freeze(false); }
|
||||
virtual bool frozen() const { return _frozen; }
|
||||
virtual bool not_frozen() const { return !_frozen; }
|
||||
|
||||
virtual bool move_first() { return move_to(0); }
|
||||
virtual bool move_prev() { return move_to(current_row()-1); }
|
||||
virtual bool move_next() { return move_to(current_row()+1); }
|
||||
@ -157,10 +164,10 @@ protected:
|
||||
public:
|
||||
bool valid_cursor() const { return _cursor != NULL; }
|
||||
virtual TCursor* cursor() const;
|
||||
void freeze(bool on = true) const { return cursor()->freeze(on); }
|
||||
void unfreeze() const { return cursor()->freeze(false); }
|
||||
bool frozen() const { return cursor()->frozen(); }
|
||||
bool not_frozen() const { return cursor()->not_frozen(); }
|
||||
virtual void freeze(bool on = true) { return cursor()->freeze(on); }
|
||||
virtual void unfreeze() { return cursor()->freeze(false); }
|
||||
virtual bool frozen() const { return cursor()->frozen(); }
|
||||
virtual bool not_frozen() const { return cursor()->not_frozen(); }
|
||||
void set(const char* use);
|
||||
virtual void requery();
|
||||
virtual TRecnotype items() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user