#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;
if (aOperation) {
- ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
+ aPanel = aOperation->propertyPanel();
if (aPanel)
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();
+ if (isChildObject(theObject, aBrowser) ||
+ isChildObject(theObject, aViewPort))
+ 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;
+}
public slots:
/// SLOT, that is called by the key in the property panel is clicked.
/// \param theEvent the mouse event
- bool onKeyReleased(QKeyEvent* theEvent);
+ /// \param theObject a sender of the event
+ bool onKeyReleased(QObject *theObject, QKeyEvent* theEvent);
/// The functionaly, that should be done by delete click
/// Fistly the active widget processes it, then workshop. If no one does not
/// process it, do nothing
- bool onProcessDelete();
+ /// \param theObject a sender of the event
+ bool onProcessDelete(QObject* theObject);
protected slots:
/// The functionaly, that should be done by enter click
/// Fistly the active widget processes it, then module. If no one does not
/// process it, the current operation is committed
- bool onProcessEnter();
+ /// \param theObject a sender of the event
+ bool onProcessEnter(QObject *theObject);
/// Slot that is called by an operation stop. Removes the stopped operation form the stack.
/// If there is a suspended operation, restart it.
private:
XGUI_Workshop* workshop() const;
+ /// Checks if the object is a parent or a child under
+ /// \param theObject an investivated object
+ /// \param theParent a candidate to be a parent
+ static bool isChildObject(const QObject* theObject, const QObject* theParent);
+
private:
typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
Operations myOperations; ///< a stack of started operations. The active operation is on top,