1. Focus processing(focusTo is boolean for a constraint editor, focusOut in eventFilter to start a new line creation in an indepmendent place in case of contour, remove the previous focusActivate functionality of the create operation).
return theFeature->data()->attribute(attributeID())->isInitialized();
}
-bool ModuleBase_ModelWidget::canFocusTo(const std::string& theAttributeName) const
-{
- return theAttributeName == attributeID();
-}
-
-void ModuleBase_ModelWidget::focusTo()
+bool ModuleBase_ModelWidget::focusTo()
{
QList<QWidget*> aControls = getControls();
QList<QWidget*>::const_iterator anIt = aControls.begin(), aLast = aControls.end();
break;
}
}
+ return true;
}
std::string ModuleBase_ModelWidget::attributeID() const
virtual bool restoreValue(FeaturePtr theFeature) = 0;
- /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
- /// \param theAttribute name
- bool canFocusTo(const std::string& theAttributeName) const;
-
/// Set focus to the first control of the current widget. The focus policy of the control is checked.
/// If the widget has the NonFocus focus policy, it is skipped.
- virtual void focusTo();
+ /// \return the state whether the widget can accept the focus
+ virtual bool focusTo();
/// Returns list of widget controls
/// \return a control list
{
if (theObject == mySpinBox) {
if (theEvent->type() == QEvent::KeyRelease) {
+ QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent;
+ if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) {
+ emit focusOutWidget(this);
+ }
emit keyReleased(attributeID(), (QKeyEvent*) theEvent);
return true;
}
return aValue;
}
-void ModuleBase_WidgetEditor::focusTo()
+bool ModuleBase_WidgetEditor::focusTo()
{
double aValue = mySpinBox->value();
bool isDone;
}
emit valuesChanged();
emit focusOutWidget(this);
+
+ return false;
}
void ModuleBase_WidgetEditor::editFeatureValue(FeaturePtr theFeature, const std::string theAttribute)
/// Set focus to the first control of the current widget. The focus policy of the control is checked.
/// If the widget has the NonFocus focus policy, it is skipped.
- virtual void focusTo();
+ /// \return the state whether the widget can accept the focus
+ virtual bool focusTo();
/// Creates an editor for the real value and set the new value to the feature
/// \param theFeature the model feature
{
if (theObject == myXSpin || theObject == myYSpin) {
if (theEvent->type() == QEvent::KeyRelease) {
+ QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent;
+ if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) {
+ emit focusOutWidget(this);
+ }
emit keyReleased(attributeID(), (QKeyEvent*) theEvent);
return true;
}
myWorkshop->operationMgr()->currentOperation());
if (aPreviewOp) {
XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
- connect(aPreviewOp, SIGNAL(focusActivated(const std::string&)),
- aPropPanel, SLOT(onFocusActivated(const std::string&)));
-
connect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)), Qt::UniqueConnection);
}
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
if (aPreviewOp) {
XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
- disconnect(aPreviewOp, SIGNAL(focusActivated(const std::string&)),
- aPropPanel, SLOT(onFocusActivated(const std::string&)));
//disconnect(aPropPanel, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
// this, SLOT(onStorePoint2D(FeaturePtr, const std::string&)));
}
}
}
}
- /*if (feature()->getKind() == SKETCH_ARC_KIND) {
- boost::shared_ptr<PartSet_FeatureArcPrs> anArcPrs =
- boost::dynamic_pointer_cast<PartSet_FeatureArcPrs>(myFeaturePrs);
- if (anArcPrs) {
- anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY);
- }
- }*/
bool isApplyed = false;
if (isPointWidget())
isApplyed = setWidgetPoint(aX, anY);
double aX, anY;
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
- /*if (myPointSelectionMode == SM_ThirdPoint) {
- if (feature()->getKind() == SKETCH_ARC_KIND) {
- boost::shared_ptr<PartSet_FeatureArcPrs> anArcPrs =
- boost::dynamic_pointer_cast<PartSet_FeatureArcPrs>(myFeaturePrs);
- if (anArcPrs) {
- anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY);
- }
- }
- }*/
setWidgetPoint(aX, anY);
flushUpdated();
}
return aNewFeature;
}
-/*void PartSet_OperationFeatureCreate::setPointSelectionMode(const PartSet_SelectionMode& theMode,
- const bool isToEmitSignal)
-{
- myPointSelectionMode = theMode;
- if (isToEmitSignal) {
- std::string aName = myFeaturePrs->getAttribute(theMode);
- if (aName.empty() && theMode == SM_DonePoint) {
- aName = XGUI::PROP_PANEL_OK;
- }
- emit focusActivated(aName);
- }
-}*/
-
bool PartSet_OperationFeatureCreate::isPointWidget() const
{
return dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget) ||
virtual FeaturePtr createFeature(const bool theFlushMessage = true);
protected:
- ///< Set the point selection mode. Emit signal about focus change if necessary.
- /// \param theMode a new selection mode
- /// \param isToEmitSignal the neccessity to emit signal
- //void setPointSelectionMode(const PartSet_SelectionMode& theMode,
- // const bool isToEmitSignal = true);
-
/// Returns true if the active widget is the point selector widget
/// \return the boolean value
bool isPointWidget() const;
/// theName the operation name
/// theFeature the operation argument
void launchOperation(std::string theName, FeaturePtr theFeature);
- /// signal about the focus activated
- /// theName the attribute name
- void focusActivated(const std::string& theAttibuteName);
-
/// Signal about the feature construing is finished
/// \param theFeature the result feature
/// \param theMode the mode of the feature modification
connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
this, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
+ connect(*anIt, SIGNAL(activated(ModuleBase_ModelWidget*)),
+ this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)));
+
ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
if (aPointWidget)
connect(aPointWidget, SIGNAL(storedPoint2D(FeaturePtr, const std::string&)),
setTabOrder(anOkBtn, aCancelBtn);
}
}
- ModuleBase_ModelWidget* aWidget = theWidgets.first();
- if (aWidget) {
- activateWidget(aWidget);
- }
+ onActivateNextWidget(0);
}
}
repaint();
}
-void XGUI_PropertyPanel::onFocusActivated(const std::string& theAttributeName)
-{
- if (theAttributeName == XGUI::PROP_PANEL_OK) {
- QPushButton* aBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
- aBtn->setFocus();
- }
- if (theAttributeName == XGUI::PROP_PANEL_CANCEL) {
- QPushButton* aBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
- aBtn->setFocus();
- }
- else {
- foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
- if (eachWidget->canFocusTo(theAttributeName)) {
- eachWidget->focusTo();
- break;
- }
- }
- }
-}
-
void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
{
ModuleBase_ModelWidget* aNextWidget = 0;
-
QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(),
aLast = myWidgets.end();
- for (;anIt != aLast; anIt++)
+ bool isFoundWidget = false;
+ for (;anIt != aLast && !aNextWidget; anIt++)
{
- if ((*anIt) == theWidget) {
- anIt++;
- if (anIt != aLast)
+ if (isFoundWidget || !theWidget) {
+ if ((*anIt)->focusTo()) {
aNextWidget = *anIt;
- break;
+ }
}
+ isFoundWidget = (*anIt) == theWidget;
}
- activateWidget(aNextWidget);
-}
-
-void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
-{
- emit widgetActivated(theWidget);
- // it is important that the signal widgetActivated goes before the focusTo() calling
- // in order to handle next possible signal in the focusTo() method
- // (e.g. the widget editor sends a signal about the widget deactivation)
- if (theWidget)
- theWidget->focusTo();
+ emit widgetActivated(aNextWidget);
}
public slots:
void updateContentWidget(FeaturePtr theFeature);
- /// slot to set the focus to the widget visualized an attribute with the given name
- /// \param theAttributteName
- void onFocusActivated(const std::string& theAttributeName);
/// slot to activate the next widget in the property panel
/// \param theWidget a widget. The next widget should be activated
void onActivateNextWidget(ModuleBase_ModelWidget* theWidget);
/// \param the attribute of the feature
void storedPoint2D(FeaturePtr theFeature, const std::string& theAttribute);
-protected:
- /// Activate the widget, which means the focus on the widget.
- /// The signal about the widget activation is emitted
- /// \param theWidget
- void activateWidget(ModuleBase_ModelWidget* theWidget);
-
private:
QWidget* myCustomWidget;