gSAFE  1.3.8
Signals | Public Member Functions | List of all members
HDynTable Class Reference

#include <datalib.h>

Inheritance diagram for HDynTable:
HBase

Signals

void dataChangedNongui (void)
 

Public Member Functions

 HDynTable (void)
 
 HDynTable (const HDynTable &t)
 
void addition (double d, QString limitTo="")
 
void addition (HDynTable dt, QString limitTo="")
 
void clear (void)
 
int countElements (QString limitTo="")
 
QString currentElementColumnName (void)
 
bool currentElementIsNumeric (void)
 
QStringList currentElementLabels (void)
 
QString currentElementName (void)
 
QString currentElementRowName (void)
 
QString currentElementSqlName (void)
 
double currentElementValueDouble (void)
 
QString currentElementValueString (void)
 
void defN (QString name, QString sqlname="", QString rowName="", QString colName="", QString labels="")
 
void defS (QString name, QString sqlname="", QString rowName="", QString colName="", QString labels="")
 
void defT (int type, QString name, QString sqlname="", QString rowName="", QString colName="", QString labels="")
 
void divide (double d, QString limitTo="")
 
void divide (HDynTable dt, QString limitTo="")
 
QString dumpElements (void)
 
bool elementHasLabel (QString name, QString label, bool *found=NULL)
 
void emptyall (QString limitTo="")
 
void firstElement (void)
 
QString getElementSqlName (QString name)
 
double getElementValueDouble (QString name, bool *found=NULL)
 
double getElementValueDoubleByRowColName (QString r, QString c, bool *found=NULL)
 
QString getElementValueString (QString name, bool *found=NULL)
 
QString getElementValueStringByRowColName (QString r, QString c, bool *found=NULL)
 
double getIndexedValueDouble (int index, bool *found=NULL)
 
QString getIndexedValueString (int index, bool *found=NULL)
 
QString indexedElementName (int index)
 
QString indexedElementSqlName (int index)
 
bool isEnded (void)
 
double max (QString limitTo="")
 
double min (QString limitTo="")
 
void multiplicate (double d, QString limitTo="")
 
void multiplicate (HDynTable dt, QString limitTo="")
 
void nextElement (void)
 
HDynTableoperator= (HDynTable s)
 
HDynTableElementNameReferencer operator[] (QString name)
 
void setCurrentElementValue (double d)
 
void setCurrentElementValue (QString s)
 
void setElementValue (QString name, double value)
 
void setElementValue (QString name, QString value)
 
void setElementValueByRowColName (QString r, QString c, double value)
 
void setElementValueByRowColName (QString r, QString c, QString value)
 
void setIndexedElementValue (int index, double d)
 
void setIndexedElementValue (int index, QString s)
 
double sum (QString limitTo="")
 
void sustraction (double d, QString limitTo="")
 
void sustraction (HDynTable dt, QString limitTo="")
 
void zeroall (QString limitTo="")
 
- Public Member Functions inherited from HBase
 HBase (void)
 
 ~HBase (void)
 
QString getWhoami (void)
 

Additional Inherited Members

- Protected Attributes inherited from HBase
QString whoami
 

Detailed Description

The HDynTable contains the collection of numeric or textual typed fileds referenced by names.\n
After you define the elements, you can easely set/get elements value referenced by it's name.
The HDynTable has many batch mathematical function to easely work with the all element together.
The mathematical functions only works on numeric elements, they don't affect the textual elements.
t.defN("a");
t.defN("b");
t.defS("t");
t["a"] = 10.2;
t["b"] = 3 * t["a"];
t.divide(t.sum());
t["b"] += 100;
t["t"] = "Texual data";

The HDynTable can dynamically build a QTableWidget from the elements you defined. (See HDynTableDispConnector)
You can define element with different column/row names, and the HDynTable will be generate the appropirate QTableWiget, It means: The same row named elements will appear in same row, if an element have unique rowname it will appear in separated row. The classes will automatically handles the refreshing the data in the memory. It means that the user changes will automatically apply on HDynTable's values. It also can handle the SQL query/update of the fileds. (See HDynTableSqlConnector)

...
//Create an empty dyntable and define the fields
HDynTable *dt = new HDynTable();
//name sqlf rown coln
dt->defN("appg" ,"appg" ,"Apple","Good");
dt->defN("appb" ,"appb" ,"Apple","Bad");
dt->defN("pearg","pearg","Pear" ,"Good");
dt->defN("pearb","pearb","Pear" ,"Bad");
dt->defN("plumg","plumg","Plum" ,"Good");
dt->defN("plumb","plumb","Plum" ,"Bad");
dt->defN("nut" ,"nut" ,"Nut" ,"Good");
//Connects the dyntable to the sql table
HDynTableSqlConnector *sql_conn = new HDynTableSqlConnector(dt,sql,"mytable");
//Initialize the ui's table with this dyntable
HDynTableDispConnector *disp_conn = new HDynTableDispConnector(dt,ui->table);
//We reads the values from sql. The gui will refresh automatically.
sql_conn->readSql();
//We want the sql table to be updated every time, when the user change a data on gui
connect(disp_conn,SIGNAL(dataChangedByGui()),sql_conn,SLOT(updateSql()));
...

The code above is generates a QTableWidget look like this:

hdyntable.png
See Also
HDynTableDispConnector
HDynTableSqlConnector

Definition at line 3781 of file datalib.h.

Constructor & Destructor Documentation

HDynTable::HDynTable ( void  )

Creates an empty HDynTable

Definition at line 7796 of file datalib.cpp.

HDynTable::HDynTable ( const HDynTable t)

Creates a copy of the given HDynTable

Definition at line 7802 of file datalib.cpp.

Member Function Documentation

void HDynTable::addition ( double  d,
QString  limitTo = "" 
)

Add a double value to all double cell

Definition at line 8167 of file datalib.cpp.

void HDynTable::addition ( HDynTable  dt,
QString  limitTo = "" 
)

Field to field addition of the tables (The two tables field's must be same)

Definition at line 8179 of file datalib.cpp.

void HDynTable::clear ( void  )
inline

Clears all element from the HDynTable

Definition at line 3826 of file datalib.h.

int HDynTable::countElements ( QString  limitTo = "")

Returns the number of all defined elements(with no argument) or a specified labelled elements. (if nonempty argument passed)

Definition at line 8245 of file datalib.cpp.

QString HDynTable::currentElementColumnName ( void  )

Returns the column name of the element in the position of internal iterator

Definition at line 8018 of file datalib.cpp.

bool HDynTable::currentElementIsNumeric ( void  )

Returns true if the element in the position of internal iterator is numeric

Definition at line 8033 of file datalib.cpp.

QStringList HDynTable::currentElementLabels ( void  )

Returns the labels of the element in the position of internal iterator

Definition at line 8028 of file datalib.cpp.

QString HDynTable::currentElementName ( void  )

Returns the name of the element in the position of internal iterator

Definition at line 8008 of file datalib.cpp.

QString HDynTable::currentElementRowName ( void  )

Returns the row name of the element in the position of internal iterator

Definition at line 8013 of file datalib.cpp.

QString HDynTable::currentElementSqlName ( void  )

Returns the sql name of the element in the position of internal iterator

Definition at line 8023 of file datalib.cpp.

double HDynTable::currentElementValueDouble ( void  )

Returns the double value of the element in the position of internal iterator

Definition at line 8038 of file datalib.cpp.

QString HDynTable::currentElementValueString ( void  )

Returns the string name of the element in the position of internal iterator

Definition at line 8043 of file datalib.cpp.

void HDynTable::dataChangedNongui ( void  )
signal

Emitted when the data changed in the memory. It does not emits when the element's structure changed (added/cleared)

void HDynTable::defN ( QString  name,
QString  sqlname = "",
QString  rowName = "",
QString  colName = "",
QString  labels = "" 
)
inline

Define a new numeric typed element (Handles double data)

Parameters
nameThe name to identify the field. Must be unique. You can set/get values by this name (t["name"] = 0.1;)
sqlnameThe sql filed name assigned to this element
rowNameThis element will be show in this named row in the dynamically builded HDynTable
colNameThis element will be show in this named column in the dynamically builded HDynTable
labelsThis parameters contains the "|" separated collections of text labels. You can filter many mathematical

Definition at line 3805 of file datalib.h.

void HDynTable::defS ( QString  name,
QString  sqlname = "",
QString  rowName = "",
QString  colName = "",
QString  labels = "" 
)
inline

Define a new string typed element (Handles textual data)

Parameters
nameThe name to identify the field. Must be unique. You can set/get values by this name (t["name"] = 0.1;)
sqlnameThe sql filed name assigned to this element
rowNameThis element will be show in this named row in the dynamically builded HDynTable
colNameThis element will be show in this named column in the dynamically builded HDynTable
labelsThis parameters contains the "|" separated collections of text labels. You can filter many mathematical

Definition at line 3814 of file datalib.h.

void HDynTable::defT ( int  type,
QString  name,
QString  sqlname = "",
QString  rowName = "",
QString  colName = "",
QString  labels = "" 
)
inline

Define a new typed element (You can give the type in parameter)

Parameters
typeThe type of the field. Can be HDYNELEMENT_DOUBLE or HDYNELEMENT_STRING
...other parameters are same as defN,defS
See Also
defN
defS

Definition at line 3822 of file datalib.h.

void HDynTable::divide ( double  d,
QString  limitTo = "" 
)

Divide all double cell with a double value

Definition at line 8215 of file datalib.cpp.

void HDynTable::divide ( HDynTable  dt,
QString  limitTo = "" 
)

Field to field divide of the tables (The two tables field's must be same)

Definition at line 8228 of file datalib.cpp.

QString HDynTable::dumpElements ( void  )

Dump out all elements name and value in one concatenated string

Definition at line 7838 of file datalib.cpp.

bool HDynTable::elementHasLabel ( QString  name,
QString  label,
bool *  found = NULL 
)

Returns true if the given named element has a given label. Otherwise returns false.

Parameters
nameThe examided element's name
labelThe label name to check
Ifyou give this bool pointer the pointer will be set to true any cases the element has been found

Definition at line 8298 of file datalib.cpp.

void HDynTable::emptyall ( QString  limitTo = "")

Sets all elements value to zero and empty string.

Parameters
limitToif you give this parameter only the given labelled element's are zeroed

Definition at line 8060 of file datalib.cpp.

void HDynTable::firstElement ( void  )

Set the internal intetator to the first element. You can walk throught the elements with this functions

...
while(!t.isEnded())
{
}
See Also
isEnded()
nextElement()

Definition at line 7990 of file datalib.cpp.

QString HDynTable::getElementSqlName ( QString  name)

Queries the given named element's sql name

Definition at line 7855 of file datalib.cpp.

double HDynTable::getElementValueDouble ( QString  name,
bool *  found = NULL 
)

Queries the given named element's double value

Definition at line 7892 of file datalib.cpp.

double HDynTable::getElementValueDoubleByRowColName ( QString  r,
QString  c,
bool *  found = NULL 
)

Queries the specified row and column crossed element's double value

Definition at line 7954 of file datalib.cpp.

QString HDynTable::getElementValueString ( QString  name,
bool *  found = NULL 
)

Queries the given named element's string value

Definition at line 7911 of file datalib.cpp.

QString HDynTable::getElementValueStringByRowColName ( QString  r,
QString  c,
bool *  found = NULL 
)

Queries the specified row and column crossed element's string value

Definition at line 7972 of file datalib.cpp.

double HDynTable::getIndexedValueDouble ( int  index,
bool *  found = NULL 
)

Returns the value name of the index'th element

Parameters
Ifyou give this bool pointer the pointer will be set to true any cases the element has been found

Definition at line 8278 of file datalib.cpp.

QString HDynTable::getIndexedValueString ( int  index,
bool *  found = NULL 
)

Returns the value name of the index'th element

Parameters
Ifyou give this bool pointer the pointer will be set to true any cases the element has been found

Definition at line 8283 of file datalib.cpp.

QString HDynTable::indexedElementName ( int  index)

Returns the name of the index'th element

Definition at line 8258 of file datalib.cpp.

QString HDynTable::indexedElementSqlName ( int  index)

Returns the sql name of the index'th element

Definition at line 8273 of file datalib.cpp.

bool HDynTable::isEnded ( void  )

Check if the internal iterator reach the end of the fields.

See Also
firstElement()

Definition at line 7996 of file datalib.cpp.

double HDynTable::max ( QString  limitTo = "")

Returns the maximum valued element.

Parameters
limitToif you give this parameter only the given labelled element's are examined

Definition at line 8092 of file datalib.cpp.

double HDynTable::min ( QString  limitTo = "")

Returns the minimum valued element.

Parameters
limitToif you give this parameter only the given labelled element's are examined

Definition at line 8111 of file datalib.cpp.

void HDynTable::multiplicate ( double  d,
QString  limitTo = "" 
)

Multiplicate all double cell with a double value

Definition at line 8191 of file datalib.cpp.

void HDynTable::multiplicate ( HDynTable  dt,
QString  limitTo = "" 
)

Field to field multiplication of the tables (The two tables field's must be same)

Definition at line 8203 of file datalib.cpp.

void HDynTable::nextElement ( void  )

Steps the internal iterator to the next element.

See Also
firstElement()

Definition at line 8003 of file datalib.cpp.

HDynTableElementNameReferencer HDynTable::operator[] ( QString  name)
inline

You can set/get element's value by name with this operator

Definition at line 3995 of file datalib.h.

void HDynTable::setCurrentElementValue ( double  d)

Sets the value of the element in the position of internal iterator

Definition at line 8048 of file datalib.cpp.

void HDynTable::setCurrentElementValue ( QString  s)

Sets the value of the element in the position of internal iterator

Definition at line 8054 of file datalib.cpp.

void HDynTable::setElementValue ( QString  name,
double  value 
)

Sets the given named element's value

Definition at line 7867 of file datalib.cpp.

void HDynTable::setElementValue ( QString  name,
QString  value 
)

Sets the given named element's value

Definition at line 7880 of file datalib.cpp.

void HDynTable::setElementValueByRowColName ( QString  r,
QString  c,
double  value 
)

Sets the specified row and column crossed element's double value

Definition at line 7930 of file datalib.cpp.

void HDynTable::setElementValueByRowColName ( QString  r,
QString  c,
QString  value 
)

Sets the specified row and column crossed element's string value

Definition at line 7942 of file datalib.cpp.

void HDynTable::setIndexedElementValue ( int  index,
double  d 
)

Sets the index'th elements value

Definition at line 8288 of file datalib.cpp.

void HDynTable::setIndexedElementValue ( int  index,
QString  s 
)

Sets the index'th elements value

Definition at line 8293 of file datalib.cpp.

double HDynTable::sum ( QString  limitTo = "")

Returns the sum of element's value.

Parameters
limitToif you give this parameter only the given labelled element's are examined

Definition at line 8130 of file datalib.cpp.

void HDynTable::sustraction ( double  d,
QString  limitTo = "" 
)

Substract a double value from all double cell

Definition at line 8143 of file datalib.cpp.

void HDynTable::sustraction ( HDynTable  dt,
QString  limitTo = "" 
)

Field to field substraction of the tables (The two tables field's must be same)

Definition at line 8155 of file datalib.cpp.

void HDynTable::zeroall ( QString  limitTo = "")

Sets all element's value to zero.

Parameters
limitToif you give this parameter only the given labelled element's are zeroed

Definition at line 8078 of file datalib.cpp.


The documentation for this class was generated from the following files: