From: nds Date: Tue, 12 Apr 2016 11:47:16 +0000 (+0300) Subject: Issue #1383 Preview button: using Config_FeatureMessage instead of list of parameters... X-Git-Tag: V_2.3.0~240^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=62a50ecb27688868d4bd44535d20fc3a45aff368;p=modules%2Fshaper.git Issue #1383 Preview button: using Config_FeatureMessage instead of list of parameters in SALOME mode. --- diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 587069d6c..ef44ec327 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -543,33 +543,15 @@ QAction* SHAPERGUI::command(const QString& theId) const return 0; } -//****************************************************** -void SHAPERGUI::setNestedActions(const QString& theId, const QStringList& theActions) -{ - myNestedActions[theId] = theActions; -} - -//****************************************************** -QStringList SHAPERGUI::nestedActions(const QString& theId) const -{ - if (myNestedActions.contains(theId)) - return myNestedActions[theId]; - return QStringList(); -} - -//****************************************************** -void SHAPERGUI::setDocumentKind(const QString& theId, const QString& theKind) +void SHAPERGUI::setFeatureInfo(const QString& theFeatureId, + const std::shared_ptr& theMessage) { - myDocumentType[theId] = theKind; + myFeaturesInfo.insert(theFeatureId, theMessage); } -//****************************************************** -QString SHAPERGUI::documentKind(const QString& theId) const +const std::shared_ptr& SHAPERGUI::featureInfo(const QString& theFeatureId) { - if (myDocumentType.contains(theId)) - return myDocumentType[theId]; - return QString(); - + return myFeaturesInfo.contains(theFeatureId) ? myFeaturesInfo[theFeatureId] : NULL; } //****************************************************** diff --git a/src/SHAPERGUI/SHAPERGUI.h b/src/SHAPERGUI/SHAPERGUI.h index 7efea881a..ed007ff91 100644 --- a/src/SHAPERGUI/SHAPERGUI.h +++ b/src/SHAPERGUI/SHAPERGUI.h @@ -92,21 +92,16 @@ Q_OBJECT virtual QAction* command(const QString& theId) const; - //! Set nested actions dependent on command Id - //! \param theId - the command ID - //! \param theActions - the list of nested actions - virtual void setNestedActions(const QString& theId, const QStringList& theActions); + //! Stores XML information for the feature kind + //! \param theFeatureId a feature kind + //! \param theMessage a container of the feature XML properties + virtual void setFeatureInfo(const QString& theFeatureId, + const std::shared_ptr& theMessage); - //! Returns list of nested actions according to the given command ID - virtual QStringList nestedActions(const QString& theId) const; - - //! Set the document kind of the action by the given command Id - //! \param theId - the command ID - //! \param theKind - the document kind - virtual void setDocumentKind(const QString& theId, const QString& theKind); - - //! Returns the document kind of the action by the given command ID - virtual QString documentKind(const QString& theId) const; + //! Returns XML information for the feature kind + //! \param theFeatureId a feature kind + //! \return theMessage a container of the feature XML properties + virtual const std::shared_ptr& featureInfo(const QString& theFeatureId); //! Returns interface to Salome viewer virtual ModuleBase_IViewer* viewer() const @@ -197,11 +192,8 @@ Q_OBJECT /// Proxy viewer for connection to OCC Viewer in SALOME SHAPERGUI_SalomeViewer* myProxyViewer; - /// Map of nested actions [ActionID: list of nested actions Id] - QMap myNestedActions; - - /// Map of document types - QMap myDocumentType; + /// Map of feature kind to a container of XML properties for the feature + QMap > myFeaturesInfo; /// Flag of opened document state bool myIsOpened; diff --git a/src/XGUI/XGUI_ActionsMgr.cpp b/src/XGUI/XGUI_ActionsMgr.cpp index f5e19cc92..849175197 100644 --- a/src/XGUI/XGUI_ActionsMgr.cpp +++ b/src/XGUI/XGUI_ActionsMgr.cpp @@ -61,7 +61,11 @@ void XGUI_ActionsMgr::addCommand(QAction* theCmd) myActions.insert(aId, theCmd); #ifdef HAVE_SALOME XGUI_Workshop* aWorkshop = static_cast(parent()); - myNestedActions[aId] = aWorkshop->salomeConnector()->nestedActions(aId); + const std::shared_ptr& anInfo = + aWorkshop->salomeConnector()->featureInfo(aId); + if (anInfo.get()) + myNestedActions[aId] = QString::fromStdString(anInfo->nestedFeatures()) + .split(" ", QString::SkipEmptyParts); #else AppElements_Command* aXCmd = dynamic_cast(theCmd); myNestedActions[aId] = aXCmd->nestedCommands(); @@ -363,7 +367,8 @@ void XGUI_ActionsMgr::updateByDocumentKind() #ifdef HAVE_SALOME QString aId = eachAction->data().toString(); if (!aId.isEmpty()) { - aCmdDocKind = aWorkshop->salomeConnector()->documentKind(aId); + aCmdDocKind = QString::fromStdString( + aWorkshop->salomeConnector()->featureInfo(aId)->documentKind()); } #else AppElements_Command* aCmd = dynamic_cast(eachAction); diff --git a/src/XGUI/XGUI_SalomeConnector.h b/src/XGUI/XGUI_SalomeConnector.h index ac2c60f40..3000b8350 100644 --- a/src/XGUI/XGUI_SalomeConnector.h +++ b/src/XGUI/XGUI_SalomeConnector.h @@ -11,6 +11,7 @@ #include class QMainWindow; +class Config_FeatureMessage; class ModuleBase_IViewer; /** @@ -99,21 +100,16 @@ class XGUI_EXPORT XGUI_SalomeConnector //! Returns list of Ids of defined actions (just by NewGeom module) virtual QStringList commandIdList() const = 0; - //! Set nested actions dependent on command Id - //! \param theId - the command ID - //! \param theActions - the list of nested actions - virtual void setNestedActions(const QString& theId, const QStringList& theActions) = 0; + //! Stores XML information for the feature kind + //! \param theFeatureId a feature kind + //! \param theMessage a container of the feature XML properties + virtual void setFeatureInfo(const QString& theFeatureId, + const std::shared_ptr& theMessage) = 0; - //! Returns list of nested actions according to the given command ID - virtual QStringList nestedActions(const QString& theId) const = 0; - - //! Set the document kind of the action by the given command Id - //! \param theId - the command ID - //! \param theKind - the document kind - virtual void setDocumentKind(const QString& theId, const QString& theKind) = 0; - - //! Returns the document kind of the action by the given command ID - virtual QString documentKind(const QString& theId) const = 0; + //! Returns XML information for the feature kind + //! \param theFeatureId a feature kind + //! \return theMessage a container of the feature XML properties + virtual const std::shared_ptr& featureInfo(const QString& theFeatureId) = 0; //! Returns interface to Salome viewer virtual ModuleBase_IViewer* viewer() const = 0; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 82fd1bcf4..e7d8483fb 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -485,7 +485,7 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation) // update visible state of Preview button #ifdef HAVE_SALOME - bool anIsAutoPreview = true;//mySalomeConnector->featureInfo(aFeatureKind)->isAutoPreview(); + bool anIsAutoPreview = mySalomeConnector->featureInfo(aFeatureKind.c_str())->isAutoPreview(); #else AppElements_MainMenu* aMenuBar = mainWindow()->menuObject(); AppElements_Command* aCommand = aMenuBar->feature(aFeatureKind.c_str()); @@ -612,8 +612,13 @@ void XGUI_Workshop::setGrantedFeatures(ModuleBase_Operation* theOperation) return; QStringList aGrantedIds; - if (isSalomeMode()) - aGrantedIds = mySalomeConnector->nestedActions(theOperation->id()); + if (isSalomeMode()) { + const std::shared_ptr& anInfo = + mySalomeConnector->featureInfo(theOperation->id()); + if (anInfo.get()) + aGrantedIds = QString::fromStdString(anInfo->nestedFeatures()) + .split(" ", QString::SkipEmptyParts); + } else aGrantedIds = myActionsMgr->nestedCommands(theOperation->id()); diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index 51b2d7405..ff6e73792 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -483,7 +483,6 @@ void XGUI_WorkshopListener::addFeature(const std::shared_ptrworkbenchId()); QStringList aNestedFeatures = QString::fromStdString(theMessage->nestedFeatures()).split(" ", QString::SkipEmptyParts); - QString aDocKind = QString::fromStdString(theMessage->documentKind()); QList aNestedActList; bool isColumnButton = !aNestedFeatures.isEmpty(); if (isColumnButton) { @@ -512,8 +511,7 @@ void XGUI_WorkshopListener::addFeature(const std::shared_ptraddFeature(aWchName, aFeatureInfo); } - aSalomeConnector->setNestedActions(aFeatureInfo.id, aNestedFeatures); - aSalomeConnector->setDocumentKind(aFeatureInfo.id, aDocKind); + aSalomeConnector->setFeatureInfo(aFeatureInfo.id, theMessage); aWorkshop->actionsMgr()->addCommand(aAction); aWorkshop->module()->actionCreated(aAction);