X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_ObjectsBrowser.cpp;h=27b92756283b4e6304239e698a03adb627b4ba26;hb=f8d51abf2ab6024a974d42c139f7650ccf0ef774;hp=e5f8c8355a7d57fb032926ec1bb35cfe3116bb45;hpb=9b59be2733fd1fe72294588b1f2ddb692d9b6b4f;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index e5f8c8355..27b927562 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -1,9 +1,11 @@ #include "XGUI_ObjectsBrowser.h" #include "XGUI_DocumentDataModel.h" +#include "XGUI_Tools.h" #include #include #include +#include #include #include @@ -82,7 +84,13 @@ void XGUI_DataTree::commitData(QWidget* theEditor) if (aEditor) { QString aRes = aEditor->text(); FeaturePtr aFeature = mySelectedData.first(); - aFeature->data()->setName(qPrintable(aRes)); + PluginManagerPtr aMgr = ModelAPI_PluginManager::get(); + aMgr->rootDocument()->startOperation(); + if (!XGUI_Tools::isModelObject(aFeature)) + aFeature->data()->setName(qPrintable(aRes)); + else + boost::dynamic_pointer_cast(aFeature)->setName(qPrintable(aRes)); + aMgr->rootDocument()->finishOperation(); } } @@ -138,7 +146,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) aLabelWgt->setFrameShape(myTreeView->frameShape()); aLabelWgt->setFrameShadow(myTreeView->frameShadow()); - connect(myTreeView, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); + connect(myTreeView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(onActivePartChanged(FeaturePtr))); connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SIGNAL(activePartChanged(FeaturePtr))); @@ -150,7 +158,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) onActivePartChanged(FeaturePtr()); // Create internal actions - QAction* aAction = new QAction(tr("Rename"), this); + QAction* aAction = new QAction(QIcon(":pictures/rename_edit.png"), tr("Rename"), this); aAction->setData("RENAME_CMD"); connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onEditItem())); addAction(aAction); @@ -289,7 +297,8 @@ void XGUI_ObjectsBrowser::onEditItem() // Find index which corresponds the feature QModelIndex aIndex; foreach(QModelIndex aIdx, selectedIndexes()) { - if (dataModel()->feature(aIdx) == aFeature) { + FeaturePtr aFea = dataModel()->feature(aIdx); + if (dataModel()->feature(aIdx)->isSame(aFeature)) { aIndex = aIdx; break; } @@ -306,4 +315,33 @@ void XGUI_ObjectsBrowser::onEditItem() myActiveDocLbl->setProperty("OldText", myActiveDocLbl->text()); } } -} \ No newline at end of file +} + +//*************************************************** +void XGUI_ObjectsBrowser::onSelectionChanged() +{ + myFeaturesList = myTreeView->selectedFeatures(); + emit selectionChanged(); +} + +//*************************************************** +void XGUI_ObjectsBrowser::rebuildDataTree() +{ + myDocModel->rebuildDataTree(); + update(); +} + +//*************************************************** +void XGUI_ObjectsBrowser::setFeaturesSelected(const QFeatureList& theFeatures) +{ + QList theIndexes; + QItemSelectionModel* aSelectModel = myTreeView->selectionModel(); + aSelectModel->clear(); + + foreach(FeaturePtr aFeature, theFeatures) { + QModelIndex aIndex = myDocModel->featureIndex(aFeature); + if (aIndex.isValid()) { + aSelectModel->select(aIndex, QItemSelectionModel::Select); + } + } +}