From e01a7b3f5397ca291c87abd3ed1b8360cf767f07 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 18 Jan 2006 09:52:40 +0000 Subject: [PATCH] Adjust to OCC_development_generic_2006 --- src/DDS/DDS_DicItem.cxx | 15 +++++++++++++++ src/DDS/DDS_DicItem.h | 5 +++++ src/QDS/QDS_Datum.cxx | 22 +++++++++++++++++----- src/QDS/QDS_Datum.h | 2 ++ src/QDS/QDS_SpinBox.cxx | 19 ++++++++++++------- src/QDS/QDS_SpinBox.h | 4 ++-- src/QDS/QDS_SpinBoxDbl.cxx | 14 +++++++++----- 7 files changed, 62 insertions(+), 19 deletions(-) diff --git a/src/DDS/DDS_DicItem.cxx b/src/DDS/DDS_DicItem.cxx index fd59f3cd6..0c8b01c6d 100644 --- a/src/DDS/DDS_DicItem.cxx +++ b/src/DDS/DDS_DicItem.cxx @@ -305,6 +305,14 @@ Standard_Real DDS_DicItem::FromSI( const Standard_Real theVal, const UnitSystem& return aRes; } +/*! + Returns 'true' if specified data exist. +*/ +Standard_Boolean DDS_DicItem::HasData( const Standard_Integer flag ) const +{ + return ( myData & flag ) == flag; +} + /*! Parse record in XML file and retrieve information relevant for this data dic item */ @@ -436,15 +444,22 @@ void DDS_DicItem::FillDataMap( TCollection_AsciiString theID, const LDOM_Element else if ( aType.IsEqual( "Integer" ) ) aEnumType = Integer; + if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_MINV" ) ).isNull() ) + myData |= MinValue; aMinV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_MINV" ) ); aMinV.RemoveAll( ' ' ); if ( aMinV.IsRealValue() ) aRealMinV = aMinV.RealValue(); + if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_MAXV" ) ).isNull() ) + myData |= MaxValue; aMaxV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_MAXV" ) ); aMaxV.RemoveAll( ' ' ); if ( aMaxV.IsRealValue() ) aRealMaxV = aMaxV.RealValue(); aDefV = aValueDescr.getAttribute( DDS_Dictionary::KeyWord( "VD_DEFV" ) ); + if ( !aValueDescr.getAttributeNode( DDS_Dictionary::KeyWord( "VD_DEFV" ) ).isNull() ) + myData |= DefaultValue; + aDefV.RemoveAll( ' ' ); if ( aDefV.IsRealValue() ) aRealDefV = aDefV.RealValue(); diff --git a/src/DDS/DDS_DicItem.h b/src/DDS/DDS_DicItem.h index 871149407..dbbedc0a7 100644 --- a/src/DDS/DDS_DicItem.h +++ b/src/DDS/DDS_DicItem.h @@ -30,6 +30,7 @@ class DDS_DicItem : public MMgt_TShared { public: enum Type { String, Float, Integer, List, Unknown }; + enum Data { MinValue = 0x01, MaxValue = 0x02, DefaultValue = 0x04 }; // This struct is intended for map of Format, Units, Precision and Scale struct UnitData @@ -134,6 +135,8 @@ public: Standard_EXPORT Standard_Real FromSI( const Standard_Real, const UnitSystem& ) const; // convert value to and from default SI units according to current units + Standard_EXPORT Standard_Boolean HasData( const Standard_Integer ) const; + private: DDS_DicItem( const DDS_DicItem& ); // Copy constructor @@ -200,6 +203,8 @@ private: Standard_Real myDefValue; TCollection_ExtendedString myDefString; + Standard_Integer myData; + // valueList TCollection_ExtendedString myListName; diff --git a/src/QDS/QDS_Datum.cxx b/src/QDS/QDS_Datum.cxx index ff3ed8aca..f2a4919ba 100644 --- a/src/QDS/QDS_Datum.cxx +++ b/src/QDS/QDS_Datum.cxx @@ -43,6 +43,7 @@ myWid( 0 ) { QHBoxLayout* base = new QHBoxLayout( this ); base->setAutoAdd( true ); + setFocusPolicy( StrongFocus ); } QDS_Datum::Wrapper::~Wrapper() @@ -70,6 +71,7 @@ void QDS_Datum::Wrapper::setWidget( QWidget* wid ) if ( myWid->parent() != this ) myWid->reparent( this, QPoint( 0, 0 ) ); + setTabOrder( this, myWid ); setFocusProxy( myWid ); myWid->updateGeometry(); @@ -154,6 +156,11 @@ QDS_Datum::~QDS_Datum() */ } +QDS_Datum::operator QWidget*() const +{ + return widget( Control ); +} + QString QDS_Datum::id() const { initDatum(); @@ -241,8 +248,8 @@ QString QDS_Datum::minimumValue() const initDatum(); QString min; - if ( !myDicItem.IsNull() ) - min = format( format(), type(), myDicItem->GetMinValue() ); + if ( !myDicItem.IsNull() && myDicItem->HasData( DDS_DicItem::MinValue ) ) + min = format( format(), type(), myDicItem->GetMinValue() ); return min; } @@ -251,7 +258,7 @@ QString QDS_Datum::maximumValue() const initDatum(); QString max; - if ( !myDicItem.IsNull() ) + if ( !myDicItem.IsNull() && myDicItem->HasData( DDS_DicItem::MaxValue ) ) max = format( format(), type(), myDicItem->GetMaxValue() ); return max; } @@ -541,10 +548,15 @@ bool QDS_Datum::isValid( const bool msgBox, const QString& extMsg, const QString if ( type() == DDS_DicItem::String && isDoubleFormat( format() ) ) return true; + QString req; + if ( !dicItem().IsNull() ) + req = toQString( dicItem()->GetRequired() ); + bool aState = true; QString aStr = getString(); + if ( aStr.isEmpty() ) - aState = false; + aState = !( req == QString( "yes" ) || req == QString( "true" ) || req.toInt() ); else aState = validate( aStr ); @@ -604,7 +616,7 @@ bool QDS_Datum::isValid( const bool msgBox, const QString& extMsg, const QString info = QString( "

%1

" ).arg( msg ); QMessageBox::critical( controlWidget() ? controlWidget()->topLevelWidget() : 0, - tr( "DATA_ERR_TITLE" ), info, tr( "BUT_OK" ) ); + tr( "DATA_ERR_TITLE" ), info, tr( "OK" ) ); if ( controlWidget() ) controlWidget()->setFocus(); } diff --git a/src/QDS/QDS_Datum.h b/src/QDS/QDS_Datum.h index be0247441..a3a056d7d 100644 --- a/src/QDS/QDS_Datum.h +++ b/src/QDS/QDS_Datum.h @@ -87,6 +87,8 @@ public: virtual bool eventFilter( QObject*, QEvent* ); + operator QWidget*() const; + signals: void paramChanged(); void paramChanged( QString& ); diff --git a/src/QDS/QDS_SpinBox.cxx b/src/QDS/QDS_SpinBox.cxx index d25322c3f..b77aa8ba0 100644 --- a/src/QDS/QDS_SpinBox.cxx +++ b/src/QDS/QDS_SpinBox.cxx @@ -1,6 +1,7 @@ #include "QDS_SpinBox.h" -#include +#include + #include /*! @@ -24,8 +25,8 @@ QDS_SpinBox::~QDS_SpinBox() QString QDS_SpinBox::getString() const { QString res; - QSpinBox* aSpinBox = spinBox(); - if ( aSpinBox ) + QtxIntSpinBox* aSpinBox = spinBox(); + if ( aSpinBox && !aSpinBox->isCleared() ) { res = aSpinBox->text(); if ( !aSpinBox->suffix().isEmpty() ) @@ -41,16 +42,20 @@ QString QDS_SpinBox::getString() const */ void QDS_SpinBox::setString( const QString& txt ) { - if ( spinBox() ) + if ( !spinBox() ) + return; + + spinBox()->setCleared( txt.isEmpty() ); + if ( !txt.isEmpty() ) spinBox()->setValue( txt.toInt() ); } /*! Returns pointer to QSpinBox widget. */ -QSpinBox* QDS_SpinBox::spinBox() const +QtxIntSpinBox* QDS_SpinBox::spinBox() const { - return ::qt_cast( controlWidget() ); + return ::qt_cast( controlWidget() ); } /*! @@ -58,7 +63,7 @@ QSpinBox* QDS_SpinBox::spinBox() const */ QWidget* QDS_SpinBox::createControl( QWidget* parent ) { - QSpinBox* aSpinBox = new QSpinBox( parent ); + QtxIntSpinBox* aSpinBox = new QtxIntSpinBox( parent ); aSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); connect( aSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged( int ) ) ); return aSpinBox; diff --git a/src/QDS/QDS_SpinBox.h b/src/QDS/QDS_SpinBox.h index d6490edbf..f018ddfb8 100644 --- a/src/QDS/QDS_SpinBox.h +++ b/src/QDS/QDS_SpinBox.h @@ -3,7 +3,7 @@ #include "QDS_Datum.h" -class QSpinBox; +class QtxIntSpinBox; class QDS_EXPORT QDS_SpinBox : public QDS_Datum { @@ -20,7 +20,7 @@ private slots: void onValueChanged( int ); protected: - QSpinBox* spinBox() const; + QtxIntSpinBox* spinBox() const; virtual QWidget* createControl( QWidget* ); diff --git a/src/QDS/QDS_SpinBoxDbl.cxx b/src/QDS/QDS_SpinBoxDbl.cxx index 42d1e2f9e..8a4160e70 100644 --- a/src/QDS/QDS_SpinBoxDbl.cxx +++ b/src/QDS/QDS_SpinBoxDbl.cxx @@ -28,7 +28,7 @@ QString QDS_SpinBoxDbl::getString() const { QString res; QtxDblSpinBox* sb = spinBox(); - if ( sb ) + if ( sb && !sb->isCleared() ) { bool hasFocus = sb->hasFocus(); if ( hasFocus ) @@ -52,12 +52,16 @@ QString QDS_SpinBoxDbl::getString() const */ void QDS_SpinBoxDbl::setString( const QString& txt ) { - if ( spinBox() ) + if ( !spinBox() ) + return; + + spinBox()->setCleared( txt.isEmpty() ); + if ( !txt.isEmpty() ) spinBox()->setValue( txt.toDouble() ); } /*! - Returns pointer to XMLGUI_SpinBoxDbl widget. + Returns pointer to QtxDblSpinBox widget. */ QtxDblSpinBox* QDS_SpinBoxDbl::spinBox() const { @@ -130,6 +134,6 @@ void QDS_SpinBoxDbl::unitSystemChanged( const QString& system ) sb->setPrecision( aPreci ); sb->setLineStep( .1 ); - sb->setMinValue( minValue().toDouble() ); - sb->setMaxValue( maxValue().toDouble() ); + sb->setMinValue( minValue().isEmpty() ? -DBL_MAX : minValue().toDouble() ); + sb->setMaxValue( maxValue().isEmpty() ? DBL_MAX : maxValue().toDouble() ); } -- 2.39.2