#include "XGUI_ModuleConnector.h"
#include "XGUI_Workshop.h"
#include "XGUI_ErrorMgr.h"
+#include <XGUI_ObjectsBrowser.h>
#include <ModuleBase_IPropertyPanel.h>
#include <ModuleBase_ModelWidget.h>
if(aKeyEvent) {
switch (aKeyEvent->key()) {
case Qt::Key_Delete: {
- isAccepted = myOperationMgr->onProcessDelete();
+ isAccepted = myOperationMgr->onProcessDelete(theObject);
}
}
}
bool isAccepted = false;
if (theEvent->type() == QEvent::KeyRelease) {
QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
- if(aKeyEvent) {
- isAccepted = onKeyReleased(aKeyEvent);
- }
+ if(aKeyEvent)
+ isAccepted = onKeyReleased(theObject, aKeyEvent);
}
if (!isAccepted)
isAccepted = QObject::eventFilter(theObject, theEvent);
}
}
-bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent)
+bool XGUI_OperationMgr::onKeyReleased(QObject *theObject, QKeyEvent* theEvent)
{
// Let the manager decide what to do with the given key combination.
ModuleBase_Operation* anOperation = currentOperation();
switch (theEvent->key()) {
case Qt::Key_Return:
case Qt::Key_Enter: {
- isAccepted = onProcessEnter();
+ isAccepted = onProcessEnter(theObject);
}
break;
case Qt::Key_N:
return isAccepted;
}
-bool XGUI_OperationMgr::onProcessEnter()
+bool XGUI_OperationMgr::onProcessEnter(QObject* theObject)
{
bool isAccepted = false;
ModuleBase_Operation* aOperation = currentOperation();
ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ // only property panel enter is processed in order to do not process enter in application dialogs
+ bool isPPChild = isChildObject(theObject, aPanel);
+ if (!isPPChild)
+ return isAccepted;
+
ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget();
bool isAborted = false;
if (!anActiveWgt) {
return isAccepted;
}
-bool XGUI_OperationMgr::onProcessDelete()
+bool XGUI_OperationMgr::onProcessDelete(QObject* theObject)
{
bool isAccepted = false;
ModuleBase_Operation* aOperation = currentOperation();
ModuleBase_ModelWidget* anActiveWgt = 0;
+ // firstly the widget should process Delete action
+ ModuleBase_IPropertyPanel* aPanel;
+ bool isPPChildObject = false;
if (aOperation) {
- ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
- if (aPanel)
- anActiveWgt = aPanel->activeWidget();
+ aPanel = aOperation->propertyPanel();
+ if (aPanel) {
+ isPPChildObject = isChildObject(theObject, aPanel);
+ // process delete in active widget only if delete sender is child of property panel
+ // it is necessary for the case when OB is shown, user perform selection and click Delete
+ if (isPPChildObject) {
+ anActiveWgt = aPanel->activeWidget();
+ if (anActiveWgt) {
+ isAccepted = anActiveWgt->processDelete();
+ }
+ }
+ }
}
- if (anActiveWgt)
- isAccepted = anActiveWgt->processDelete();
if (!isAccepted) {
- workshop()->deleteObjects();
+ // after widget, object browser and viewer should process delete
+ /// other widgets such as line edit controls should not lead to
+ /// processing delete by workshop
+ XGUI_ObjectsBrowser* aBrowser = workshop()->objectBrowser();
+ QWidget* aViewPort = myWorkshop->viewer()->activeViewPort();
+ // property panel childe object is processed to process delete performed on Apply button of PP
+ if (isChildObject(theObject, aBrowser) ||
+ isChildObject(theObject, aViewPort) ||
+ isPPChildObject)
+ workshop()->deleteObjects();
isAccepted = true;
}
return aConnector->workshop();
}
+bool XGUI_OperationMgr::isChildObject(const QObject* theObject, const QObject* theParent)
+{
+ bool isPPChild = false;
+ if (theParent && theObject) {
+ QObject* aParent = (QObject*)theObject;
+ while (aParent ) {
+ isPPChild = aParent == theParent;
+ if (isPPChild)
+ break;
+ aParent = aParent->parent();
+ }
+ }
+ return isPPChild;
+}