The document kind is saved in the NewGeom module for each action.
return QStringList();
}
+//******************************************************
+void NewGeom_Module::setDocumentKind(const QString& theId, const QString& theKind)
+{
+ myDocumentType[theId] = theKind;
+}
+
+//******************************************************
+QString NewGeom_Module::documentKind(const QString& theId) const
+{
+ if (myDocumentType.contains(theId))
+ return myDocumentType[theId];
+ return QString();
+
+}
+
//******************************************************
void NewGeom_Module::selectionChanged()
{
//! 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 interface to Salome viewer
virtual ModuleBase_IViewer* viewer() const
{
NewGeom_SalomeViewer* myProxyViewer;
QMap<QString, QStringList> myNestedActions;
+ QMap<QString, QString> myDocumentType;
bool myIsOpened;
bool myIsStorePositions;
{
std::string aStdDocKind = ModelAPI_Session::get()->activeDocument()->kind();
QString aDocKind = QString::fromStdString(aStdDocKind);
+ XGUI_Workshop* aWorkshop = static_cast<XGUI_Workshop*>(parent());
foreach(QAction* eachAction, myActions.values()) {
XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(eachAction);
+ QString aCmdDocKind;
if(aCmd) {
- QString aCmdDocKind = aCmd->documentKind();
- if(!aCmdDocKind.isEmpty() && aCmdDocKind != aDocKind) {
- eachAction->setEnabled(false);
+ aCmdDocKind = aCmd->documentKind();
+ }
+ else {
+ QString aId = eachAction->data().toString();
+ if (!aId.isEmpty()) {
+ aCmdDocKind = aWorkshop->salomeConnector()->documentKind(aId);
}
}
+ if(!aCmdDocKind.isEmpty() && aCmdDocKind != aDocKind) {
+ eachAction->setEnabled(false);
+ }
}
}
//! 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 interface to Salome viewer
virtual ModuleBase_IViewer* viewer() const = 0;
QKeySequence(),
isUsePropPanel);
salomeConnector()->setNestedActions(aFeatureId, aNestedFeatures.split(" ", QString::SkipEmptyParts));
+ salomeConnector()->setDocumentKind(aFeatureId, QString::fromStdString(theMessage->documentKind()));
+
myActionsMgr->addCommand(aAction);
myModule->featureCreated(aAction);
} else {