gSAFE
1.3.8
|
#include <datalib.h>
Public Slots | |
int | disableReadonlyMask (void) |
int | enableReadonlyMask (void) |
QString | getInsertedKey (void) |
int | insertRecord (bool insertkey=false, bool disable_tr=false, bool resetafterinsert=true) |
int | insertRecordAll (bool disable_tr=false) |
void | rereadNextInsertedKey (void) |
int | returnToDefault (bool all=true) |
int | saveRecord (bool all=false, bool tdisabled=false) |
int | saveRecordAll (bool tdisabled=false) |
int | setKey (QString key) |
int | updateWithKey (QString key="", bool all=false, bool update=true, bool tdisabled=false) |
int | updateWithKeyAll (QString key="", bool update=true, bool tdisabled=false) |
Public Slots inherited from HTableBase | |
void | addDependTableName (QString n) |
int | errorPassSlot (QString err) |
Public Member Functions | |
HTable (QString t) | |
HTable (HTable *t) | |
~HTable (void) | |
void | blockReInitialize (QString hide_marker, QString ro_marker) |
void | clearDataChangeLogger (void) |
void | deepcopy_from_htable (HTable *x) |
QString | getKey (bool head_val, QString intable="") |
QVariant | getSqlFieldValue (QString sqln) |
QVariant | operator[] (int i) |
bool | readonlyMask (void) |
int | recordCount (void) |
void | setDataChangeLogger (HDataChangeLogger *dcl) |
void | setSqlFieldValue (QString sqln, QVariant v, bool sdisable=false) |
QString | sqlInsert (bool insertkey=false) |
QString | sqlInsertAll (void) |
QString | sqlUpdate (bool all=false) |
QString | sqlUpdateAll (void) |
Public Member Functions inherited from HTableBase | |
HTableBase (QString t) | |
HTableBase (HTableBase *t) | |
~HTableBase (void) | |
void | addField (HDataField *i) |
void | blockReInitializeBase (QString hide_marker, QString ro_marker) |
void | clearAndFreeConnections (void) |
void | clearConnections (void) |
void | clearRoles (void) |
void | clearSqlSynced (void) |
void | connectTable (HTableBase *ct, int type=INNER_JOIN, QString connconstraint="") |
void | connectTable (HTableBase *ct, QString thiskey, QString thatkey, int type=INNER_JOIN, QString connconstraint="") |
void | dataUpdated (void) |
void | deepcopy_from_htablebase (HTableBase *x) |
void | delRole (QString name) |
HDataField * | fieldByIndex (int i, bool all=false) |
HDataField * | fieldBySqlName (QString sqln, bool all=false, QString containerSqlTable="") |
int | fieldCount (bool withconnect=false) |
void | firstField (void) |
void | freeTable (void) |
QStringList | getExplainHeads (void) |
QStringList | getHeads (int what) |
QStringList | getShortTitleHeads (void) |
bool | isChanged (bool all=false) |
bool | isReallyChanged (void) |
HDataField * | nextField (void) |
HDataField * | nextFieldAll (void) |
QVariant | operator[] (int i) |
void | removeSqlCooseButtons (void) |
void | resetLogging (void) |
void | returnToDefaultAllMarked (QString mark) |
void | setAllNOSet (void) |
void | setAllYESSet (void) |
void | setColor (int r, int g, int b) |
void | setColorAllMarked (QString mark, int r, int g, int b) |
void | setEditable (void) |
void | setEditableAllMarked (QString mark) |
void | setGuiDisabledAllMarked (QString mark) |
void | setGuiEnabledAllMarked (QString mark) |
void | setHide (void) |
void | setHideAllMarked (QString mark) |
void | setLogging (void) |
void | setLoggingAllMarked (QString mark) |
void | setReadolnyAllMarked (QString mark) |
void | setReadonly (void) |
void | setShow (void) |
void | setShowAllMarked (QString mark) |
void | setTableTitle (QString s) |
QString | sqlCreateString (QString switches="") |
QString | sqlSelect (QString tail="", bool all=false, bool keypart=false) |
QString | sqlSelectAll (QString tail="") |
QString | sqlSelectWk (QString tail="", bool all=false) |
QString | sqlSelectWkAll (QString tail="") |
void | sqlSynced (HDataChangeLogger *dclog=NULL, bool forcechange=false, bool forcelog=false) |
QString | sqlTableName (void) |
HDataField * | staticFieldByTitle (QString title="") |
QString | tableTitle (void) |
void | useRole (QString name) |
QString | validate (bool all=true) |
Public Member Functions inherited from HSqlHandler | |
HSqlHandler (void) | |
~HSqlHandler (void) | |
QSqlQuery * | allocateQSqlQuery (void) |
void | cloneSqlSettingsFrom (HSqlHandler *other) |
void | commit (void) |
bool | errorStatus (void) |
void | rollback (void) |
bool | submit0ResultQuery (QString q, QString err, bool tdisabled=false) |
QVariant | submit1ResultQuery (QString q, QString err, bool tdisabled=false) |
HPlainDataMatrix * | submitNResultQuery (int N, QString q, QString err, bool tdisabled=false) |
void | transaction (void) |
QSqlDatabase | workDB (void) |
Public Member Functions inherited from HSqlInterface | |
HSqlInterface () | |
~HSqlInterface () | |
void | cloneSqlInterfaceSettingsFrom (HSqlInterface *other) |
HSqlSingleInterface * | myInterface (void) |
QString | sqlConcatenateToLocal (QString string) |
QString | sqlConcatenateToLocal (QStringList fields) |
Public Member Functions inherited from HBase | |
HBase (void) | |
~HBase (void) | |
QString | getWhoami (void) |
Protected Member Functions | |
QString | getKeyValueAfterInsert (void) |
QString | specifyKey (QString tablename) |
Protected Attributes | |
HDataChangeLogger * | dclog |
QString | insertedKey |
bool | reread_key |
bool | ro_mask |
Protected Attributes inherited from HTableBase | |
QString | conn_part |
QStack< HTableBase * > * | connectedTableBases |
QStringList * | depend |
int | field |
QString | imc_thatkey |
HTableBase * | imc_thattable |
QString | imc_thiskey |
HDataField_List * | run |
QString | sqlTable |
HDataField_List * | table |
QString | tabletitle |
Protected Attributes inherited from HSqlHandler | |
bool | query_error_occured |
Protected Attributes inherited from HBase | |
QString | whoami |
Additional Inherited Members | |
Signals inherited from HTableBase | |
void | dataChanged (void) |
void | dataModifiedSignal (void) |
void | dataUpdatedSignal (void) |
void | doWorking (void) |
void | endWorking (void) |
void | startWorking (void) |
Signals inherited from HSqlHandler | |
void | errorSignal (QString err) |
Static Public Member Functions inherited from HSqlHandler | |
static void | setCustomSqlDatabase (QString databaseName, QString sqlinterfacename="") |
static void | setDefaultSqlDatabase (void) |
Static Public Member Functions inherited from HSqlInterface | |
static HSqlSingleInterface * | currentDefaultSqlInterface (void) |
static HSqlSingleInterface * | getSqlInterface (QString interfacename) |
static void | setSqlMode (QString modename) |
static void | setSqlModeBackToFirst (void) |
Public Attributes inherited from HTableBase | |
QString | errstr |
bool | extrafeatures |
bool | gui_showtabletitle |
Static Public Attributes inherited from HSqlHandler | |
static int | trans = 0 |
The HTable class is handle/store an sql record. Holds a meta-record of the meta table with values.
This is the base read-write sql related class which can be used to edit the sql data.
However this class usally hold only a record, its name is "HTable" because the usual appearance:
This record can be a whole sql table record or a subset of a sql record or can contain more field. (by join, calculated data,static data etc...)
Here every field (of the HTableBase) can store a value. This is a record or a record of a joined table system. This record can be read/store/reload/edited with this class.
Here is an sql table:
And the correspond HTable: (You can see the XML format in HFactory calss description)
The HTable is showed by HDispTable in gui, looks like this way:
HTable::HTable | ( | QString | t | ) |
Creates an empty table. The created table don't contain any data field and don't have any connections.
t | the sql name of the table. |
Definition at line 3096 of file datalib.cpp.
HTable::~HTable | ( | void | ) |
Destructor
Definition at line 3106 of file datalib.cpp.
HTable::HTable | ( | HTable * | t | ) |
Deepcopy constructor. It clones the parameter HTable to itself. It copies the full data structure and state and attributes and values of the parameter table. But connected tables is not copied neither the connection data. Only the base table is copied! If you would like to copy a whole connected table you have to copy the tables one by one, and connect them again.
t | the source table |
Definition at line 3113 of file datalib.cpp.
void HTable::blockReInitialize | ( | QString | hide_marker, |
QString | ro_marker | ||
) |
Equivalent calling the following functions:
Which is equivalent to call:
hide_marker | the text HIDE_MARKER_PARAMETER |
ro_marker | the text RO_MARKER_PARAMETER |
Definition at line 3938 of file datalib.cpp.
|
inline |
Clears the data change logger object to the HTable. It's disables the logging data changes to an sql table. It does not delete the given object
void HTable::deepcopy_from_htable | ( | HTable * | x | ) |
Deepcopy function. It clones the parameter HTable to itself. It copies the full data structure and state and attributes and values of the parameter table. But connected tables is not copied neither the connection data. Only the base table is copied! If you would like to copy a whole connected table you have to copy the tables one by one, and connect them again.
x | the source table |
Definition at line 3121 of file datalib.cpp.
|
inlineslot |
Disables the read only mask of the table. You can set a read only mask to the table which is tell the gui to show the whole table in read only mode. If the read only mask is enable the whole table will be read only irrespectively of the status of the read_only value of the fields. The independent read only value of the fields are untouched. So this read only mask DOES NOT MODIFY THE READ ONLY STATUS OF THE FIELDS!
Useful to show a read only view from a memory instance of an editable table.
|
inlineslot |
Enables the read only mask of the table. You can set a read only mask to the table which is tell the gui to show the whole table in read only mode. If the read only mask is enable the whole table will be read only irrespectively of the status of the read_only value of the fields. The independent read only value of the fields are untouched. So this read only mask DOES NOT MODIFY THE READ ONLY STATUS OF THE FIELDS!
Useful to show a read only view from a memory instance of an editable table.
|
inlineslot |
Gets the value of the HKey field immediatly after the insert command. The method is queries the value of the HKey field. It queries the key value according to the value of timestamp.
THE RECORD/TABLE HAVE TO CONTAINS A TIMESTAMP FIELD TO WORK THIS FUNCTION CORRECTLY.
The timestamp field have to enabled the check/controll option. This function need to be run in one sql transaction with the insert. You have to run the rereadNextInsertedKey() before the insert.
It only works with insertRecord() , the insertRecordAll() is unsupported!
QString HTable::getKey | ( | bool | head_val, |
QString | intable = "" |
||
) |
Returns of the header string/value of the key field of the record.
head_val | If true the function returns the sql name of the key field If false the functionr returns the value of the key field |
intable | Act as a filter. If a table name is specified the key field is searched only that table which named in this parameter |
Definition at line 3249 of file datalib.cpp.
QVariant HTable::getSqlFieldValue | ( | QString | sqln | ) |
Returns the value of the specified field of the record
sqln | the sql name of the field which is about to query |
Definition at line 3141 of file datalib.cpp.
|
slot |
Inserts the current (in memory) record to the sql database. Inserts the values of the HConnect fields too.
insertkey | if true the function will inserts the value of the HKey field too, otherwise (false) the key field is does not appear in the insert command. Useful if the key field is autogenerated. |
disable_tr | if this parameter false the insert runs in a separate transaction so the function starts a transaction and to a commit after its, otherwise (true) the function doesn't call any transaction related things. |
resetafterinsert | if this true (default) the HTable calls returnToDefault() after a successfully insert. |
Definition at line 3548 of file datalib.cpp.
|
slot |
Inserts the current (in memory) record to the sql database. This function inserts the connected tables too. The function drops the values of the HConnect fields because it's filled during the connections.
disable_tr | if this parameter false the insert runs in a separate transaction so the function starts a transaction and to a commit after its, otherwise (true) the function doesn't call any transaction related things. |
Definition at line 3614 of file datalib.cpp.
QVariant HTable::operator[] | ( | int | i | ) |
Returns the (in memory) value of the specified field.
i | the index of the requested field. |
Definition at line 3231 of file datalib.cpp.
|
inline |
Returns the current status of the read only mask of the table. You can set a read only mask to the table which is tell the gui to show the whole table in read only mode. If the read only mask is enable the whole table will be read only irrespectively of the status of the read_only value of the fields. The independent read only value of the fields are untouched.
So this read only mask! DOES NOT MODIFY THE READ ONLY STATUS OF THE FIELDS! Useful to show a read only view from a memory instance of an editable table.
|
inline |
|
inlineslot |
The inserted key value will be queryied after the insert
|
slot |
Sets the values to the data fields to the default. Useful to run after the insert (before inserting a new element)
all | if true the function works on connected tables too |
Definition at line 3378 of file datalib.cpp.
|
slot |
Store the (in memory) record to the sql database according to the key value of the HKey field.
all | store the connected tables too |
tdisabled | if this parameter false the save runs in a separate transaction so the function starts a transaction and to a commit after its, otherwise (true) the function doesn't call any transaction related things. |
Definition at line 3403 of file datalib.cpp.
|
inlineslot |
Store the record to the sql database with the saveRecord function but always works on connected tables too.
|
inline |
Adds a data change logger object to the HTable. It's enables the logging data changes to an sql table. It does not delete the given object
|
slot |
Sets the value of the first HKey field. (Set the key field of the record)
key | the value to set |
Definition at line 3276 of file datalib.cpp.
void HTable::setSqlFieldValue | ( | QString | sqln, |
QVariant | v, | ||
bool | sdisable = false |
||
) |
Sets the value of the specified field of the record
sqln | the sql name of the field which is about to set |
v | the value to set |
sdisable | if this true the dataUpdated signal is disabled, otherwise (default) is emitted. |
Definition at line 3129 of file datalib.cpp.
QString HTable::sqlInsert | ( | bool | insertkey = false | ) |
Generates the sql insert command of the record. (But does not execute the any SQL command, just create a string) The insert contains the current values of the record. The insert sets the values of the HConnect fields too.
insertkey | If the inserkey is true the insert command will contain the key field and the current key value. Otherwise the key field is not appear in the insert. (In that case you can use an auto key generation algorithm) |
Definition at line 3660 of file datalib.cpp.
QString HTable::sqlInsertAll | ( | void | ) |
Generates the sql insert command of the connected record group. (But does not execute the any SQL command, just create a string) The insert contains the current values of the record. The function generates the insert command of all table. Calculate the dependencies, and calculate the connection keys.
Example:
INSERT INTO peoples(name,age) VALUES('frank',20);
INSERT INTO telephonenum(peopleid,number) VALUES((SELECT id FROM peoples WHERE name='frank' AND age=20 ORDER BY timestamp DESC),'00-1-XXXX-YYYY-ZZZZ');
Definition at line 3694 of file datalib.cpp.
QString HTable::sqlUpdate | ( | bool | all = false | ) |
Generates the sql update command of the table which refresh the values of the sql record. (But does not execute the any SQL command, just create a string)
all | if all is true the command will update the connected tables too. Otherwise only the record of the base table is updated. |
Definition at line 3152 of file datalib.cpp.
|
inline |
|
slot |
Queries a record from the sql database. And the values are actualized in this table. After the query 1 rows result are expected, and the memory values are automatically updated.
key | if the key contains a key value that key values record will be queried, otherwise the current value of the key field will be used to limit the query to one record. |
all | if the all parameter is true the connected tables are updated too. |
update | if this parameter is true the dataUpdated signal is emitted |
tdisabled | if this parameter false the update runs in a separate transaction so the function starts a transaction and to a commit after its, otherwise (true) the function doesn't call any transaction related things. |
Definition at line 3291 of file datalib.cpp.
|
inlineslot |
Do an updateWithKey which run on the connected tabled too.