Salome HOME
Issue #2406: Use accept data method from Commit function of an operation
[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())
171     return;
172   foreach (ModuleBase_ModelWidget* aWidget, theWidgets) {
173     connect(aWidget, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
174             this,    SLOT(onFocusInWidget(ModuleBase_ModelWidget*)));
175     connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
176             this,    SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
177     connect(aWidget, SIGNAL(keyReleased(QObject*, QKeyEvent*)),
178             this,    SIGNAL(keyReleased(QObject*, QKeyEvent*)));
179     connect(aWidget, SIGNAL(enterClicked(QObject*)),
180             this,    SIGNAL(enterClicked(QObject*)));
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   if (aFeatureInfo.get())
230     findButton(PROP_PANEL_OK_PLUS)->setVisible(aFeatureInfo->isApplyContinue());
231 }
232
233 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
234 {
235   // it is possible that the property panel widgets have not been visualized
236   // (e.g. on start operation), so it is strictly important to do not check visualized state
237   activateNextWidget(theWidget, false);
238 }
239
240 void XGUI_PropertyPanel::onFocusInWidget(ModuleBase_ModelWidget* theWidget)
241 {
242 #ifdef DEBUG_ACTIVE_WIDGET
243   std::cout << "onFocusInWidget" << std::endl;
244 #endif
245   if (theWidget->canAcceptFocus())
246     activateWidget(theWidget);
247 }
248
249 void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
250 {
251   // this slot happens when some widget lost focus, the next widget which accepts the focus
252   // should be shown, so the second parameter is true
253   // it is important for features where in cases the same attributes are used, isCase for this
254   // attribute returns true, however it can be placed in hidden stack widget(extrusion: elements,
255   // sketch multi rotation -> single/full point)
256   // it is important to check the widget visibility to do not check of the next widget visible
257   // state if the current is not shown. (example: sketch circle re-entrant operation after mouse
258   // release in the viewer, next, radius,
259   // widget should be activated but the first is not visualized)
260   bool isVisible = theWidget->isVisible();
261   activateNextWidget(theWidget, isVisible);
262 }
263
264
265 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget,
266                                             const bool isCheckVisibility)
267 {
268   // TO CHECK: Editing operation does not have automatical activation of widgets
269   if (isEditingMode()) {
270     activateWidget(NULL);
271     return;
272   }
273   ModelAPI_ValidatorsFactory* aValidators = ModelAPI_Session::get()->validators();
274
275   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
276   bool isFoundWidget = false;
277   ModuleBase_Tools::activateWindow(this, "XGUI_PropertyPanel::activateNextWidget()");
278   for (; anIt != aLast; anIt++) {
279     ModuleBase_ModelWidget* aCurrentWidget = *anIt;
280     if (isFoundWidget || !theWidget) {
281
282       if (!aValidators->isCase(aCurrentWidget->feature(), aCurrentWidget->attributeID()))
283         continue; // this attribute does not participate in the current case
284       if (isCheckVisibility && !aCurrentWidget->isInternal()) {
285         if (!aCurrentWidget->isVisible())
286           continue;
287       }
288       if (!aCurrentWidget->isObligatory())
289         continue; // not obligatory widgets are not activated automatically
290
291       if (!aCurrentWidget->canAcceptFocus())
292         continue; // do not set focus if it can not be accepted, case: optional choice
293
294       if (aCurrentWidget->focusTo()) {
295         aCurrentWidget->emitFocusInWidget();
296         return;
297       }
298     }
299     isFoundWidget = isFoundWidget || (*anIt) == theWidget;
300   }
301   // set focus to Ok/Cancel button in Property panel if there are no more active widgets
302   // it should be performed before activateWidget(NULL) because it emits some signals which
303   // can be processed by moudule for example as to activate another widget with setting focus
304   QWidget* aNewFocusWidget = 0;
305   QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
306   if (anOkBtn->isEnabled())
307     aNewFocusWidget = anOkBtn;
308   else {
309     QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
310     if (aCancelBtn->isEnabled())
311       aNewFocusWidget = aCancelBtn;
312   }
313   if (aNewFocusWidget)
314     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::activateNextWidget");
315
316   activateWidget(NULL);
317 }
318
319 void findDirectChildren(QWidget* theParent, QList<QWidget*>& theWidgets, const bool theDebug)
320 {
321   QList<QWidget*> aWidgets;
322
323   if (theParent) {
324     QLayout* aLayout = theParent->layout();
325     if (aLayout) {
326       for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
327         QLayoutItem* anItem = aLayout->itemAt(i);
328         QWidget* aWidget = anItem ? anItem->widget() : 0;
329         if (aWidget) {
330           if (aWidget->isVisible()) {
331             if (aWidget->focusPolicy() != Qt::NoFocus)
332               theWidgets.append(aWidget);
333             findDirectChildren(aWidget, theWidgets, false);
334           }
335         }
336         else if (anItem->layout()) {
337           QLayout* aLayout = anItem->layout();
338           for (int i = 0, aCount = aLayout->count(); i < aCount; i++) {
339             QLayoutItem* anItem = aLayout->itemAt(i);
340             QWidget* aWidget = anItem ? anItem->widget() : 0;
341             if (aWidget) {
342               if (aWidget->isVisible()) {
343                 if (aWidget->focusPolicy() != Qt::NoFocus)
344                   theWidgets.append(aWidget);
345                 findDirectChildren(aWidget, theWidgets, false);
346               }
347             }
348             else {
349               // TODO: improve recursive search for the case when here QLayout is used
350               // currently, the switch widget uses only 1 level of qlayout in qlayout using for
351               // example for construction plane feature. If there are more levels,
352               // it should be implemented here
353             }
354           }
355         }
356       }
357     }
358   }
359 #ifdef DEBUG_TAB_WIDGETS
360   if (theDebug) {
361     QStringList aWidgetTypes;
362     QList<QWidget*>::const_iterator anIt =  theWidgets.begin(), aLast = theWidgets.end();
363     for (; anIt != aLast; anIt++) {
364       QWidget* aWidget = *anIt;
365       if (aWidget)
366         aWidgetTypes.append(aWidget->objectName());
367     }
368     QString anInfo = QString("theWidgets[%1]: %2")
369       .arg(theWidgets.count()).arg(aWidgetTypes.join(","));
370     qDebug(anInfo.toStdString().c_str());
371   }
372 #endif
373 }
374
375 bool XGUI_PropertyPanel::setFocusNextPrevChild(bool theIsNext)
376 {
377   return focusNextPrevChild(theIsNext);
378 }
379
380 bool XGUI_PropertyPanel::focusNextPrevChild(bool theIsNext)
381 {
382   // it wraps the Tabs clicking to follow in the chain:
383   // controls, last control, Apply, Cancel, first control, controls
384   bool isChangedFocus = false;
385
386   QWidget* aFocusWidget = focusWidget();
387 #ifdef DEBUG_TAB_WIDGETS
388   if (aFocusWidget) {
389     QString anInfo = QString("focus Widget: %1").arg(aFocusWidget->objectName());
390     qDebug(anInfo.toStdString().c_str());
391   }
392 #endif
393   ModuleBase_ModelWidget* aFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
394                                                                          aFocusWidget);
395   if (aFocusMWidget)
396     aFocusMWidget->setHighlighted(false);
397
398   QWidget* aNewFocusWidget = 0;
399   if (aFocusWidget) {
400     QList<QWidget*> aChildren;
401     findDirectChildren(this, aChildren, true);
402     int aChildrenCount = aChildren.count();
403     int aFocusWidgetIndex = aChildren.indexOf(aFocusWidget);
404     QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
405     if (aFocusWidgetIndex >= 0) {
406       if (theIsNext) {
407         if (aFocusWidgetIndex == aChildrenCount-1) {
408           // after the last widget focus should be set to "Apply"
409           if (anOkBtn->isEnabled())
410             aNewFocusWidget = anOkBtn;
411           else {
412             QToolButton* aCancelBtn = findButton(PROP_PANEL_CANCEL);
413             if (aCancelBtn->isEnabled())
414               aNewFocusWidget = aCancelBtn;
415           }
416         }
417         else {
418           aNewFocusWidget = aChildren[aFocusWidgetIndex+1];
419         }
420       }
421       else {
422         if (aFocusWidgetIndex == 0) {
423           // before the first widget, the last should accept focus
424           aNewFocusWidget = aChildren[aChildrenCount - 1];
425         }
426         else {
427           // before the "Apply" button, the last should accept focus for consistency with "Next"
428           if (aFocusWidget == anOkBtn) {
429             aNewFocusWidget = aChildren[aChildrenCount - 1];
430           }
431           else {
432             aNewFocusWidget = aChildren[aFocusWidgetIndex-1];
433           }
434         }
435       }
436     }
437   }
438   if (aNewFocusWidget) {
439     if (myActiveWidget) {
440       bool isFirstControl = !theIsNext;
441       QWidget* aLastFocusControl = myActiveWidget->getControlAcceptingFocus(isFirstControl);
442       if (aFocusWidget == aLastFocusControl) {
443         setActiveWidget(NULL, false);
444       }
445     }
446
447     // we want to have property panel as an active window to enter values in double control
448     ModuleBase_Tools::setFocus(aNewFocusWidget, "XGUI_PropertyPanel::focusNextPrevChild()");
449
450     ModuleBase_ModelWidget* aNewFocusMWidget = ModuleBase_ModelWidget::findModelWidget(this,
451                                                                               aNewFocusWidget);
452     if (aNewFocusMWidget)
453       aNewFocusMWidget->emitFocusInWidget();
454     isChangedFocus = true;
455   }
456   return isChangedFocus;
457 }
458
459 void XGUI_PropertyPanel::activateNextWidget()
460 {
461   activateNextWidget(myActiveWidget);
462 }
463
464 void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget, const bool theEmitSignal)
465 {
466   std::string aPreviosAttributeID;
467   if(myActiveWidget)
468     aPreviosAttributeID = myActiveWidget->attributeID();
469
470   // Avoid activation of already actve widget. It could happen on focusIn event many times
471   setActiveWidget(theWidget, theEmitSignal);
472 }
473
474 bool XGUI_PropertyPanel::setActiveWidget(ModuleBase_ModelWidget* theWidget, const bool isEmitSignal)
475 {
476   // Avoid activation of already actve widget. It could happen on focusIn event many times
477   if (theWidget == myActiveWidget) {
478     return false;
479   }
480   std::string aPreviosAttributeID;
481   ModuleBase_ModelWidget* aDeactivatedWidget = NULL, *anActivatedWidget = NULL;
482   if(myActiveWidget) {
483     aPreviosAttributeID = myActiveWidget->attributeID();
484     myActiveWidget->processValueState();
485     myActiveWidget->deactivate();
486     myActiveWidget->setHighlighted(false);
487     aDeactivatedWidget = myActiveWidget;
488   }
489   if(theWidget) {
490     emit beforeWidgetActivated(theWidget);
491     theWidget->setHighlighted(true);
492     theWidget->activate();
493     anActivatedWidget = theWidget;
494   }
495   myActiveWidget = theWidget;
496
497 #ifdef DEBUG_ACTIVE_WIDGET
498   std::cout << "myActiveWidget = " << (theWidget ? theWidget->context().c_str() : "") << std::endl;
499 #endif
500   bool aHasMoreWidgets = true;
501   if (isEmitSignal) {
502     //emit widgetActivated(myActiveWidget);
503     if (!myActiveWidget && !isEditingMode()) {
504       aHasMoreWidgets = false;
505       emit noMoreWidgets(aPreviosAttributeID);
506     }
507   }
508   if (myActiveWidget)
509     emit propertyPanelActivated();
510   else
511     emit propertyPanelDeactivated();
512   myOperationMgr->workshop()->selectionActivate()->updateSelectionModes();
513   myOperationMgr->workshop()->selectionActivate()->updateSelectionFilters();
514
515   if (aHasMoreWidgets && aDeactivatedWidget)
516     aDeactivatedWidget->updateAfterDeactivation();
517   if (aHasMoreWidgets && anActivatedWidget)
518     anActivatedWidget->updateAfterActivation();
519
520   if (aHasMoreWidgets && myActiveWidget)
521   {
522     // restore widget selection should be done after selection modes of widget activating
523     static Events_ID anEvent = Events_Loop::eventByName(EVENT_UPDATE_BY_WIDGET_SELECTION);
524     Events_Loop::loop()->flush(anEvent);
525   }
526   return true;
527 }
528
529 void XGUI_PropertyPanel::setFocusOnOkButton()
530 {
531   QToolButton* anOkBtn = findButton(PROP_PANEL_OK);
532   ModuleBase_Tools::setFocus(anOkBtn, "XGUI_PropertyPanel::setFocusOnOkButton()");
533 }
534
535 void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
536 {
537   QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
538   anCancelBtn->setEnabled(theEnabled);
539 }
540
541 bool XGUI_PropertyPanel::isCancelEnabled() const
542 {
543   QToolButton* anCancelBtn = findButton(PROP_PANEL_CANCEL);
544   return anCancelBtn->isEnabled();
545 }
546
547 void XGUI_PropertyPanel::setEditingMode(bool isEditing)
548 {
549   ModuleBase_IPropertyPanel::setEditingMode(isEditing);
550   foreach(ModuleBase_ModelWidget* aWgt, myWidgets) {
551     aWgt->setEditingMode(isEditing);
552   }
553 }
554
555 void XGUI_PropertyPanel::setupActions(XGUI_ActionsMgr* theMgr)
556 {
557   QStringList aButtonNames;
558   aButtonNames << PROP_PANEL_OK<< PROP_PANEL_OK_PLUS << PROP_PANEL_CANCEL
559                << PROP_PANEL_HELP << PROP_PANEL_PREVIEW;
560   QList<XGUI_ActionsMgr::OperationStateActionId> aActionIds;
561   aActionIds << XGUI_ActionsMgr::Accept << XGUI_ActionsMgr::AcceptPlus << XGUI_ActionsMgr::Abort
562              << XGUI_ActionsMgr::Help << XGUI_ActionsMgr::Preview;
563   for (int i = 0; i < aButtonNames.size(); ++i) {
564     QToolButton* aBtn = findButton(aButtonNames.at(i).toStdString().c_str());
565     QAction* anAct = theMgr->operationStateAction(aActionIds.at(i));
566     aBtn->setDefaultAction(anAct);
567   }
568 }
569
570 void XGUI_PropertyPanel::onAcceptData()
571 {
572   foreach (ModuleBase_ModelWidget* aWidget, myWidgets) {
573     aWidget->onFeatureAccepted();
574   }
575 }
576
577
578 ModuleBase_ModelWidget* XGUI_PropertyPanel::preselectionWidget() const
579 {
580   return myPreselectionWidget;
581 }
582
583 void XGUI_PropertyPanel::setPreselectionWidget(ModuleBase_ModelWidget* theWidget)
584 {
585   myPreselectionWidget = theWidget;
586 }
587
588
589 void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent)
590 {
591   ModuleBase_Operation* aOp = myOperationMgr->currentOperation();
592   if (aOp) {
593     if (myOperationMgr->canStopOperation(aOp)) {
594       myOperationMgr->abortOperation(aOp);
595       if (myOperationMgr->hasOperation())
596         theEvent->ignore();
597       else
598         theEvent->accept();
599     } else
600       theEvent->ignore();
601   } else
602     ModuleBase_IPropertyPanel::closeEvent(theEvent);
603 }
604
605 QToolButton* XGUI_PropertyPanel::findButton(const char* theInternalName) const
606 {
607   return findChild<QToolButton*>(theInternalName);
608 }