From: vsv Date: Fri, 6 Jul 2018 12:38:31 +0000 (+0300) Subject: Issue #2513: Provide selection for selector in undocked window X-Git-Tag: EDF_2018-1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5fbbaa3e846b1dbf241bd08850c7b5e23a6be582;p=modules%2Fshaper.git Issue #2513: Provide selection for selector in undocked window --- diff --git a/src/ModuleBase/ModuleBase_ListView.cpp b/src/ModuleBase/ModuleBase_ListView.cpp index d1dc0158a..a245b9e6f 100644 --- a/src/ModuleBase/ModuleBase_ListView.cpp +++ b/src/ModuleBase/ModuleBase_ListView.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #ifndef WIN32 @@ -34,47 +33,6 @@ const int ATTRIBUTE_SELECTION_INDEX_ROLE = Qt::UserRole + 1; -/** -* Customization of a List Widget to make it to be placed on full width of container -*/ -class CustomListWidget : public QListWidget -{ -public: - /// Constructor - /// \param theParent a parent widget - CustomListWidget(QWidget* theParent) - : QListWidget(theParent) - { - } - - /// Redefinition of virtual method - virtual QSize sizeHint() const - { - int aHeight = 2*QFontMetrics(font()).height(); - QSize aSize = QListWidget::sizeHint(); - return QSize(aSize.width(), aHeight); - } - - /// Redefinition of virtual method - virtual QSize minimumSizeHint() const - { - int aHeight = 4/*2*/*QFontMetrics(font()).height(); - QSize aSize = QListWidget::minimumSizeHint(); - return QSize(aSize.width(), aHeight); - } - -#ifndef WIN32 -// The code is necessary only for Linux because -//it can not update viewport on widget resize -protected: - void resizeEvent(QResizeEvent* theEvent) - { - QListWidget::resizeEvent(theEvent); - QTimer::singleShot(5, viewport(), SLOT(repaint())); - } -#endif -}; - //******************************************************************** ModuleBase_ListView::ModuleBase_ListView(QWidget* theParent, const QString& theObjectName, const QString& theToolTip) @@ -98,6 +56,7 @@ ModuleBase_ListView::ModuleBase_ListView(QWidget* theParent, const QString& theO myListControl->setContextMenuPolicy(Qt::ActionsContextMenu); connect(myListControl, SIGNAL(itemSelectionChanged()), SLOT(onListSelection())); + connect(myListControl, SIGNAL(activated()), this, SIGNAL(listActivated())); } //******************************************************************** diff --git a/src/ModuleBase/ModuleBase_ListView.h b/src/ModuleBase/ModuleBase_ListView.h index 9fd0f578a..6cafd597c 100644 --- a/src/ModuleBase/ModuleBase_ListView.h +++ b/src/ModuleBase/ModuleBase_ListView.h @@ -25,6 +25,7 @@ #include #include +#include #include @@ -32,6 +33,59 @@ class QAction; class QListWidget; class QWidget; + +/** +* Customization of a List Widget to make it to be placed on full width of container +*/ +class CustomListWidget : public QListWidget +{ + Q_OBJECT +public: + /// Constructor + /// \param theParent a parent widget + CustomListWidget(QWidget* theParent) + : QListWidget(theParent) + { + } + + /// Redefinition of virtual method + virtual QSize sizeHint() const + { + int aHeight = 2 * QFontMetrics(font()).height(); + QSize aSize = QListWidget::sizeHint(); + return QSize(aSize.width(), aHeight); + } + + /// Redefinition of virtual method + virtual QSize minimumSizeHint() const + { + int aHeight = 4/*2*/ * QFontMetrics(font()).height(); + QSize aSize = QListWidget::minimumSizeHint(); + return QSize(aSize.width(), aHeight); + } + +signals: + void activated(); + +protected: + virtual void mouseReleaseEvent(QMouseEvent* e) { + QListWidget::mouseReleaseEvent(e); + emit activated(); + } + +#ifndef WIN32 + // The code is necessary only for Linux because + //it can not update viewport on widget resize +protected: + void resizeEvent(QResizeEvent* theEvent) + { + QListWidget::resizeEvent(theEvent); + QTimer::singleShot(5, viewport(), SLOT(repaint())); + } +#endif +}; + + /** * \ingroup GUI * An extension of QListWidget to provide Undo/Redo functionality @@ -85,10 +139,13 @@ protected slots: /// Slot is called on selection of list of selected items void onListSelection(); + signals: /// Signal about delete action click void deleteActionClicked(); + void listActivated(); + protected: QListWidget* myListControl; ///< List control diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 8dd40756b..44b11938f 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -155,6 +155,7 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen myListView = new ModuleBase_ListView(this, anObjName, aToolTip); connect(myListView->getControl(), SIGNAL(itemSelectionChanged()), SLOT(onListSelection())); connect(myListView, SIGNAL(deleteActionClicked()), SLOT(onDeleteItem())); + connect(myListView, SIGNAL(listActivated()), SLOT(onListActivated())); aMainLay->addWidget(myListView->getControl(), 2, 0, 1, -1); aMainLay->setRowStretch(2, 1); @@ -1019,3 +1020,9 @@ void ModuleBase_WidgetMultiSelector::onFeatureAccepted() { defaultValues[myFeatureId + attributeID()] = myDefMode; } + +void ModuleBase_WidgetMultiSelector::onListActivated() +{ + //focusTo(); + emitFocusInWidget(); +} \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 221ba0e6b..1a40c1303 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -130,6 +130,8 @@ protected slots: /// Slot is called on selection of list of selected items void onListSelection(); + void onListActivated(); + protected: /// Returns true if the event is processed. The default implementation is empty, returns false. virtual bool processDelete(); diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 0ea8af4c0..3ce0ed171 100755 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -402,8 +402,8 @@ bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext) #endif ModuleBase_ModelWidget* aFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this, aFocusWidget); - if (aFocusMWidget) - aFocusMWidget->setHighlighted(false); + //if (aFocusMWidget) + // aFocusMWidget->setHighlighted(false); QWidget* aNewFocusWidget = 0; if (aFocusWidget) { @@ -459,9 +459,13 @@ bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext) ModuleBase_ModelWidget* aNewFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this, aNewFocusWidget); - if (aNewFocusMWidget) + if (aNewFocusMWidget) { + if (aFocusMWidget) { + aFocusMWidget->setHighlighted(false); + } aNewFocusMWidget->emitFocusInWidget(); - isChangedFocus = true; + isChangedFocus = true; + } } return isChangedFocus; }