From 668152fa53c6b93d14f6ec2fda7833ea220763d0 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 29 Apr 2016 17:14:10 +0300 Subject: [PATCH] implementation "clear_in_neutral_point" for multi-selection control --- src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp | 13 +++++++++++++ src/ModuleBase/ModuleBase_WidgetMultiSelector.h | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 180f0ee8b..2e0c7e0ea 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -156,6 +156,8 @@ ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParen myListControl->setContextMenuPolicy(Qt::ActionsContextMenu); connect(myListControl, SIGNAL(itemSelectionChanged()), SLOT(onListSelection())); + + myIsNeutralPointClear = theData->getBooleanAttribute("clear_in_neutral_point", true); } ModuleBase_WidgetMultiSelector::~ModuleBase_WidgetMultiSelector() @@ -379,6 +381,17 @@ void ModuleBase_WidgetMultiSelector::onSelectionTypeChanged() myWorkshop->setSelected(anEmptyList); } +//******************************************************************** +void ModuleBase_WidgetMultiSelector::onSelectionChanged() +{ + if (!myIsNeutralPointClear) { + QList aSelected = getFilteredSelected(); + if (aSelected.size() == 0) + return; + } + ModuleBase_WidgetSelector::onSelectionChanged(); +} + void ModuleBase_WidgetMultiSelector::updateFocus() { // Set focus to List control in order to make possible diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h index 1fbc337c9..56aa91a23 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.h +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.h @@ -89,6 +89,10 @@ public slots: /// Slot is called on selection type changed void onSelectionTypeChanged(); + /// Slot which is called on selection event. Redefined to process XML state about + /// clear selection in neutral point + virtual void onSelectionChanged(); + protected slots: /// Slot for copy command in a list pop-up menu void onCopyItem(); @@ -182,6 +186,9 @@ protected: /// A flag to store use_choice parameter state bool myIsUseChoice; + + /// A flag to clear selection by click in empty place in the viewer + bool myIsNeutralPointClear; }; #endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */ -- 2.39.2