1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: XGUI_OperationMgr.cpp
4 // Created: 20 Apr 2014
5 // Author: Natalia ERMOLAEVA
7 #include "XGUI_OperationMgr.h"
8 #include "XGUI_ModuleConnector.h"
9 #include "XGUI_Workshop.h"
10 #include "XGUI_ErrorMgr.h"
11 #include "XGUI_Tools.h"
12 #include "XGUI_ObjectsBrowser.h"
13 #include "XGUI_ContextMenuMgr.h"
15 #include <ModuleBase_IPropertyPanel.h>
16 #include <ModuleBase_ModelWidget.h>
17 #include "ModuleBase_Operation.h"
18 #include "ModuleBase_IWorkshop.h"
19 #include "ModuleBase_IModule.h"
20 #include <ModuleBase_IViewer.h>
21 #include "ModuleBase_OperationDescription.h"
22 #include "ModuleBase_OperationFeature.h"
23 #include "ModuleBase_Tools.h"
25 #include "ModelAPI_CompositeFeature.h"
26 #include "ModelAPI_Session.h"
28 #include <XGUI_PropertyPanel.h>
29 #include <QToolButton>
31 #include <QMessageBox>
32 #include <QApplication>
35 //#define DEBUG_CURRENT_FEATURE
37 /// Processes "Delete" key event of application. This key is used by several application actions.
38 /// There is a logical order of the actions processing. So the key can not be set for actions
39 /// as a shortcut. The class listens the key event and call operation manager processor.
40 class XGUI_ShortCutListener : public QObject
44 /// \param theParent the parent to be deleted when the parent is deleted
45 /// \param theOperationMgr the class to perform deletion
46 XGUI_ShortCutListener(QObject* theParent, XGUI_OperationMgr* theOperationMgr)
47 : QObject(theParent), myOperationMgr(theOperationMgr)
49 qApp->installEventFilter(this);
51 ~XGUI_ShortCutListener() {}
53 /// Switch on short cut listener
54 void setActive(const bool theIsActive) { myIsActive = theIsActive; }
56 /// Redefinition of virtual function to process Delete key release
57 virtual bool eventFilter(QObject *theObject, QEvent *theEvent)
59 bool isAccepted = false;
60 if (myIsActive && theEvent->type() == QEvent::KeyRelease) {
61 QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
63 switch (aKeyEvent->key()) {
64 case Qt::Key_Delete: {
65 isAccepted = myOperationMgr->onProcessDelete(theObject);
71 isAccepted = QObject::eventFilter(theObject, theEvent);
76 XGUI_OperationMgr* myOperationMgr; /// processor for key event
77 bool myIsActive; /// boolean state whether the event filter perform own signal processing
80 XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent,
81 ModuleBase_IWorkshop* theWorkshop)
82 : QObject(theParent), myWorkshop(theWorkshop)
84 /// we need to install filter to the application in order to react to 'Delete' key button
85 /// this key can not be a short cut for a corresponded action because we need to set
86 /// the actions priority
87 myShortCutListener = new XGUI_ShortCutListener(theParent, this);
90 XGUI_OperationMgr::~XGUI_OperationMgr()
94 void XGUI_OperationMgr::activate()
96 myShortCutListener->setActive(true);
99 void XGUI_OperationMgr::deactivate()
101 myShortCutListener->setActive(false);
104 ModuleBase_Operation* XGUI_OperationMgr::currentOperation() const
106 return myOperations.count() > 0 ? myOperations.last() : 0;
109 bool XGUI_OperationMgr::isCurrentOperation(ModuleBase_Operation* theOperation)
113 return currentOperation() == theOperation;
116 bool XGUI_OperationMgr::hasOperation() const
118 return !myOperations.isEmpty() && (myOperations.last() != NULL);
121 bool XGUI_OperationMgr::hasOperation(const QString& theId) const
123 foreach(ModuleBase_Operation* aOp, myOperations) {
124 if (aOp->id() == theId)
130 ModuleBase_Operation* XGUI_OperationMgr::findOperation(const QString& theId) const
132 QList<ModuleBase_Operation*>::const_iterator anIt = myOperations.end();
133 while (anIt != myOperations.begin()) {
135 ModuleBase_Operation* anOperation = *anIt;
136 if (anOperation->id() == theId)
143 int XGUI_OperationMgr::operationsCount() const
145 return myOperations.count();
148 QStringList XGUI_OperationMgr::operationList() const
151 foreach(ModuleBase_Operation* eachOperation, myOperations) {
152 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(eachOperation);
154 FeaturePtr aFeature = aFOperation->feature();
156 result << QString::fromStdString(aFeature->getKind());
163 ModuleBase_Operation* XGUI_OperationMgr::previousOperation(ModuleBase_Operation* theOperation) const
165 int idx = myOperations.lastIndexOf(theOperation);
166 if(idx == -1 || idx == 0) {
169 return myOperations.at(idx - 1);
172 bool XGUI_OperationMgr::eventFilter(QObject *theObject, QEvent *theEvent)
174 bool isAccepted = false;
175 if (theEvent->type() == QEvent::KeyRelease) {
176 QKeyEvent* aKeyEvent = dynamic_cast<QKeyEvent*>(theEvent);
178 isAccepted = onKeyReleased(theObject, aKeyEvent);
181 isAccepted = QObject::eventFilter(theObject, theEvent);
186 bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
189 currentOperation()->postpone();
190 myOperations.append(theOperation);
192 connect(theOperation, SIGNAL(beforeStarted()), SLOT(onBeforeOperationStarted()));
193 connect(theOperation, SIGNAL(beforeAborted()), SLOT(onBeforeOperationAborted()));
194 connect(theOperation, SIGNAL(beforeCommitted()), SLOT(onBeforeOperationCommitted()));
196 connect(theOperation, SIGNAL(started()), SLOT(onOperationStarted()));
197 connect(theOperation, SIGNAL(aborted()), SLOT(onOperationAborted()));
198 connect(theOperation, SIGNAL(committed()), SLOT(onOperationCommitted()));
200 connect(theOperation, SIGNAL(stopped()), SLOT(onOperationStopped()));
201 connect(theOperation, SIGNAL(resumed()), SLOT(onOperationResumed()));
203 bool isStarted = theOperation->start();
205 onValidateOperation();
209 bool XGUI_OperationMgr::abortAllOperations()
215 if (operationsCount() == 1) {
216 ModuleBase_Operation* aCurrentOperation = currentOperation();
217 if (canStopOperation(aCurrentOperation)) {
218 abortOperation(aCurrentOperation);
224 aResult = QMessageBox::question(qApp->activeWindow(),
225 tr("Abort operation"),
226 tr("All active operations will be aborted."),
227 QMessageBox::Ok | QMessageBox::Cancel,
228 QMessageBox::Cancel) == QMessageBox::Ok;
229 while(aResult && hasOperation()) {
230 abortOperation(currentOperation());
236 bool XGUI_OperationMgr::commitAllOperations()
238 bool isCompositeCommitted = false, anOperationProcessed = false;
239 while (hasOperation()) {
240 ModuleBase_Operation* anOperation = currentOperation();
241 if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled()) {
242 anOperationProcessed = onCommitOperation();
244 abortOperation(anOperation);
245 anOperationProcessed = true;
247 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
250 FeaturePtr aFeature = aFOperation->feature();
251 CompositeFeaturePtr aComposite =
252 std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
253 isCompositeCommitted = aComposite.get();
254 if (isCompositeCommitted)
257 // not processed[committed] operation might be used in composite feature,
258 // so the while will be stopped by the previous check.
259 // this code is not necessary, but logically should be done when the processing will not
260 // be done for not composite feature by some reasons
261 if (!anOperationProcessed)
267 void XGUI_OperationMgr::onValidateOperation()
271 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
272 (currentOperation());
273 if(aFOperation && aFOperation->feature().get())
274 XGUI_Tools::workshop(myWorkshop)->errorMgr()->updateActions(aFOperation->feature());
277 void XGUI_OperationMgr::updateApplyOfOperations(ModuleBase_Operation* theOperation)
279 XGUI_ErrorMgr* anErrorMgr = XGUI_Tools::workshop(myWorkshop)->errorMgr();
281 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(theOperation);
283 anErrorMgr->updateAcceptAllAction(aFOperation->feature());
286 foreach(ModuleBase_Operation* anOperation, myOperations) {
288 updateApplyOfOperations(anOperation);
291 // Apply button of the current operation should also be updated
292 onValidateOperation();
295 bool XGUI_OperationMgr::canStopOperation(ModuleBase_Operation* theOperation)
297 //in case of nested (sketch) operation no confirmation needed
298 if (isGrantedOperation(theOperation->id()))
300 if (theOperation && theOperation->isModified()) {
301 QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id());
302 int anAnswer = QMessageBox::question(qApp->activeWindow(),
303 tr("Abort operation"),
305 QMessageBox::Ok | QMessageBox::Cancel,
306 QMessageBox::Cancel);
307 return anAnswer == QMessageBox::Ok;
312 bool XGUI_OperationMgr::commitOperation()
314 //if (hasOperation() && currentOperation()->isValid()) {
315 // onCommitOperation();
319 return onCommitOperation();
322 void XGUI_OperationMgr::resumeOperation(ModuleBase_Operation* theOperation)
324 theOperation->resume();
327 bool XGUI_OperationMgr::isGrantedOperation(const QString& theId)
329 bool isGranted = false;
331 QListIterator<ModuleBase_Operation*> anIt(myOperations);
333 ModuleBase_Operation* aPreviousOperation = 0;
334 while (anIt.hasPrevious() && !isGranted) {
335 ModuleBase_Operation* anOp = anIt.previous();
337 isGranted = anOp->isGranted(theId);
342 void XGUI_OperationMgr::setCurrentFeature(const FeaturePtr& theFeature)
344 SessionPtr aMgr = ModelAPI_Session::get();
345 DocumentPtr aDoc = aMgr->activeDocument();
346 bool aIsOp = aMgr->isOperation();
348 aMgr->startOperation(QString("Set current feature: %1").arg(theFeature->getKind().c_str()).toStdString());
349 aDoc->setCurrentFeature(theFeature, false);
351 aMgr->finishOperation();
354 bool XGUI_OperationMgr::canStartOperation(const QString& theId)
356 bool aCanStart = true;
357 ModuleBase_Operation* aCurrentOp = currentOperation();
359 bool aGranted = aCurrentOp->isGranted(theId);
360 // the started operation is granted for the current one,
361 // e.g. current - Sketch, started - Line
366 if (!isGrantedOperation(theId)) {
367 // the operation is not granted in the current list of operations
368 // e.g. Edit Parameter when Sketch, Line in Sketch is active.
369 aCanStart = abortAllOperations();
371 else if (canStopOperation(aCurrentOp)) {
372 // the started operation is granted in the parrent operation,
373 // e.g. current - Line in Sketch, started Circle
374 stopOperation(aCurrentOp);
383 void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation)
385 if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && theOperation->isModified())
386 theOperation->commit();
388 abortOperation(theOperation);
391 void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
393 ModuleBase_Operation* aCurrentOperation = currentOperation();
394 if (theOperation == aCurrentOperation)
395 theOperation->abort();
397 // it is possible to trigger upper operation(e.g. sketch, current is sketch line)
398 // all operation from the current to triggered should also be aborted
399 // operations over the parameter one are not aborted(e.g. extrusion cut, sketch abort)
400 while(hasOperation()) {
401 ModuleBase_Operation* aCurrentOperation = currentOperation();
402 aCurrentOperation->abort();
403 if(theOperation == aCurrentOperation)
409 bool XGUI_OperationMgr::onCommitOperation()
411 bool isCommitted = false;
412 ModuleBase_Operation* anOperation = currentOperation();
413 if (anOperation && myWorkshop->module()->canCommitOperation())
414 isCommitted = anOperation->commit();
418 void XGUI_OperationMgr::onAbortOperation()
420 ModuleBase_Operation* aCurrentOperation = currentOperation();
421 if (aCurrentOperation && canStopOperation(aCurrentOperation)) {
422 abortOperation(aCurrentOperation);
426 void XGUI_OperationMgr::onBeforeOperationStarted()
428 ModuleBase_Operation* aCurrentOperation = dynamic_cast<ModuleBase_Operation*>(sender());
429 if (!aCurrentOperation)
432 /// Set current feature and remeber old current feature
433 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(aCurrentOperation);
435 SessionPtr aMgr = ModelAPI_Session::get();
436 DocumentPtr aDoc = aMgr->activeDocument();
437 // the parameter of current feature should be false, we should use all feature, not only visible
438 // in order to correctly save the previous feature of the nested operation, where the
439 // features can be not visible in the tree. The problem case is Edit sketch entitity(line)
440 // in the Sketch, created in ExtrusionCut operation. The entity disappears by commit.
441 // When sketch entity operation started, the sketch should be cashed here as the current.
442 // Otherwise(the flag is true), the ExtrusionCut is cashed, when commit happens, the sketch
443 // is disabled, sketch entity is disabled as extrusion cut is created earliest then sketch.
444 // As a result the sketch disappears from the viewer. However after commit it is displayed back.
445 aFOperation->setPreviousCurrentFeature(aDoc->currentFeature(false));
447 #ifdef DEBUG_CURRENT_FEATURE
448 FeaturePtr aFeature = aFOperation->feature();
449 QString aKind = aFeature ? aFeature->getKind().c_str() : "";
450 qDebug(QString("onBeforeOperationStarted(), edit operation = %1, feature = %2")
451 .arg(aFOperation->isEditOperation())
452 .arg(ModuleBase_Tools::objectInfo(aFeature)).toStdString().c_str());
454 qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
455 ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
458 if (aFOperation->isEditOperation()) {// it should be performed by the feature edit only
459 // in create operation, the current feature is changed by addFeature()
460 aDoc->setCurrentFeature(aFOperation->feature(), false);
461 // this is the only place where flushes must be called after setCurrentFeature for the current
462 // moment: after this the opertion is not finished, so, the ObjectBrowser state may be corrupted
464 static Events_Loop* aLoop = Events_Loop::loop();
465 static Events_ID aCreateEvent = aLoop->eventByName(EVENT_OBJECT_CREATED);
466 aLoop->flush(aCreateEvent);
467 static Events_ID aDeleteEvent = aLoop->eventByName(EVENT_OBJECT_DELETED);
468 aLoop->flush(aDeleteEvent);
471 #ifdef DEBUG_CURRENT_FEATURE
472 qDebug("\tdocument->setCurrentFeature");
473 qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
474 ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
479 void XGUI_OperationMgr::onOperationStarted()
481 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
482 updateApplyOfOperations(aSenderOperation);
483 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
484 aWorkshop->operationStarted(aSenderOperation);
487 void XGUI_OperationMgr::onBeforeOperationAborted()
489 onBeforeOperationCommitted();
492 void XGUI_OperationMgr::onOperationAborted()
494 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
495 emit operationAborted(aSenderOperation);
498 void XGUI_OperationMgr::onBeforeOperationCommitted()
500 ModuleBase_Operation* aCurrentOperation = dynamic_cast<ModuleBase_Operation*>(sender());
501 if (!aCurrentOperation)
504 /// Restore the previous current feature
505 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(aCurrentOperation);
507 #ifdef DEBUG_CURRENT_FEATURE
508 QString aKind = aFOperation->feature()->getKind().c_str();
509 qDebug(QString("onBeforeOperationCommitted(), edit operation = %1, feature = %2")
510 .arg(aFOperation->isEditOperation())
511 .arg(ModuleBase_Tools::objectInfo(aFOperation->feature())).toStdString().c_str());
513 qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
514 ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
517 if (aFOperation->isEditOperation()) {
518 /// Restore the previous current feature
519 setCurrentFeature(aFOperation->previousCurrentFeature());
521 else { // create operation
522 // the Top created feature should stays the current. In nested operations, like Line in the Sketch or
523 // Sketch in ExtrusionCut, a previous feature should be restored on commit. It is performed here
524 // in order to perform it in the current transaction without opening a new one.
525 if (myOperations.front() != aFOperation)
526 setCurrentFeature(aFOperation->previousCurrentFeature());
528 #ifdef DEBUG_CURRENT_FEATURE
529 qDebug("\tdocument->setCurrentFeature");
530 qDebug(QString("\tdocument->currentFeature(false) = %1").arg(
531 ModuleBase_Tools::objectInfo(ModelAPI_Session::get()->activeDocument()->currentFeature(false))).toStdString().c_str());
533 ModuleBase_IModule* aModule = myWorkshop->module();
535 aModule->beforeOperationStopped(aFOperation);
539 void XGUI_OperationMgr::onOperationCommitted()
541 // apply state for all features from the stack of operations should be updated
542 updateApplyOfOperations();
544 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
545 emit operationCommitted(aSenderOperation);
548 void XGUI_OperationMgr::onOperationResumed()
550 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
551 emit operationResumed(aSenderOperation);
554 void XGUI_OperationMgr::onOperationStopped()
556 ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
557 ModuleBase_Operation* aCurrentOperation = currentOperation();
558 if (!aSenderOperation || !aCurrentOperation || aSenderOperation != aCurrentOperation)
561 myOperations.removeAll(aCurrentOperation);
562 aCurrentOperation->deleteLater();
564 emit operationStopped(aCurrentOperation);
566 // get last operation which can be resumed
567 ModuleBase_Operation* aResultOp = 0;
568 QListIterator<ModuleBase_Operation*> anIt(myOperations);
570 while (anIt.hasPrevious()) {
571 ModuleBase_Operation* anOp = anIt.previous();
578 bool isModified = aCurrentOperation->isModified();
579 aResultOp->setIsModified(aResultOp->isModified() || isModified);
580 resumeOperation(aResultOp);
581 onValidateOperation();
585 bool XGUI_OperationMgr::onKeyReleased(QObject *theObject, QKeyEvent* theEvent)
587 // Let the manager decide what to do with the given key combination.
588 ModuleBase_Operation* anOperation = currentOperation();
589 bool isAccepted = false;
590 switch (theEvent->key()) {
592 case Qt::Key_Enter: {
593 isAccepted = onProcessEnter(theObject);
598 bool noModifiers = (theEvent->modifiers() == Qt::NoModifier);
600 ModuleBase_IViewer* aViewer = myWorkshop->viewer();
601 Handle(AIS_InteractiveContext) aContext = aViewer->AISContext();
602 if (!aContext.IsNull()) {
603 Handle(V3d_View) aView = aViewer->activeView();
604 if ((theEvent->key() == Qt::Key_N))
605 aContext->HilightNextDetected(aView);
606 else if ((theEvent->key() == Qt::Key_P))
607 aContext->HilightPreviousDetected(aView);
618 // anOperation->keyReleased(theEvent->key());
623 bool XGUI_OperationMgr::onProcessEnter(QObject* theObject)
625 bool isAccepted = false;
626 ModuleBase_Operation* aOperation = currentOperation();
627 // to avoid enter processing when operation has not been started yet
630 ModuleBase_IPropertyPanel* aPanel = aOperation->propertyPanel();
631 // only property panel enter is processed in order to do not process enter in application dialogs
632 bool isPPChild = isChildObject(theObject, aPanel);
636 ModuleBase_ModelWidget* anActiveWgt = aPanel->activeWidget();
637 bool isAborted = false;
639 QWidget* aFocusWidget = aPanel->focusWidget();
640 QToolButton* aCancelBtn = dynamic_cast<XGUI_PropertyPanel*>(aPanel)->findButton(PROP_PANEL_CANCEL);
641 if (aFocusWidget && aCancelBtn && aFocusWidget == aCancelBtn) {
642 abortOperation(aOperation);
648 isAccepted = anActiveWgt && anActiveWgt->processEnter();
650 isAccepted = myWorkshop->module()->processEnter(anActiveWgt ? anActiveWgt->attributeID() : "");
652 /// functionality is similar to Apply click
653 ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>(currentOperation());
654 if (!aFOperation || myWorkshop->module()->getFeatureError(aFOperation->feature()).isEmpty()) {
655 // key released is emitted to apply the current value to the model if it was modified in PP
656 emit keyEnterReleased();
668 bool XGUI_OperationMgr::onProcessDelete(QObject* theObject)
670 bool isAccepted = false;
671 ModuleBase_Operation* aOperation = currentOperation();
672 ModuleBase_ModelWidget* anActiveWgt = 0;
673 // firstly the widget should process Delete action
674 ModuleBase_IPropertyPanel* aPanel;
675 bool isPPChildObject = false;
677 aPanel = aOperation->propertyPanel();
679 isPPChildObject = isChildObject(theObject, aPanel);
680 // process delete in active widget only if delete sender is child of property panel
681 // it is necessary for the case when OB is shown, user perform selection and click Delete
682 if (isPPChildObject) {
683 anActiveWgt = aPanel->activeWidget();
685 isAccepted = anActiveWgt->processDelete();
691 // after widget, object browser and viewer should process delete
692 /// other widgets such as line edit controls should not lead to
693 /// processing delete by workshop
694 XGUI_ObjectsBrowser* aBrowser = XGUI_Tools::workshop(myWorkshop)->objectBrowser();
695 QWidget* aViewPort = myWorkshop->viewer()->activeViewPort();
696 bool isToDeleteObject = false;
697 XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
698 XGUI_ContextMenuMgr* aContextMenuMgr = aWorkshop->contextMenuMgr();
699 if (theObject == aBrowser->treeView()) {
700 aContextMenuMgr->updateObjectBrowserMenu();
701 isToDeleteObject = aContextMenuMgr->action("DELETE_CMD")->isEnabled();
703 else if (isChildObject(theObject, aViewPort)) {
704 aContextMenuMgr->updateViewerMenu();
705 isToDeleteObject = aContextMenuMgr->action("DELETE_CMD")->isEnabled();
707 else if (isPPChildObject) {
708 // property panel child object is processed to process delete performed on Apply button of PP
709 isToDeleteObject = true;
711 if (isToDeleteObject) {
712 aWorkshop->deleteObjects();
720 bool XGUI_OperationMgr::isChildObject(const QObject* theObject, const QObject* theParent)
722 bool isPPChild = false;
723 if (theParent && theObject) {
724 QObject* aParent = (QObject*)theObject;
726 isPPChild = aParent == theParent;
729 aParent = aParent->parent();