From c51527e28b51e41ec94032349b8fe5fa883a7b16 Mon Sep 17 00:00:00 2001 From: stv Date: Wed, 11 Oct 2006 12:30:21 +0000 Subject: [PATCH] Cell editors stored as cell properties. --- src/QDS/QDS_Table.cxx | 23 ++++------------------- src/QDS/QDS_Table.h | 14 +++++++++++--- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/QDS/QDS_Table.cxx b/src/QDS/QDS_Table.cxx index b14e80c8f..12e796314 100644 --- a/src/QDS/QDS_Table.cxx +++ b/src/QDS/QDS_Table.cxx @@ -141,11 +141,11 @@ QDS_Datum* QDS_Table::columnEditor( const int col ) const QDS_Datum* QDS_Table::cellEditor( const int row, const int col ) const { - if ( !myCellEdit.contains( row ) ) + QVariant res = cellProperty( row, col, Datum ); + if ( !res.canCast( QVariant::LongLong ) ) return 0; - const DatumMap& map = myCellEdit[row]; - return map.contains( col ) ? map[col] : 0; + return (QDS_Datum*)res.toLongLong(); } void QDS_Table::setTableEditor( QDS_Datum* dat ) @@ -195,10 +195,7 @@ void QDS_Table::setCellEditor( const int row, const int col, QDS_Datum* dat ) if ( isEditing() && currEditRow() == row && currEditCol() == col && actualCellEditor( row, col ) != dat ) endEdit( currEditRow(), currEditCol(), false, false ); - if ( !myCellEdit.contains( row ) ) - myCellEdit.insert( row, DatumMap() ); - - myCellEdit[row].insert( col, dat ); + setCellProperty( row, col, Datum, (Q_LLONG)dat ); initEditor( dat ); } @@ -222,11 +219,7 @@ void QDS_Table::setNumRows( int r ) if ( isKeepEditors() ) myRowEdit.resize( QMAX( (int)myRowEdit.size(), r ) ); else - { myRowEdit.resize( r ); - for ( int i = r + 1; i <= old; i++ ) - myCellEdit.remove( i ); - } } void QDS_Table::setNumCols( int c ) @@ -237,15 +230,7 @@ void QDS_Table::setNumCols( int c ) if ( isKeepEditors() ) myColEdit.resize( QMAX( (int)myColEdit.size(), c ) ); else - { myColEdit.resize( c ); - for ( CellMap::Iterator it = myCellEdit.begin(); it != myCellEdit.end(); ++it ) - { - DatumMap& map = it.data(); - for ( int i = c + 1; i <= old; i++ ) - map.remove( i ); - } - } } void QDS_Table::clearCellWidget( int row, int col ) diff --git a/src/QDS/QDS_Table.h b/src/QDS/QDS_Table.h index c7d33abf9..691de4b71 100644 --- a/src/QDS/QDS_Table.h +++ b/src/QDS/QDS_Table.h @@ -26,6 +26,10 @@ #include #include +#ifdef WIN32 +#pragma warning( disable : 4251 ) +#endif + class QDS_EXPORT QDS_Table : public QtxTable { class DeleteFilter; @@ -70,6 +74,9 @@ public: bool isKeepEditors() const; void setKeepEditors( const bool ); +protected: + enum { Datum = QtxTable::User, User }; + protected: virtual QWidget* createHeaderEditor( QHeader*, const int, const bool = true ); virtual QWidget* createEditor( int, int, bool ) const; @@ -83,17 +90,18 @@ private: private: typedef QPtrVector DatumVector; - typedef QMap DatumMap; - typedef QMap CellMap; private: QDS_Datum* myHorEdit; QDS_Datum* myVerEdit; DatumVector myRowEdit; DatumVector myColEdit; - CellMap myCellEdit; QDS_Datum* myTableEdit; bool myKeepEdits; }; +#ifdef WIN32 +#pragma warning( default: 4251 ) +#endif + #endif -- 2.39.2