From 8a02a929809e2aebc321a043fbca55754f5d0237 Mon Sep 17 00:00:00 2001 From: jfa Date: Fri, 10 Mar 2006 10:56:06 +0000 Subject: [PATCH] Join modifications from branch BR_L_2_3_5. --- src/LightApp/LightApp_Application.cxx | 31 ++++++ src/LightApp/LightApp_Application.h | 6 ++ src/LightApp/LightApp_Study.cxx | 2 + src/LightApp/LightApp_Study.h | 148 +++++++++++++------------- src/PyInterp/PyInterp_base.cxx | 6 +- src/Qtx/QtxDockAction.cxx | 44 +++++++- src/Qtx/QtxDockAction.h | 2 + 7 files changed, 163 insertions(+), 76 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 5affcb5d9..ad9682a94 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -135,6 +135,13 @@ static const char* imageEmptyIcon[] = { "....................", "...................."}; +int LightApp_Application::lastStudyId = 0; + +int LightApp_Application::studyId() +{ + return LightApp_Application::lastStudyId; +} + /*!Create new instance of LightApp_Application.*/ extern "C" LIGHTAPP_EXPORT SUIT_Application* createApplication() { @@ -1409,6 +1416,8 @@ void LightApp_Application::updateActions() //======================================================================= SUIT_Study* LightApp_Application::createNewStudy() { + LightApp_Application::lastStudyId++; + LightApp_Study* aStudy = new LightApp_Study( this ); // Set up processing of major study-related events @@ -1836,6 +1845,11 @@ void LightApp_Application::updateDesktopTitle() { if ( !aVer.isEmpty() ) aTitle += QString( " " ) + aVer; + if ( activeStudy() ) { + QString sName = SUIT_Tools::file( activeStudy()->studyName().stripWhiteSpace(), false ); + aTitle += QString( " - [%1]" ).arg( sName ); + } + desktop()->setCaption( aTitle ); } @@ -1891,6 +1905,9 @@ void LightApp_Application::currentViewManagers( QStringList& lst ) const /*!Update windows.*/ void LightApp_Application::updateWindows() { + if ( !activeStudy() ) + return; + QMap winMap; currentWindows( winMap ); @@ -2106,3 +2123,17 @@ bool LightApp_Application::isLibExists( const QString& moduleTitle ) const return false; } +/*! default name for an active study */ +void LightApp_Application::setDefaultStudyName( const QString& theName ) +{ + QStringList anInfoList; + modules( anInfoList, false ); + + LightApp_Study* aStudy = (LightApp_Study*)activeStudy(); + if( anInfoList.count() == 1 && // to avoid a conflict between different modules + !aStudy->isSaved() ) + { + aStudy->setStudyName( theName ); + updateDesktopTitle(); + } +} diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index bfcf376d6..c435188a4 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -125,6 +125,10 @@ public: SUIT_Accel* accel() const; + void setDefaultStudyName( const QString& theName ); + + static int studyId(); + signals: void studyOpened(); void studySaved(); @@ -218,6 +222,8 @@ protected: SUIT_Accel* myAccel; static LightApp_Preferences* _prefs_; + + static int lastStudyId; }; #ifdef WIN32 diff --git a/src/LightApp/LightApp_Study.cxx b/src/LightApp/LightApp_Study.cxx index 31cb22594..0b8b9005e 100644 --- a/src/LightApp/LightApp_Study.cxx +++ b/src/LightApp/LightApp_Study.cxx @@ -67,6 +67,8 @@ LightApp_Study::~LightApp_Study() */ void LightApp_Study::createDocument() { + setStudyName( QString( "Study%1" ).arg( LightApp_Application::studyId() ) ); + // create myRoot setRoot( new LightApp_RootObject( this ) ); diff --git a/src/LightApp/LightApp_Study.h b/src/LightApp/LightApp_Study.h index 1280fd99a..2e0ac3226 100644 --- a/src/LightApp/LightApp_Study.h +++ b/src/LightApp/LightApp_Study.h @@ -16,76 +16,78 @@ // // See http://www.salome-platform.org/ // -#ifndef LIGHTAPP_STUDY_H -#define LIGHTAPP_STUDY_H - -#include -#include - -#include -#include -#include - -#include "string" -#include "vector" - -class SUIT_Application; -class CAM_DataModel; - -class LIGHTAPP_EXPORT LightApp_Study : public CAM_Study -{ - Q_OBJECT - -public: - LightApp_Study( SUIT_Application* ); - virtual ~LightApp_Study(); - - virtual void createDocument(); - virtual bool openDocument( const QString& ); - virtual bool loadDocument( const QString& ); - - virtual bool saveDocument(); - virtual bool saveDocumentAs( const QString& ); - - virtual void closeDocument(bool permanently = true); - - virtual bool isSaved() const; - virtual bool isModified() const; - - virtual void addComponent ( const CAM_DataModel* dm); - - virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile ); - - virtual QString componentDataType( const QString& ) const; - virtual QString referencedToEntry( const QString& ) const; - virtual bool isComponent( const QString& ) const; - virtual void children( const QString&, QStringList& ) const; - virtual void components( QStringList& ) const; - -protected: - virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); - virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles ); - virtual bool saveStudyData ( const QString& theFileName ); - virtual bool openStudyData ( const QString& theFileName ); - - virtual std::vector GetListOfFiles ( const char* theModuleName ) const; - virtual void SetListOfFiles ( const char* theModuleName, - const std::vector theListOfFiles ); - - virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const; - -protected: - virtual bool openDataModel ( const QString&, CAM_DataModel* ); - -signals: - void saved ( SUIT_Study* ); - void opened ( SUIT_Study* ); - void closed ( SUIT_Study* ); - void created( SUIT_Study* ); - - -private: - LightApp_Driver* myDriver; -}; - -#endif +#ifndef LIGHTAPP_STUDY_H +#define LIGHTAPP_STUDY_H + +#include +#include + +#include +#include +#include + +#include "string" +#include "vector" + +class SUIT_Application; +class CAM_DataModel; + +class LIGHTAPP_EXPORT LightApp_Study : public CAM_Study +{ + Q_OBJECT + +public: + LightApp_Study( SUIT_Application* ); + virtual ~LightApp_Study(); + + virtual void createDocument(); + virtual bool openDocument( const QString& ); + virtual bool loadDocument( const QString& ); + + virtual bool saveDocument(); + virtual bool saveDocumentAs( const QString& ); + + virtual void closeDocument(bool permanently = true); + + virtual bool isSaved() const; + virtual bool isModified() const; + + virtual void addComponent ( const CAM_DataModel* dm); + + virtual std::string GetTmpDir ( const char* theURL, const bool isMultiFile ); + + virtual QString componentDataType( const QString& ) const; + virtual QString referencedToEntry( const QString& ) const; + virtual bool isComponent( const QString& ) const; + virtual void children( const QString&, QStringList& ) const; + virtual void components( QStringList& ) const; + +protected: + virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles ); + virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles ); + virtual bool saveStudyData ( const QString& theFileName ); + virtual bool openStudyData ( const QString& theFileName ); + + virtual std::vector GetListOfFiles ( const char* theModuleName ) const; + virtual void SetListOfFiles ( const char* theModuleName, + const std::vector theListOfFiles ); + + virtual void RemoveTemporaryFiles ( const char* theModuleName, const bool isMultiFile ) const; + +protected: + virtual bool openDataModel ( const QString&, CAM_DataModel* ); + +signals: + void saved ( SUIT_Study* ); + void opened ( SUIT_Study* ); + void closed ( SUIT_Study* ); + void created( SUIT_Study* ); + + +private: + LightApp_Driver* myDriver; + + friend class LightApp_Application; +}; + +#endif diff --git a/src/PyInterp/PyInterp_base.cxx b/src/PyInterp/PyInterp_base.cxx index 69ccefc9d..0e0a5622c 100644 --- a/src/PyInterp/PyInterp_base.cxx +++ b/src/PyInterp/PyInterp_base.cxx @@ -112,8 +112,10 @@ void PyInterp_base::initialize() // Create cStringIO to capture stdout and stderr PycString_IMPORT; - _vout = PycStringIO->NewOutput(128); - _verr = PycStringIO->NewOutput(128); + if (PycStringIO) { // CTH11627 : additional check + _vout = PycStringIO->NewOutput(128); + _verr = PycStringIO->NewOutput(128); + } // All the initRun outputs are redirected to the standard output (console) initRun(); diff --git a/src/Qtx/QtxDockAction.cxx b/src/Qtx/QtxDockAction.cxx index 89e72344c..0a0295559 100755 --- a/src/Qtx/QtxDockAction.cxx +++ b/src/Qtx/QtxDockAction.cxx @@ -28,6 +28,7 @@ #include #include #include +#include #include /*! @@ -707,7 +708,36 @@ void QtxDockAction::dockWindows( QPtrList& lst, QMainWindow* main ) if ( !mw ) return; - lst = mw->dockWindows(); + QObjectList* objs = mw->queryList( "QDockWindow" ); + if ( objs ) + { + for ( QObjectListIt it( *objs ); it.current(); ++it ) + { + QDockWindow* dockWin = ::qt_cast( it.current() ); + if ( dockWin && dockMainWindow( mw, dockWin ) ) + lst.append( dockWin ); + } + } + delete objs; +} + +bool QtxDockAction::dockMainWindow( QMainWindow* mw, QObject* win ) const +{ + if ( !mw || !win ) + return false; + + while ( win ) + { + if ( win->parent() && win->parent() == mw ) + return true; + + if ( ::qt_cast( win->parent() ) ) + return false; + + win = win->parent(); + } + + return false; } /*! @@ -772,6 +802,14 @@ void QtxDockAction::loadPlaceInfo( QDockWindow* dw ) const if ( !myInfo.contains( dw ) ) return; + QMainWindow* mw = mainWindow(); + if ( !mw ) + return; + + QObject* p = dw->parent(); + if ( !( !p || p == mw || ( p->parent() && p->parent() == mw ) ) ) + return; + QString winName = myInfo[dw].name; if ( winName.isEmpty() || !myGeom.contains( winName ) ) return; @@ -807,6 +845,10 @@ void QtxDockAction::loadPlaceInfo() const QMap nameMap; for ( QPtrListIterator itr( lst ); itr.current(); ++itr ) { + QObject* p = itr.current()->parent(); + if ( !( !p || p == mw || ( p->parent() && p->parent() == mw ) ) ) + continue; + QString name; if ( myInfo.contains( itr.current() ) ) name = myInfo[itr.current()].name; diff --git a/src/Qtx/QtxDockAction.h b/src/Qtx/QtxDockAction.h index 4583bebda..5e3ae2de8 100755 --- a/src/Qtx/QtxDockAction.h +++ b/src/Qtx/QtxDockAction.h @@ -121,6 +121,8 @@ private: void updateMenus(); + bool dockMainWindow( QMainWindow*, QObject* ) const; + private: enum { AutoAdd = QEvent::User, LoadArea }; -- 2.39.2