From: stv Date: Mon, 11 Sep 2006 13:37:10 +0000 (+0000) Subject: Property "KeepEditors" X-Git-Tag: LAST_STABLE_VERSION_21_09_2006_ON_3_2_0~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bd479d851e586268394ebfbb50c5f3c3384dbceb;p=modules%2Fgui.git Property "KeepEditors" --- diff --git a/src/QDS/QDS_Table.cxx b/src/QDS/QDS_Table.cxx index 4b63ec73a..b14e80c8f 100644 --- a/src/QDS/QDS_Table.cxx +++ b/src/QDS/QDS_Table.cxx @@ -19,6 +19,8 @@ #include "QDS_Table.h" +#include "QDS_LineEdit.h" + class QDS_Table::DeleteFilter : public QObject { public: @@ -49,7 +51,8 @@ QDS_Table::QDS_Table( QWidget* parent, const char* name ) : QtxTable( parent, name ), myHorEdit( 0 ), myVerEdit( 0 ), -myTableEdit( 0 ) +myTableEdit( 0 ), +myKeepEdits( false ) { } @@ -57,7 +60,8 @@ QDS_Table::QDS_Table( int r, int c, QWidget* parent, const char* name ) : QtxTable( r, c, parent, name ), myHorEdit( 0 ), myVerEdit( 0 ), -myTableEdit( 0 ) +myTableEdit( 0 ), +myKeepEdits( false ) { myRowEdit.resize( r ); myColEdit.resize( c ); @@ -214,23 +218,33 @@ void QDS_Table::setNumRows( int r ) { int old = numRows(); QtxTable::setNumRows( r ); - myRowEdit.resize( r ); - for ( int i = r + 1; i <= old; i++ ) - myCellEdit.remove( i ); + 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 ) { int old = numCols(); QtxTable::setNumCols( c ); - myColEdit.resize( c ); - for ( CellMap::Iterator it = myCellEdit.begin(); it != myCellEdit.end(); ++it ) + if ( isKeepEditors() ) + myColEdit.resize( QMAX( (int)myColEdit.size(), c ) ); + else { - DatumMap& map = it.data(); - for ( int i = c + 1; i <= old; i++ ) - map.remove( i ); + 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 ); + } } } @@ -243,6 +257,16 @@ void QDS_Table::clearCellWidget( int row, int col ) QtxTable::clearCellWidget( row, col ); } +bool QDS_Table::isKeepEditors() const +{ + return myKeepEdits; +} + +void QDS_Table::setKeepEditors( const bool on ) +{ + myKeepEdits = on; +} + QWidget* QDS_Table::createHeaderEditor( QHeader* header, const int sect, const bool init ) { if ( !header ) @@ -256,7 +280,7 @@ QWidget* QDS_Table::createHeaderEditor( QHeader* header, const int sect, const b dat->setStringValue( header->label( sect ) ); else dat->clear(); -// dat->selectAll(); + dat->setProperty( "Selection", true ); } else wid = QtxTable::createHeaderEditor( header, sect, init ); @@ -274,7 +298,7 @@ QWidget* QDS_Table::createEditor( int row, int col, bool init ) const dat->setStringValue( text( row, col ) ); else dat->clear(); -// dat->selectAll(); + dat->setProperty( "Selection", true ); } else wid = QtxTable::createEditor( row, col, init ); diff --git a/src/QDS/QDS_Table.h b/src/QDS/QDS_Table.h index 89a2cad98..c7d33abf9 100644 --- a/src/QDS/QDS_Table.h +++ b/src/QDS/QDS_Table.h @@ -32,6 +32,8 @@ class QDS_EXPORT QDS_Table : public QtxTable Q_OBJECT + Q_PROPERTY( bool KeepEditors READ isKeepEditors WRITE setKeepEditors ) + public: QDS_Table( QWidget* = 0, const char* = 0 ); QDS_Table( int, int, QWidget* = 0, const char* = 0 ); @@ -65,6 +67,9 @@ public: virtual void setNumCols( int ); virtual void clearCellWidget( int, int ); + bool isKeepEditors() const; + void setKeepEditors( const bool ); + protected: virtual QWidget* createHeaderEditor( QHeader*, const int, const bool = true ); virtual QWidget* createEditor( int, int, bool ) const; @@ -88,6 +93,7 @@ private: DatumVector myColEdit; CellMap myCellEdit; QDS_Datum* myTableEdit; + bool myKeepEdits; }; #endif