00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __KDCHARTTABLEINTERFACE_H__
00030 #define __KDCHARTTABLEINTERFACE_H__
00031
00032
00033 class QTable;
00034
00035 #include <qvariant.h>
00036 #include <qobject.h>
00037 #include <qdatetime.h>
00038
00039 #include <kdchart_export.h>
00040
00041 #if defined( SUN7 ) || defined (_SGIAPI)
00042 #include <float.h>
00043 #include <limits.h>
00044 #else
00045 #include <cfloat>
00046 #include <climits>
00047 #endif
00048
00049
00059 #define KDCHART_POS_INFINITE DBL_MAX
00060
00070 #define KDCHART_NEG_INFINITE -DBL_MAX
00071
00072
00086
00087 class KDCHART_EXPORT KDChartTableDataBase :public QObject
00088 {
00089 Q_OBJECT
00090 public:
00096 KDChartTableDataBase() :
00097 QObject( 0 ),
00098 _sorted(false),
00099 _useUsedRows(false),
00100 _useUsedCols(false) {}
00106 KDChartTableDataBase( const KDChartTableDataBase& other ) :QObject(0)
00107 {
00108 _sorted = other._sorted;
00109 _useUsedRows = other._useUsedRows;
00110 _useUsedCols = other._useUsedCols;
00111 _usedRows = other._usedRows;
00112 _usedCols = other._usedCols;
00113 }
00119 virtual ~KDChartTableDataBase() {}
00120
00121 public slots:
00132 virtual uint rows() const = 0;
00143 virtual uint cols() const = 0;
00144
00159 virtual void setCell( uint _row, uint _col,
00160 const QVariant& _value1,
00161 const QVariant& _value2=QVariant() ) = 0;
00174 virtual void setProp( uint _row, uint _col,
00175 int _propSet=0 ) = 0;
00176
00193 virtual bool cellCoord( uint _row, uint _col,
00194 QVariant& _value,
00195 int coordinate=1 ) const = 0;
00196
00218 virtual QVariant cellVal( uint _row, uint _col, int coordinate=1 ) const {
00219 QVariant value;
00220 if( cellCoord( _row, _col, value, coordinate ) )
00221 return value;
00222 else
00223 return QVariant();
00224 }
00225
00238 virtual bool cellProp( uint _row, uint _col,
00239 int& _prop ) const = 0;
00240
00255 virtual void expand( uint _rows, uint _cols ) = 0;
00256
00257
00258
00259
00260
00261
00262
00269 virtual bool cellContent( uint _row, uint _col,
00270 QVariant& _value1,
00271 QVariant& _value2,
00272 int& _prop ) const
00273 {
00274 return cellCoords(_row,_col, _value1,_value2) &&
00275 cellProp(_row,_col, _prop);
00276 }
00283 virtual bool cellCoords( uint _row, uint _col,
00284 QVariant& _value1,
00285 QVariant& _value2 ) const
00286 {
00287 return cellCoord(_row,_col, _value1, 1) &&
00288 cellCoord(_row,_col, _value2, 2);
00289 }
00290
00291
00302 virtual void setUsedRows( uint _rows );
00310 virtual uint usedRows() const;
00311
00322 virtual void setUsedCols( uint _cols );
00330 virtual uint usedCols() const;
00331
00332
00347 virtual uint colsScrolledBy() const
00348 {
00349 return 0;
00350 }
00351
00352
00358 virtual void setSorted(bool sorted);
00364 virtual bool sorted() const;
00365
00377 virtual bool isPosInfinite( double value ) const
00378 {
00379 return value == KDCHART_POS_INFINITE;
00380 }
00381
00393 virtual bool isNegInfinite( double value ) const
00394 {
00395 return value == KDCHART_NEG_INFINITE;
00396 }
00397
00410 virtual bool isNormalDouble( double value ) const
00411 {
00412 return !isPosInfinite( value ) && !isNegInfinite( value );
00413 }
00414
00429 bool isNormalDouble( QVariant value, double& dVal ) const
00430 {
00431 if( QVariant::Double != value.type() )
00432 return false;
00433 dVal = value.toDouble();
00434 return isNormalDouble( dVal );
00435 }
00436
00437 virtual void importFromQTable( QTable* table );
00438
00439 virtual double maxValue( int coordinate=1 ) const;
00440 virtual double minValue( int coordinate=1, bool bOnlyGTZero=false ) const;
00441
00442 virtual QDateTime maxDtValue( int coordinate=1 ) const;
00443 virtual QDateTime minDtValue( int coordinate=1 ) const;
00444
00445 virtual double maxColSum( int coordinate=1 ) const;
00446 virtual double minColSum( int coordinate=1 ) const;
00447 virtual double maxColSum( uint row, uint row2, int coordinate=1 ) const;
00448 virtual double minColSum( uint row, uint row2, int coordinate=1 ) const;
00449 virtual double colSum( uint col, int coordinate=1 ) const;
00450 virtual double colAbsSum( uint col, int coordinate=1 ) const;
00451 virtual double maxRowSum( int coordinate=1 ) const;
00452 virtual double minRowSum( int coordinate=1 ) const;
00453 virtual double rowSum( uint row, int coordinate=1 ) const;
00454 virtual double rowAbsSum( uint row, int coordinate=1 ) const;
00455 virtual double maxInColumn( uint col, int coordinate=1 ) const;
00456 virtual double minInColumn( uint col, int coordinate=1 ) const;
00457 virtual double maxInRow( uint row, int coordinate=1 ) const;
00458 virtual double minInRow( uint row, int coordinate=1 ) const;
00459 virtual double maxInRows( uint row, uint row2, int coordinate=1 ) const;
00460 virtual double minInRows( uint row, uint row2, int coordinate=1, bool bOnlyGTZero=false ) const;
00461 virtual QDateTime maxDtInRows( uint row, uint row2, int coordinate=1 ) const;
00462 virtual QDateTime minDtInRows( uint row, uint row2, int coordinate=1 ) const;
00463 virtual uint lastPositiveCellInColumn( uint col, int coordinate=1 ) const;
00464 virtual bool cellsHaveSeveralCoordinates(QVariant::Type* type2Ref) const;
00465 virtual bool cellsHaveSeveralCoordinates(uint row1=0, uint row2=UINT_MAX,
00466 QVariant::Type* type2Ref=NULL) const;
00467 virtual QVariant::Type cellsValueType( uint row1, uint row2=UINT_MAX,
00468 int coordinate=1 ) const;
00469 virtual QVariant::Type cellsValueType( int coordinate=1 ) const;
00470 private:
00471 bool _sorted;
00472 protected:
00473 bool _useUsedRows, _useUsedCols;
00474 private:
00475 uint _usedRows, _usedCols;
00476 };
00477
00478 #endif