X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FXGUI%2FXGUI_ObjectsBrowser.cpp;h=2ff582bb7c70b08fa7024558839f717aa2a8eca3;hb=90c499710fd0db7a6b744457f5b7bac32096f4e1;hp=9cd3bc933ddd928ceb7b80b0b559e6704740e7df;hpb=6d9f778b60206147106c918852c4a9595898f892;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 9cd3bc933..2ff582bb7 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + #include "XGUI_ObjectsBrowser.h" #include "XGUI_DocumentDataModel.h" #include "XGUI_Tools.h" @@ -7,6 +9,8 @@ #include #include +#include + #include #include #include @@ -57,16 +61,10 @@ void XGUI_DataTree::mouseDoubleClickEvent(QMouseEvent* theEvent) if (theEvent->button() == Qt::LeftButton) { QModelIndex aIndex = currentIndex(); XGUI_DocumentDataModel* aModel = dataModel(); - - if ((aModel->activePartIndex() != aIndex) && aModel->activePartIndex().isValid()) { - setExpanded(aModel->activePartIndex(), false); - } - bool isChanged = aModel->activatedIndex(aIndex); - QTreeView::mouseDoubleClickEvent(theEvent); - if (isChanged) { - if (aModel->activePartIndex().isValid()) - setExpanded(aIndex, true); - emit activePartChanged(aModel->activePart()); + ObjectPtr aObject = aModel->object(aIndex); + ResultPartPtr aPart = std::dynamic_pointer_cast(aObject); + if (aPart) { + aPart->activate(); } } else QTreeView::mouseDoubleClickEvent(theEvent); @@ -84,12 +82,20 @@ void XGUI_DataTree::commitData(QWidget* theEditor) QString aRes = aEditor->text(); ObjectPtr aFeature = mySelectedData.first(); SessionPtr aMgr = ModelAPI_Session::get(); - aMgr->startOperation(); + aMgr->startOperation("Rename"); aFeature->data()->setName(qPrintable(aRes)); aMgr->finishOperation(); } } +void XGUI_DataTree::clear() +{ + mySelectedData.clear(); + XGUI_DocumentDataModel* aModel = dataModel(); + aModel->clear(); + reset(); +} + //******************************************************************** //******************************************************************** //******************************************************************** @@ -97,7 +103,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) : QWidget(theParent) { QVBoxLayout* aLayout = new QVBoxLayout(this); - aLayout->setContentsMargins(0, 0, 0, 0); + ModuleBase_Tools::zeroMargins(aLayout); aLayout->setSpacing(0); QFrame* aLabelWgt = new QFrame(this); @@ -108,7 +114,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) aLayout->addWidget(aLabelWgt); QHBoxLayout* aLabelLay = new QHBoxLayout(aLabelWgt); - aLabelLay->setContentsMargins(0, 0, 0, 0); + ModuleBase_Tools::zeroMargins(aLabelLay); aLabelLay->setSpacing(0); QLabel* aLbl = new QLabel(aLabelWgt); @@ -266,7 +272,7 @@ void XGUI_ObjectsBrowser::activatePart(const ResultPartPtr& thePart) void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent) { myObjectsList = myTreeView->selectedObjects(); - bool toEnable = myObjectsList.size() > 0; + bool toEnable = myObjectsList.size() == 1; foreach(QAction* aCmd, actions()) { aCmd->setEnabled(toEnable); @@ -334,7 +340,7 @@ void XGUI_ObjectsBrowser::rebuildDataTree() } //*************************************************** -void XGUI_ObjectsBrowser::setObjectsSelected(const QList& theObjects) +void XGUI_ObjectsBrowser::setObjectsSelected(const QObjectPtrList& theObjects) { QList theIndexes; QItemSelectionModel* aSelectModel = myTreeView->selectionModel(); @@ -350,7 +356,15 @@ void XGUI_ObjectsBrowser::setObjectsSelected(const QList& theObjects) } //*************************************************** -void XGUI_ObjectsBrowser::processEvent(const Events_Message* theMessage) +void XGUI_ObjectsBrowser::processEvent(const std::shared_ptr& theMessage) { myDocModel->processEvent(theMessage); } + + +//*************************************************** +void XGUI_ObjectsBrowser::clearContent() +{ + myObjectsList.clear(); + myTreeView->clear(); +}