From cb9c4b526f837397f3d0973fa62fd6cad86bfc5d Mon Sep 17 00:00:00 2001 From: mkr Date: Wed, 23 May 2007 11:26:36 +0000 Subject: [PATCH] Porting to Qt4. --- src/DDS/DDS.pro | 37 +++++++++++ src/Makefile.am | 2 +- src/QDS/Makefile.am | 63 ++++++++++++------ src/QDS/QDS.cxx | 17 +++-- src/QDS/QDS.h | 8 +-- src/QDS/QDS.pro | 55 ++++++++++++++++ src/QDS/QDS_CheckBox.cxx | 10 +-- src/QDS/QDS_ComboBox.cxx | 77 +++++++++++----------- src/QDS/QDS_ComboBox.h | 12 ++-- src/QDS/QDS_Datum.cxx | 111 +++++++++++++++++--------------- src/QDS/QDS_Datum.h | 12 ++-- src/QDS/QDS_LineEdit.cxx | 18 +++--- src/QDS/QDS_RadioBox.cxx | 128 +++++++++++++++++++++---------------- src/QDS/QDS_RadioBox.h | 17 +++-- src/QDS/QDS_SpinBox.cxx | 24 +++---- src/QDS/QDS_SpinBoxDbl.cxx | 16 +++-- src/QDS/QDS_Table.h | 4 +- src/QDS/QDS_TextEdit.cxx | 6 +- src/QDS/QDS_Validator.cxx | 14 ++-- src/QDS/QDS_Validator.h | 2 +- src/src.pro | 2 + 21 files changed, 388 insertions(+), 247 deletions(-) create mode 100644 src/DDS/DDS.pro create mode 100644 src/QDS/QDS.pro diff --git a/src/DDS/DDS.pro b/src/DDS/DDS.pro new file mode 100644 index 000000000..96434e96d --- /dev/null +++ b/src/DDS/DDS.pro @@ -0,0 +1,37 @@ +TEMPLATE = lib +TARGET = DDS +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +CASROOT = $$(CASROOT) +CAS_CPPFLAGS = $${CASROOT}/inc + +CAS_KERNEL = -L$${CASROOT}/Linux/lib -lTKernel + +CAS_OCAF = -L$${CASROOT}/Linux/lib -lPTKernel -lTKernel -lTKCDF -lTKLCAF -lTKPCAF -lTKStdSchema + +INCLUDEPATH += ../../include $${CAS_CPPFLAGS} +LIBS += $${CAS_KERNEL} $${CAS_OCAF} + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += DDS_EXPORTS OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS + +HEADERS = DDS.h +HEADERS += DDS_DicGroup.h +HEADERS += DDS_DicItem.h +HEADERS += DDS_Dictionary.h +HEADERS += DDS_KeyWords.h + +SOURCES = DDS_DicGroup.cxx +SOURCES += DDS_DicItem.cxx +SOURCES += DDS_Dictionary.cxx +SOURCES += DDS_KeyWords.cxx + +includes.files = $$HEADERS +includes.path = ../../include + +INSTALLS += includes diff --git a/src/Makefile.am b/src/Makefile.am index 5276ed7e9..e0e99408e 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,7 +27,7 @@ # VSR: this is the original packages list #SUBDIRS = Qtx Style DDS QDS SUIT STD CAF SUITApp LogWindow ObjBrowser Prs # VSR: already migrated to Qt4 packages -SUBDIRS = Qtx SUIT SUITApp STD CAF CAM LogWindow Prs +SUBDIRS = Qtx DDS QDS SUIT SUITApp STD CAF CAM LogWindow Prs if ENABLE_SALOMEOBJECT # VSR: this is the original packages list diff --git a/src/QDS/Makefile.am b/src/QDS/Makefile.am index 03513ac3c..6392bdf10 100755 --- a/src/QDS/Makefile.am +++ b/src/QDS/Makefile.am @@ -26,27 +26,42 @@ include $(top_srcdir)/adm_local/unix/make_common_starter.am lib_LTLIBRARIES = libQDS.la # header files -salomeinclude_HEADERS= QDS.h \ - QDS_CheckBox.h \ - QDS_ComboBox.h \ - QDS_Datum.h \ - QDS_LineEdit.h \ - QDS_SpinBox.h \ - QDS_SpinBoxDbl.h \ - QDS_TextEdit.h \ - QDS_Validator.h -dist_libQDS_la_SOURCES= \ - QDS.cxx \ - QDS_CheckBox.cxx \ - QDS_ComboBox.cxx \ - QDS_Datum.cxx \ - QDS_LineEdit.cxx \ - QDS_SpinBox.cxx \ - QDS_SpinBoxDbl.cxx \ - QDS_TextEdit.cxx \ - QDS_Validator.cxx - +#MKR: already migrated to Qt4 files +salomeinclude_HEADERS= \ + QDS.h \ + QDS_CheckBox.h \ + QDS_ComboBox.h \ + QDS_Datum.h \ + QDS_LineEdit.h \ + QDS_SpinBox.h \ + QDS_SpinBoxDbl.h \ + QDS_TextEdit.h \ + QDS_Validator.h \ + QDS_RadioBox.h + +#MKR: not yet migrated to Qt4 files +# \ + QDS_Table.h + +#MKR: already migrated to Qt4 files +dist_libQDS_la_SOURCES= \ + QDS.cxx \ + QDS_CheckBox.cxx \ + QDS_ComboBox.cxx \ + QDS_Datum.cxx \ + QDS_LineEdit.cxx \ + QDS_SpinBox.cxx \ + QDS_SpinBoxDbl.cxx \ + QDS_TextEdit.cxx \ + QDS_Validator.cxx \ + QDS_RadioBox.cxx + +#MKR: not yet migrated to Qt4 files +# \ + QDS_Table.cxx + +#MKR: already migrated to Qt4 files MOC_FILES= \ QDS_CheckBox_moc.cxx \ QDS_ComboBox_moc.cxx \ @@ -54,7 +69,13 @@ MOC_FILES= \ QDS_LineEdit_moc.cxx \ QDS_SpinBox_moc.cxx \ QDS_SpinBoxDbl_moc.cxx \ - QDS_TextEdit_moc.cxx + QDS_TextEdit_moc.cxx \ + QDS_RadioBox_moc.cxx + +#MKR: not yet migrated to Qt4 files +# \ + QDS_Table_moc.cxx + nodist_libQDS_la_SOURCES= $(MOC_FILES) # may be neccessary for the external projects or future improvements diff --git a/src/QDS/QDS.cxx b/src/QDS/QDS.cxx index fb1cdae24..dbba63912 100644 --- a/src/QDS/QDS.cxx +++ b/src/QDS/QDS.cxx @@ -20,7 +20,7 @@ #include "QDS_Datum.h" -#include +#include #include #include @@ -28,7 +28,7 @@ #include #include -QValueList QDS::_datumList; +QList QDS::_datumList; /*! Convert the OpenCascade ascii string to Qt string. @@ -82,17 +82,16 @@ QString QDS::toQString( const Handle(TCollection_HExtendedString)& src ) TCollection_AsciiString QDS::toAsciiString( const QString& src ) { TCollection_AsciiString res; - if ( src.latin1() ) + if ( src.toLatin1().constData() ) { QTextCodec* codec = QTextCodec::codecForLocale(); if ( codec ) { - int len = -1; - QCString str = codec->fromUnicode( src, len ); - res = TCollection_AsciiString( (Standard_CString)(const char*)str, len ); + QByteArray str = codec->fromUnicode( src ); + res = TCollection_AsciiString( (Standard_CString)(const char*)str, str.size() ); } else - res = TCollection_AsciiString( (char*)src.latin1() ); + res = TCollection_AsciiString( (char*)src.toLatin1().constData() ); } return res; } @@ -209,7 +208,7 @@ void QDS::setActiveUnitSystem( const QString& sys, const QString& comp ) return; TCollection_AsciiString aComp = toAsciiString( comp ); - for ( QValueList::iterator it = _datumList.begin(); it != _datumList.end(); ++it ) + for ( QList::iterator it = _datumList.begin(); it != _datumList.end(); ++it ) { QDS_Datum* datum = *it; if ( !datum ) @@ -248,5 +247,5 @@ void QDS::removeDatum( QDS_Datum* datum ) if ( !datum ) return; - _datumList.remove( datum ); + _datumList.removeAt( _datumList.indexOf(datum) ); } diff --git a/src/QDS/QDS.h b/src/QDS/QDS.h index 6f3fecd85..414dcfa52 100644 --- a/src/QDS/QDS.h +++ b/src/QDS/QDS.h @@ -34,10 +34,8 @@ #pragma warning ( disable:4786 ) #endif -#include -#include - -#include +#include +#include #include @@ -87,7 +85,7 @@ protected: static void removeDatum( QDS_Datum* ); private: - static QValueList _datumList; + static QList _datumList; }; #endif diff --git a/src/QDS/QDS.pro b/src/QDS/QDS.pro new file mode 100644 index 000000000..c53a1a1ab --- /dev/null +++ b/src/QDS/QDS.pro @@ -0,0 +1,55 @@ +TEMPLATE = lib +TARGET = QDS +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +CASROOT = $$(CASROOT) +CAS_CPPFLAGS = $${CASROOT}/inc + +CAS_KERNEL = -L$${CASROOT}/Linux/lib -lTKernel + +INCLUDEPATH += ../../include $${CAS_CPPFLAGS} ../Qtx ../DDS +LIBS += -L../../lib -lqtx -lDDS $${CAS_KERNEL} + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += QDS_EXPORTS OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS + +HEADERS = QDS.h +HEADERS += QDS_CheckBox.h +HEADERS += QDS_ComboBox.h +HEADERS += QDS_Datum.h +HEADERS += QDS_LineEdit.h +HEADERS += QDS_SpinBox.h +HEADERS += QDS_SpinBoxDbl.h +HEADERS += QDS_TextEdit.h +HEADERS += QDS_Validator.h +HEADERS += QDS_RadioBox.h +#HEADERS += QDS_Table.h + +SOURCES = QDS.cxx +SOURCES += QDS_CheckBox.cxx +SOURCES += QDS_ComboBox.cxx +SOURCES += QDS_Datum.cxx +SOURCES += QDS_LineEdit.cxx +SOURCES += QDS_SpinBox.cxx +SOURCES += QDS_SpinBoxDbl.cxx +SOURCES += QDS_TextEdit.cxx +SOURCES += QDS_Validator.cxx +SOURCES += QDS_RadioBox.cxx +#SOURCES += QDS_Table.cxx + +TRANSLATIONS = resources/QDS_msg_en.ts + +ICONS = resources/*.png + +includes.files = $$HEADERS +includes.path = ../../include + +resources.files = $$ICONS resources/*.qm +resources.path = ../../resources + +INSTALLS += includes resources diff --git a/src/QDS/QDS_CheckBox.cxx b/src/QDS/QDS_CheckBox.cxx index 9713ca5e4..5df42bbef 100644 --- a/src/QDS/QDS_CheckBox.cxx +++ b/src/QDS/QDS_CheckBox.cxx @@ -18,7 +18,7 @@ // #include "QDS_CheckBox.h" -#include +#include /* \class QDS_CheckBox @@ -68,7 +68,7 @@ void QDS_CheckBox::clear() QString QDS_CheckBox::getString() const { QString val; - if ( checkBox() && checkBox()->state() != QButton::NoChange ) + if ( checkBox() && checkBox()->checkState() != Qt::PartiallyChecked ) val = checkBox()->isChecked() ? "1" : "0"; return val; } @@ -88,7 +88,7 @@ void QDS_CheckBox::setString( const QString& txt ) if ( isOk && val < 0 ) { checkBox()->setTristate(); - checkBox()->setNoChange(); + checkBox()->setCheckState(Qt::PartiallyChecked); } else checkBox()->setChecked( isOk && val != 0 ); @@ -99,7 +99,7 @@ void QDS_CheckBox::setString( const QString& txt ) */ QCheckBox* QDS_CheckBox::checkBox() const { - return ::qt_cast( controlWidget() ); + return ::qobject_cast( controlWidget() ); } /*! @@ -128,7 +128,7 @@ void QDS_CheckBox::onParamChanged() */ void QDS_CheckBox::onStateChanged( int state ) { - if ( state != QButton::NoChange && checkBox() ) + if ( state != Qt::PartiallyChecked && checkBox() ) checkBox()->setTristate( false ); } diff --git a/src/QDS/QDS_ComboBox.cxx b/src/QDS/QDS_ComboBox.cxx index ac068735e..6907ae281 100644 --- a/src/QDS/QDS_ComboBox.cxx +++ b/src/QDS/QDS_ComboBox.cxx @@ -20,11 +20,10 @@ #include -#include #include #include -#include +#include /* \class QDS_ComboBox @@ -73,7 +72,7 @@ void QDS_ComboBox::setEditable( const bool on ) if ( aCombo && aCombo->lineEdit() ) { aCombo->lineEdit()->setReadOnly( !on ); - aCombo->clearValidator(); + aCombo->setValidator(0); if ( on ) aCombo->setValidator( validator() ); } @@ -97,7 +96,7 @@ int QDS_ComboBox::count( bool total ) const Returns list of list item identifiers \aids. If \atotal is 'false' then only visible items are taken into account otherwise all items. */ -void QDS_ComboBox::values( QValueList& ids, bool total ) const +void QDS_ComboBox::values( QList& ids, bool total ) const { ids.clear(); for ( QIntList::const_iterator it = myDataIds.begin(); it != myDataIds.end(); ++it ) @@ -112,11 +111,11 @@ int QDS_ComboBox::integerValue() const { QComboBox* cb = comboBox(); QString cur = getString(); - if ( cb && cb->count() > 0 && cb->currentItem() >= 0 ) - cur = cb->text( cb->currentItem() ); + if ( cb && cb->count() > 0 && cb->currentIndex() >= 0 ) + cur = cb->itemText( cb->currentIndex() ); if ( cb && cur == getString() ) - return getId( cb->currentItem() ); + return getId( cb->currentIndex() ); else return getId( getString() ); } @@ -130,11 +129,11 @@ double QDS_ComboBox::doubleValue() const QComboBox* cb = comboBox(); QString cur = getString(); - if ( cb && cb->count() > 0 && cb->currentItem() >= 0 ) - cur = cb->text( cb->currentItem() ); + if ( cb && cb->count() > 0 && cb->currentIndex() >= 0 ) + cur = cb->itemText( cb->currentIndex() ); if ( cb && cur == getString() ) - return getId( cb->currentItem() ); + return getId( cb->currentIndex() ); else return getId( getString() ); } @@ -184,7 +183,7 @@ bool QDS_ComboBox::state( const int id ) const */ void QDS_ComboBox::setState( const bool on, const int id, const bool append ) { - QValueList lst; + QList lst; if ( id < 0 ) { for ( IdStateMap::Iterator it = myState.begin(); it != myState.end(); ++it ) @@ -201,7 +200,7 @@ void QDS_ComboBox::setState( const bool on, const int id, const bool append ) If \aappend is set then keep status for other items otherwise status of other items will be cleared. */ -void QDS_ComboBox::setState( const bool on, const QValueList& ids, const bool append ) +void QDS_ComboBox::setState( const bool on, const QList& ids, const bool append ) { initDatum(); @@ -212,21 +211,21 @@ void QDS_ComboBox::setState( const bool on, const QValueList& ids, const bo QMap aMap; for ( uint i = 0; i < ids.count(); i++ ) - aMap.insert( *ids.at( i ), 0 ); + aMap.insert( ids.at( i ), 0 ); for ( IdStateMap::Iterator it = myState.begin(); it != myState.end(); ++it ) { if ( aMap.contains( it.key() ) ) { - if ( it.data() != on ) + if ( it.value() != on ) { - it.data() = on; + it.value() = on; changed = true; } } - else if ( !append && it.data() == on ) + else if ( !append && it.value() == on ) { - it.data() = !on; + it.value() = !on; changed = true; } } @@ -239,7 +238,7 @@ void QDS_ComboBox::setState( const bool on, const QValueList& ids, const bo list items will be added into the combobox. This functionality allow to user override items. */ -void QDS_ComboBox::setValues( const QValueList& ids, const QStringList& names ) +void QDS_ComboBox::setValues( const QList& ids, const QStringList& names ) { initDatum(); @@ -253,13 +252,13 @@ void QDS_ComboBox::setValues( const QValueList& ids, const QStringList& nam /*! This is an overloaded member function, provided for convenience. It behaves essentially like the above function. It creates - QValueList (0, 1, 2 ... ) and call previous method. + QList (0, 1, 2 ... ) and call previous method. */ void QDS_ComboBox::setValues( const QStringList& names ) { initDatum(); - QValueList< int > ids; + QList< int > ids; for ( int i = 0, n = names.count(); i < n; i++ ) ids.append( i ); setValues( ids, names ); @@ -310,7 +309,7 @@ QString QDS_ComboBox::getString() const QtxComboBox* cb = comboBox(); if ( cb ) { - if ( !cb->editable() ) + if ( !cb->isEditable() ) { if ( !cb->isCleared() ) res = cb->currentText(); @@ -334,20 +333,20 @@ void QDS_ComboBox::setString( const QString& txt ) int idx = -1; for ( int i = 0; i < cb->count() && idx == -1; i++ ) - if ( cb->text( i ) == txt ) + if ( cb->itemText( i ) == txt ) idx = i; - int old = cb->currentItem(); + int old = cb->currentIndex(); if ( idx != -1 ) - cb->setCurrentItem( idx ); + cb->setCurrentIndex( idx ); else if ( txt.isEmpty() ) { - if ( !cb->editable() ) - cb->setCurrentText( txt ); + if ( !cb->isEditable() ) + cb->setItemText( cb->currentIndex(), txt ); else cb->lineEdit()->setText( txt ); } - if ( isClear != txt.isEmpty() || ( !isClear && old != cb->currentItem() ) ) + if ( isClear != txt.isEmpty() || ( !isClear && old != cb->currentIndex() ) ) { onParamChanged(); QString str = getString(); @@ -363,7 +362,7 @@ void QDS_ComboBox::setString( const QString& txt ) */ QtxComboBox* QDS_ComboBox::comboBox() const { - return ::qt_cast( controlWidget() ); + return ::qobject_cast( controlWidget() ); } /*! @@ -478,7 +477,7 @@ void QDS_ComboBox::onTextChanged( const QString& ) void QDS_ComboBox::onActivated( int idx ) { if ( comboBox() ) - comboBox()->setCurrentItem( comboBox()->currentItem() ); + comboBox()->setCurrentIndex( comboBox()->currentIndex() ); int id = getId( idx ); if ( id != -1 ) @@ -507,7 +506,7 @@ void QDS_ComboBox::updateComboBox() { isClear = cb->isCleared(); - curId = getId( cb->currentItem() ); + curId = getId( cb->currentIndex() ); cb->clear(); } @@ -524,9 +523,9 @@ void QDS_ComboBox::updateComboBox() if ( cb ) { if ( myIcons.contains( id ) ) - cb->insertItem( myIcons[id], myValue[id] ); + cb->insertItem( -1, QIcon(myIcons[id]), myValue[id] ); else - cb->insertItem( myValue[id] ); + cb->insertItem( -1, myValue[id] ); } } @@ -536,13 +535,13 @@ void QDS_ComboBox::updateComboBox() cb->updateGeometry(); if ( isClear ) - cb->setCurrentText( "" ); + cb->setItemText( cb->currentIndex(), "" ); else { if ( getIndex( curId ) != -1 ) - cb->setCurrentItem( getIndex( curId ) ); - if ( curId != getId( cb->currentItem() ) ) - onActivated( cb->currentItem() ); + cb->setCurrentIndex( getIndex( curId ) ); + if ( curId != getId( cb->currentIndex() ) ) + onActivated( cb->currentIndex() ); } } } @@ -568,7 +567,7 @@ int QDS_ComboBox::getIndex( const QString& str ) const if ( cb ) { for ( int i = 0; i < cb->count() && idx == -1; i++ ) - if ( cb->text( i ) == str ) + if ( cb->itemText( i ) == str ) idx = i; } return idx; @@ -582,7 +581,7 @@ int QDS_ComboBox::getId( const int idx ) const int id = -1; IdIndexMap::ConstIterator it = myIndex.begin(); for (; it != myIndex.end() && id == -1; ++it ) - if ( it.data() == idx ) + if ( it.value() == idx ) id = it.key(); return id; } @@ -597,7 +596,7 @@ int QDS_ComboBox::getId( const QString& str ) const IdValueMap::ConstIterator it = myValue.begin(); for (; it != myValue.end() && id == -1; ++it ) { - if ( it.data() == str ) + if ( it.value() == str ) { if ( state( it.key() ) ) id = it.key(); diff --git a/src/QDS/QDS_ComboBox.h b/src/QDS/QDS_ComboBox.h index 1f0b90fc2..f55fb815e 100644 --- a/src/QDS/QDS_ComboBox.h +++ b/src/QDS/QDS_ComboBox.h @@ -21,9 +21,9 @@ #include "QDS_Datum.h" -#include -#include -#include +#include +#include +#include #include @@ -43,7 +43,7 @@ public: void setEditable( const bool ); int count( bool = false ) const; - void values( QValueList&, bool = false ) const; + void values( QList&, bool = false ) const; virtual int integerValue() const; virtual double doubleValue() const; @@ -52,8 +52,8 @@ public: bool state( const int ) const; void setState( const bool, const int, const bool = true ); - void setState( const bool, const QValueList&, const bool = true ); - void setValues( const QValueList&, const QStringList& ); + void setState( const bool, const QList&, const bool = true ); + void setValues( const QList&, const QStringList& ); void setValues( const QStringList& ); virtual void reset(); diff --git a/src/QDS/QDS_Datum.cxx b/src/QDS/QDS_Datum.cxx index a542a19b4..053c70dd1 100644 --- a/src/QDS/QDS_Datum.cxx +++ b/src/QDS/QDS_Datum.cxx @@ -22,14 +22,15 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -52,15 +53,17 @@ public: private: QWidget* myWid; + QHBoxLayout* myBase; }; QDS_Datum::Wrapper::Wrapper( QWidget* parent ) : QWidget( parent ), myWid( 0 ) { - QHBoxLayout* base = new QHBoxLayout( this ); - base->setAutoAdd( true ); - setFocusPolicy( StrongFocus ); + //QHBoxLayout* base = new QHBoxLayout( this ); + //base->setAutoAdd( true ); + myBase = new QHBoxLayout( this ); + setFocusPolicy( Qt::StrongFocus ); } QDS_Datum::Wrapper::~Wrapper() @@ -82,8 +85,12 @@ void QDS_Datum::Wrapper::setWidget( QWidget* wid ) if ( !myWid ) return; - if ( myWid->parent() != this ) - myWid->reparent( this, QPoint( 0, 0 ) ); + if ( myWid->parent() != this ) { + myWid->setParent( this ); + myWid->move( QPoint( 0, 0 ) ); + myWid->hide(); + myBase->addWidget( myWid ); + } setTabOrder( this, myWid ); setFocusProxy( myWid ); @@ -168,7 +175,7 @@ myInitialised( false ) myWrapper.insert( Units, new Wrapper( parent ) ); for ( QMap::Iterator it = myWrapper.begin(); it != myWrapper.end(); ++it ) - connect( it.data(), SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) ); + connect( it.value(), SIGNAL( destroyed( QObject* ) ), this, SLOT( onDestroyed( QObject* ) ) ); Handle(DDS_Dictionary) aDict = DDS_Dictionary::Get(); if ( aDict.IsNull() ) @@ -308,7 +315,7 @@ QString QDS_Datum::defaultValue() const if ( !myDicItem.IsNull() ) def = toQString( myDicItem->GetDefaultValue() ); - QString aDef = def.stripWhiteSpace(); + QString aDef = def.trimmed(); if ( !pref.isEmpty() && aDef.left( pref.length() ) == pref ) aDef = aDef.mid( pref.length() ); @@ -418,7 +425,7 @@ double QDS_Datum::optionDouble( const QString& name ) const { double res = 0; QVariant opt = option( name ); - if ( opt.isValid() && opt.canCast( QVariant::Double ) ) + if ( opt.isValid() && opt.canConvert( QVariant::Double ) ) res = opt.toDouble(); return res; } @@ -431,7 +438,7 @@ int QDS_Datum::optionInteger( const QString& name ) const { int res = 0; QVariant opt = option( name ); - if ( opt.isValid() && opt.canCast( QVariant::Int ) ) + if ( opt.isValid() && opt.canConvert( QVariant::Int ) ) res = opt.toInt(); return res; } @@ -574,7 +581,7 @@ void QDS_Datum::clear() */ void QDS_Datum::setValue( const QVariant& val ) { - if ( val.isValid() && val.canCast( QVariant::String ) ) + if ( val.isValid() && val.canConvert( QVariant::String ) ) setStringValue( val.toString() ); else clear(); @@ -897,9 +904,9 @@ void QDS_Datum::setAlignment( const int align, const int type ) initDatum(); if ( ( type & Label ) && labelWidget() ) - labelWidget()->setAlignment( align ); + labelWidget()->setAlignment( Qt::Alignment(align) ); if ( ( type & Units ) && unitsWidget() ) - unitsWidget()->setAlignment( align ); + unitsWidget()->setAlignment( Qt::Alignment(align) ); } /*! @@ -910,7 +917,7 @@ bool QDS_Datum::eventFilter( QObject* o, QEvent* e ) if ( o == parent() ) { if ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent || - ( e->type() == QEvent::ChildInserted && ((QChildEvent*)e)->child() == this ) ) + ( e->type() == QEvent::ChildAdded && ((QChildEvent*)e)->child() == this ) ) initDatum(); } return QObject::eventFilter( o, e ); @@ -1013,7 +1020,7 @@ QValidator* QDS_Datum::validator( const bool limits ) const QString aFormat = canonicalFormat( format(), aFlags ); int len = -1; - int pos = aFormat.find( "." ); + int pos = aFormat.indexOf( "." ); if ( pos != -1 ) { QString numStr = aFormat.mid( pos + 1, aFormat.length() - pos - 2 ); @@ -1118,9 +1125,9 @@ void QDS_Datum::initialize() QString lDescr = longDescription(); QString sDescr = shortDescription(); if ( !sDescr.isEmpty() ) - QToolTip::add( ctrl, sDescr ); + ctrl->setToolTip( sDescr ); if ( !lDescr.isEmpty() ) - QWhatsThis::add( ctrl, lDescr ); + ctrl->setWhatsThis( lDescr ); } if ( labelWidget() && ctrl && !( flags() & NotAccel ) ) @@ -1160,7 +1167,7 @@ QString QDS_Datum::unitsToText( const QString& uni ) { int pos = -1; QString aUnits = uni; - while ( ( pos = aUnits.find( "**" ) ) != -1 ) + while ( ( pos = aUnits.indexOf( "**" ) ) != -1 ) { aUnits = aUnits.mid( 0, pos ) + QString( "" ) + aUnits.mid( pos + 2, 1 ) + QString( "" ) + @@ -1176,12 +1183,12 @@ QString QDS_Datum::textToUnits( const QString& txt ) { int pos = -1; QString aUnits = txt; - while ( ( pos = aUnits.find( "" ) ) != -1 ) + while ( ( pos = aUnits.indexOf( "" ) ) != -1 ) { aUnits.remove( pos, 5 ); aUnits.insert( pos, "**" ); } - while ( ( pos = aUnits.find( "" ) ) != -1 ) + while ( ( pos = aUnits.indexOf( "" ) ) != -1 ) aUnits.remove( pos, 6 ); return aUnits; } @@ -1280,11 +1287,11 @@ QString QDS_Datum::format( const QString& aFormat, const int aType, const int aV { case DDS_DicItem::Float: txt = sprintf( aFormat, (double)aValue ); - txt = txt.stripWhiteSpace(); + txt = txt.trimmed(); break; case DDS_DicItem::Integer: txt = sprintf( aFormat, aValue ); - txt = txt.stripWhiteSpace(); + txt = txt.trimmed(); break; case DDS_DicItem::String: default: @@ -1310,16 +1317,16 @@ QString QDS_Datum::format( const QString& aFormat, const int aType, const double switch ( aType ) { case DDS_DicItem::Float: - txt = QString().sprintf( aFormat, aValue ); - txt = txt.stripWhiteSpace(); + txt = QString().sprintf( aFormat.toLatin1().constData(), aValue ); + txt = txt.trimmed(); break; case DDS_DicItem::Integer: - txt = QString().sprintf( aFormat, (int)aValue ); - txt = txt.stripWhiteSpace(); + txt = QString().sprintf( aFormat.toLatin1().constData(), (int)aValue ); + txt = txt.trimmed(); break; case DDS_DicItem::String: default: - txt = QString().sprintf( aFormat, aValue ); + txt = QString().sprintf( aFormat.toLatin1().constData(), aValue ); break; } } @@ -1337,7 +1344,7 @@ QString QDS_Datum::format( const QString& aFormat, const int aType, const QStrin QString txt = aValue; if ( aType != DDS_DicItem::String ) - txt = txt.stripWhiteSpace(); + txt = txt.trimmed(); if ( aFormat.isEmpty() || txt.isEmpty() ) return txt; @@ -1347,11 +1354,11 @@ QString QDS_Datum::format( const QString& aFormat, const int aType, const QStrin case DDS_DicItem::Float: txt = txt.replace( 'd', 'e' ).replace( 'D', 'E' ); txt = sprintf( aFormat, txt.toDouble() ); - txt = txt.stripWhiteSpace(); + txt = txt.trimmed(); break; case DDS_DicItem::Integer: txt = sprintf( aFormat, txt.toInt() ); - txt = txt.stripWhiteSpace(); + txt = txt.trimmed(); break; case DDS_DicItem::String: txt = sprintf( aFormat, txt ); @@ -1367,7 +1374,7 @@ QString QDS_Datum::format( const QString& aFormat, const int aType, const QStrin */ QString QDS_Datum::sprintf( const QString& fmt, const int val ) { - return QString().sprintf( canonicalFormat( fmt ), val ); + return QString().sprintf( canonicalFormat( fmt ).toLatin1().constData(), val ); } /*! @@ -1376,7 +1383,7 @@ QString QDS_Datum::sprintf( const QString& fmt, const int val ) */ QString QDS_Datum::sprintf( const QString& fmt, const double val ) { - return QString().sprintf( canonicalFormat( fmt ), val ); + return QString().sprintf( canonicalFormat( fmt ).toLatin1().constData(), val ); } /*! @@ -1391,11 +1398,11 @@ QString QDS_Datum::sprintf( const QString& fmt, const QString& val ) QString txt = val; QRegExp rx( "^(%[0-9]*.?[0-9]*s)$" ); - if ( aFormat.find( rx ) != -1 ) + if ( aFormat.indexOf( rx ) != -1 ) { // QString().sprintf() always expects string in UTF8 encoding, so we cannot use it here char* buf = new char[txt.length() + 1]; - ::sprintf( buf, aFormat.latin1(), (const char*)(txt.local8Bit()) ); + ::sprintf( buf, aFormat.toLatin1().constData(), (const char*)(txt.toLocal8Bit()) ); txt = QString::fromLocal8Bit( buf ); delete[] buf; @@ -1412,10 +1419,10 @@ QString QDS_Datum::sprintf( const QString& fmt, const QString& val ) }*/ } - if ( aFlags.contains( "u", false ) ) - txt = txt.upper(); - if ( aFlags.contains( "l", false ) ) - txt = txt.lower(); + if ( aFlags.contains( "u", Qt::CaseInsensitive ) ) + txt = txt.toUpper(); + if ( aFlags.contains( "l", Qt::CaseInsensitive ) ) + txt = txt.toLower(); return txt; } @@ -1438,7 +1445,7 @@ QString QDS_Datum::canonicalFormat( const QString& fmt, QString& flags ) flags = QString::null; QRegExp rx( "^(%[0-9]*.?[0-9]*)([a-z,A-Z]+)[g|c|d|i|o|u|x|e|f|n|p|s|X|E|G]$" ); - if ( rx.search( newFmt ) >= 0 ) + if ( rx.indexIn( newFmt ) >= 0 ) { flags = rx.cap( 2 ); newFmt.remove( rx.pos( 2 ), flags.length() ); @@ -1488,7 +1495,7 @@ QString QDS_Datum::minValue() const QString pref = prefix(); QString suff = suffix(); - QString aMin = minimumValue().stripWhiteSpace(); + QString aMin = minimumValue().trimmed(); if ( !pref.isEmpty() && aMin.left( pref.length() ) == pref ) aMin = aMin.mid( pref.length() ); @@ -1507,7 +1514,7 @@ QString QDS_Datum::maxValue() const QString pref = prefix(); QString suff = suffix(); - QString aMax = maximumValue().stripWhiteSpace(); + QString aMax = maximumValue().trimmed(); if ( !pref.isEmpty() && aMax.left( pref.length() ) == pref ) aMax = aMax.mid( pref.length() ); @@ -1580,7 +1587,7 @@ void QDS_Datum::initDatum() const that->initialize(); if ( parent() ) - parent()->removeEventFilter( this ); + parent()->removeEventFilter( (QObject*)this ); } /*! @@ -1594,8 +1601,8 @@ QDS_Datum::Wrapper* QDS_Datum::wrapper( QWidget* wid ) const Wrapper* wrap = 0; for ( QMap::ConstIterator it = myWrapper.begin(); it != myWrapper.end() && !wrap; ++it ) { - if ( it.data() && it.data()->widget() == wid ) - wrap = it.data(); + if ( it.value() && it.value()->widget() == wid ) + wrap = it.value(); } return wrap; } @@ -1619,7 +1626,7 @@ int QDS_Datum::wrapperType( QDS_Datum::Wrapper* wrap ) const int id = -1; for ( QMap::ConstIterator it = myWrapper.begin(); it != myWrapper.end() && id == -1; ++it ) { - if ( it.data() == wrap ) + if ( it.value() == wrap ) id = it.key(); } return id; diff --git a/src/QDS/QDS_Datum.h b/src/QDS/QDS_Datum.h index 9ff431f66..adbca1274 100644 --- a/src/QDS/QDS_Datum.h +++ b/src/QDS/QDS_Datum.h @@ -21,10 +21,10 @@ #include "QDS.h" -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -183,8 +183,8 @@ private: static QString canonicalFormat( const QString&, QString& ); private: - typedef QGuardedPtr GuardedLabel; - typedef QGuardedPtr GuardedWidget; + typedef QPointer GuardedLabel; + typedef QPointer GuardedWidget; private: QString myId; diff --git a/src/QDS/QDS_LineEdit.cxx b/src/QDS/QDS_LineEdit.cxx index cb5ddf148..95829950a 100644 --- a/src/QDS/QDS_LineEdit.cxx +++ b/src/QDS/QDS_LineEdit.cxx @@ -18,8 +18,8 @@ // #include "QDS_LineEdit.h" -#include -#include +#include +#include /* class: QDS_LineEdit::Editor @@ -88,14 +88,14 @@ void QDS_LineEdit::unitSystemChanged( const QString& system ) return; delete le->validator(); - le->clearValidator(); + le->setValidator(0); QValidator* valid = validator(); if ( valid ) le->setValidator( valid ); QString aFormat = format(); int num = 0; - int pos = aFormat.find( '%' ); + int pos = aFormat.indexOf( '%' ); if ( pos != -1 ) { pos++; @@ -112,7 +112,7 @@ void QDS_LineEdit::unitSystemChanged( const QString& system ) int minLen = format( format(), type(), minValue() ).length(); int maxLen = format( format(), type(), maxValue() ).length(); - num = QMAX( QMAX( num, zeroLen ), QMAX( minLen, maxLen ) ); + num = qMax( qMax( num, zeroLen ), qMax( minLen, maxLen ) ); ((Editor*)le)->setNumber( num ); } @@ -159,7 +159,7 @@ bool QDS_LineEdit::hasSelection() const void QDS_LineEdit::setAlignment( const int align, const int type ) { if ( ( type & Control ) && lineEdit() ) - lineEdit()->setAlignment( align ); + lineEdit()->setAlignment( Qt::Alignment(align) ); QDS_Datum::setAlignment( align, type ); } @@ -189,7 +189,7 @@ void QDS_LineEdit::setString( const QString& txt ) */ QLineEdit* QDS_LineEdit::lineEdit() const { - return ::qt_cast( controlWidget() ); + return ::qobject_cast( controlWidget() ); } /*! @@ -229,9 +229,9 @@ void QDS_LineEdit::onParamChanged() QPalette aPal = anEdit->palette(); if ( !aValid ) - aPal.setColor( QPalette::Active, QColorGroup::Text, QColor( 255, 0, 0 ) ); + aPal.setColor( QPalette::Active, QPalette::Text, QColor( 255, 0, 0 ) ); else - aPal.setColor( QPalette::Active, QColorGroup::Text, QColor( 0, 0, 0 ) ); + aPal.setColor( QPalette::Active, QPalette::Text, QColor( 0, 0, 0 ) ); anEdit->setPalette( aPal ); } diff --git a/src/QDS/QDS_RadioBox.cxx b/src/QDS/QDS_RadioBox.cxx index 44771f0fc..a11e08a6b 100644 --- a/src/QDS/QDS_RadioBox.cxx +++ b/src/QDS/QDS_RadioBox.cxx @@ -20,13 +20,13 @@ #include -#include #include #include -#include -#include -#include +#include +#include +#include +#include /* \class QDS_RadioBox @@ -46,7 +46,8 @@ search of dictionary item. */ QDS_RadioBox::QDS_RadioBox( const QString& id, QWidget* parent, const int flags, const QString& comp ) -: QDS_Datum( id, parent, flags & ~( Label | Units ), comp ) + : QDS_Datum( id, parent, flags & ~( Label | Units ), comp ), + myButtonGroup( 0 ) { } @@ -67,7 +68,7 @@ int QDS_RadioBox::count( bool total ) const return myValue.count(); else { - QPtrList bList; + QList bList; buttons( bList ); return bList.count(); } @@ -77,7 +78,7 @@ int QDS_RadioBox::count( bool total ) const Returns list of button identifiers \aids. If \atotal is 'false' then only visible buttons are taken into account otherwise all buttons. */ -void QDS_RadioBox::values( QValueList& ids, bool total ) const +void QDS_RadioBox::values( QList& ids, bool total ) const { ids.clear(); for ( QIntList::const_iterator it = myDataIds.begin(); it != myDataIds.end(); ++it ) @@ -103,7 +104,7 @@ bool QDS_RadioBox::state( const int id ) const */ void QDS_RadioBox::setState( const bool on, const int id, const bool append ) { - QValueList lst; + QList lst; if ( id < 0 ) { for ( IdStateMap::Iterator it = myState.begin(); it != myState.end(); ++it ) @@ -120,7 +121,7 @@ void QDS_RadioBox::setState( const bool on, const int id, const bool append ) If \aappend is set then keep status for other buttons otherwise status of other buttons will be cleared. */ -void QDS_RadioBox::setState( const bool on, const QValueList& ids, const bool append ) +void QDS_RadioBox::setState( const bool on, const QList& ids, const bool append ) { if ( ids.isEmpty() && append ) return; @@ -129,21 +130,21 @@ void QDS_RadioBox::setState( const bool on, const QValueList& ids, const bo QMap aMap; for ( uint i = 0; i < ids.count(); i++ ) - aMap.insert( *ids.at( i ), 0 ); + aMap.insert( ids.at( i ), 0 ); for ( IdStateMap::Iterator it = myState.begin(); it != myState.end(); ++it ) { if ( aMap.contains( it.key() ) ) { - if ( it.data() != on ) + if ( it.value() != on ) { - it.data() = on; + it.value() = on; changed = true; } } - else if ( !append && it.data() == on ) + else if ( !append && it.value() == on ) { - it.data() = !on; + it.value() = !on; changed = true; } } @@ -156,7 +157,7 @@ void QDS_RadioBox::setState( const bool on, const QValueList& ids, const bo button from list will be added into the radio box. This functionality allow to user override buttons. */ -void QDS_RadioBox::setValues( const QValueList& ids, const QStringList& names ) +void QDS_RadioBox::setValues( const QList& ids, const QStringList& names ) { if ( ids.count() != names.count() ) return; @@ -172,7 +173,7 @@ void QDS_RadioBox::setValues( const QValueList& ids, const QStringList& nam */ void QDS_RadioBox::setValues( const QStringList& names ) { - QValueList< int > ids; + QList< int > ids; for ( int i = 0, n = names.count(); i < n; i++ ) ids.append( i ); setValues( ids, names ); @@ -188,7 +189,7 @@ QString QDS_RadioBox::getString() const QButtonGroup* bg = buttonGroup(); if ( bg ) { - int id = bg->selectedId(); + int id = bg->checkedId(); if ( id != -1 ) res = QString::number( id ); } @@ -205,14 +206,15 @@ void QDS_RadioBox::setString( const QString& txt ) if ( !bg ) return; - int oldId = bg->selectedId(); + int oldId = bg->checkedId(); if ( txt.isEmpty() ) { - QPtrList bList; + QList bList; buttons( bList ); - for ( QPtrListIterator it( bList ); it.current(); ++it ) - it.current()->setChecked( false ); + QListIterator it( bList ); + while ( it.hasNext() ) + it.next()->setChecked( false ); } else { @@ -223,11 +225,11 @@ void QDS_RadioBox::setString( const QString& txt ) bool block = signalsBlocked(); blockSignals( true ); - bg->setButton( id ); + bg->button(id)->setChecked(true); blockSignals( block ); } - int newId = bg->selectedId(); + int newId = bg->checkedId(); if ( oldId != newId ) { @@ -244,7 +246,15 @@ void QDS_RadioBox::setString( const QString& txt ) */ QButtonGroup* QDS_RadioBox::buttonGroup() const { - return ::qt_cast( controlWidget() ); + return myButtonGroup; +} + +/*! + Returns pointer to QGroupBox widget. +*/ +QGroupBox* QDS_RadioBox::groupBox() const +{ + return ::qobject_cast( controlWidget() ); } /*! @@ -252,10 +262,14 @@ QButtonGroup* QDS_RadioBox::buttonGroup() const */ QWidget* QDS_RadioBox::createControl( QWidget* parent ) { - QButtonGroup* bg = new QButtonGroup( 1, Qt::Vertical, "", parent ); - bg->setExclusive( true ); - bg->setRadioButtonExclusive( true ); - return bg; + myButtonGroup = new QButtonGroup( parent ); + myButtonGroup->setExclusive( true ); + + QGroupBox *gb = new QGroupBox( "", parent ); + QVBoxLayout *vbox = new QVBoxLayout; + vbox->addStretch(1); + gb->setLayout(vbox); + return gb; } /*! @@ -325,9 +339,8 @@ void QDS_RadioBox::unitSystemChanged( const QString& system ) for ( QIntList::iterator iter2 = add.begin(); iter2 != add.end(); ++iter2 ) myState.insert( *iter2, true ); - QButtonGroup* bg = buttonGroup(); - if ( bg ) - bg->setTitle( label() ); + QGroupBox* gb = groupBox(); + if ( gb ) gb->setTitle( label() ); updateRadioBox(); } @@ -355,12 +368,20 @@ void QDS_RadioBox::updateRadioBox() if ( !bg ) return; - int curId = bg->selectedId(); + QGroupBox* gb = groupBox(); + if ( !gb ) + return; + + int curId = bg->checkedId(); - QPtrList bList; + QList bList; buttons( bList ); - for ( QPtrListIterator itr( bList ); itr.current(); ++itr ) - delete itr.current(); + QListIterator itr( bList ); + while ( itr.hasNext() ) { + QRadioButton* aButton = itr.next(); + if ( gb->layout() ) gb->layout()->removeWidget(aButton); + delete aButton; + } for ( QIntList::const_iterator it = myDataIds.begin(); it != myDataIds.end(); ++it ) { @@ -368,8 +389,10 @@ void QDS_RadioBox::updateRadioBox() if ( !myValue.contains( id ) || !myState.contains( id ) || !myState[id] ) continue; - QRadioButton* rb = new QRadioButton( myValue[id], bg ); - bg->insert( rb, id ); + QRadioButton* rb = new QRadioButton( myValue[id] ); + ((QObject*)rb)->setParent( bg ); + bg->addButton( rb, id ); + if ( gb->layout() ) gb->layout()->addWidget(rb); connect( rb, SIGNAL( toggled( bool ) ), this, SLOT( onToggled( bool ) ) ); } @@ -377,49 +400,42 @@ void QDS_RadioBox::updateRadioBox() if ( curId != -1 ) { int id = curId; - if ( !bg->find( id ) ) + if ( !bg->button( id ) ) { - QPtrList bList; + QList bList; buttons( bList ); if ( !bList.isEmpty() ) - id = bg->id( bList.getFirst() ); + id = bg->id( bList.empty() ? 0 : bList.first() ); } bool block = signalsBlocked(); blockSignals( true ); - bg->setButton( id ); + bg->button(id)->setChecked(true); blockSignals( block ); } - if ( curId != bg->selectedId() ) + if ( curId != bg->checkedId() ) { onParamChanged(); emit paramChanged(); - emit paramChanged( getString() ); + QString str = getString(); + emit paramChanged( str ); } } /*! Returns the list of the radio buttons from the button group. */ -void QDS_RadioBox::buttons( QPtrList& lst ) const +void QDS_RadioBox::buttons( QList& lst ) const { - lst.setAutoDelete( false ); lst.clear(); QButtonGroup* bg = buttonGroup(); if ( !bg ) return; - QObjectList* objs = bg->queryList( "QRadioButton" ); - if ( objs ) - { - for ( QObjectListIt it( *objs ); it.current(); ++it ) - { - QRadioButton* rb = ::qt_cast( it.current() ); - if ( rb ) - lst.append( rb ); - } - } - delete objs; + QList objs = bg->findChildren(); + QListIterator it( objs ); + while ( it.hasNext() ) + lst.append( it.next() ); } diff --git a/src/QDS/QDS_RadioBox.h b/src/QDS/QDS_RadioBox.h index da0cc82f0..32d0f6f93 100644 --- a/src/QDS/QDS_RadioBox.h +++ b/src/QDS/QDS_RadioBox.h @@ -23,15 +23,15 @@ #include -#include -#include -#include +#include +#include #ifdef WIN32 #pragma warning( disable:4251 ) #endif class QButtonGroup; +class QGroupBox; class QRadioButton; class QDS_EXPORT QDS_RadioBox : public QDS_Datum @@ -43,15 +43,15 @@ public: virtual ~QDS_RadioBox(); int count( bool = false ) const; - void values( QValueList&, bool = false ) const; + void values( QList&, bool = false ) const; int columns() const; void setColumns( const int ); bool state( const int ) const; void setState( const bool, const int, const bool = true ); - void setState( const bool, const QValueList&, const bool = true ); - void setValues( const QValueList&, const QStringList& ); + void setState( const bool, const QList&, const bool = true ); + void setValues( const QList&, const QStringList& ); void setValues( const QStringList& ); signals: @@ -62,8 +62,9 @@ protected slots: protected: QButtonGroup* buttonGroup() const; + QGroupBox* groupBox() const; virtual QWidget* createControl( QWidget* ); - void buttons( QPtrList& ) const; + void buttons( QList& ) const; virtual QString getString() const; virtual void setString( const QString& ); @@ -84,6 +85,8 @@ private: QIntList myDataIds; QIntList myUserIds; QStringList myUserNames; + + QButtonGroup* myButtonGroup; }; #ifdef WIN32 diff --git a/src/QDS/QDS_SpinBox.cxx b/src/QDS/QDS_SpinBox.cxx index 71864cb51..6205f61d5 100644 --- a/src/QDS/QDS_SpinBox.cxx +++ b/src/QDS/QDS_SpinBox.cxx @@ -20,7 +20,7 @@ #include -#include +//#include /* \class QDS_SpinBox @@ -58,9 +58,9 @@ QString QDS_SpinBox::getString() const { res = aSpinBox->text(); if ( !aSpinBox->suffix().isEmpty() ) - res.remove( res.find( aSpinBox->suffix() ), aSpinBox->suffix().length() ); + res.remove( res.indexOf( aSpinBox->suffix() ), aSpinBox->suffix().length() ); if ( !aSpinBox->prefix().isEmpty() ) - res.remove( res.find( aSpinBox->prefix() ), aSpinBox->prefix().length() ); + res.remove( res.indexOf( aSpinBox->prefix() ), aSpinBox->prefix().length() ); } return res; } @@ -83,7 +83,7 @@ void QDS_SpinBox::setString( const QString& txt ) */ QtxIntSpinBox* QDS_SpinBox::spinBox() const { - return ::qt_cast( controlWidget() ); + return ::qobject_cast( controlWidget() ); } /*! @@ -114,7 +114,7 @@ void QDS_SpinBox::onValueChanged( int val ) void QDS_SpinBox::setStep( const int step ) { if ( spinBox() ) - spinBox()->setLineStep( step ); + spinBox()->setSingleStep( step ); } /*! @@ -124,7 +124,7 @@ int QDS_SpinBox::step() const { int s = 0; if ( spinBox() ) - s = spinBox()->lineStep(); + s = spinBox()->singleStep(); return s; } @@ -139,13 +139,15 @@ void QDS_SpinBox::unitSystemChanged( const QString& system ) QSpinBox* sb = spinBox(); if ( sb ) { - delete sb->validator(); - QValidator* valid = validator(); - sb->setValidator( valid ); + // not porting this code to qt4, only commented, since from the task context + // the new setted validator accepts all integers + //delete sb->validator(); + //QValidator* valid = validator(); + //sb->setValidator( valid ); sb->setSuffix( suffix() ); sb->setPrefix( prefix() ); - sb->setMinValue( minValue().toInt() ); - sb->setMaxValue( maxValue().toInt() ); + sb->setMinimum( minValue().toInt() ); + sb->setMaximum( maxValue().toInt() ); } } diff --git a/src/QDS/QDS_SpinBoxDbl.cxx b/src/QDS/QDS_SpinBoxDbl.cxx index 0bd7bcf26..213d041ce 100644 --- a/src/QDS/QDS_SpinBoxDbl.cxx +++ b/src/QDS/QDS_SpinBoxDbl.cxx @@ -20,7 +20,7 @@ #include -#include +//#include #include @@ -64,9 +64,9 @@ QString QDS_SpinBoxDbl::getString() const res = sb->text(); if ( !sb->suffix().isEmpty() ) - res.remove( res.find( sb->suffix() ), sb->suffix().length() ); + res.remove( res.indexOf( sb->suffix() ), sb->suffix().length() ); if ( !sb->prefix().isEmpty() ) - res.remove( res.find( sb->prefix() ), sb->prefix().length() ); + res.remove( res.indexOf( sb->prefix() ), sb->prefix().length() ); if ( hasFocus ) sb->setFocus(); @@ -93,7 +93,7 @@ void QDS_SpinBoxDbl::setString( const QString& txt ) */ QtxDblSpinBox* QDS_SpinBoxDbl::spinBox() const { - return ::qt_cast( controlWidget() ); + return ::qobject_cast( controlWidget() ); } /*! @@ -151,9 +151,11 @@ void QDS_SpinBoxDbl::unitSystemChanged( const QString& system ) if ( !sb ) return; - delete sb->validator(); - QValidator* valid = validator(); - sb->setValidator( valid ); + // not porting this code to qt4, only commented, since from the task context + // the new setted validator accepts any double + //delete sb->validator(); + //QValidator* valid = validator(); + //sb->setValidator( valid ); sb->setSuffix( suffix() ); sb->setPrefix( prefix() ); diff --git a/src/QDS/QDS_Table.h b/src/QDS/QDS_Table.h index c7d33abf9..a542cabe7 100644 --- a/src/QDS/QDS_Table.h +++ b/src/QDS/QDS_Table.h @@ -23,8 +23,8 @@ #include -#include -#include +#include +#include class QDS_EXPORT QDS_Table : public QtxTable { diff --git a/src/QDS/QDS_TextEdit.cxx b/src/QDS/QDS_TextEdit.cxx index 1eb66dad9..9a364dae1 100644 --- a/src/QDS/QDS_TextEdit.cxx +++ b/src/QDS/QDS_TextEdit.cxx @@ -18,7 +18,7 @@ // #include "QDS_TextEdit.h" -#include +#include /* \class QDS_TextEdit @@ -51,7 +51,7 @@ QString QDS_TextEdit::getString() const { QString res; if ( textEdit() ) - res = textEdit()->text(); + res = textEdit()->toPlainText(); return res; } @@ -69,7 +69,7 @@ void QDS_TextEdit::setString( const QString& txt ) */ QTextEdit* QDS_TextEdit::textEdit() const { - return ::qt_cast( controlWidget() ); + return ::qobject_cast( controlWidget() ); } /*! diff --git a/src/QDS/QDS_Validator.cxx b/src/QDS/QDS_Validator.cxx index 37b2ea658..2aaa59944 100644 --- a/src/QDS/QDS_Validator.cxx +++ b/src/QDS/QDS_Validator.cxx @@ -67,7 +67,7 @@ QValidator::State QDS_IntegerValidator::validate( QString& input, int& pos ) con if ( ivState != Invalid && !myFilter.isEmpty() ) rgState = QRegExpValidator( QRegExp( myFilter ), 0 ).validate( input, pos ); - ivState = QMIN( ivState, rgState ); + ivState = qMin( ivState, rgState ); return ivState; } @@ -121,7 +121,7 @@ QValidator::State QDS_DoubleValidator::validate( QString& input, int& pos ) cons if ( dvState != Invalid && !myFilter.isEmpty() ) rgState = QRegExpValidator( QRegExp( myFilter ), 0 ).validate( input, pos ); - dvState = QMIN( dvState, rgState ); + dvState = qMin( dvState, rgState ); return dvState; } @@ -205,10 +205,10 @@ QValidator::State QDS_StringValidator::validate( QString& input, int& pos ) cons return Acceptable; QString orig = input; - if ( myFlags.contains( 'u', false ) ) - input = input.upper(); - if ( myFlags.contains( 'l', false ) ) - input = input.lower(); + if ( myFlags.contains( 'u', Qt::CaseInsensitive ) ) + input = input.toUpper(); + if ( myFlags.contains( 'l', Qt::CaseInsensitive ) ) + input = input.toLower(); State rgState = Acceptable; State svState = orig == input ? Acceptable : Intermediate; @@ -219,7 +219,7 @@ QValidator::State QDS_StringValidator::validate( QString& input, int& pos ) cons if ( !myFilter.isEmpty() ) rgState = QRegExpValidator( QRegExp( myFilter ), 0 ).validate( input, pos ); - svState = QMIN( svState, rgState ); + svState = qMin( svState, rgState ); return svState; } diff --git a/src/QDS/QDS_Validator.h b/src/QDS/QDS_Validator.h index e7fed65aa..9b5aab350 100644 --- a/src/QDS/QDS_Validator.h +++ b/src/QDS/QDS_Validator.h @@ -21,7 +21,7 @@ #include "QDS.h" -#include +#include /*! class QDS_IntegerValidator diff --git a/src/src.pro b/src/src.pro index 709188340..3057752ad 100644 --- a/src/src.pro +++ b/src/src.pro @@ -2,6 +2,8 @@ TEMPLATE = subdirs CONFIG += ordered SUBDIRS = Qtx +SUBDIRS += DDS +SUBDIRS += QDS SUBDIRS += SUIT SUBDIRS += SUITApp SUBDIRS += STD -- 2.39.2