From: vsr Date: Thu, 11 Aug 2016 06:43:21 +0000 (+0300) Subject: Allow setting / getting QByteArray preference item in Python modules. X-Git-Tag: V8_1_0rc1~8^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d51e3c95a93b840a0784404af8e4e9086a386b9c;p=modules%2Fgui.git Allow setting / getting QByteArray preference item in Python modules. - Additional change to previous commit - revert a way QByteArray value is stored in the string. --- diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index d0d2d356d..022fb88a8 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -1573,11 +1573,13 @@ bool QtxResourceMgr::value( const QString& sect, const QString& name, QByteArray if ( !value( sect, name, val, true ) ) return false; - if ( val.startsWith( QLatin1String("@ByteArray(") ) && - val.endsWith( QLatin1Char(')' ) ) ) { + if ( val.startsWith( "@ByteArray(" ) && val.endsWith( ')' ) ) { baVal = QByteArray( val.midRef( 11, val.size() - 12 ).toLatin1() ); } else { + if ( val.startsWith( "@ByteArray[" ) && val.endsWith( ']' ) ) { + val = val.mid( 11, val.size() - 12 ); + } baVal.clear(); QStringList lst = val.split( QRegExp( "[\\s|,]" ), QString::SkipEmptyParts ); for ( QStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it ) @@ -2058,11 +2060,15 @@ void QtxResourceMgr::setValue( const QString& sect, const QString& name, const Q if ( checkExisting() && value( sect, name, res ) && res == val ) return; - QString result; - result = QLatin1String("@ByteArray("); - result += QString::fromLatin1(val.constData(), val.size()); - result += QLatin1Char(')'); + char buf[8]; + QStringList lst; + for ( int i = 0; i < val.size(); i++ ) + { + ::sprintf( buf, "#%02X", (unsigned char)val.at( i ) ); + lst.append( QString( buf ) ); + } + QString result = QString( "@ByteArray[%1]" ).arg( lst.join( " " ) ); setResource( sect, name, result ); }