Salome HOME
Merge branch 'Dev_GroupsRevision'
[modules/shaper.git] / src / XGUI / XGUI_PropertyPanel.cpp
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include <XGUI_ActionsMgr.h>
22 #include <XGUI_ActiveControlMgr.h>
23 #include <XGUI_SelectionActivate.h>
24 #include <XGUI_ActiveControlSelector.h>
25 #include <XGUI_PropertyPanel.h>
26 #include <XGUI_PropertyPanelSelector.h>
27 #include <XGUI_OperationMgr.h>
28 #include <XGUI_Tools.h>
29 #include <XGUI_Workshop.h>
30
31 //#include <AppElements_Constants.h>
32 #include <ModuleBase_WidgetMultiSelector.h>
33 #include <ModuleBase_Tools.h>
34 #include <ModuleBase_PageBase.h>
35 #include <ModuleBase_PageWidget.h>
36 #include <ModuleBase_WidgetFactory.h>
37 #include <ModuleBase_OperationDescription.h>
38 #include <ModuleBase_Events.h>
39 #include <ModuleBase_IWorkshop.h>
40
41 #include <Events_Loop.h>
42
43 #include <ModelAPI_Session.h>
44 #include <ModelAPI_Validator.h>
45
46 #include <QEvent>
47 #include <QFrame>
48 #include <QIcon>
49 #include <QKeyEvent>
50 #include <QLayoutItem>
51 #include <QToolButton>
52 #include <QVBoxLayout>
53 #include <QGridLayout>
54 #include <QWidget>
55 #include <QAction>
56
57 #ifdef _DEBUG
58 #include <iostream>
59 #endif
60
61 //#define DEBUG_TAB_WIDGETS
62
63 //#define DEBUG_ACTIVE_WIDGET
64
65 XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr)
66     : ModuleBase_IPropertyPanel(theParent),
67     myActiveWidget(NULL),
68     myPreselectionWidget(NULL),
69     myPanelPage(NULL),
70     myOperationMgr(theMgr)
71 {
72   setWindowTitle(tr("Property Panel"));
73   QAction* aViewAct = toggleViewAction();
74   setObjectName(PROP_PANEL);
75   setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
76
77   QWidget* aContent = new QWidget(this);
78   QGridLayout* aMainLayout = new QGridLayout(aContent);
79   const int kPanelColumn = 0;
80   int aPanelRow = 0;
81   aMainLayout->setContentsMargins(3, 3, 3, 3);
82   setWidget(aContent);
83
84   QFrame* aFrm = new QFrame(aContent);
85   aFrm->setFrameStyle(QFrame::Raised);
86   aFrm->setFrameShape(QFrame::Panel);
87   QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
88   ModuleBase_Tools::zeroMargins(aBtnLay);
89   aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
90
91   myHeaderWidget = aFrm;
92
93   QStringList aBtnNames;
94   aBtnNames << QString(PROP_PANEL_HELP)
95             << QString(PROP_PANEL_OK)
96             << QString(PROP_PANEL_OK_PLUS)
97             << QString(PROP_PANEL_CANCEL);
98   foreach(QString eachBtnName, aBtnNames) {
99     QToolButton* aBtn = new QToolButton(aFrm);
100     aBtn->setObjectName(eachBtnName);
101     aBtn->setAutoRaise(true);
102     aBtnLay->addWidget(aBtn);
103   }
104   aBtnLay->insertStretch(1, 1);
105
106   myPanelPage = new ModuleBase_PageWidget(aContent);
107   myPanelPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
108   aMainLayout->addWidget(myPanelPage, aPanelRow, kPanelColumn);
109
110   // spit to make the preview button on the bottom of the panel
111   aMainLayout->setRowStretch(aPanelRow++, 1);
112
113   // preview button on the bottom of panel
114   aFrm = new QFrame(aContent);
115   aBtnLay = new QHBoxLayout(aFrm);
116   aBtnLay->addStretch(1);
117   ModuleBase_Tools::zeroMargins(aBtnLay);
118   aMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
119
120   QToolButton* aBtn = new QToolButton(aFrm);
121   aBtn->setObjectName(PROP_PANEL_PREVIEW);
122   aBtnLay->addWidget(aBtn);
123 }
124
125 XGUI_PropertyPanel::~XGUI_PropertyPanel()
126 {
127 }
128
129 void XGUI_PropertyPanel::cleanContent()
130 {
131   if (myActiveWidget)
132     myActiveWidget->deactivate();
133
134   XGUI_ActiveControlSelector* aPPSelector = XGUI_Tools::workshop(myOperationMgr->workshop())->
135     activeControlMgr()->getSelector(XGUI_PropertyPanelSelector::Type());
136   aPPSelector->reset(); // it removes need to be updated widget link
137
138   /// as the widgets are deleted later, it is important that the signals
139   /// of these widgets are not processed. An example of the error is issue 986.
140   /// In the given case, the property panel is firstly filled by new widgets
141   /// of restarted operation and after that the mouse release signal come from
142   /// the widget of the previous operation (Point2d widget about mouse is released
143   /// and focus is out of this widget)
144   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(),
145                                                  aLast = myWidgets.end();
146   for (; anIt != aLast; anIt++) {
147     QWidget* aWidget = *anIt;
148     if (aWidget) {
149       aWidget->blockSignals(true);
150     }
151   }
152
153   myWidgets.clear();
154   myPanelPage->clearPage();
155   myActiveWidget = NULL;
156   emit propertyPanelDeactivated();
157   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
158   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
159 #ifdef DEBUG_ACTIVE_WIDGET
160   std::cout << "myActiveWidget = NULL" << std::endl;
161 #endif
162
163   findButton(PROP_PANEL_PREVIEW)->setVisible(false); /// by default it is hidden
164   setWindowTitle(tr("Property Panel"));
165 }
166
167 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
168 {
169   myWidgets = theWidgets;
170   if (theWidgets.empty()) return;
171   foreach (ModuleBase_ModelWidget* aWidget, theWidgets) {
172     connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
173             this,    SLOT(onFocusInWidget(ModuleBase_ModelWidget*)));
174     connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
175             this,    SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
176     connect(aWidget, SIGNAL(keyReleased(QObject*, QKeyEvent*)),
177             this,    SIGNAL(keyReleased(QObject*, QKeyEvent*)));
178     connect(aWidget, SIGNAL(enterClicked(QObject*)),
179             this,    SIGNAL(enterClicked(QObject*)));
180
181   }
182 }
183
184 const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
185 {
186   return myWidgets;
187 }
188
189 ModuleBase_PageBase* XGUI_PropertyPanel::contentWidget()
190 {
191   return static_cast<ModuleBase_PageBase*>(myPanelPage);
192 }
193
194 void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
195 {
196   // Invalid feature case on abort of the operation
197   if (theFeature.get() == NULL)
198     return;
199   if (theFeature->isAction() || !theFeature->data())
200     return;
201   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
202     if (!eachWidget->feature().get())
203       eachWidget->setFeature(theFeature);
204     eachWidget->restoreValue();
205   }
206   // the repaint is used here to immediately react in GUI to the values change.
207   repaint();
208 }
209
210 void XGUI_PropertyPanel::createContentPanel(FeaturePtr theFeature)
211 {
212   // Invalid feature case on abort of the operation
213   if (theFeature.get() == NULL)
214     return;
215   if (theFeature->isAction() || !theFeature->data())
216     return;
217
218   if (myWidgets.empty()) {
219     ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
220     QString aXmlRepr = anOperation->getDescription()->xmlRepresentation();
221
222     ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myOperationMgr->workshop());
223     aFactory.createPanel(contentWidget(), theFeature);
224     /// Apply button should be update if the feature was modified by the panel
225     myOperationMgr->onValidateOperation();
226   }
227   std::shared_ptr<Config_FeatureMessage> aFeatureInfo =
228     myOperationMgr->workshop()->featureInfo(theFeature->getKind().c_str());
229   findButton(PROP_PANEL_OK_PLUS)->setVisible(aFeatureInfo->isApplyContinue());
230 }
231
232 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
233 {
234   // it is possible that the property panel widgets have not been visualized
235   // (e.g. on start operation), so it is strictly important to do not check visualized state
236   activateNextWidget(theWidget, false);
237 }
238
239 void XGUI_PropertyPanel::onFocusInWidget(ModuleBase_ModelWidget* theWidget)
240 {
241 #ifdef DEBUG_ACTIVE_WIDGET
242   std::cout << "onFocusInWidget" << std::endl;
243 #endif
244   if (theWidget->canAcceptFocus())
245     activateWidget(theWidget);
246 }
247
248 void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
249 {
250   // this slot happens when some widget lost focus, the next widget which accepts the focus
251   // should be shown, so the second parameter is true
252   // it is important for features where in cases the same attributes are used, isCase for this
253   // attribute returns true, however it can be placed in hidden stack widget(extrusion: elements,
254   // sketch multi rotation -> single/full point)
255   // it is important to check the widget visibility to do not check of the next widget visible
256   // state if the current is not shown. (example: sketch circle re-entrant operation after mouse
257   // release in the viewer, next, radius,
258   // widget should be activated but the first is not visualized)
259   bool isVisible = theWidget->isVisible();
260   activateNextWidget(theWidget, isVisible);
261 }
262
263
264 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget,
265                                             const bool isCheckVisibility)
266 {
267   // TO CHECK: Editing operation does not have automatical activation of widgets
268   if (isEditingMode()) {
269     activateWidget(NULL);
270     return;
271   }
272   ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
273
274   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
275   bool isFoundWidget = false;
276   ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()");
277   for (; anIt != aLast; anIt++) {
278     ModuleBase_ModelWidget* aCurrentWidget = *anIt;
279     if (isFoundWidget || !theWidget) {
280
281       if (!aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID()))
282         continue; // this attribute does not participate in the current case
283       if (isCheckVisibility && !aCurrentWidget->isInternal()) {
284         if (!aCurrentWidget->isVisible())
285           continue;
286       }
287       if (!aCurrentWidget->isObligatory())
288         continue; // not obligatory widgets are not activated automatically
289
290       if (!aCurrentWidget->canAcceptFocus())
291         continue; // do not set focus if it can not be accepted, case: optional choice
292
293       if (aCurrentWidget->focusTo()) {
294         aCurrentWidget->emitFocusInWidget();
295         return;
296       }
297     }
298     isFoundWidget = isFoundWidget || (*anIt) == theWidget;
299   }
300   // set focus to Ok/Cancel button in Property panel if there are no more active widgets
301   // it should be performed before activateWidget(NULL) because it emits some signals which
302   // can be processed by moudule for example as to activate another widget with setting focus
303   QWidget* aNewFocusWidget = 0;
304   QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
305   if (anOkBtn->isEnabled())
306     aNewFocusWidget = anOkBtn;
307   else {
308     QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
309     if (aCancelBtn->isEnabled())
310       aNewFocusWidget = aCancelBtn;
311   }
312   if (aNewFocusWidget)
313     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::activateNextWidget");
314
315   activateWidget(NULL);
316 }
317
318 void findDirectChildren(QWidget* theParent, QList<QWidget*>& theWidgets, const bool theDebug)
319 {
320   QList<QWidget*> aWidgets;
321
322   if (theParent) {
323     QLayout* aLayout = theParent->layout();
324     if (aLayout) {
325       for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
326         QLayoutItem* anItem = aLayout->itemAt(i);
327         QWidget* aWidget = anItem ? anItem->widget() : 0;
328         if (aWidget) {
329           if (aWidget->isVisible()) {
330             if (aWidget->focusPolicy() != Qt::NoFocus)
331               theWidgets.append(aWidget);
332             findDirectChildren(aWidget, theWidgets, false);
333           }
334         }
335         else if (anItem->layout()) {
336           QLayout* aLayout = anItem->layout();
337           for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
338             QLayoutItem* anItem = aLayout->itemAt(i);
339             QWidget* aWidget = anItem ? anItem->widget() : 0;
340             if (aWidget) {
341               if (aWidget->isVisible()) {
342                 if (aWidget->focusPolicy() != Qt::NoFocus)
343                   theWidgets.append(aWidget);
344                 findDirectChildren(aWidget, theWidgets, false);
345               }
346             }
347             else {
348               // TODO: improve recursive search for the case when here QLayout is used
349               // currently, the switch widget uses only 1 level of qlayout in qlayout using for
350               // example for construction plane feature. If there are more levels,
351               // it should be implemented here
352             }
353           }
354         }
355       }
356     }
357   }
358 #ifdef DEBUG_TAB_WIDGETS
359   if (theDebug) {
360     QStringList aWidgetTypes;
361     QList<QWidget*>::const_iterator anIt =  theWidgets.begin(), aLast = theWidgets.end();
362     for (; anIt != aLast; anIt++) {
363       QWidget* aWidget = *anIt;
364       if (aWidget)
365         aWidgetTypes.append(aWidget->objectName());
366     }
367     QString anInfo = QString("theWidgets[%1]: %2")
368       .arg(theWidgets.count()).arg(aWidgetTypes.join(","));
369     qDebug(anInfo.toStdString().c_str());
370   }
371 #endif
372 }
373
374 bool XGUI_PropertyPanel::setFocusNextPrevChild(bool theIsNext)
375 {
376   return focusNextPrevChild(theIsNext);
377 }
378
379 bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
380 {
381   // it wraps the Tabs clicking to follow in the chain:
382   // controls, last control, Apply, Cancel, first control, controls
383   bool isChangedFocus = false;
384
385   QWidget* aFocusWidget = focusWidget();
386 #ifdef DEBUG_TAB_WIDGETS
387   if (aFocusWidget) {
388     QString anInfo = QString("focus Widget: %1").arg(aFocusWidget->objectName());
389     qDebug(anInfo.toStdString().c_str());
390   }
391 #endif
392   ModuleBase_ModelWidget* aFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
393                                                                          aFocusWidget);
394   if (aFocusMWidget)
395     aFocusMWidget->setHighlighted(false);
396
397   QWidget* aNewFocusWidget = 0;
398   if (aFocusWidget) {
399     QList<QWidget*> aChildren;
400     findDirectChildren(this, aChildren, true);
401     int aChildrenCount = aChildren.count();
402     int aFocusWidgetIndex = aChildren.indexOf(aFocusWidget);
403     QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
404     if (aFocusWidgetIndex >= 0) {
405       if (theIsNext) {
406         if (aFocusWidgetIndex == aChildrenCount-1) {
407           // after the last widget focus should be set to "Apply"
408           if (anOkBtn->isEnabled())
409             aNewFocusWidget = anOkBtn;
410           else {
411             QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
412             if (aCancelBtn->isEnabled())
413               aNewFocusWidget = aCancelBtn;
414           }
415         }
416         else {
417           aNewFocusWidget = aChildren[aFocusWidgetIndex+1];
418         }
419       }
420       else {
421         if (aFocusWidgetIndex == 0) {
422           // before the first widget, the last should accept focus
423           aNewFocusWidget = aChildren[aChildrenCount - 1];
424         }
425         else {
426           // before the "Apply" button, the last should accept focus for consistency with "Next"
427           if (aFocusWidget == anOkBtn) {
428             aNewFocusWidget = aChildren[aChildrenCount - 1];
429           }
430           else {
431             aNewFocusWidget = aChildren[aFocusWidgetIndex-1];
432           }
433         }
434       }
435     }
436   }
437   if (aNewFocusWidget) {
438     if (myActiveWidget) {
439       bool isFirstControl = !theIsNext;
440       QWidget* aLastFocusControl = myActiveWidget->getControlAcceptingFocus(isFirstControl);
441       if (aFocusWidget == aLastFocusControl) {
442         setActiveWidget(NULL, false);
443       }
444     }
445
446     // we want to have property panel as an active window to enter values in double control
447     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::focusNextPrevChild()");
448
449     ModuleBase_ModelWidget* aNewFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
450                                                                               aNewFocusWidget);
451     if (aNewFocusMWidget)
452       aNewFocusMWidget->emitFocusInWidget();
453     isChangedFocus = true;
454   }
455   return isChangedFocus;
456 }
457
458 void XGUI_PropertyPanel::activateNextWidget()
459 {
460   activateNextWidget(myActiveWidget);
461 }
462
463 void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget, const bool theEmitSignal)
464 {
465   std::string aPreviosAttributeID;
466   if(myActiveWidget)
467     aPreviosAttributeID = myActiveWidget->attributeID();
468
469   // Avoid activation of already actve widget. It could happen on focusIn event many times
470   setActiveWidget(theWidget, theEmitSignal);
471 }
472
473 bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget, const bool isEmitSignal)
474 {
475   // Avoid activation of already actve widget. It could happen on focusIn event many times
476   if (theWidget == myActiveWidget) {
477     return false;
478   }
479   std::string aPreviosAttributeID;
480   ModuleBase_ModelWidget* aDeactivatedWidget = NULL, *anActivatedWidget = NULL;
481   if(myActiveWidget) {
482     aPreviosAttributeID = myActiveWidget->attributeID();
483     myActiveWidget->processValueState();
484     myActiveWidget->deactivate();
485     myActiveWidget->setHighlighted(false);
486     aDeactivatedWidget = myActiveWidget;
487   }
488   if(theWidget) {
489     emit beforeWidgetActivated(theWidget);
490     theWidget->setHighlighted(true);
491     theWidget->activate();
492     anActivatedWidget = theWidget;
493   }
494   myActiveWidget = theWidget;
495
496 #ifdef DEBUG_ACTIVE_WIDGET
497   std::cout << "myActiveWidget = " << (theWidget ? theWidget->context().c_str() : "") << std::endl;
498 #endif
499   bool aHasMoreWidgets = true;
500   if (isEmitSignal) {
501     //emit widgetActivated(myActiveWidget);
502     if (!myActiveWidget && !isEditingMode()) {
503       aHasMoreWidgets = false;
504       emit noMoreWidgets(aPreviosAttributeID);
505     }
506   }
507   if (myActiveWidget)
508     emit propertyPanelActivated();
509   else
510     emit propertyPanelDeactivated();
511   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
512   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
513
514   if (aHasMoreWidgets && aDeactivatedWidget)
515     aDeactivatedWidget->updateAfterDeactivation();
516   if (aHasMoreWidgets && anActivatedWidget)
517     anActivatedWidget->updateAfterActivation();
518
519   if (aHasMoreWidgets && myActiveWidget)
520   {
521     // restore widget selection should be done after selection modes of widget activating
522     static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
523     Events_Loop::loop()->flush(anEvent);
524   }
525   return true;
526 }
527
528 void XGUI_PropertyPanel::setFocusOnOkButton()
529 {
530   QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
531   ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::setFocusOnOkButton()");
532 }
533
534 void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
535 {
536   QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
537   anCancelBtn->setEnabled(theEnabled);
538 }
539
540 bool XGUI_PropertyPanel::isCancelEnabled() const
541 {
542   QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
543   return anCancelBtn->isEnabled();
544 }
545
546 void XGUI_PropertyPanel::setEditingMode(bool isEditing)
547 {
548   ModuleBase_IPropertyPanel::setEditingMode(isEditing);
549   foreach(ModuleBase_ModelWidget* aWgt, myWidgets) {
550     aWgt->setEditingMode(isEditing);
551   }
552 }
553
554 void XGUI_PropertyPanel::setupActions(XGUI_ActionsMgr* theMgr)
555 {
556   QStringList aButtonNames;
557   aButtonNames << PROP_PANEL_OK<< PROP_PANEL_OK_PLUS << PROP_PANEL_CANCEL
558                << PROP_PANEL_HELP << PROP_PANEL_PREVIEW;
559   QList<XGUI_ActionsMgr::OperationStateActionId> aActionIds;
560   aActionIds << XGUI_ActionsMgr::Accept << XGUI_ActionsMgr::AcceptPlus << XGUI_ActionsMgr::Abort
561              << XGUI_ActionsMgr::Help << XGUI_ActionsMgr::Preview;
562   for (int i = 0; i < aButtonNames.size(); ++i) {
563     QToolButton* aBtn = findButton(aButtonNames.at(i).toStdString().c_str());
564     QAction* anAct = theMgr->operationStateAction(aActionIds.at(i));
565     aBtn->setDefaultAction(anAct);
566   }
567 }
568
569 ModuleBase_ModelWidget* XGUI_PropertyPanel::preselectionWidget() const
570 {
571   return myPreselectionWidget;
572 }
573
574 void XGUI_PropertyPanel::setPreselectionWidget(ModuleBase_ModelWidget* theWidget)
575 {
576   myPreselectionWidget = theWidget;
577 }
578
579
580 void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent)
581 {
582   ModuleBase_Operation* aOp = myOperationMgr->currentOperation();
583   if (aOp) {
584     if (myOperationMgr->canStopOperation(aOp)) {
585       myOperationMgr->abortOperation(aOp);
586       if (myOperationMgr->hasOperation())
587         theEvent->ignore();
588       else
589         theEvent->accept();
590     } else
591       theEvent->ignore();
592   } else
593     ModuleBase_IPropertyPanel::closeEvent(theEvent);
594 }
595
596 QToolButton* XGUI_PropertyPanel::findButton(const char* theInternalName) const
597 {
598   return findChild<QToolButton*>(theInternalName);
599 }