From eb5a696ee9e1438a1e0dfadec0d7b58d329fe3c8 Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 16 Oct 2012 08:25:57 +0000 Subject: [PATCH] 0021478: EDF 2083 ALL: Write the version of Salome used to create the study in the hdf file --- src/CAM/CAM_Application.cxx | 18 ++++---- src/CAM/CAM_Application.h | 22 ++++----- src/SalomeApp/CMakeLists.txt | 2 + src/SalomeApp/Makefile.am | 6 ++- .../SalomeApp_Engine_i.cxx | 22 ++++++++- .../SalomeApp_Engine_i.h} | 8 ++-- src/SalomeApp/SalomeApp_Study.cxx | 2 +- .../SalomeApp_StudyPropertiesDlg.cxx | 45 ++++++++++++++----- src/SalomeApp/SalomeApp_StudyPropertiesDlg.h | 1 + src/SalomeApp/resources/SalomeApp_msg_en.ts | 12 +++++ src/SalomeApp/resources/SalomeApp_msg_fr.ts | 12 +++++ src/Session/CMakeLists.txt | 2 - src/Session/Makefile.am | 6 +-- 13 files changed, 114 insertions(+), 44 deletions(-) rename src/{Session => SalomeApp}/SalomeApp_Engine_i.cxx (95%) rename src/{Session/SalomeApp_Engine_i.hxx => SalomeApp/SalomeApp_Engine_i.h} (97%) mode change 100755 => 100644 diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index fc99c754c..0f742ad87 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -82,6 +82,8 @@ extern "C" CAM_EXPORT SUIT_Application* createApplication() - etc */ +CAM_Application::ModuleInfoList CAM_Application::myInfoList; + /*! \brief Constructor. @@ -361,7 +363,7 @@ CAM_Module* CAM_Application::loadModule( const QString& modName, const bool show char* version = getVersion ? getVersion() : 0; - if(version) { + if ( version ) { for ( ModuleInfoList::iterator it = myInfoList.begin(); it != myInfoList.end(); ++it ) { if ( (*it).title == modName ) { if( (*it).version.isEmpty() ) { @@ -518,7 +520,7 @@ void CAM_Application::moduleAdded( CAM_Module* /*mod*/ ) \param title module title (user name) \return module name or null QString if module is not found */ -QString CAM_Application::moduleName( const QString& title ) const +QString CAM_Application::moduleName( const QString& title ) { QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it ) @@ -534,7 +536,7 @@ QString CAM_Application::moduleName( const QString& title ) const \param name module name \return module title (user name) or null QString if module is not found */ -QString CAM_Application::moduleTitle( const QString& name ) const +QString CAM_Application::moduleTitle( const QString& name ) { QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it ) @@ -550,7 +552,7 @@ QString CAM_Application::moduleTitle( const QString& name ) const \param name module name \return module icon or null QString if module is not found */ -QString CAM_Application::moduleIcon( const QString& name ) const +QString CAM_Application::moduleIcon( const QString& name ) { QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isNull(); ++it ) @@ -568,7 +570,7 @@ QString CAM_Application::moduleIcon( const QString& name ) const \param title module title (user name) \return \c true if module is accessible (can be loaded) or \c false otherwise */ -bool CAM_Application::isModuleAccessible( const QString& title ) const +bool CAM_Application::isModuleAccessible( const QString& title ) { bool found = false; bool blocked = false; @@ -599,7 +601,7 @@ bool CAM_Application::isModuleAccessible( const QString& title ) const \param full if \c true, return full library name, otherwise return its internal name \return module library name or null QString if module is not found */ -QString CAM_Application::moduleLibrary( const QString& title, const bool full ) const +QString CAM_Application::moduleLibrary( const QString& title, const bool full ) { QString res; for ( ModuleInfoList::const_iterator it = myInfoList.begin(); it != myInfoList.end() && res.isEmpty(); ++it ) @@ -777,8 +779,8 @@ void CAM_Application::createEmptyStudy() /*! \brief Return information about version of the each module. */ -CAM_Application::ModuleShortInfoList CAM_Application::getVersionInfo() const { - +CAM_Application::ModuleShortInfoList CAM_Application::getVersionInfo() +{ ModuleShortInfoList info; ModuleShortInfo kernel; diff --git a/src/CAM/CAM_Application.h b/src/CAM/CAM_Application.h index 45b527a65..546781b97 100755 --- a/src/CAM/CAM_Application.h +++ b/src/CAM/CAM_Application.h @@ -66,14 +66,14 @@ public: virtual void contextMenuPopup( const QString&, QMenu*, QString& ); - QString moduleName( const QString& ) const; - QString moduleTitle( const QString& ) const; - QString moduleIcon( const QString& ) const; - bool isModuleAccessible( const QString& ) const; + static QString moduleName( const QString& ); + static QString moduleTitle( const QString& ); + static QString moduleIcon( const QString& ); + static bool isModuleAccessible( const QString& ); virtual void createEmptyStudy(); - ModuleShortInfoList getVersionInfo() const; + static ModuleShortInfoList getVersionInfo(); protected: virtual SUIT_Study* createNewStudy(); @@ -86,7 +86,7 @@ protected: virtual void setActiveStudy( SUIT_Study* ); - QString moduleLibrary( const QString&, const bool = true ) const; + static QString moduleLibrary( const QString&, const bool = true ); private: void readModuleList(); @@ -96,11 +96,11 @@ private: typedef QList ModuleInfoList; private: - CAM_Module* myModule; //!< active module - ModuleList myModules; //!< loaded modules list - ModuleInfoList myInfoList; //!< modules info list - bool myAutoLoad; //!< auto loading flag - bool myBlocked; //!< "blocked" flag, internal usage + CAM_Module* myModule; //!< active module + ModuleList myModules; //!< loaded modules list + static ModuleInfoList myInfoList; //!< modules info list + bool myAutoLoad; //!< auto loading flag + bool myBlocked; //!< "blocked" flag, internal usage }; #ifdef WIN32 diff --git a/src/SalomeApp/CMakeLists.txt b/src/SalomeApp/CMakeLists.txt index 5418df21f..0ade4fd05 100755 --- a/src/SalomeApp/CMakeLists.txt +++ b/src/SalomeApp/CMakeLists.txt @@ -126,6 +126,7 @@ SET(SalomeApp_SOURCES SalomeApp_NoteBookDlg.cxx SalomeApp_DoubleSpinBox.cxx SalomeApp_IntSpinBox.cxx + SalomeApp_Engine_i.cxx ) SET(GUITS_SOURCES @@ -160,6 +161,7 @@ SET(COMMON_HEADERS_H SalomeApp_NoteBookDlg.h SalomeApp_DoubleSpinBox.h SalomeApp_IntSpinBox.h + SalomeApp_Engine_i.h ) INSTALL(FILES ${COMMON_HEADERS_H} DESTINATION ${GUI_salomeinclude_HEADERS}) diff --git a/src/SalomeApp/Makefile.am b/src/SalomeApp/Makefile.am index 6191bd8e2..2d6d0b7ec 100755 --- a/src/SalomeApp/Makefile.am +++ b/src/SalomeApp/Makefile.am @@ -57,7 +57,8 @@ salomeinclude_HEADERS = \ SalomeApp_ExitDlg.h \ SalomeApp_NoteBookDlg.h \ SalomeApp_DoubleSpinBox.h \ - SalomeApp_IntSpinBox.h + SalomeApp_IntSpinBox.h \ + SalomeApp_Engine_i.h dist_libSalomeApp_la_SOURCES = \ SalomeApp_Module.cxx \ @@ -79,7 +80,8 @@ dist_libSalomeApp_la_SOURCES = \ SalomeApp_ExitDlg.cxx \ SalomeApp_NoteBookDlg.cxx \ SalomeApp_DoubleSpinBox.cxx \ - SalomeApp_IntSpinBox.cxx + SalomeApp_IntSpinBox.cxx \ + SalomeApp_Engine_i.cxx MOC_FILES = \ SalomeApp_Application_moc.cxx \ diff --git a/src/Session/SalomeApp_Engine_i.cxx b/src/SalomeApp/SalomeApp_Engine_i.cxx similarity index 95% rename from src/Session/SalomeApp_Engine_i.cxx rename to src/SalomeApp/SalomeApp_Engine_i.cxx index 15bb917c1..6c803e2ff 100644 --- a/src/Session/SalomeApp_Engine_i.cxx +++ b/src/SalomeApp/SalomeApp_Engine_i.cxx @@ -24,7 +24,8 @@ // File : SalomeApp_Engine_i.cxx // Author : Alexander SLADKOV -#include "SalomeApp_Engine_i.hxx" +#include "SalomeApp_Engine_i.h" +#include "SalomeApp_Application.h" #include #include @@ -278,6 +279,24 @@ char* SalomeApp_Engine_i::ComponentDataType() return const_cast( myComponentName.c_str() ); } +/*! + \return Component version +*/ +char* SalomeApp_Engine_i::getVersion() +{ + SalomeApp_Application::ModuleShortInfoList versions = SalomeApp_Application::getVersionInfo(); + QString version; + SalomeApp_Application::ModuleShortInfo version_info; + foreach ( version_info, versions ) { + if ( SalomeApp_Application::moduleName( version_info.name ) == myComponentName.c_str() ) { + version = version_info.version; + break; + } + } + + return CORBA::string_dup( version.toLatin1().constData() ); +} + /*! \return */ @@ -393,4 +412,3 @@ SalomeApp_Engine_i* SalomeApp_Engine_i::GetInstance( const char* theComponentNam theComponentName << ", aServant = " << aServant); return aServant; } - diff --git a/src/Session/SalomeApp_Engine_i.hxx b/src/SalomeApp/SalomeApp_Engine_i.h old mode 100755 new mode 100644 similarity index 97% rename from src/Session/SalomeApp_Engine_i.hxx rename to src/SalomeApp/SalomeApp_Engine_i.h index 0e728da62..51b8f6967 --- a/src/Session/SalomeApp_Engine_i.hxx +++ b/src/SalomeApp/SalomeApp_Engine_i.h @@ -27,7 +27,7 @@ #ifndef _SALOMEAPP_ENGINE_I_HXX_ #define _SALOMEAPP_ENGINE_I_HXX_ -#include "SALOME_Session.hxx" +#include "SalomeApp.h" #include "SALOME_Component_i.hxx" @@ -39,8 +39,8 @@ class SALOME_NamingService; -class SESSION_EXPORT SalomeApp_Engine_i: public POA_SalomeApp::Engine, - public Engines_Component_i +class SALOMEAPP_EXPORT SalomeApp_Engine_i: public POA_SalomeApp::Engine, + public Engines_Component_i { public: SalomeApp_Engine_i( const char* theComponentName ); @@ -88,6 +88,8 @@ public: CORBA::Boolean CanPaste( const char*, CORBA::Long ) {return 0;} SALOMEDS::SObject_ptr PasteInto( const SALOMEDS::TMPFile&, CORBA::Long, SALOMEDS::SObject_ptr ) {return 0;} + char* getVersion(); + private: static CORBA::ORB_var orb(); static PortableServer::POA_var poa(); diff --git a/src/SalomeApp/SalomeApp_Study.cxx b/src/SalomeApp/SalomeApp_Study.cxx index 1a38c88e1..a6dd9377f 100644 --- a/src/SalomeApp/SalomeApp_Study.cxx +++ b/src/SalomeApp/SalomeApp_Study.cxx @@ -26,7 +26,7 @@ #include "SalomeApp_DataObject.h" #include "SalomeApp_DataModel.h" #include "SalomeApp_Application.h" -#include "SalomeApp_Engine_i.hxx" +#include "SalomeApp_Engine_i.h" #include "SalomeApp_VisualState.h" // temporary commented diff --git a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx index 2fd7dcb8a..54abf6d2f 100644 --- a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx +++ b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.cxx @@ -109,9 +109,20 @@ SalomeApp_StudyPropertiesDlg::SalomeApp_StudyPropertiesDlg(QWidget* parent) QStringList columnNames; columnNames.append(tr("PRP_AUTHOR")); columnNames.append(tr("PRP_DATE_MODIF")); + myModifications->setHeaderLabels( columnNames ); - QTreeWidgetItem * headerItem = new QTreeWidgetItem(columnNames); - myModifications->setHeaderItem ( headerItem ); + //Component versions + QLabel* versionsLabel = new QLabel(tr("PRP_VERSIONS"),this); + myVersions = new QTreeWidget(this); + myVersions->setRootIsDecorated(false); + myVersions->setUniformRowHeights(true); + myVersions->setAllColumnsShowFocus(true); + myVersions->setColumnCount(2); + myVersions->setMaximumHeight(80); + columnNames.clear(); + columnNames.append(tr("PRP_COMPONENT")); + columnNames.append(tr("PRP_VERSION")); + myVersions->setHeaderLabels( columnNames ); QFrame* buttonFrame = new QFrame(this); @@ -140,7 +151,9 @@ SalomeApp_StudyPropertiesDlg::SalomeApp_StudyPropertiesDlg(QWidget* parent) gridLayout->addWidget(myComment, 4, 1, 1, 2); gridLayout->addWidget(modificationsLabel, 5, 0, 1, 1); gridLayout->addWidget(myModifications, 5, 1, 1, 2); - gridLayout->addWidget(buttonFrame, 6, 0, 1, 3); + gridLayout->addWidget(versionsLabel, 6, 0, 1, 1); + gridLayout->addWidget(myVersions, 6, 1, 1, 2); + gridLayout->addWidget(buttonFrame, 7, 0, 1, 3); connect(myOkButton, SIGNAL(clicked()), this, SLOT(clickOnOk())); connect(myCancelButton, SIGNAL(clicked()), this, SLOT(reject())); @@ -183,15 +196,11 @@ void SalomeApp_StudyPropertiesDlg::initData() bool isModified = false; SalomeApp_Study* study = dynamic_cast (SUIT_Session::session()->activeApplication()->activeStudy()); - if (study) { - isModified = study->isModified(); - if (hasData) { - if (propAttr->IsModified() != isModified) { - propAttr->SetModified((int)isModified); - } - } + isModified = study->isModified(); + if (propAttr->IsModified() != isModified) { + propAttr->SetModified((int)isModified); } - + QString modif = propAttr->IsModified() ? tr( "PRP_MODIFIED" ) : tr( "PRP_NOT_MODIFIED" ); myModification->setText(modif); @@ -236,6 +245,20 @@ void SalomeApp_StudyPropertiesDlg::initData() QTreeWidgetItem* item = new QTreeWidgetItem(aList); myModifications->addTopLevelItem(item); } + + //Component versions + std::vector aComponents = propAttr->GetStoredComponents(); + for ( int i = 0; i < aComponents.size(); i++ ) { + std::vector aMins, aHours, aDays, aMonths, aYears; + std::vector aVersions = propAttr->GetComponentVersions(aComponents[i]); + QStringList aData; + aData.append( aComponents[i].c_str() ); + aData.append( aVersions.empty() || aVersions[0] == "" ? "unknown" : aVersions[0].c_str() ); + QTreeWidgetItem* item = new QTreeWidgetItem( aData ); + if ( aVersions.size() > 1 ) + item->setForeground( 1, Qt::red ); + myVersions->addTopLevelItem(item); + } } adjustSize(); } diff --git a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h index 8ff0500d9..ad8c18246 100644 --- a/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h +++ b/src/SalomeApp/SalomeApp_StudyPropertiesDlg.h @@ -69,6 +69,7 @@ private: QComboBox* myUnits; QTextEdit* myComment; QTreeWidget* myModifications; + QTreeWidget* myVersions; QPushButton* myOkButton; QPushButton* myCancelButton; }; diff --git a/src/SalomeApp/resources/SalomeApp_msg_en.ts b/src/SalomeApp/resources/SalomeApp_msg_en.ts index c248a811d..dedd0f7c6 100644 --- a/src/SalomeApp/resources/SalomeApp_msg_en.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_en.ts @@ -363,6 +363,18 @@ Do you want to reload it ? PRP_MODIFICATIONS Modifications + + PRP_COMPONENT + Component + + + PRP_VERSION + Version + + + PRP_VERSIONS + Stored data + PRP_DATE_MODIF Date diff --git a/src/SalomeApp/resources/SalomeApp_msg_fr.ts b/src/SalomeApp/resources/SalomeApp_msg_fr.ts index dc4f87c52..9adf4ae95 100755 --- a/src/SalomeApp/resources/SalomeApp_msg_fr.ts +++ b/src/SalomeApp/resources/SalomeApp_msg_fr.ts @@ -363,6 +363,18 @@ Voulez-vous le recharger ? PRP_MODIFICATIONS Modifications + + PRP_COMPONENT + Component + + + PRP_VERSION + Version + + + PRP_VERSIONS + Stored data + PRP_DATE_MODIF Date diff --git a/src/Session/CMakeLists.txt b/src/Session/CMakeLists.txt index 2968dfecd..2a8cf2c8d 100755 --- a/src/Session/CMakeLists.txt +++ b/src/Session/CMakeLists.txt @@ -69,7 +69,6 @@ SET(SalomeSession_SOURCES Session_ServerThread.cxx Session_ServerLauncher.cxx Session_ServerCheck.cxx - SalomeApp_Engine_i.cxx ) ADD_LIBRARY(SalomeSession SHARED ${SalomeSession_SOURCES}) SET_TARGET_PROPERTIES(SalomeSession PROPERTIES COMPILE_FLAGS "${COMMON_FLAGS}") @@ -106,6 +105,5 @@ SET(COMMON_HEADERS_H Session_ServerLauncher.hxx Session_ServerThread.hxx Session_ServerCheck.hxx - SalomeApp_Engine_i.hxx ) INSTALL(FILES ${COMMON_HEADERS_H} DESTINATION ${GUI_salomeinclude_HEADERS}) diff --git a/src/Session/Makefile.am b/src/Session/Makefile.am index eaf315c84..26a25db0c 100755 --- a/src/Session/Makefile.am +++ b/src/Session/Makefile.am @@ -35,8 +35,7 @@ salomeinclude_HEADERS = \ SALOME_Session.hxx \ Session_ServerLauncher.hxx \ Session_ServerThread.hxx \ - Session_ServerCheck.hxx \ - SalomeApp_Engine_i.hxx + Session_ServerCheck.hxx # Libraries targets @@ -44,8 +43,7 @@ dist_libSalomeSession_la_SOURCES = \ Session_Session_i.cxx \ Session_ServerThread.cxx \ Session_ServerLauncher.cxx \ - Session_ServerCheck.cxx \ - SalomeApp_Engine_i.cxx + Session_ServerCheck.cxx libSalomeSession_la_CPPFLAGS = $(QT_MT_INCLUDES) $(PYTHON_INCLUDES) \ $(HDF5_INCLUDES) $(BOOST_CPPFLAGS) @KERNEL_CXXFLAGS@ $(CAS_CPPFLAGS) \ -- 2.39.2