connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered()));
}
-QStringList PartSet_Module::nestedFeatures(QString)
-{
- return QStringList();
-}
-
std::string PartSet_Module::featureFile(const std::string& theFeatureId)
{
return myFeaturesInFiles[theFeatureId];
/// Called on creation of menu item in desktop
virtual void featureCreated(QAction* theFeature);
- /// Returnc list of nested commands for the given feature
- virtual QStringList nestedFeatures(QString theFeature);
std::string featureFile(const std::string&);
/// Creates an operation and send it to loop
if (myOperationMgr->hasOperation()) {
setAllEnabled(false);
ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
- QString anOperationId = anOperation->id();
+ FeaturePtr aFeature = anOperation->feature();
+ QString anOperationId = QString::fromStdString(aFeature->getKind()); //anOperation->id();
setActionEnabled(anOperationId, true);
bool isNestedEnabled = anOperation->isNestedOperationsEnabled();
setNestedCommandsEnabled(isNestedEnabled, anOperationId);
{
QStringList ltNestedActions;
if (theParent.isEmpty()) { //Disable ALL nested
- foreach(QString eachParent, myNestedActions.keys())
- {
+ foreach(QString eachParent, myNestedActions.keys()) {
ltNestedActions << myNestedActions[eachParent];
}
} else {
ltNestedActions << myNestedActions[theParent];
}
- foreach(QString eachNested, ltNestedActions)
- {
+ foreach(QString eachNested, ltNestedActions) {
setActionEnabled(eachNested, theEnabled);
}
}
void XGUI_ActionsMgr::updateCheckState()
{
QString eachCommand = QString();
- foreach(eachCommand, myActions.keys())
- {
+ foreach(eachCommand, myActions.keys()) {
setActionChecked(eachCommand, false);
}
QStringList ltActiveCommands = myOperationMgr->operationList();
- foreach(eachCommand, ltActiveCommands)
- {
+ foreach(eachCommand, ltActiveCommands) {
setActionChecked(eachCommand, true);
}
}
#include "XGUI_Command.h"
#include <QEvent>
#include <QToolButton>
+#include <QVariant>
+#include <QDebug>
XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
: QWidgetAction(parent),
void XGUI_Command::setNestedCommands(const QStringList& myUnblockableCommands)
{
this->myNestedCommands = myUnblockableCommands;
-}
+}
\ No newline at end of file
QStringList XGUI_OperationMgr::operationList()
{
QStringList result;
- foreach(ModuleBase_Operation* eachOperation, myOperations)
- {
- result << eachOperation->id();
+ foreach(ModuleBase_Operation* eachOperation, myOperations) {
+ FeaturePtr aFeature = eachOperation->feature();
+ if(aFeature) {
+ result << QString::fromStdString(aFeature->getKind());
+ }
}
return result;
}
bool XGUI_OperationMgr::abortAllOperations()
{
- if (operationsCount() == 1) {
+ if(!hasOperation()) {
+ return true;
+ } else if (operationsCount() == 1) {
onAbortOperation();
return true;
}
{
// Let the manager decide what to do with the given key combination.
ModuleBase_Operation* anOperation = currentOperation();
- if(anOperation) {
- anOperation->activateNextToCurrentWidget();
- }
bool isRestart = false;
switch (theEvent->key()) {
case Qt::Key_Escape: {
break;
case Qt::Key_Return:
case Qt::Key_Enter: {
+ if(anOperation) {
+ anOperation->activateNextToCurrentWidget();
+ }
commitOperation();
}
break;
setTabOrder(anOkBtn, aCancelBtn);
}
}
- onActivateNextWidget(NULL);
}
const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
}
myPropertyPanel->setModelWidgets(aWidgets);
+ myPropertyPanel->onActivateNextWidget(NULL);
myPropertyPanel->setWindowTitle(aOperation->getDescription()->description());
}
updateCommandStatus();
aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
} else {
XGUI_MainMenu* aMenu = myMainWindow->menuObject();
- aCommand = aMenu->feature(theOperation->getDescription()->operationId());
+ FeaturePtr aFeature = theOperation->feature();
+ if(aFeature)
+ aCommand = aMenu->feature(QString::fromStdString(aFeature->getKind()));
}
//Abort operation on uncheck the command
- if (aCommand)
+ if (aCommand) {
connect(aCommand, SIGNAL(triggered(bool)), theOperation, SLOT(setRunning(bool)));
+ }
}
/*
if (aMgr->hasModuleDocument()) {
QAction* aUndoCmd;
QAction* aRedoCmd;
- foreach(QAction* aCmd, aCommands)
- {
+ foreach(QAction* aCmd, aCommands) {
QString aId = aCmd->data().toString();
if (aId == "UNDO_CMD")
aUndoCmd = aCmd;
aUndoCmd->setEnabled(aMgr->canUndo());
aRedoCmd->setEnabled(aMgr->canRedo());
} else {
- foreach(QAction* aCmd, aCommands)
- {
+ foreach(QAction* aCmd, aCommands) {
QString aId = aCmd->data().toString();
if (aId == "NEW_CMD")
aCmd->setEnabled(true);
//**************************************************************
void XGUI_Workshop::updateCommandsOnViewSelection()
{
- SessionPtr aMgr = ModelAPI_Session::get();
- ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
XGUI_Selection* aSelection = mySelector->selection();
if (aSelection->getSelected().size() == 0)
return;
+ // Restrict validators to manage only nested (child) features
+ // of the current feature i.e. if current feature is Sketch -
+ // Sketch Features & Constraints can be validated.
+ QStringList aNestedIds;
+ if(myOperationMgr->hasOperation()) {
+ FeaturePtr aFeature = myOperationMgr->currentOperation()->feature();
+ if(aFeature) {
+ aNestedIds << myActionsMgr->nestedCommands(QString::fromStdString(aFeature->getKind()));
+ }
+ }
+ SessionPtr aMgr = ModelAPI_Session::get();
+ ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
QList<QAction*> aActions = getModuleCommands();
- foreach(QAction* aAction, aActions)
- {
+ foreach(QAction* aAction, aActions) {
QString aId = aAction->data().toString();
+ if(!aNestedIds.contains(aId))
+ continue;
std::list<ModelAPI_Validator*> aValidators;
std::list<std::list<std::string> > anArguments;
aFactory->validators(aId.toStdString(), aValidators, anArguments);