From 966d3757e525a5ac4a89fc98322fb0be1d23c754 Mon Sep 17 00:00:00 2001 From: prascle Date: Mon, 14 Mar 2005 15:21:40 +0000 Subject: [PATCH] PR: SARGE port... --- salome_adm/unix/config_files/check_pyqt.m4 | 20 +++---- salome_adm/unix/config_files/check_qt.m4 | 20 +++++++ salome_adm/unix/config_files/check_sip.m4 | 12 ++--- salome_adm/unix/make_commence.in | 1 + src/PatchQt/Makefile.in | 24 +++++---- src/PatchQt/qactionP.h | 8 +++ src/PatchQt/qfiledialogP.h | 7 +++ src/PatchQt/qworkspaceP.h | 7 ++- src/SALOMEGUI/PyInterp_PyQt.cxx | 9 ++-- src/SALOMEGUI/PyInterp_base.cxx | 32 ++++------- src/SALOMEGUI/QAD_Desktop.h | 5 -- src/SALOMEGUI/QAD_FileDlg.h | 6 --- src/SALOMEGUI/QAD_PyInterp.cxx | 2 + src/SALOME_PYQT/Makefile.in | 50 +++++++++++++---- src/SALOME_PYQT/SALOME_PYQT_GUI.cxx | 9 +++- src/SALOME_PYQT/SalomePyQt.sip | 8 ++- src/SALOME_PYQT/SalomePyQt_v4.sip | 62 ++++++++++++++++++++++ 17 files changed, 201 insertions(+), 81 deletions(-) create mode 100644 src/SALOME_PYQT/SalomePyQt_v4.sip diff --git a/salome_adm/unix/config_files/check_pyqt.m4 b/salome_adm/unix/config_files/check_pyqt.m4 index b1d608adf..9374319a6 100644 --- a/salome_adm/unix/config_files/check_pyqt.m4 +++ b/salome_adm/unix/config_files/check_pyqt.m4 @@ -56,17 +56,17 @@ fi AC_CHECK_FILE("$PYUIC",pyqt_ok=yes,pyqt_ok=no) -#if test "x$pyqt_ok" = xyes ; then -# AC_CHECK_FILES("$PYQTLIB/qt.py",pyqt_ok=yes,pyqt_ok=no) -#fi +dnl if test "x$pyqt_ok" = xyes ; then +dnl AC_CHECK_FILES("$PYQTLIB/qt.py",pyqt_ok=yes,pyqt_ok=no) +dnl fi -#if test "x$pyqt_ok" = xno ; then -# AC_CHECK_FILES("$PYQTLIB/qt/qt.py",pyqt_ok=yes,pyqt_ok=no) -#fi +dnl if test "x$pyqt_ok" = xno ; then +dnl AC_CHECK_FILES("$PYQTLIB/qt/qt.py",pyqt_ok=yes,pyqt_ok=no) +dnl fi -#if test "x$pyqt_ok" = xyes ; then -# AC_CHECK_FILE("$PYQTLIB/libqtcmodule.so",pyqt_ok=yes,pyqt_ok=no) -#fi +dnl if test "x$pyqt_ok" = xyes ; then +dnl AC_CHECK_FILE("$PYQTLIB/libqtcmodule.so",pyqt_ok=yes,pyqt_ok=no) +dnl fi if test "x$pyqt_ok" = xyes ; then AC_CHECK_FILES("$PYQT_SIPS/qtmod.sip",pyqt_ok=yes,pyqt_ok=no) @@ -78,7 +78,7 @@ fi if test "x$pyqt_ok" = xyes ; then PYQT_ROOT=$PYQTDIR PYQT_INCLUDES="-I$PYQT_SIPS" - PYQT_LIBS="-L$PYQTLIB -lqtcmodule" + PYQT_LIBS="-L$PYQTLIB " AC_SUBST(PYQT_ROOT) AC_SUBST(PYQT_INCLUDES) AC_SUBST(PYQT_LIBS) diff --git a/salome_adm/unix/config_files/check_qt.m4 b/salome_adm/unix/config_files/check_qt.m4 index 305a4335f..b1557decd 100644 --- a/salome_adm/unix/config_files/check_qt.m4 +++ b/salome_adm/unix/config_files/check_qt.m4 @@ -75,6 +75,25 @@ then fi fi +version=`moc -v > mocversion 2>&1;cut -c40-44 mocversion;rm -rf mocversion` +case "$version" in + 3.3.3) + QT_VERS=v3_3_3 + AC_MSG_RESULT(QT3.3.3 install detected) + qt_ok=yes;; + 3.0.5) + AC_MSG_RESULT(QT3.0.5 install detected) + QT_VERS=v3_0_5 + qt_ok=yes;; + *) + AC_MSG_RESULT(qt version $version not supported) + qt_ok=no + QT_VERS=no ;; +esac + +AC_SUBST(QT_VERS) +AC_MSG_RESULT(qt version $QT_VERS ) + AC_SUBST(QTDIR) QT_ROOT=$QTDIR @@ -160,6 +179,7 @@ AC_SUBST(QT_ROOT) AC_SUBST(QT_INCLUDES) AC_SUBST(QT_LIBS) AC_SUBST(QT_MT_LIBS) +AC_SUBST(QT_VERS) AC_LANG_RESTORE diff --git a/salome_adm/unix/config_files/check_sip.m4 b/salome_adm/unix/config_files/check_sip.m4 index 0a551209b..84d35f629 100644 --- a/salome_adm/unix/config_files/check_sip.m4 +++ b/salome_adm/unix/config_files/check_sip.m4 @@ -38,8 +38,8 @@ else SIP_VERS=new ;; 3.10*) SIP_VERS=new2 ;; - 4.1*) - SIP_VERS=new3 ;; + 4.1*) + SIP_VERS=v4_1 ;; *) AC_MSG_RESULT(sip version $version not supported) SIP_VERS=no ;; @@ -86,15 +86,15 @@ else SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages -lsip" fi - if test "x$SIP_VERS" = "xnew3" + if test "x$SIP_VERS" = "xv4_1" then - dnl new3 install : includes and libs are in python install - AC_MSG_RESULT(new3 install detected) + dnl 4.1 install : includes and libs are in python install + AC_MSG_RESULT(4.1 install detected) sip_ok=yes AC_CHECK_FILE($PYTHON_PREFIX/include/python$PYTHON_VERSION/sip.h,sip_ok=$sip_ok,sip_ok=no) SIP_INCLUDES="${PYTHON_INCLUDES}" AC_CHECK_FILE($PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages/sip.so,sip_ok=$sip_ok,sip_ok=no) - SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages -lsip" + SIP_LIBS="${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/sip.so" fi fi diff --git a/salome_adm/unix/make_commence.in b/salome_adm/unix/make_commence.in index 620cfd9ff..d23993edf 100644 --- a/salome_adm/unix/make_commence.in +++ b/salome_adm/unix/make_commence.in @@ -81,6 +81,7 @@ QT_MT_LIBS = @QT_MT_LIBS@ MOC = @MOC@ UIC = @UIC@ +QT_VERS = @QT_VERS@ #QWT diff --git a/src/PatchQt/Makefile.in b/src/PatchQt/Makefile.in index 0923a7efd..7909f104a 100644 --- a/src/PatchQt/Makefile.in +++ b/src/PatchQt/Makefile.in @@ -33,30 +33,32 @@ VPATH=.:@srcdir@:@top_srcdir@/idl EXPORT_HEADERS = \ qsplitterP.h \ - qactionP.h - -# qfiledialogP.h \ -# qworkspaceP.h \ + qworkspaceP.h \ + qactionP.h \ + qfiledialogP.h # Libraries targets +ifeq ($(QT_VERS),v3_3_3) + LIB_SRC = qsplitterP.cxx qsplitterP_moc.cxx +else + LIB_SRC = qsplitterP.cxx qsplitterP_moc.cxx qworkspaceP.cxx qworkspaceP_moc.cxx qactionP.cxx qactionP_moc.cxx qfiledialogP.cxx qfiledialogP_moc.cxx +endif LIB = libqsplitterP.la -#LIB_SRC = qsplitterP.cxx qsplitterP_moc.cxx qworkspaceP.cxx qworkspaceP_moc.cxx qactionP.cxx qactionP_moc.cxx qfiledialogP.cxx qfiledialogP_moc.cxx -LIB_SRC = qsplitterP.cxx qsplitterP_moc.cxx qactionP.cxx qactionP_moc.cxx qsplitterP_moc.cxx: $(inc_builddir)/qsplitterP.h $(MOC) $(inc_builddir)/qsplitterP.h -o qsplitterP_moc.cxx -#qworkspaceP_moc.cxx: $(inc_builddir)/qworkspaceP.h -# $(MOC) $(inc_builddir)/qworkspaceP.h -o qworkspaceP_moc.cxx +qworkspaceP_moc.cxx: $(inc_builddir)/qworkspaceP.h + $(MOC) $(inc_builddir)/qworkspaceP.h -o qworkspaceP_moc.cxx qactionP_moc.cxx: $(inc_builddir)/qactionP.h $(MOC) $(inc_builddir)/qactionP.h -o qactionP_moc.cxx -#qfiledialogP_moc.cxx: $(inc_builddir)/qfiledialogP.h -# $(MOC) $(inc_builddir)/qfiledialogP.h -o qfiledialogP_moc.cxx +qfiledialogP_moc.cxx: $(inc_builddir)/qfiledialogP.h + $(MOC) $(inc_builddir)/qfiledialogP.h -o qfiledialogP_moc.cxx -CPPFLAGS+=$(QT_INCLUDES) -I${QTDIR}/src/kernel -I$(QTDIR)/mkspecs/linux-g++ +CPPFLAGS+=$(QT_INCLUDES) -I${QTDIR}/src/kernel -I$(QTDIR)/mkspecs/linux-g++ -I/usr/share/qt3/mkspecs/linux-g++ CXXFLAGS+= LDFLAGS+=$(QT_MT_LIBS) diff --git a/src/PatchQt/qactionP.h b/src/PatchQt/qactionP.h index 1fcf05053..160324087 100644 --- a/src/PatchQt/qactionP.h +++ b/src/PatchQt/qactionP.h @@ -53,6 +53,12 @@ #ifndef QT_NO_ACTION +#if QT_VERSION > 0x030005 +#include +#define QActionP QAction +#define QActionPGroup QActionGroup +#else + class QActionPPrivate; class QActionPGroupPrivate; class QStatusBar; @@ -184,4 +190,6 @@ public: #endif +#endif // QT_VERSION + #endif diff --git a/src/PatchQt/qfiledialogP.h b/src/PatchQt/qfiledialogP.h index f7355a193..ab615b753 100644 --- a/src/PatchQt/qfiledialogP.h +++ b/src/PatchQt/qfiledialogP.h @@ -68,6 +68,11 @@ class QFileDialogQFileListView; #include "qlineedit.h" #endif // QT_H +#if QT_VERSION > 0x030005 +#include +#define QFileDialogP QFileDialog +#else + #ifndef QT_NO_FILEDIALOG class Q_EXPORT QFileIconProviderP : public QObject @@ -525,4 +530,6 @@ private: #endif +#endif // QT_VERSION + #endif // QFILEDIALOG_H diff --git a/src/PatchQt/qworkspaceP.h b/src/PatchQt/qworkspaceP.h index fb1523735..2197da251 100644 --- a/src/PatchQt/qworkspaceP.h +++ b/src/PatchQt/qworkspaceP.h @@ -54,6 +54,11 @@ #include #endif // QT_H +#if QT_VERSION > 0x030005 +#include +#define QWorkspaceP QWorkspace +#else + class QWorkspacePChild; class QShowEvent; class QWorkspacePPrivate; @@ -350,5 +355,5 @@ private: QTitleBarPPrivate *d; }; - +#endif // QT_VERSION #endif // QWORKSPACEP_H diff --git a/src/SALOMEGUI/PyInterp_PyQt.cxx b/src/SALOMEGUI/PyInterp_PyQt.cxx index 2d6119b51..9ebf3f1d9 100644 --- a/src/SALOMEGUI/PyInterp_PyQt.cxx +++ b/src/SALOMEGUI/PyInterp_PyQt.cxx @@ -31,6 +31,7 @@ PyInterp_PyQt::~PyInterp_PyQt() void PyInterp_PyQt::initState() { SCRUTE(PyInterp_base::_gtstate); + //PyLockWrapper aLock(_tstate); _tstate=PyInterp_base::_gtstate; PyThreadState_Swap(_tstate); SCRUTE(_tstate); @@ -38,6 +39,7 @@ void PyInterp_PyQt::initState() void PyInterp_PyQt::initContext() { + //PyLockWrapper aLock(_tstate); _g = PyDict_New(); // create interpreter dictionnary context PyObject *bimod = PyImport_ImportModule("__builtin__"); PyDict_SetItemString(_g, "__builtins__", bimod); @@ -47,14 +49,11 @@ void PyInterp_PyQt::initContext() void PyInterp_PyQt::run(const char *command) { MESSAGE("compile"); - //PyLockWrapper aLock(_tstate); - PyEval_AcquireLock(); - PyThreadState_Swap(_tstate); + PyLockWrapper aLock(_tstate); PyObject *code = Py_CompileString((char *)command,"PyGUI",Py_file_input); if(!code){ // Une erreur s est produite en general SyntaxError PyErr_Print(); - PyEval_ReleaseLock(); return; } PyObject *r = PyEval_EvalCode(code,_g,_g); @@ -62,10 +61,8 @@ void PyInterp_PyQt::run(const char *command) if(!r){ // Une erreur s est produite a l execution PyErr_Print(); - PyEval_ReleaseLock(); return; } Py_DECREF(r); - PyEval_ReleaseLock(); } diff --git a/src/SALOMEGUI/PyInterp_base.cxx b/src/SALOMEGUI/PyInterp_base.cxx index 851fc73f6..92c2e68ba 100644 --- a/src/SALOMEGUI/PyInterp_base.cxx +++ b/src/SALOMEGUI/PyInterp_base.cxx @@ -36,18 +36,19 @@ static int MYPYDEBUG = 0; static QMutex myMutex(true); -PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): +PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): myThreadState(theThreadState), mySaveThreadState(PyInterp_base::_gtstate) { PyEval_AcquireLock(); - mySaveThreadState = PyThreadState_Swap(theThreadState); + mySaveThreadState = PyThreadState_Swap(myThreadState); // store previous current in save, + // set local in current } PyLockWrapper::~PyLockWrapper(){ - PyThreadState_Swap(mySaveThreadState); - PyEval_ReleaseLock(); + PyThreadState_Swap(mySaveThreadState); // restore previous current (no need to get local, + PyEval_ReleaseLock(); // local thread state* already in _tstate } @@ -112,11 +113,8 @@ PyInterp_base::PyInterp_base(): _tstate(0), _vout(0), _verr(0), _g(0), _atFirst( PyInterp_base::~PyInterp_base() { if(MYPYDEBUG) MESSAGE("PyInterp_base::~PyInterp_base() - this = "<cgetvalue(_verr)); string aRet(PyString_AsString(v)); - PyEval_ReleaseLock(); return aRet; } string PyInterp_base::getvout(){ - //PyLockWrapper aLock(_tstate); - PyEval_AcquireLock(); - PyThreadState_Swap(_tstate); + PyLockWrapper aLock(_tstate); PyObjWrapper v(PycStringIO->cgetvalue(_vout)); string aRet(PyString_AsString(v)); - PyEval_ReleaseLock(); return aRet; } diff --git a/src/SALOMEGUI/QAD_Desktop.h b/src/SALOMEGUI/QAD_Desktop.h index a14f7d785..35c71416e 100644 --- a/src/SALOMEGUI/QAD_Desktop.h +++ b/src/SALOMEGUI/QAD_Desktop.h @@ -55,12 +55,7 @@ #include #include #include -#if QT_VERSION == 0x030005 #include "qworkspaceP.h" -#else -#include -#define QWorkspaceP QWorkspace -#endif #include #include #include diff --git a/src/SALOMEGUI/QAD_FileDlg.h b/src/SALOMEGUI/QAD_FileDlg.h index a234de43d..71b19cfe2 100644 --- a/src/SALOMEGUI/QAD_FileDlg.h +++ b/src/SALOMEGUI/QAD_FileDlg.h @@ -15,13 +15,7 @@ #include #include -// VSR (18/01/2005): use patched QFileDialog only for the official 3.0.5 version of Qt -#if QT_VERSION == 0x030005 #include -#else -#include -#define QFileDialogP QFileDialog -#endif #include "QAD.h" #include "QAD_FileValidator.h" diff --git a/src/SALOMEGUI/QAD_PyInterp.cxx b/src/SALOMEGUI/QAD_PyInterp.cxx index d7da14e42..ac0ddd2b5 100644 --- a/src/SALOMEGUI/QAD_PyInterp.cxx +++ b/src/SALOMEGUI/QAD_PyInterp.cxx @@ -72,6 +72,7 @@ QAD_PyInterp::~QAD_PyInterp() void QAD_PyInterp::initState() { + //PyLockWrapper aLock(_tstate); _tstate = Py_NewInterpreter(); // create an interpreter and save current state PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv if(MYDEBUG) MESSAGE("QAD_PyInterp::initState - this = "< + +#if QT_VERSION > 0x030005 #include +#else +#include +#endif + #include #include diff --git a/src/SALOME_PYQT/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt.sip index 69bbcfd13..ebfac3e00 100644 --- a/src/SALOME_PYQT/SalomePyQt.sip +++ b/src/SALOME_PYQT/SalomePyQt.sip @@ -2,12 +2,15 @@ %Import qtmod.sip + class SALOME_Selection : QObject { -%TypeHeaderCode + +%HeaderCode #include %End + public: SALOME_Selection(const QString &); void Clear(); @@ -29,7 +32,8 @@ enum MenuName { class SalomePyQt { -%TypeHeaderCode + +%HeaderCode #include %End diff --git a/src/SALOME_PYQT/SalomePyQt_v4.sip b/src/SALOME_PYQT/SalomePyQt_v4.sip new file mode 100644 index 000000000..69bbcfd13 --- /dev/null +++ b/src/SALOME_PYQT/SalomePyQt_v4.sip @@ -0,0 +1,62 @@ +%Module SalomePyQt + +%Import qtmod.sip + +class SALOME_Selection : QObject +{ +%TypeHeaderCode +#include +%End + +public: + SALOME_Selection(const QString &); + void Clear(); + void ClearIObjects(); + +signals: + void currentSelectionChanged(); +}; + +enum MenuName { + File = 1, + View = 2, + Edit = 3, + Preferences = 4, + Tools = 5, + Window = 6, + Help = 7 +}; + +class SalomePyQt +{ +%TypeHeaderCode +#include +%End + +public: + static QWidget* getDesktop(); + static QWorkspace* getMainFrame(); + static QMenuBar* getMainMenuBar(); + static QPopupMenu* getPopupMenu( const MenuName ); + static SALOME_Selection* getSelection(); + static int getStudyId(); + static void putInfo( const QString& ); + static void putInfo( const QString&, int ); + + static const QString& getActiveComponent(); + + static void updateObjBrowser( int, bool ); + + + static bool removeSettings(QString); + static QString getSetting(QString); + static void addStringSetting(QString, QString, bool); + static void addIntSetting(QString, int, bool); + static void addDoubleSetting(QString, double, bool); + + static QString getFileName(QWidget*, const QString&, const QStringList&, const QString&, bool); + static QStringList getOpenFileNames(QWidget*, const QString&, const QStringList&, const QString&); + static QString getExistingDirectory(QWidget*, const QString&, const QString&); + static void helpContext(const QString&, const QString&); + static bool dumpView(const QString&); +}; -- 2.39.2