98 return _useUsedRows ? _usedRows :
rows();
105 return _useUsedCols ? _usedCols :
cols();
109bool KDChartTableDataBase::cellsHaveSeveralCoordinates(
110 TQVariant::Type* type2Ref )
const
112 return cellsHaveSeveralCoordinates( 0, UINT_MAX, type2Ref );
116bool KDChartTableDataBase::cellsHaveSeveralCoordinates(
119 TQVariant::Type* type2Ref )
const
126 bool severalCoordinates = row1 <
usedRows();
127 if( severalCoordinates ) {
128 severalCoordinates =
false;
129 TQVariant::Type testType = TQVariant::Invalid;
130 const uint r2 = (UINT_MAX == row2)
135 for ( uint row = row1; row < r2; ++row ){
136 for ( uint col = 0; col <
usedCols(); ++col ){
138 if( TQVariant::Invalid != value2.type() ){
139 if( (TQVariant::Invalid != testType) &&
140 (value2.type() != testType) ){
141 severalCoordinates =
false;
144 testType = value2.type();
145 if( NULL != type2Ref )
146 *type2Ref = testType;
147 severalCoordinates =
true;
149 }
else if( TQVariant::Invalid != value1.type() ){
150 severalCoordinates =
false;
157 return severalCoordinates;
161TQVariant::Type KDChartTableDataBase::cellsValueType(
164 int coordinate )
const
166 TQVariant::Type res = TQVariant::Invalid;
167 const uint r2 = (UINT_MAX == row2)
172 for ( uint row = row1; row < r2; ++row )
173 for ( uint col = 0; col <
usedCols(); ++col )
174 if(
cellCoord( row, col, value, coordinate ) )
175 if( TQVariant::Invalid != value.type() )
181TQVariant::Type KDChartTableDataBase::cellsValueType(
182 int coordinate )
const
184 return cellsValueType( 0, UINT_MAX, coordinate );
188double KDChartTableDataBase::maxValue(
int coordinate )
const
190 double maxValue = 0.0;
194 for ( uint row = 0; row <
usedRows(); row++ ) {
195 for ( uint col = 0; col <
usedCols(); col++ ) {
196 if(
cellCoord( row, col, value, coordinate ) &&
197 TQVariant::Double == value.type() ) {
198 dVal = value.toDouble();
204 maxValue = TQMAX( maxValue, dVal );
214double KDChartTableDataBase::minValue(
int coordinate,
bool bOnlyGTZero )
const
216 double minValue = 0.0;
220 for ( uint row = 0; row <
usedRows(); row++ ) {
221 for ( uint col = 0; col <
usedCols(); col++ ) {
222 if(
cellCoord( row, col, value, coordinate ) &&
223 TQVariant::Double == value.type() ) {
224 dVal = value.toDouble();
225 if( !bOnlyGTZero || 0.0 < dVal ){
230 minValue = TQMIN( minValue, dVal );
240TQDateTime KDChartTableDataBase::maxDtValue(
int coordinate )
const
242 TQDateTime maxValue = TQDateTime( TQDate(1970,1,1) );
246 for ( uint row = 0; row <
usedRows(); row++ ) {
247 for ( uint col = 0; col <
usedCols(); col++ ) {
248 if(
cellCoord( row, col, value, coordinate ) &&
249 TQVariant::DateTime == value.type() ) {
250 dtVal = value.toDateTime();
255 maxValue = TQMAX(maxValue, dtVal);
264TQDateTime KDChartTableDataBase::minDtValue(
int coordinate )
const
266 TQDateTime minValue = TQDateTime( TQDate(1970,1,1) );
270 for ( uint row = 0; row <
usedRows(); row++ ) {
271 for ( uint col = 0; col <
usedCols(); col++ ) {
272 if(
cellCoord( row, col, value, coordinate ) &&
273 TQVariant::DateTime == value.type() ) {
274 dtVal = value.toDateTime();
279 minValue = TQMIN(minValue, dtVal);
287double KDChartTableDataBase::maxColSum(
int coordinate )
const
289 double maxValue = 0.0;
291 for ( uint col = 0; col <
usedCols(); col++ ) {
292 double colValue = colSum( col, coordinate );
297 maxValue = TQMAX( maxValue, colValue );
303double KDChartTableDataBase::minColSum(
int coordinate )
const
305 double minValue = 0.0;
307 for ( uint col = 0; col <
usedCols(); col++ ) {
308 double colValue = colSum( col, coordinate );
313 minValue = TQMIN( minValue, colValue );
320double KDChartTableDataBase::maxColSum( uint row, uint row2,
int coordinate )
const
331 for ( uint col = 0; col <
usedCols(); col++ ) {
332 double valueValue = 0.0;
335 for ( uint row = a; row <= z; row++ ) {
336 if(
cellCoord( row, col, value, coordinate ) &&
337 TQVariant::Double == value.type() ) {
338 dVal = value.toDouble();
344 maxValue = valueValue;
347 maxValue = TQMAX( maxValue, valueValue );
354double KDChartTableDataBase::minColSum( uint row, uint row2,
int coordinate )
const
365 for ( uint col = 0; col <
usedCols(); col++ ) {
366 double valueValue = 0.0;
369 for ( uint row = a; row <= z; row++ ) {
370 if(
cellCoord( row, col, value, coordinate ) &&
371 TQVariant::Double == value.type() ) {
372 dVal = value.toDouble();
378 minValue = valueValue;
381 minValue = TQMIN( minValue, valueValue );
388double KDChartTableDataBase::colSum( uint col,
int coordinate )
const
393 for ( uint row = 0; row <
usedRows(); row++ ) {
394 if(
cellCoord( row, col, value, coordinate ) &&
395 TQVariant::Double == value.type() ) {
396 dVal = value.toDouble();
406double KDChartTableDataBase::colAbsSum( uint col,
int coordinate )
const
411 for ( uint row = 0; row <
usedRows(); row++ ) {
412 if(
cellCoord( row, col, value, coordinate ) &&
413 TQVariant::Double == value.type() ) {
414 dVal = value.toDouble();
424double KDChartTableDataBase::maxRowSum(
int coordinate )
const
426 double maxValue = 0.0;
428 for ( uint row = 0; row <
usedRows(); row++ ) {
429 double rowValue = rowSum( row, coordinate );
434 maxValue = TQMAX( maxValue, rowValue );
440double KDChartTableDataBase::minRowSum(
int coordinate )
const
442 double minValue = 0.0;
444 for ( uint row = 0; row <
usedRows(); row++ ) {
445 double rowValue = rowSum( row, coordinate );
450 minValue = TQMIN( minValue, rowValue );
457double KDChartTableDataBase::rowSum( uint row,
int coordinate )
const
462 for ( uint col = 0; col <
usedCols(); col++ ) {
463 if(
cellCoord( row, col, value, coordinate ) &&
464 TQVariant::Double == value.type() ) {
465 dVal = value.toDouble();
474double KDChartTableDataBase::rowAbsSum( uint row,
int coordinate )
const
479 for ( uint col = 0; col <
usedCols(); col++ ) {
480 if(
cellCoord( row, col, value, coordinate ) &&
481 TQVariant::Double == value.type() ) {
482 dVal = value.toDouble();
491double KDChartTableDataBase::maxInColumn( uint col,
int coordinate )
const
493 double maxValue = 0.0;
497 for ( uint row = 0; row <
usedRows(); row++ ) {
498 if(
cellCoord( row, col, value, coordinate ) &&
499 TQVariant::Double == value.type() ) {
500 dVal = value.toDouble();
506 maxValue = TQMAX( maxValue, dVal );
515double KDChartTableDataBase::minInColumn( uint col,
int coordinate )
const
517 double minValue = 0.0;
521 for ( uint row = 0; row <
usedRows(); row++ ) {
522 if(
cellCoord( row, col, value, coordinate ) &&
523 TQVariant::Double == value.type() ) {
524 dVal = value.toDouble();
530 minValue = TQMIN( minValue, dVal );
539double KDChartTableDataBase::maxInRow( uint row,
int coordinate )
const
541 double maxValue = DBL_MIN;
545 if ( UINT_MAX > row ) {
546 for ( uint col = 0; col <
usedCols(); col++ ) {
547 if(
cellCoord( row, col, value, coordinate ) &&
548 TQVariant::Double == value.type() ) {
549 dVal = value.toDouble();
555 maxValue = TQMAX( maxValue, dVal );
564double KDChartTableDataBase::minInRow( uint row,
int coordinate )
const
566 double minValue = DBL_MAX;
570 if ( UINT_MAX > row ) {
571 for ( uint col = 0; col <
usedCols(); col++ ) {
572 if(
cellCoord( row, col, value, coordinate ) &&
573 TQVariant::Double == value.type() ) {
574 dVal = value.toDouble();
580 minValue = TQMIN( minValue, dVal );
589double KDChartTableDataBase::maxInRows( uint row, uint row2,
int coordinate )
const
591 double maxValue = 0.0;
602 for ( uint row = a; row <= z; ++row ) {
605 for ( uint col = 0; col <
usedCols(); ++col ) {
606 if(
cellCoord( row, col, value, coordinate ) &&
607 TQVariant::Double == value.type() ) {
608 dVal = value.toDouble();
614 maxValue = TQMAX( maxValue, dVal );
624double KDChartTableDataBase::minInRows( uint row, uint row2,
int coordinate,
bool bOnlyGTZero )
const
626 double minValue = 0.0;
637 for ( uint row = a; row <= z; ++row ) {
640 for ( uint col = 0; col <
usedCols(); ++col ) {
641 if(
cellCoord( row, col, value, coordinate ) &&
642 TQVariant::Double == value.type() ) {
643 dVal = value.toDouble();
645 if( !bOnlyGTZero || 0.0 < dVal ){
650 minValue = TQMIN( minValue, dVal );
662TQDateTime KDChartTableDataBase::maxDtInRows( uint row, uint row2,
663 int coordinate )
const
665 TQDateTime maxValue = TQDateTime( TQDate(1970,1,1) );
674 for ( uint row = a; row <= z; ++row ) {
677 for ( uint col = 0; col <
usedCols(); ++col ) {
678 if(
cellCoord( row, col, value, coordinate ) &&
679 TQVariant::DateTime == value.type() ) {
680 dtVal = value.toDateTime();
685 maxValue = TQMAX( maxValue, dtVal );
694TQDateTime KDChartTableDataBase::minDtInRows( uint row, uint row2,
695 int coordinate )
const
697 TQDateTime minValue = TQDateTime( TQDate(1970,1,1) );
706 for ( uint row = a; row <= z; ++row ) {
709 for ( uint col = 0; col <
usedCols(); ++col ) {
710 if(
cellCoord( row, col, value, coordinate ) &&
711 TQVariant::DateTime == value.type() ) {
712 dtVal = value.toDateTime();
717 minValue = TQMIN( minValue, dtVal );
726uint KDChartTableDataBase::lastPositiveCellInColumn( uint col,
int coordinate )
const
731 for ( uint row = 0; row <
usedRows(); row++ ) {
732 if(
cellCoord( row, col, value, coordinate ) &&
733 TQVariant::Double == value.type() ) {
734 dVal = value.toDouble();
743void KDChartTableDataBase::importFromQTable( TQTable* table )
745 if( table->numRows() > (
int)
rows() ||
746 table->numCols() > (
int)
cols() )
747 expand( table->numRows(), table->numCols() );
750 for(
int row = 0; row < table->numRows(); row++ )
751 for(
int col = 0; col < table->numCols(); col++ ) {
752 TQString cellContents = table->text( row, col );
753 if( !cellContents.isEmpty() ) {
756 double value = cellContents.toDouble( &ok );
762 setCell( row, col, cellContents );
779#include "KDChartTableBase.moc"
Provides a table class holding all data values that are to be used in a chart.
virtual uint usedCols() const
Returns the number of cols in the table that actually contain data.
virtual bool cellCoord(uint _row, uint _col, TQVariant &_value, int coordinate=1) const =0
Returns one of the coordinate data value(s) stored in a cell.
virtual bool isNormalDouble(double value) const
Returns true if the given value represents a normal double value.
virtual void setSorted(bool sorted)
Specified whether the table is sorted.
virtual void setUsedCols(uint _cols)
Sets the number of cols in the table that actually contain data.
virtual void expand(uint _rows, uint _cols)=0
Increases the number of rows (and/or columns, resp.) stored in this table.
virtual uint cols() const =0
Returns the number of cols in the table.
virtual uint rows() const =0
Returns the number of rows in the table.
virtual bool cellCoords(uint _row, uint _col, TQVariant &_value1, TQVariant &_value2) const
virtual uint usedRows() const
Returns the number of rows in the table that actually contain data.
virtual void setUsedRows(uint _rows)
Sets the number of rows in the table that actually contain data.
virtual bool sorted() const
Returns whether the table is sorted.
virtual void setCell(uint _row, uint _col, const TQVariant &_value1, const TQVariant &_value2=TQVariant())=0
Stores data in a cell.