X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSALOME_PYQT%2FSALOME_PYQT_GUILight%2FSALOME_PYQT_PyModule.cxx;h=ba32cb1bc3871ca63815249422be08cdeda56e44;hb=3e5f3ccf11b6d2124731a3e0532cd46c6bb8c850;hp=4264610e4a729b1ce54f23a7ed61ff541cccfa14;hpb=7e5424a12a7f6894a5b9a029fd8251f2cb5780b8;p=modules%2Fgui.git diff --git a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx index 4264610e4..ba32cb1bc 100644 --- a/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx +++ b/src/SALOME_PYQT/SALOME_PYQT_GUILight/SALOME_PYQT_PyModule.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -66,7 +66,7 @@ const int DEFAULT_GROUP = 40; QMutex myInitMutex; /*! DEBUG mode */ -const bool DEBUG = false; +const bool theDEBUG = false; /*! \var IsCallOldMethods @@ -168,17 +168,17 @@ public: FuncMsg( const QString& funcName ) { myName = funcName; - if ( DEBUG ) + if ( theDEBUG ) MESSAGE( qPrintable( myName ) << " [ begin ]" ); } ~FuncMsg() { - if ( DEBUG ) + if ( theDEBUG ) MESSAGE( qPrintable( myName ) << " [ end ]" ); } void message( const QString& msg ) { - if ( DEBUG ) + if ( theDEBUG ) MESSAGE( qPrintable( myName ) << " : " << qPrintable( msg ) ); } private: @@ -371,7 +371,7 @@ QIcon PyModuleHelper::XmlHandler::loadIcon( const QString& fileName ) SUIT_ResourceMgr* resMgr = module()->getApp()->resourceMgr(); QPixmap pixmap = resMgr->loadPixmap( module()->name(), QApplication::translate( module()->name().toLatin1().data(), - fileName.toLatin1().data() ) ); + fileName.toUtf8().data() ) ); if ( !pixmap.isNull() ) icon = QIcon( pixmap ); } @@ -1755,7 +1755,7 @@ void PyModuleHelper::initInterp() } // ... then call a method int embedded = 1; - PyObjWrapper aRes( PyObject_CallMethod( aMod, (char*)"salome_init", (char*)"i", embedded ) ); + PyObjWrapper aRes( PyObject_CallMethod( aMod, (char*)"salome_init", (char*)"si", NULL, embedded ) ); if ( !aRes ) { // Error! PyErr_Print(); @@ -1846,11 +1846,12 @@ void PyModuleHelper::setWorkSpace() if ( d ) aWorkspace = d->workstack(); } -#if SIP_VERSION < 0x040800 - PyObjWrapper pyws( sipBuildResult( 0, "M", aWorkspace, sipClass_QWidget) ); -#else - PyObjWrapper pyws( sipBuildResult( 0, "D", aWorkspace, sipType_QWidget , NULL) ); +#if SIP_VERSION >= 0x041300 + static const sipTypeDef *sipType_QWidget = 0; + if (!sipType_QWidget) + sipType_QWidget = sipFindType("QWidget"); #endif + PyObjWrapper pyws( sipBuildResult( 0, "D", aWorkspace, sipType_QWidget , NULL) ); // ... and finally call Python module's setWorkSpace() method (obsolete) if ( PyObject_HasAttrString( myPyModule, (char*)"setWorkSpace" ) ) { PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"setWorkSpace", (char*)"O", pyws.get() ) ); @@ -2128,7 +2129,7 @@ void PyModuleHelper::internalClosedStudy( SUIT_Study* theStudy ) } // then call Python module's deactivate() method if ( PyObject_HasAttrString( myPyModule , (char*)"closeStudy" ) ) { - PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"closeStudy", (char*)"i" ) ); + PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"closeStudy", (char*)"" ) ); if( !res ) { PyErr_Print(); } @@ -2161,8 +2162,8 @@ void PyModuleHelper::internalPreferencesChanged( const QString& section, const Q PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"preferenceChanged", (char*)"ss", - section.toLatin1().constData(), - setting.toLatin1().constData() ) ); + section.toUtf8().constData(), + setting.toUtf8().constData() ) ); if( !res ) { PyErr_Print(); } @@ -2208,7 +2209,7 @@ void PyModuleHelper::internalStudyChanged( SUIT_Study* study ) // call Python module's activeStudyChanged() method if ( PyObject_HasAttrString( myPyModule, (char*)"activeStudyChanged" ) ) { - PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"activeStudyChanged", (char*)"i" ) ); + PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"activeStudyChanged", (char*)"" ) ); if( !res ) { PyErr_Print(); } @@ -2262,11 +2263,12 @@ void PyModuleHelper::internalSelectionUpdated(const QStringList& entries) QStringList* theList = new QStringList(entries); -#if SIP_VERSION < 0x040800 - PyObjWrapper sipList(sipBuildResult(0, "M", theList, sipClass_QStringList)); -#else - PyObjWrapper sipList( sipBuildResult( 0, "D", theList, sipType_QStringList, NULL ) ); +#if SIP_VERSION >= 0x041300 + static const sipTypeDef *sipType_QStringList = 0; + if (!sipType_QStringList) + sipType_QStringList = sipFindType("QStringList"); #endif + PyObjWrapper sipList( sipBuildResult( 0, "D", theList, sipType_QStringList, NULL ) ); if (PyObject_HasAttrString(myPyModule, (char*) "onSelectionUpdated")) { MESSAGE("call onSelectionUpdated"); @@ -2313,9 +2315,9 @@ void PyModuleHelper::internalContextMenu( const QString& context, QMenu* menu ) PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"definePopup", (char*)"sss", - context.toLatin1().constData(), - aObject.toLatin1().constData(), - aParent.toLatin1().constData() ) ); + context.toUtf8().constData(), + aObject.toUtf8().constData(), + aParent.toUtf8().constData() ) ); if( !res ) { PyErr_Print(); } @@ -2335,11 +2337,12 @@ void PyModuleHelper::internalContextMenu( const QString& context, QMenu* menu ) if ( myXmlHandler ) myXmlHandler->createPopup( menu, aContext, aParent, aObject ); -#if SIP_VERSION < 0x040800 - PyObjWrapper sipPopup( sipBuildResult( 0, "M", menu, sipClass_QMenu ) ); -#else - PyObjWrapper sipPopup( sipBuildResult( 0, "D", menu, sipType_QMenu, NULL ) ); +#if SIP_VERSION >= 0x041300 + static const sipTypeDef *sipType_QMenu = 0; + if (!sipType_QMenu) + sipType_QMenu = sipFindType("QMenu"); #endif + PyObjWrapper sipPopup( sipBuildResult( 0, "D", menu, sipType_QMenu, NULL ) ); // then call Python module's createPopupMenu() method (for new modules) if ( PyObject_HasAttrString( myPyModule, (char*)"createPopupMenu" ) ) { @@ -2347,7 +2350,7 @@ void PyModuleHelper::internalContextMenu( const QString& context, QMenu* menu ) (char*)"createPopupMenu", (char*)"Os", sipPopup.get(), - context.toLatin1().constData() ) ); + context.toUtf8().constData() ) ); if( !res1 ) { PyErr_Print(); } @@ -2360,9 +2363,9 @@ void PyModuleHelper::internalContextMenu( const QString& context, QMenu* menu ) (char*)"customPopup", (char*)"Osss", sipPopup.get(), - aContext.toLatin1().constData(), - aObject.toLatin1().constData(), - aParent.toLatin1().constData() ) ); + aContext.toUtf8().constData(), + aObject.toUtf8().constData(), + aParent.toUtf8().constData() ) ); if( !res2 ) { PyErr_Print(); } @@ -2506,12 +2509,12 @@ void PyModuleHelper::internalSave( QStringList& files, const QString& url ) // try with two parameters (new syntax) PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"saveFiles", (char*)"ss", - files.first().toLatin1().constData(), - url.toLatin1().constData() ) ); + files.first().toUtf8().constData(), + url.toUtf8().constData() ) ); if ( !res ) // try with single parameter (old syntax) res = PyObject_CallMethod( myPyModule, (char*)"saveFiles", - (char*)"s", files.first().toLatin1().constData() ); + (char*)"s", files.first().toUtf8().constData() ); if ( !res ) { PyErr_Print(); @@ -2555,17 +2558,18 @@ void PyModuleHelper::internalLoad( const QStringList& files, const QString& url, QStringList* theList = new QStringList( files ); -#if SIP_VERSION < 0x040800 - PyObjWrapper sipList( sipBuildResult( 0, "M", theList, sipClass_QStringList ) ); -#else - PyObjWrapper sipList( sipBuildResult( 0, "D", theList, sipType_QStringList, NULL ) ); +#if SIP_VERSION >= 0x041300 + static const sipTypeDef *sipType_QStringList = 0; + if (!sipType_QStringList) + sipType_QStringList = sipFindType("QStringList"); #endif + PyObjWrapper sipList( sipBuildResult( 0, "D", theList, sipType_QStringList, NULL ) ); if ( PyObject_HasAttrString(myPyModule , (char*)"openFiles") ) { // try with two parameters (new syntax) PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"openFiles", (char*)"Os", sipList.get(), - url.toLatin1().constData() ) ); + url.toUtf8().constData() ) ); if ( !res ) // try with single parameter (old syntax) @@ -2599,7 +2603,7 @@ void PyModuleHelper::internalDumpPython( QStringList& files ) if ( PyObject_HasAttrString(myPyModule, (char*)"dumpStudy") ) { PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"dumpStudy", - (char*)"s", files.first().toLatin1().constData())); + (char*)"s", files.first().toUtf8().constData())); if ( !res ) { PyErr_Print(); @@ -2645,7 +2649,7 @@ bool PyModuleHelper::internalIsDraggable( LightApp_DataObject* what ) if ( PyObject_HasAttrString(myPyModule , (char*)"isDraggable") ) { PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"isDraggable", - (char*)"s", what->entry().toLatin1().constData() ) ); + (char*)"s", what->entry().toUtf8().constData() ) ); if( !res || !PyBool_Check( res )) { PyErr_Print(); draggable = false; @@ -2677,7 +2681,7 @@ bool PyModuleHelper::internalIsDropAccepted( LightApp_DataObject* where ) if ( PyObject_HasAttrString(myPyModule , (char*)"isDropAccepted") ) { PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"isDropAccepted", - (char*)"s", where->entry().toLatin1().constData() ) ); + (char*)"s", where->entry().toUtf8().constData() ) ); if( !res || !PyBool_Check( res )) { PyErr_Print(); dropAccepted = false; @@ -2718,15 +2722,16 @@ void PyModuleHelper::internalDropObjects( const DataObjectList& what, SUIT_DataO if ( dataObject ) theList->append( dataObject->entry() ); } -#if SIP_VERSION < 0x040800 - PyObjWrapper sipList( sipBuildResult( 0, "M", theList, sipClass_QStringList) ); -#else - PyObjWrapper sipList( sipBuildResult( 0, "D", theList, sipType_QStringList, NULL) ); +#if SIP_VERSION >= 0x041300 + static const sipTypeDef *sipType_QStringList = 0; + if (!sipType_QStringList) + sipType_QStringList = sipFindType("QStringList"); #endif + PyObjWrapper sipList( sipBuildResult( 0, "D", theList, sipType_QStringList, NULL) ); if ( PyObject_HasAttrString(myPyModule, (char*)"dropObjects") ) { PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"dropObjects", (char*)"Osii", sipList.get(), - whereObject->entry().toLatin1().constData(), + whereObject->entry().toUtf8().constData(), row, action ) ); if( !res ) { @@ -2814,7 +2819,7 @@ void PyModuleHelper::internalOBClickedPython( const QString& theObj, int theColu return; // Error if ( PyObject_HasAttrString( myPyModule, (char*)"onObjectBrowserClicked" ) ) { - PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"onObjectBrowserClicked", (char*)"si", theObj.toLatin1().constData(), theColumn ) ); + PyObjWrapper res( PyObject_CallMethod( myPyModule, (char*)"onObjectBrowserClicked", (char*)"si", theObj.toUtf8().constData(), theColumn ) ); if( !res ) { PyErr_Print(); }