X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_ObjectsBrowser.cpp;h=754034d3a3cc8b42178ae05569a920e59a5b9880;hb=dff2e776460fc98e6b234181479ec680a91e9623;hp=37f2fe0c559e37c0734c2f619f6825d14c220d6f;hpb=4f065faea064d3407157bfe570d0cd67622a6d7b;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 37f2fe0c5..754034d3a 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "XGUI_ObjectsBrowser.h" @@ -26,11 +25,13 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -50,7 +51,6 @@ #define FIRST_COL_WIDTH 20 #define SECOND_COL_WIDTH 30 - /** * \ingroup GUI * Tree item delegate for definition of data in column items editor @@ -131,7 +131,7 @@ void XGUI_DataTree::commitData(QWidget* theEditor) if (XGUI_Tools::canRename(aObj, aName)) { SessionPtr aMgr = ModelAPI_Session::get(); aMgr->startOperation("Rename"); - aObj->data()->setName(qPrintable(aName)); + aObj->data()->setName(aName.toStdString()); aMgr->finishOperation(); } } @@ -228,34 +228,34 @@ void XGUI_DataTree::processHistoryChange(const QModelIndex& theIndex) update(aModel->index(i, 1, aParent)); update(aModel->index(i, 2, aParent)); } + XGUI_ObjectsBrowser* aObjBrowser = qobject_cast(parent()); + aObjBrowser->workshop()->displayer()->updateViewer(); } void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex) { + XGUI_ObjectsBrowser* aObjBrowser = qobject_cast(parent()); XGUI_DataModel* aModel = dataModel(); ObjectPtr aObj = aModel->object(theIndex); if (aObj.get()) { - ResultPtr aResObj = std::dynamic_pointer_cast(aObj); - XGUI_ObjectsBrowser* aObjBrowser = qobject_cast(parent()); - if (aResObj.get()) { - std::set anObjects; - anObjects.insert(aResObj); - - bool hasHiddenState = aModel->hasHiddenState(theIndex); - if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects)) - return; - if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem) - if (aResObj->isDisplayed()) - aResObj->setDisplayed(false); - aResObj->setDisplayed(true); - } - else - aResObj->setDisplayed(!aResObj->isDisplayed()); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); - update(theIndex); + std::set anObjects; + anObjects.insert(aObj); + + bool hasHiddenState = aModel->hasHiddenState(theIndex); + if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects)) + return; + if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem) + if (aObj->isDisplayed()) + aObj->setDisplayed(false); + aObj->setDisplayed(true); } + else + aObj->setDisplayed(!aObj->isDisplayed()); + // Update list of selected objects because this event happens after // selection event in object browser + Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); + update(theIndex); if (aObjBrowser) { aObjBrowser->onSelectionChanged(); } @@ -417,7 +417,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent, XGUI_Workshop* theW aLabelWgt->setPalette(aPalet); myDocModel = new XGUI_DataModel(this); - connect(myDocModel, SIGNAL(modelAboutToBeReset()), SLOT(onBeforeReset())); + connect(myDocModel, SIGNAL(beforeTreeRebuild()), SLOT(onBeforeReset())); connect(myDocModel, SIGNAL(treeRebuilt()), SLOT(onAfterModelReset())); connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, @@ -510,16 +510,17 @@ void XGUI_ObjectsBrowser::onEditItem() } //*************************************************** -QModelIndexList XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent) const +QList XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent) const { - QModelIndexList aIndexes; + QList aIndexes; QModelIndex aIndex; - for (int i = 0; i < myDocModel->rowCount(theParent); i++) { + int aCount = myDocModel->rowCount(theParent); + for (int i = 0; i < aCount; i++) { aIndex = myDocModel->index(i, 0, theParent); if (myDocModel->hasChildren(aIndex)) { if (myTreeView->isExpanded(aIndex)) { - aIndexes.append(aIndex); - QModelIndexList aSubIndexes = expandedItems(aIndex); + aIndexes.append((ModuleBase_ITreeNode*)aIndex.internalPointer()); + QList aSubIndexes = expandedItems(aIndex); if (!aSubIndexes.isEmpty()) aIndexes.append(aSubIndexes); } @@ -656,10 +657,16 @@ void XGUI_ObjectsBrowser::onBeforeReset() void XGUI_ObjectsBrowser::onAfterModelReset() { - foreach(QModelIndex aIndex, myExpandedItems) { - if (myTreeView->dataModel()->hasIndex(aIndex)) - myTreeView->setExpanded(aIndex, true); + XGUI_DataModel* aModel = myTreeView->dataModel(); + QModelIndex aIndex; + foreach(ModuleBase_ITreeNode* aNode, myExpandedItems) { + if (aModel->hasNode(aNode)) { + aIndex = aModel->getIndex(aNode, 0); + if (aIndex.isValid() && (myTreeView->dataModel()->hasIndex(aIndex))) + myTreeView->setExpanded(aIndex, true); + } } + myExpandedItems.clear(); } std::list XGUI_ObjectsBrowser::getStateForDoc(DocumentPtr theDoc) const @@ -728,3 +735,10 @@ void XGUI_ObjectsBrowser::setFoldersState(const QMap& theStates myTreeView->setExpanded(aIdx, aIt.value()); } } + + +void XGUI_ObjectsBrowser::resizeEvent(QResizeEvent* theEvent) +{ + QWidget::resizeEvent(theEvent); + emit sizeChanged(); +}