From: nds Date: Wed, 23 Dec 2015 13:35:09 +0000 (+0300) Subject: Correction tab logic. X-Git-Tag: V_2.1.0~60 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e25330fc6173134d1b9e5ac4580fc7ccc32c519e;p=modules%2Fshaper.git Correction tab logic. --- diff --git a/src/ModuleBase/ModuleBase_ToolBox.cpp b/src/ModuleBase/ModuleBase_ToolBox.cpp index 7f8736a25..592b5a032 100644 --- a/src/ModuleBase/ModuleBase_ToolBox.cpp +++ b/src/ModuleBase/ModuleBase_ToolBox.cpp @@ -49,6 +49,7 @@ void ModuleBase_ToolBox::addItem( QWidget* thePage, const QString& theName, cons aButton->setIcon( theIcon ); aButton->setIconSize( theIcon.size() ); aButton->setToolTip( theName ); + aButton->setObjectName( theName ); myButtonsGroup->addButton( aButton, anOldCount ); myButtonsLayout->insertWidget( anOldCount, aButton ); } diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 95dfd185f..40149e343 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -125,6 +125,9 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen } myListControl = new CustomListWidget(this); + QString anObjName = QString::fromStdString(attributeID()); + myListControl->setObjectName(anObjName); + aMainLay->addWidget(myListControl, 2, 0, 1, -1); aMainLay->setRowStretch(2, 1); //aMainLay->addWidget(new QLabel(this)); //FIXME(sbh)??? diff --git a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp index 47fc4b44c..4db52fd2a 100644 --- a/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetShapeSelector.cpp @@ -81,6 +81,8 @@ ModuleBase_WidgetShapeSelector::ModuleBase_WidgetShapeSelector(QWidget* theParen QString aToolTip = QString::fromStdString(theData->widgetTooltip()); myTextLine = new QLineEdit(this); + QString anObjName = QString::fromStdString(attributeID()); + myTextLine->setObjectName(anObjName); myTextLine->setReadOnly(true); myTextLine->setToolTip(aToolTip); myTextLine->installEventFilter(this); diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 413059e2a..1e61bf5e7 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -181,12 +181,91 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) activateWidget(NULL); } +#ifdef DEBUG_TAB +void findDirectChildren(QWidget* theParent, QList& theWidgets, const bool theDebug) +{ + QList aWidgets; + + if (theParent) { + QLayout* aLayout = theParent->layout(); + if (aLayout) { + for (int i = 0, aCount = aLayout->count(); i < aCount; i++) { + QLayoutItem* anItem = aLayout->itemAt(i); + QWidget* aWidget = anItem ? anItem->widget() : 0; + if (aWidget && aWidget->isVisible()) { + if (aWidget->focusPolicy() != Qt::NoFocus) + theWidgets.append(aWidget); + findDirectChildren(aWidget, theWidgets, false); + } + else { + if (aWidget) { + QString anInfo = QString("widget [%1] is visible = %2, nofocus policy = %3").arg(aWidget->objectName()). + arg(aWidget->isVisible()).arg(aWidget->focusPolicy() == Qt::NoFocus); + qDebug(anInfo.toStdString().c_str()); + } + } + } + } + } + if (theDebug) { + QStringList aWidgetTypes; + QList::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end(); + for (; anIt != aLast; anIt++) { + QWidget* aWidget = *anIt; + if (aWidget) + aWidgetTypes.append(aWidget->objectName()); + } + QString anInfo = QString("theWidgets[%1]: %2").arg(theWidgets.count()).arg(aWidgetTypes.join(",")); + qDebug(anInfo.toStdString().c_str()); + } +} + 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; + + QWidget* aFocusWidget = focusWidget(); + if (aFocusWidget) { + QString anInfo = QString("focus Widget: %1").arg(aFocusWidget->objectName()); + qDebug(anInfo.toStdString().c_str()); + } + QWidget* aNewFocusWidget = 0; + if (theIsNext) { + if (aFocusWidget) { + QList aChildren; + findDirectChildren(this, aChildren, true); + + int aChildrenCount = aChildren.count(); + int aFocusWidgetIndex = aChildren.indexOf(aFocusWidget); + if (aFocusWidgetIndex >= 0) { + if (aFocusWidgetIndex == aChildrenCount-1) { + QToolButton* anOkBtn = findChild(PROP_PANEL_OK); + aNewFocusWidget = anOkBtn; + } + else { + aNewFocusWidget = aChildren[aFocusWidgetIndex+1]; + } + } + } + } + else { + } + if (aNewFocusWidget) { + ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::focusNextPrevChild()"); + isChangedFocus = true; + } + return isChangedFocus; +} +#else +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(PROP_PANEL_CANCEL); if (aCancelBtn->hasFocus()) { @@ -235,10 +314,10 @@ bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext) if (!isChangedFocus) isChangedFocus = ModuleBase_IPropertyPanel::focusNextPrevChild(theIsNext); - return isChangedFocus; } +#endif void XGUI_PropertyPanel::activateNextWidget() { activateNextWidget(myActiveWidget);