kchart
KDChartTableDataBase Class Reference
#include <KDChartTableBase.h>
Inheritance diagram for KDChartTableDataBase:

Detailed Description
KD Chart's build-in table data for an easy way of storing data values.
- Note:
- To create your data table you would not use a
KDChartTableDataBase
but instantiate the classKDChartTableData
. TheKDChartTableData
class is an auxiliary class: depending on your Qt version it will be mapped onto aKDChartVectorTableData
or onto aKDChartListTableData
both of which are derived fromKDChartTableDataBase
and implement all of its functions. Thus you would create a table of 3 datasets with 25 cells each like this:KDChartTableData myData( 3, 25 );
setCell()
. Cell specific properties may be specified via setCellProp()
.You may adjust or modify your table like this:
- Entering the data can be done either manually using
setCell()
or by passing a QTable to theimportFromQTable()
function.
- Performance of KD Chart can be increased by specifying the number of rows and or the number of columns actually used:
setUsedRows()
and/orsetUsedCols()
prevents KD Chart from iterating over thousands of empty rows/cols that might follow your data cells in case your table is much bigger than needed.
- In case you want to increase your table's size without using the data stored in it please call the
expand()
function with the new total number of rows and cells.
- Accessing one data cell is possible via
cellCoord()
and viacellProp()
, e.g. you might assign a special property set ID to all cells with a future absicssa axis value:const QDateTime currentTime( QDateTime::currentDateTime() ); for( int iCell = 0; iCell < usedValues; ++iCell ){ KDChartData& cell = myData.cell( 0, iCell ); // assign special property set ID if X value is in the future if( cell.isDateTime( 2 ) && cell.dateTimeValue( 2 ) > currentTime ) cell.setPropertySet( idProp_FutureValues ); }
- Note:
- All of the other functions provided by KDChartTableDataBase are either used internally by KD Chart or they are const methods returning some usefull figures like the sum of all values in a row...
Definition at line 87 of file KDChartTableBase.h.
Public Slots | |
virtual uint | rows () const =0 |
virtual uint | cols () const =0 |
virtual void | setCell (uint _row, uint _col, const QVariant &_value1, const QVariant &_value2=QVariant())=0 |
virtual void | setProp (uint _row, uint _col, int _propSet=0)=0 |
virtual bool | cellCoord (uint _row, uint _col, QVariant &_value, int coordinate=1) const =0 |
virtual QVariant | cellVal (uint _row, uint _col, int coordinate=1) const |
virtual bool | cellProp (uint _row, uint _col, int &_prop) const =0 |
virtual void | expand (uint _rows, uint _cols)=0 |
virtual bool | cellContent (uint _row, uint _col, QVariant &_value1, QVariant &_value2, int &_prop) const |
virtual bool | cellCoords (uint _row, uint _col, QVariant &_value1, QVariant &_value2) const |
virtual void | setUsedRows (uint _rows) |
virtual uint | usedRows () const |
virtual void | setUsedCols (uint _cols) |
virtual uint | usedCols () const |
virtual uint | colsScrolledBy () const |
virtual void | setSorted (bool sorted) |
virtual bool | sorted () const |
virtual bool | isPosInfinite (double value) const |
virtual bool | isNegInfinite (double value) const |
virtual bool | isNormalDouble (double value) const |
bool | isNormalDouble (QVariant value, double &dVal) const |
virtual void | importFromQTable (QTable *table) |
virtual double | maxValue (int coordinate=1) const |
virtual double | minValue (int coordinate=1, bool bOnlyGTZero=false) const |
virtual QDateTime | maxDtValue (int coordinate=1) const |
virtual QDateTime | minDtValue (int coordinate=1) const |
virtual double | maxColSum (int coordinate=1) const |
virtual double | minColSum (int coordinate=1) const |
virtual double | maxColSum (uint row, uint row2, int coordinate=1) const |
virtual double | minColSum (uint row, uint row2, int coordinate=1) const |
virtual double | colSum (uint col, int coordinate=1) const |
virtual double | colAbsSum (uint col, int coordinate=1) const |
virtual double | maxRowSum (int coordinate=1) const |
virtual double | minRowSum (int coordinate=1) const |
virtual double | rowSum (uint row, int coordinate=1) const |
virtual double | rowAbsSum (uint row, int coordinate=1) const |
virtual double | maxInColumn (uint col, int coordinate=1) const |
virtual double | minInColumn (uint col, int coordinate=1) const |
virtual double | maxInRow (uint row, int coordinate=1) const |
virtual double | minInRow (uint row, int coordinate=1) const |
virtual double | maxInRows (uint row, uint row2, int coordinate=1) const |
virtual double | minInRows (uint row, uint row2, int coordinate=1, bool bOnlyGTZero=false) const |
virtual QDateTime | maxDtInRows (uint row, uint row2, int coordinate=1) const |
virtual QDateTime | minDtInRows (uint row, uint row2, int coordinate=1) const |
virtual uint | lastPositiveCellInColumn (uint col, int coordinate=1) const |
virtual bool | cellsHaveSeveralCoordinates (QVariant::Type *type2Ref) const |
virtual bool | cellsHaveSeveralCoordinates (uint row1=0, uint row2=UINT_MAX, QVariant::Type *type2Ref=NULL) const |
virtual QVariant::Type | cellsValueType (uint row1, uint row2=UINT_MAX, int coordinate=1) const |
virtual QVariant::Type | cellsValueType (int coordinate=1) const |
Public Member Functions | |
KDChartTableDataBase () | |
KDChartTableDataBase (const KDChartTableDataBase &other) | |
virtual | ~KDChartTableDataBase () |
Protected Attributes | |
bool | _useUsedRows |
bool | _useUsedCols |
Constructor & Destructor Documentation
KDChartTableDataBase::KDChartTableDataBase | ( | ) | [inline] |
Default constructor.
Creates an empty table and sets the sorted flag to false.
Definition at line 96 of file KDChartTableBase.h.
KDChartTableDataBase::KDChartTableDataBase | ( | const KDChartTableDataBase & | other | ) | [inline] |
Default copy constructor.
Just initializes the QObject part of this class and copies the sorted flag.
Definition at line 106 of file KDChartTableBase.h.
virtual KDChartTableDataBase::~KDChartTableDataBase | ( | ) | [inline, virtual] |
Default destructor.
Does nothing, only defined to have it virtual.
Definition at line 119 of file KDChartTableBase.h.
Member Function Documentation
virtual bool KDChartTableDataBase::cellContent | ( | uint | _row, | |
uint | _col, | |||
QVariant & | _value1, | |||
QVariant & | _value2, | |||
int & | _prop | |||
) | const [inline, virtual, slot] |
- Note:
- To improve runtime speed this virtual function may be reimplemented by classes derived from KDChartTableDataBase.
- See also:
- cellCoords, cellProp, setCell, setProp
Definition at line 269 of file KDChartTableBase.h.
virtual bool KDChartTableDataBase::cellCoord | ( | uint | _row, | |
uint | _col, | |||
QVariant & | _value, | |||
int | coordinate = 1 | |||
) | const [pure virtual, slot] |
Returns one of the coordinate data value(s) stored in a cell.
- Note:
- This pure-virtual function has to be implemented by each class derived from KDChartTableDataBase.
- Parameters:
-
_row the row number of the cell to be retrieved. _col the column number of the cell to be retrieved. _value the coordinate variable to be filled by this method. coordinate the number of the coordinate to be retrieved, normally 1 is the Y value and 2 is the X value.
- Returns:
- TRUE if the row and col are addressing a cell in the table.
- See also:
- cellCoords, cellProp, cellContent, cellVal, setCell, setProp
Implemented in KDChartListTableData, and KDChartVectorTableData.
virtual bool KDChartTableDataBase::cellCoords | ( | uint | _row, | |
uint | _col, | |||
QVariant & | _value1, | |||
QVariant & | _value2 | |||
) | const [inline, virtual, slot] |
- Note:
- To improve runtime speed this virtual function may be reimplemented by classes derived from KDChartTableDataBase.
- See also:
- cellCoord, cellProp, cellContent, setCell, setProp
Definition at line 283 of file KDChartTableBase.h.
virtual bool KDChartTableDataBase::cellProp | ( | uint | _row, | |
uint | _col, | |||
int & | _prop | |||
) | const [pure virtual, slot] |
Returns the property set ID stored in a cell.
- Note:
- This pure-virtual function has to be implemented by each class derived from KDChartTableDataBase.
- Parameters:
-
_prop the property set ID of the cell to be retrieved.
- Returns:
- TRUE if the row and col are addressing a cell in the table.
- See also:
- cellCoord, cellCoords, cellContent, setCell, setProp
Implemented in KDChartListTableData, and KDChartVectorTableData.
virtual QVariant KDChartTableDataBase::cellVal | ( | uint | _row, | |
uint | _col, | |||
int | coordinate = 1 | |||
) | const [inline, virtual, slot] |
Returns one of the coordinate data value(s) stored in a cell.
This convenience method calls the bool cellCoord() function and returns the result if it returned successfully - otherwise it returns an invalid QVariant.
- Note:
- If you know that a cell is containing valid double data you may quickly access them like this:
const double yVal = data.cellVal( r, c ).toDouble(); const double xVal = data.cellVal( r, c, 2 ).toDouble();
- Parameters:
-
_row the row number of the cell to be retrieved. _col the column number of the cell to be retrieved. coordinate the number of the coordinate to be retrieved, normally 1 is the Y value and 2 is the X value.
- Returns:
- cell contens if the row and col are addressing a cell in the table, otherwise an invalid QVariant is returned.
- See also:
- cellCoords, cellProp, cellContent, setCell, setProp
Definition at line 218 of file KDChartTableBase.h.
virtual uint KDChartTableDataBase::cols | ( | ) | const [pure virtual, slot] |
Returns the number of cols in the table.
- Note:
- This pure-virtual function has to be implemented by each class derived from KDChartTableDataBase.
- Returns:
- the number of cols in the table.
Implemented in KDChartListTableData, KDChartSeriesCollection, and KDChartVectorTableData.
virtual uint KDChartTableDataBase::colsScrolledBy | ( | ) | const [inline, virtual, slot] |
Returns the number of cols the table has been scrolled by.
Default implementation of this always returns zero, so make sure to return the appropriate value if your class derived from KDChartTableDataBase is supporting internal data scrolling technics.
See the KD Chart Programmers Manual for details described in the Data Scrolling chapter.
- Returns:
- the number of cols the table has been scrolled by.
Definition at line 347 of file KDChartTableBase.h.
virtual void KDChartTableDataBase::expand | ( | uint | _rows, | |
uint | _cols | |||
) | [pure virtual, slot] |
Increases the number of rows (and/or columns, resp.
) stored in this table.
- Note:
- This pure-virtual function has to be implemented by each class derived from KDChartTableDataBase.
The old content of the table must be preserved (e.g. by copying the data into the cells of the new table).
- Parameters:
-
_row the new number of rows. _col the new number of columns.
- See also:
- cell
Implemented in KDChartListTableData, KDChartSeriesCollection, and KDChartVectorTableData.
virtual bool KDChartTableDataBase::isNegInfinite | ( | double | value | ) | const [inline, virtual, slot] |
Returns true if the given value represents a negative infinite value.
- Note:
- This virtual function may be implemented by classes derived from KDChartTableDataBase. This should be done if your data are not stored as special value KDCHART_NEG_INFINITE to indicate negative infinite values
- Returns:
- TRUE if the value given is a negative infinite value.
Definition at line 393 of file KDChartTableBase.h.
bool KDChartTableDataBase::isNormalDouble | ( | QVariant | value, | |
double & | dVal | |||
) | const [inline, slot] |
Returns true if the given QVariant value represents a normal double value.
This method tests if value
has type QVariant::Double: if no, it returns false; if yes, it sets dVal
accordingly and calls the virtual method isNormalDouble( double value ).
- Parameters:
-
value The QVariant value to be tested and converted. dVal Points to the double variable to be filled with the converted value.
- Returns:
- TRUE if the value given is neither positive infinite nor negative infinite,
value
is set to the converted value if the type ofvalue
is QVariant::Double, otherwise it is not modified.
Definition at line 429 of file KDChartTableBase.h.
virtual bool KDChartTableDataBase::isNormalDouble | ( | double | value | ) | const [inline, virtual, slot] |
Returns true if the given value represents a normal double value.
Normal double values are defined as values that are neither positive infinite nor negative infinite. This method is provided to let derived classed use their own way to determine when a double value is to be threated as normal.
- Note:
- To improve runtime speed this virtual function may be reimplemented by classes derived from KDChartTableDataBase.
- Returns:
- TRUE if the value given is neither positive infinite nor negativr infinite.
Definition at line 410 of file KDChartTableBase.h.
virtual bool KDChartTableDataBase::isPosInfinite | ( | double | value | ) | const [inline, virtual, slot] |
Returns true if the given value represents a positive infinite value.
- Note:
- This virtual function may be implemented by classes derived from KDChartTableDataBase. This should be done if your data are not stored as special value KDCHART_POS_INFINITE to indicate positive infinite values
- Returns:
- TRUE if the value given is a positive infinite value.
Definition at line 377 of file KDChartTableBase.h.
virtual uint KDChartTableDataBase::rows | ( | ) | const [pure virtual, slot] |
Returns the number of rows in the table.
- Note:
- This pure-virtual function has to be implemented by each class derived from KDChartTableDataBase.
- Returns:
- the number of rows in the table.
Implemented in KDChartListTableData, KDChartSeriesCollection, and KDChartVectorTableData.
virtual void KDChartTableDataBase::setCell | ( | uint | _row, | |
uint | _col, | |||
const QVariant & | _value1, | |||
const QVariant & | _value2 = QVariant() | |||
) | [pure virtual, slot] |
Stores data in a cell.
- Note:
- This pure-virtual function has to be implemented by each class derived from KDChartTableDataBase.
- Parameters:
-
_row the row number of the cell to store the data object into. _col the column number of the cell to store the data object into. _value1 the first value to be stored, normally the Y value, possible types: int, double, QString QString might be used in case you want to use this cell's content for axis label _value2 the second value to be stored, normally the X value (if any), possible types: int, double, QDateTime
- See also:
- cellCoords, cellContent, setProp
Implemented in KDChartListTableData, and KDChartVectorTableData.
virtual void KDChartTableDataBase::setProp | ( | uint | _row, | |
uint | _col, | |||
int | _propSet = 0 | |||
) | [pure virtual, slot] |
Specifies the property set ID for a cell.
- Note:
- This pure-virtual function has to be implemented by each class derived from KDChartTableDataBase.
- Parameters:
-
_row the row number of the cell. _col the column number of the cell. _propSet the property set ID to be stored for this data cell, defaults to zero for normal data.
- See also:
- cellProp, cellContent, setCell
Implemented in KDChartListTableData, and KDChartVectorTableData.
void KDChartTableDataBase::setSorted | ( | bool | sorted | ) | [virtual, slot] |
Specified whether the table is sorted.
- See also:
- sorted
Definition at line 770 of file KDChartTableBase.cpp.
void KDChartTableDataBase::setUsedCols | ( | uint | _cols | ) | [virtual, slot] |
Sets the number of cols in the table that actually contain data.
- Note:
- You might want to re-implement this function in derived classes, the default implementation just stores the new number of used cols.
- Parameters:
-
_cols the number of cols in the table that actually contain data.
Reimplemented in KDChartListTableData, KDChartSeriesCollection, and KDChartVectorTableData.
Definition at line 100 of file KDChartTableBase.cpp.
void KDChartTableDataBase::setUsedRows | ( | uint | _rows | ) | [virtual, slot] |
Sets the number of rows in the table that actually contain data.
- Note:
- You might want to re-implement this function in derived classes, the default implementation just stores the new number of used rows.
- Parameters:
-
_rows the number of rows in the table that actually contain data.
Reimplemented in KDChartListTableData, KDChartSeriesCollection, and KDChartVectorTableData.
Definition at line 93 of file KDChartTableBase.cpp.
bool KDChartTableDataBase::sorted | ( | ) | const [virtual, slot] |
Returns whether the table is sorted.
- See also:
- setSorted
Definition at line 774 of file KDChartTableBase.cpp.
uint KDChartTableDataBase::usedCols | ( | ) | const [virtual, slot] |
Returns the number of cols in the table that actually contain data.
- Returns:
- the number of cols in the table that actually contain data.
- See also:
- setUsedCols, rows, cols
Reimplemented in KDChartListTableData, KDChartSeriesCollection, and KDChartVectorTableData.
Definition at line 104 of file KDChartTableBase.cpp.
uint KDChartTableDataBase::usedRows | ( | ) | const [virtual, slot] |
Returns the number of rows in the table that actually contain data.
- Returns:
- the number of rows in the table that actually contain data.
- See also:
- setUsedRows, rows, cols
Reimplemented in KDChartListTableData, KDChartSeriesCollection, and KDChartVectorTableData.
Definition at line 97 of file KDChartTableBase.cpp.
The documentation for this class was generated from the following files: