Patch level : 2.2

Files correlati     : stampe report
Ricompilazione Demo : [ ]
Commento            :

Permessa customizzazione filtri su query dei report


git-svn-id: svn://10.65.10.50/trunk@13179 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2005-06-07 14:19:42 +00:00
parent 1d145dda27
commit 7ba3f85254
7 changed files with 87 additions and 38 deletions

View File

@ -507,7 +507,7 @@ int TAVM::find_matching(const TBytecode& bytecode, AVM_opcode op1, AVM_opcode op
TAVM_op& theop = (TAVM_op&)bytecode[i]; TAVM_op& theop = (TAVM_op&)bytecode[i];
if ((theop.op() == op1 || theop.op() == op2) && theop.var().is_null()) if ((theop.op() == op1 || theop.op() == op2) && theop.var().is_null())
{ {
theop.var() = bytecode.items(); theop.var() = long(bytecode.items());
break; break;
} }
} }

View File

@ -592,6 +592,7 @@ static void sort_files(TString_array& files)
path = *row; path = *row;
path = path.name(); path = path.name();
path.ext(""); path.ext("");
path.lower();
*row = path; *row = path;
} }
files.sort(); // Ordina alfabeticamente files.sort(); // Ordina alfabeticamente
@ -604,9 +605,44 @@ static void sort_files(TString_array& files)
} }
} }
bool select_custom_file(TFilename& path, const char* ext, const char* library) static bool get_xml_attr(const TString& line, const char* attr, TString& value)
{ {
TString_array files; TString80 str; str << ' ' << attr << "=\"";
const int pos = line.find(str);
if (pos >= 0)
{
const int apicia = line.find('"', pos)+1;
const int apicic = line.find('"', apicia);
if (apicic > apicia)
{
value = line.sub(apicia, apicic);
return true;
}
}
return false;
}
static bool get_xml_child(const TString& line, const char* tag, TString& value)
{
TString80 str; str << '<' << tag << '>';
const int pos = line.find(str);
if (pos >= 0)
{
const int apicia = line.find('>', pos)+1;
const int apicic = line.find('<', apicia);
if (apicic > apicia)
{
value = line.sub(apicia, apicic);
return true;
}
}
return false;
}
bool list_custom_files(const char* ext, const char* library, TString_array& files)
{
TString_array lista;
TFilename path;
// Leggo i files in custom // Leggo i files in custom
if (main_app().has_module(RSAUT)) if (main_app().has_module(RSAUT))
@ -620,53 +656,62 @@ bool select_custom_file(TFilename& path, const char* ext, const char* library)
path.add("*"); path.add("*");
path.ext(ext); path.ext(ext);
list_files(path, files); list_files(path, lista);
} }
path = "*."; path.ext(ext); // Leggo i files in campo path = "*"; path.ext(ext); // Leggo i files in campo
list_files(path, files); list_files(path, lista);
sort_files(files); // Ordino i files e rimuovo i doppioni sort_files(lista); // Ordino i files e rimuovo i doppioni
TArray_sheet sheet(-1, -1, 78, 20, TR("Selezione"), HR("Nome@20|Descrizione@50|Librerie@20")); TToken_string libraries(50, ',');
TString stringona, desc;
TString str; FOR_EACH_ARRAY_ROW(lista, i, row)
FOR_EACH_ARRAY_ROW(files, i, row)
{ {
path = *row; path.ext(ext); path = *row; path.ext(ext);
if (path.custom_path()) bool ok = path.custom_path();
{ if (ok)
TXmlItem item; {
bool ok = item.Load(path); TScanner scan(path);
stringona.cut(0);
if (ok && library != NULL && *library) for (int i = 0; i < 3 && scan.good(); i++) // Leggo solo le prime righe
{ stringona << scan.line();
const TString& include = item.GetAttr("libraries"); get_xml_attr(stringona, "libraries", libraries);
ok = include.find(library) >= 0; get_xml_child(stringona, "description", desc);
}
if (library && *library)
ok = libraries.get_pos(library) >= 0;
if (ok) if (ok)
{ {
TToken_string* riga = new TToken_string; TToken_string* riga = new TToken_string;
riga->add(*row); riga->add(*row);
riga->add(desc);
const TXmlItem* desc = item.FindFirst("description"); riga->add(libraries);
str = *row; files.add(riga);
if (desc != NULL)
desc->GetEnclosedText(str);
riga->add(str);
riga->add(item.GetAttr("libraries"));
sheet.add(riga);
} }
} }
} }
bool ok = sheet.run() == K_ENTER; return !files.empty();
}
bool select_custom_file(TFilename& path, const char* ext, const char* library)
{
TArray_sheet sheet(-1, -1, 78, 20, TR("Selezione"), HR("Nome@20|Descrizione@50|Librerie@20"));
TString_array& files = sheet.rows_array();
bool ok = list_custom_files(ext, library, files);
if (ok) if (ok)
{ {
path = sheet.row(-1).get(0); ok = sheet.run() == K_ENTER;
path.ext(ext); if (ok)
ok = path.custom_path(); {
path = sheet.row(-1).get(0);
path.ext(ext);
ok = path.custom_path();
}
} }
return ok; return ok;
} }
@ -1807,6 +1852,7 @@ TCursor* TISAM_recordset::cursor() const
if (_cursor != NULL) if (_cursor != NULL)
{ {
set_custom_filter(*_cursor);
const TRecnotype items = _cursor->items(); const TRecnotype items = _cursor->items();
_cursor->freeze(); _cursor->freeze();
if (items > 0) if (items > 0)

View File

@ -131,6 +131,7 @@ protected:
virtual void reset(); virtual void reset();
TVariant& get_tmp_var() const; TVariant& get_tmp_var() const;
virtual const TVariant& get(int logic, const char* field) const; virtual const TVariant& get(int logic, const char* field) const;
virtual void set_custom_filter(TCursor& cursor) const { }
public: public:
TCursor* cursor() const; TCursor* cursor() const;
@ -169,6 +170,7 @@ public:
// Utility // Utility
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
bool list_custom_files(const char* ext, const char* library, TString_array& files);
bool select_custom_file(TFilename& path, const char* ext, const char* library = NULL); bool select_custom_file(TFilename& path, const char* ext, const char* library = NULL);
const TString& logic2table(int logic_num); const TString& logic2table(int logic_num);
int table2logic(const TString& name); int table2logic(const TString& name);

View File

@ -2266,12 +2266,12 @@ bool TReport::get_report_field(const TString& name, TVariant& var) const
if (xvt_str_compare_ignoring_case(str, "PAGE") == 0) if (xvt_str_compare_ignoring_case(str, "PAGE") == 0)
{ {
var = _rep_page; var = long(_rep_page);
return true; return true;
} else } else
if (xvt_str_compare_ignoring_case(str, "BOOKPAGE") == 0) if (xvt_str_compare_ignoring_case(str, "BOOKPAGE") == 0)
{ {
var = _book_page; var = long(_book_page);
return true; return true;
} }

View File

@ -228,8 +228,8 @@ public:
void set_postscript(const char* src); void set_postscript(const char* src);
void update_recordset_parent(); // Internal use only void update_recordset_parent(); // Internal use only
bool set_recordset(TRecordset* rs); virtual bool set_recordset(TRecordset* rs);
bool set_recordset(const TString& sql); virtual bool set_recordset(const TString& sql);
TRecordset* recordset() const { return _recordset; } TRecordset* recordset() const { return _recordset; }
bool get_record_field(const char* name, TVariant& var) const; bool get_record_field(const char* name, TVariant& var) const;

View File

@ -701,7 +701,7 @@ public:
{ return (TToken_string&)operator[](n); } { return (TToken_string&)operator[](n); }
// @cmember Ritorna la stringa n dell'array (se non c'e' ritorna errore) // @cmember Ritorna la stringa n dell'array (se non c'e' ritorna errore)
const TToken_string& row(int n) const const TToken_string& row(int n) const
{ return (TToken_string&)operator[](n); } { return (const TToken_string&)operator[](n); }
// @cmember Restituisce il puntatore alla stringa n dell'array (NULL se non esiste) // @cmember Restituisce il puntatore alla stringa n dell'array (NULL se non esiste)
TToken_string* rowptr(int n) TToken_string* rowptr(int n)
{ return (TToken_string*)objptr(n); } { return (TToken_string*)objptr(n); }

View File

@ -45,6 +45,7 @@ public:
TVariant& operator=(const real& r) { set(r); return *this; } TVariant& operator=(const real& r) { set(r); return *this; }
TVariant& operator=(const long n) { set(n); return *this; } TVariant& operator=(const long n) { set(n); return *this; }
TVariant& operator=(const TDate& d) { set(d); return *this; } TVariant& operator=(const TDate& d) { set(d); return *this; }
TVariant& operator=(bool b) { set(long(b)); return *this; }
const TString& as_string() const; const TString& as_string() const;
bool as_string(TString& str) const; bool as_string(TString& str) const;