#include <ModuleBase_PageBase.h>
#include <ModuleBase_PageWidget.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
#include <QEvent>
#include <QFrame>
#include <QIcon>
this, SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)),
this, SIGNAL(keyReleased(QKeyEvent*)));
- }
- ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
- if (aLastWidget) {
- QList<QWidget*> aControls = aLastWidget->getControls();
- if (!aControls.empty()) {
- QWidget* aLastControl = aControls.last();
+ connect(aWidget, SIGNAL(enterClicked()),
+ this, SIGNAL(enterClicked()));
- QToolButton* anOkBtn = findChild<QToolButton*>(PROP_PANEL_OK);
- QToolButton* aCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
-
- setTabOrder(aLastControl, anOkBtn);
- setTabOrder(anOkBtn, aCancelBtn);
- }
}
}
ModuleBase_PageBase* XGUI_PropertyPanel::contentWidget()
{
-
return static_cast<ModuleBase_PageBase*>(myPanelPage);
}
activateWidget(NULL);
return;
}
+ ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
+
QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
bool isFoundWidget = false;
- activateWindow();
+ ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()");
for (; anIt != aLast; anIt++) {
+ ModuleBase_ModelWidget* aCurrentWidget = *anIt;
if (isFoundWidget || !theWidget) {
- if ((*anIt)->focusTo()) {
+
+ if (!aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID()))
+ continue; // this attribute is not participated in the current case
+
+ if (aCurrentWidget->focusTo()) {
return;
}
}
- isFoundWidget = (*anIt) == theWidget;
+ isFoundWidget = isFoundWidget || (*anIt) == theWidget;
}
activateWidget(NULL);
}
+bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
+{
+ // it wraps the Tabs clicking to follow in the chain:
+ // controls, last control, Apply, Cancel, first control, controls
+
+ bool isChangedFocus = false;
+ if (theIsNext) { // forward by Tab
+ QToolButton* aCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
+ if (aCancelBtn->hasFocus()) {
+ // after cancel, the first control should be focused
+ QWidget* aFirstControl = 0;
+ for (int i = 0, aSize = myWidgets.size(); i < aSize && !aFirstControl; i++)
+ aFirstControl = myWidgets[i]->getControlAcceptingFocus(true);
+ if (aFirstControl)
+ ModuleBase_Tools::setFocus(aFirstControl, "XGUI_PropertyPanel::focusNextPrevChild()");
+ isChangedFocus = true;
+ }
+ else {
+ // after the last control, the Apply button should be focused
+ QWidget* aLastControl = 0;
+ for (int i = myWidgets.size()-1; i >= 0 && !aLastControl; i--)
+ aLastControl = myWidgets[i]->getControlAcceptingFocus(false);
+ if (aLastControl && aLastControl->hasFocus()) {
+ setFocusOnOkButton();
+ isChangedFocus = true;
+ }
+ }
+ }
+ else { // backward by SHIFT + Tab
+ QToolButton* anOkBtn = findChild<QToolButton*>(PROP_PANEL_OK);
+ if (anOkBtn->hasFocus()) {
+ // after Apply, the last control should be focused
+ QWidget* aLastControl = 0;
+ for (int i = myWidgets.size()-1; i >= 0 && !aLastControl; i--)
+ aLastControl = myWidgets[i]->getControlAcceptingFocus(false);
+ if (aLastControl)
+ ModuleBase_Tools::setFocus(aLastControl, "XGUI_PropertyPanel::focusNextPrevChild()");
+ isChangedFocus = true;
+ }
+ else {
+ // after the first control, the Cancel button should be focused
+ QWidget* aFirstControl = 0;
+ for (int i = 0, aSize = myWidgets.size(); i < aSize && !aFirstControl; i++)
+ aFirstControl = myWidgets[i]->getControlAcceptingFocus(true);
+ if (aFirstControl && aFirstControl->hasFocus()) {
+ QToolButton* aCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
+ ModuleBase_Tools::setFocus(aCancelBtn, "XGUI_PropertyPanel::focusNextPrevChild()");
+ isChangedFocus = true;
+ }
+ }
+ }
+
+ if (!isChangedFocus)
+ isChangedFocus = ModuleBase_IPropertyPanel::focusNextPrevChild(theIsNext);
+
+ return isChangedFocus;
+}
+
void XGUI_PropertyPanel::activateNextWidget()
{
activateNextWidget(myActiveWidget);
}
void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
+{
+ std::string aPreviosAttributeID;
+ if(myActiveWidget)
+ aPreviosAttributeID = myActiveWidget->attributeID();
+
+ // Avoid activation of already actve widget. It could happen on focusIn event many times
+ if (setActiveWidget(theWidget)) {
+ emit widgetActivated(myActiveWidget);
+ if (!myActiveWidget && !isEditingMode()) {
+ emit noMoreWidgets(aPreviosAttributeID);
+ }
+ }
+}
+
+bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget)
{
// Avoid activation of already actve widget. It could happen on focusIn event many times
if (theWidget == myActiveWidget) {
- return;
+ return false;
}
+ std::string aPreviosAttributeID;
if(myActiveWidget) {
+ aPreviosAttributeID = myActiveWidget->attributeID();
myActiveWidget->deactivate();
myActiveWidget->setHighlighted(false);
}
theWidget->activate();
}
myActiveWidget = theWidget;
- if (myActiveWidget) {
- emit widgetActivated(theWidget);
- } else if (!isEditingMode()) {
- emit noMoreWidgets();
- }
+ return true;
}
void XGUI_PropertyPanel::setFocusOnOkButton()
{
QToolButton* anOkBtn = findChild<QToolButton*>(PROP_PANEL_OK);
- anOkBtn->setFocus();
+ ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::setFocusOnOkButton()");
}
void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
ModuleBase_Operation* aOp = myOperationMgr->currentOperation();
if (aOp) {
if (myOperationMgr->canStopOperation(aOp)) {
- myOperationMgr->abortOperation(aOp);
+ myOperationMgr->abortAllOperations();
theEvent->accept();
} else
theEvent->ignore();
} else
ModuleBase_IPropertyPanel::closeEvent(theEvent);
-}
\ No newline at end of file
+}