29#ifndef __KDCHARTVECTORTABLE_H__
30#define __KDCHARTVECTORTABLE_H__
32#include <tqvaluevector.h>
36#include <KDChartDataIntern.h>
39class KDCHART_EXPORT KDChartVectorTablePrivate :
public TQShared
42 KDChartVectorTablePrivate() : TQShared() {
47 KDChartVectorTablePrivate( uint _rows, uint _cols ) : TQShared() {
53 KDChartVectorTablePrivate(
const KDChartVectorTablePrivate& _t ) :
56 col_count( _t.col_count ),
57 row_count( _t.row_count ) {}
59 ~KDChartVectorTablePrivate() {}
61 void expand( uint _rows, uint _cols ) {
63 TQValueVector<KDChartData> save( matrix );
70 for( uint row = 0; row < TQMIN( row_count, _rows ); row++ )
71 for( uint col = 0; col < TQMIN( col_count, _cols ); col++ )
72 matrix[ row * _cols + col ].setAll( save[ row * col_count + col ] );
80 Q_ASSERT( _row < row_count );
81 Q_ASSERT( _col < col_count );
82 return matrix[
static_cast < int > ( _row * col_count + _col ) ];
84 const KDChartData& cell( uint _row, uint _col )
const {
85 Q_ASSERT( _row < row_count );
86 Q_ASSERT( _col < col_count );
87 return matrix[
static_cast < int > ( _row * col_count + _col ) ];
89 void setCell( uint _row, uint _col,
const KDChartData& _element ) {
90 Q_ASSERT( _row < row_count );
91 Q_ASSERT( _col < col_count );
92 matrix[
static_cast < int > ( _row * col_count + _col ) ].setAll( _element );
95 void clearCell( uint _row, uint _col ) {
96 Q_ASSERT( _row < row_count );
97 Q_ASSERT( _col < col_count );
98 matrix[
static_cast < int > ( _row * col_count + _col ) ].clearValue();
101 void clearAllCells() {
102 for ( uint r = 0; r < row_count; ++r )
103 for ( uint c = 0; c < col_count; ++c )
104 matrix[ r * col_count + c ].clearValue();
107 TQValueVector<KDChartData> matrix;
120 typedef KDChartVectorTablePrivate Priv;
121 uint _usedRows, _usedCols;
127 typedef TQValueVector<KDChartData>::iterator Iterator;
128 typedef TQValueVector<KDChartData>::const_iterator ConstIterator;
130 typedef TQValueVector<int>::iterator RowIterator;
131 typedef TQValueVector<int>::const_iterator ConstRowIterator;
133 typedef TQValueVector<int>::iterator ColIterator;
134 typedef TQValueVector<int>::const_iterator ConstColIterator;
139 KDChartVectorTableData() :
146 KDChartVectorTableData( uint _rows, uint _cols ) :
149 sh =
new Priv( _rows, _cols );
154 KDChartVectorTableData(
const KDChartVectorTableData& _t ) :
156 _useUsedRows = _t._useUsedRows;
157 _useUsedCols = _t._useUsedCols;
158 _usedRows = _t._usedRows;
159 _usedCols = _t._usedCols;
162 setSorted( _t.sorted() );
165 virtual ~KDChartVectorTableData() {
170 KDChartVectorTableData& operator=(
const KDChartVectorTableData& t ) {
173 _useUsedRows = t._useUsedRows;
174 _useUsedCols = t._useUsedCols;
175 _usedRows = t._usedRows;
176 _usedCols = t._usedCols;
181 setSorted( t.sorted() );
187 return sh->matrix.begin();
190 ConstIterator begin()
const {
191 return sh->matrix.begin();
195 return sh->matrix.end();
198 ConstIterator end()
const {
199 return sh->matrix.end();
202 bool isEmpty()
const {
203 return ( sh->col_count == 0 && sh->row_count == 0 );
207 return sh->col_count;
211 return sh->row_count;
223 virtual bool cellCoord( uint _row, uint _col,
225 int coordinate=1 )
const
227 if( _row >= sh->row_count || _col >= sh->col_count )
229 _value = sh->cell( _row, _col ).value( coordinate );
233 virtual bool cellProp( uint _row, uint _col,
236 if( _row >= sh->row_count || _col >= sh->col_count )
238 _prop = sh->cell( _row, _col ).propertySet();
242 virtual void setCell( uint _row, uint _col,
243 const TQVariant& _value1,
244 const TQVariant& _value2=TQVariant() ) {
247 sh->setCell( _row, _col, element );
250 virtual void setProp( uint _row, uint _col,
253 sh->cell( _row, _col ).setPropertySet( _propSet );
256 void clearCell( uint _row, uint _col ) {
258 sh->clearCell( _row, _col );
261 void clearAllCells() {
266 void expand( uint _rows, uint _cols ) {
268 sh->expand( _rows, _cols );
271 setUsedCols( TQMIN( _usedCols, _cols ) );
273 setUsedRows( TQMIN( _usedRows, _rows ) );
276 void setUsedRows( uint _rows ) {
277 Q_ASSERT( _rows <= rows() );
278 if( _usedRows < _rows )
284 uint usedRows()
const {
285 return _useUsedRows ? _usedRows : rows();
288 void setUsedCols( uint _cols ) {
289 Q_ASSERT( _cols <= cols() );
290 if( _usedCols < _cols )
296 uint usedCols()
const {
297 return _useUsedCols ? _usedCols : cols();
305 if ( sh->count > 1 ) {
307 sh =
new Priv( *sh );
Provides a table class holding all data values that are to be used in a chart.
Encapsulates one data cell in a chart.
KD Chart's build-in table data for an easy way of storing data values.