Salome HOME
Copyright update 2022
[modules/shaper.git] / src / XGUI / XGUI_ObjectsBrowser.cpp
index 173e4e8fb72c4f7c0f7ed7302bf3e71da1e26d74..34c113f2cdc01ef0a3b68fe714316684678d9a95 100644 (file)
@@ -1,4 +1,21 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+// Copyright (C) 2014-2022  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "XGUI_ObjectsBrowser.h"
 #include "XGUI_Tools.h"
@@ -8,8 +25,13 @@
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultField.h>
 
 #include <ModuleBase_Tools.h>
+#include <ModuleBase_ITreeNode.h>
+
+#include <XGUI_Workshop.h>
+#include <XGUI_Displayer.h>
 
 #include <QLayout>
 #include <QLineEdit>
 #include <QAction>
 #include <QStyledItemDelegate>
 #include <QMessageBox>
+#include <QApplication>
 
-#ifdef WIN32
-#ifdef HAVE_SALOME
-// PORTING_TO_SALOME_8
-//#include <QWindowsStyle>
-#include <QCommonStyle>
-#endif
+#ifdef DEBUG_INDXES
+#include <QToolTip>
 #endif
 
-
 /// Width of second column (minimum acceptable = 27)
+#define FIRST_COL_WIDTH 20
 #define SECOND_COL_WIDTH 30
 
-
 /**
 * \ingroup GUI
 * Tree item delegate for definition of data in column items editor
@@ -55,7 +73,7 @@ public:
       XGUI_DataModel* aModel = myTreedView->dataModel();
       ObjectPtr aObj = aModel->object(index);
       if (aObj.get() != NULL) {
-        aEditor->setText(aObj->data()->name().c_str());
+        aEditor->setText(QString::fromStdWString(aObj->data()->name()));
         return;
       }
     }
@@ -70,21 +88,13 @@ private:
 XGUI_DataTree::XGUI_DataTree(QWidget* theParent)
     : QTreeView(theParent)
 {
-#ifdef WIN32
-#ifdef HAVE_SALOME
-  setStyle(new QCommonStyle());
-#else
-  myStyle = new XGUI_TreeViewStyle();
-  setStyle(myStyle);
-#endif
-#endif
-
   setHeaderHidden(true);
+  setTreePosition(1);
   setEditTriggers(QAbstractItemView::NoEditTriggers);
   setSelectionBehavior(QAbstractItemView::SelectRows);
   setSelectionMode(QAbstractItemView::ExtendedSelection);
 
-  setItemDelegateForColumn(0, new XGUI_TreeViewItemDelegate(this));
+  setItemDelegateForColumn(1, new XGUI_TreeViewItemDelegate(this));
 
   connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
     SLOT(onDoubleClick(const QModelIndex&)));
@@ -121,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.toStdWString());
         aMgr->finishOperation();
       }
     }
@@ -140,15 +150,46 @@ void XGUI_DataTree::resizeEvent(QResizeEvent* theEvent)
   QTreeView::resizeEvent(theEvent);
   QSize aSize = theEvent->size();
   if (aSize.isValid()) {
-    setColumnWidth(0, aSize.width() - SECOND_COL_WIDTH - 6);
-    setColumnWidth(1, SECOND_COL_WIDTH);
+    setColumnWidth(0, FIRST_COL_WIDTH);
+    setColumnWidth(1, aSize.width() - SECOND_COL_WIDTH - FIRST_COL_WIDTH - 10);
+    setColumnWidth(2, SECOND_COL_WIDTH);
   }
 }
 
-void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
+#ifdef DEBUG_INDXES
+void XGUI_DataTree::mousePressEvent(QMouseEvent* theEvent)
 {
-  if (theIndex.column() != 1)
+  QTreeView::mousePressEvent(theEvent);
+  if (theEvent->button() != Qt::MidButton)
     return;
+  QModelIndex aInd = indexAt(theEvent->pos());
+  QString aTxt =
+    QString("r=%1 c=%2 p=%3").arg(aInd.row()).arg(aInd.column()).arg((long)aInd.internalPointer());
+
+  QModelIndex aPar = aInd.parent();
+  QString aTxt1 =
+    QString("r=%1 c=%2 p=%3").arg(aPar.row()).arg(aPar.column()).arg((long)aPar.internalPointer());
+  QToolTip::showText(theEvent->globalPos(), aTxt + '\n' + aTxt1);
+}
+#endif
+
+void XGUI_DataTree::mouseReleaseEvent(QMouseEvent* theEvent)
+{
+  QTreeView::mouseReleaseEvent(theEvent);
+#ifdef DEBUG_INDXES
+  if (theEvent->button() != Qt::MidButton)
+    return;
+  QToolTip::hideText();
+#endif
+  if (theEvent->button() == Qt::LeftButton) {
+    QModelIndex aInd = indexAt(theEvent->pos());
+    if (aInd.column() == 0)
+      processEyeClick(aInd);
+  }
+}
+
+void XGUI_DataTree::processHistoryChange(const QModelIndex& theIndex)
+{
   SessionPtr aMgr = ModelAPI_Session::get();
   // When operation is opened then we can not change history
   if (aMgr->isOperation())
@@ -169,10 +210,10 @@ void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
     aMgr->finishOperation();
   } else {
     // Ignore clicks on folders outside current document
-    if ((theIndex.internalId() == -1) && (aDoc != aMgr->moduleDocument()))
+    if ((theIndex.internalId() == 0) && (aDoc != aMgr->moduleDocument()))
       // Clicked folder under root but active document is another
       return;
-    if ((theIndex.internalId() != -1) && (aDoc.get() != theIndex.internalPointer()))
+    if ((theIndex.internalId() != 0) && (aDoc != aModel->document(theIndex)))
       // Cliced not on active document folder
       return;
 
@@ -180,47 +221,55 @@ void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
     aDoc->setCurrentFeature(FeaturePtr(), true);
     aMgr->finishOperation();
   }
-  QModelIndex aNewIndex = aModel->lastHistoryIndex();
   QModelIndex aParent = theIndex.parent();
   int aSize = aModel->rowCount(aParent);
   for (int i = 0; i < aSize; i++) {
     update(aModel->index(i, 0, aParent));
     update(aModel->index(i, 1, aParent));
+    update(aModel->index(i, 2, aParent));
   }
+  XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
+  aObjBrowser->workshop()->displayer()->updateViewer();
 }
 
-#if (!defined HAVE_SALOME) && (defined WIN32)
-void XGUI_DataTree::drawRow(QPainter* thePainter,
-                            const QStyleOptionViewItem& theOptions,
-                            const QModelIndex& theIndex) const
+void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
 {
-  QStyleOptionViewItemV4 aOptions = theOptions;
-  myStyle->setIndex(theIndex);
-  QTreeView::drawRow(thePainter, aOptions, theIndex);
-}
+  XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
+  XGUI_DataModel* aModel = dataModel();
+  ObjectPtr aObj = aModel->object(theIndex);
+  if (aObj.get()) {
+    std::set<ObjectPtr> anObjects;
+    anObjects.insert(aObj);
 
-//********************************************************************
-//********************************************************************
-//********************************************************************
-void XGUI_TreeViewStyle::drawPrimitive(PrimitiveElement theElement,
-                                       const QStyleOption* theOption,
-                                       QPainter* thePainter, const QWidget* theWidget) const
-{
-  if ((theElement == QStyle::PE_PanelItemViewRow) || (theElement == QStyle::PE_PanelItemViewItem)) {
-    const QStyleOptionViewItemV4* aOptions =
-      qstyleoption_cast<const QStyleOptionViewItemV4 *>(theOption);
-    if (myIndex.isValid() && ((myIndex.flags() & Qt::ItemIsSelectable) == 0)) {
-      QStyle::State aState = aOptions->state;
-      if ((aState & QStyle::State_MouseOver) != 0)
-        aState &= ~QStyle::State_MouseOver;
-      QStyleOptionViewItemV4* aOpt = (QStyleOptionViewItemV4*) aOptions;
-      aOpt->state = aState;
-      QCommonStyle/*QWindowsVistaStyle*/::drawPrimitive(theElement, aOpt, thePainter, theWidget);
+    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();
     }
   }
-  QCommonStyle/*QWindowsVistaStyle*/::drawPrimitive(theElement, theOption, thePainter, theWidget);
 }
-#endif
+
+void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
+{
+  switch (theIndex.column()) {
+  case 2:
+    processHistoryChange(theIndex);
+    break;
+  }
+}
 
 
 //********************************************************************
@@ -245,9 +294,10 @@ void XGUI_ActiveDocLbl::setTreeView(QTreeView* theView)
   QColor aHighlightText = aPalet.highlightedText().color();
 
   myPreSelectionStyle = "QLabel {background-color: ";
-  myPreSelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:1 " +
-    aHighlight.lighter(170).name() + ");";
-  myPreSelectionStyle += "border: 1px solid lightblue; border-radius: 2px }";
+  myPreSelectionStyle += aHighlight.lighter(170).name() + "}";
+  //myPreSelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:1 " +
+  //  aHighlight.lighter(170).name() + ");";
+  //myPreSelectionStyle += "border: 1px solid lightblue; border-radius: 2px }";
 
   QString aName = aPalet.color(QPalette::Base).name();
   myNeutralStyle = "QLabel { border: 1px solid " + aName + " }";
@@ -255,9 +305,11 @@ void XGUI_ActiveDocLbl::setTreeView(QTreeView* theView)
 
 #if (!defined HAVE_SALOME) && (defined WIN32)
   mySelectionStyle = "QLabel {background-color: ";
-  mySelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(236, 245, 255)";
-  mySelectionStyle += ", stop:1 rgb(208, 229, 255));";
-  mySelectionStyle += "border: 1px solid rgb(132, 172, 221); border-radius: 2px }";
+  mySelectionStyle += "rgb(205, 232, 255); ";
+  //mySelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(236, 245, 255)";
+  //mySelectionStyle += ", stop:1 rgb(208, 229, 255));";
+  //mySelectionStyle += "border: 1px solid rgb(132, 172, 221); border-radius: 2px }";
+  mySelectionStyle += "border: 1px solid rgb(153, 209, 255) }";
 #else
   mySelectionStyle = "QLabel {background-color: " + aHighlight.name();
   mySelectionStyle += "; color : " + aHighlightText.name() + "}";
@@ -318,8 +370,8 @@ void XGUI_ActiveDocLbl::unselect()
 //********************************************************************
 //********************************************************************
 //********************************************************************
-XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
-    : QWidget(theParent), myDocModel(0)
+XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent, XGUI_Workshop* theWorkshop)
+    : QWidget(theParent), myDocModel(0), myWorkshop(theWorkshop)
 {
   QVBoxLayout* aLayout = new QVBoxLayout(this);
   ModuleBase_Tools::zeroMargins(aLayout);
@@ -365,7 +417,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent)
   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,
@@ -377,9 +429,10 @@ XGUI_ObjectsBrowser::~XGUI_ObjectsBrowser()
 {
 }
 
-void XGUI_ObjectsBrowser::setXMLReader(Config_DataModelReader* theReader)
+void XGUI_ObjectsBrowser::initialize(ModuleBase_ITreeNode* theRoot)
 {
-  myDocModel->setXMLReader(theReader);
+  //myDocModel->setXMLReader(theReader);
+  myDocModel->setRoot(theRoot);
   myTreeView->setModel(myDocModel);
 
   // It has to be done after setting of model
@@ -439,10 +492,12 @@ void XGUI_ObjectsBrowser::onEditItem()
       // Find index which corresponds the feature
       QModelIndex aIndex;
       foreach(QModelIndex aIdx, selectedIndexes()) {
-        ObjectPtr aFea = dataModel()->object(aIdx);
-        if (dataModel()->object(aIdx)->isSame(anObject)) {
-          aIndex = aIdx;
-          break;
+        if (aIdx.column() == 1) {
+          ObjectPtr aFea = dataModel()->object(aIdx);
+          if (dataModel()->object(aIdx)->isSame(anObject)) {
+            aIndex = aIdx;
+            break;
+          }
         }
       }
       if (aIndex.isValid()) {
@@ -455,16 +510,17 @@ void XGUI_ObjectsBrowser::onEditItem()
 }
 
 //***************************************************
-QModelIndexList XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent) const
+QList<ModuleBase_ITreeNode*> XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent) const
 {
-  QModelIndexList aIndexes;
+  QList<ModuleBase_ITreeNode*> 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<ModuleBase_ITreeNode*> aSubIndexes = expandedItems(aIndex);
         if (!aSubIndexes.isEmpty())
           aIndexes.append(aSubIndexes);
       }
@@ -476,6 +532,7 @@ QModelIndexList XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent)
 //***************************************************
 void XGUI_ObjectsBrowser::rebuildDataTree()
 {
+  myDocModel->root()->update();
   myDocModel->rebuildDataTree();
   update();
 }
@@ -483,16 +540,74 @@ void XGUI_ObjectsBrowser::rebuildDataTree()
 //***************************************************
 void XGUI_ObjectsBrowser::setObjectsSelected(const QObjectPtrList& theObjects)
 {
-  QList<QModelIndex> theIndexes;
   QItemSelectionModel* aSelectModel = myTreeView->selectionModel();
-  aSelectModel->clear();
+  QModelIndexList aIndexes = aSelectModel->selectedIndexes();
+  if (theObjects.size() == 0) {
+    bool aIsBlock = aSelectModel->blockSignals(true);
+    aSelectModel->clear();
+    aSelectModel->blockSignals(aIsBlock);
+    foreach(QModelIndex aIdx, aIndexes) {
+      myTreeView->update(aIdx);
+    }
+    return;
+  }
 
-  foreach(ObjectPtr aFeature, theObjects)
-  {
-    QModelIndex aIndex = myDocModel->objectIndex(aFeature);
-    if (aIndex.isValid()) {
-      aSelectModel->select(aIndex, QItemSelectionModel::Select);
+  ObjectPtr aObject;
+  QModelIndexList aUnselect;
+  QObjectPtrList aToSelect = theObjects;
+  QHash<qint64, ObjectPtr> aNotChanged;
+  foreach(QModelIndex aIdx, aIndexes) {
+    aObject = myDocModel->object(aIdx);
+    if (aObject.get()) {
+      if (aToSelect.contains(aObject)) {
+        aNotChanged.insert((qint64)aObject.get(), aObject);
+      } else {
+        aUnselect.append(aIdx);
+      }
+    }
+    else {
+      aUnselect.append(aIdx);
+    }
+  }
+
+  foreach(ObjectPtr aObj, aNotChanged)
+    aToSelect.removeAll(aObj);
+
+  bool aIsBlock = aSelectModel->blockSignals(true);
+  foreach(QModelIndex aIdx, aUnselect) {
+    aSelectModel->select(aIdx, QItemSelectionModel::Deselect);
+    myTreeView->update(aIdx);
+  }
+
+  QModelIndex aIndex0, aIndex1, aIndex2, aCurrent;
+  foreach(ObjectPtr aFeature, aToSelect) {
+    aIndex1 = myDocModel->objectIndex(aFeature, 1);
+    if (aIndex1.isValid()) {
+      if (!aCurrent.isValid())
+        aCurrent = aIndex1;
+      aIndex0 = myDocModel->objectIndex(aFeature, 0);
+      aIndex2 = myDocModel->objectIndex(aFeature, 2);
+      aSelectModel->select(aIndex1, QItemSelectionModel::Select | QItemSelectionModel::Rows);
+      myTreeView->update(aIndex0);
+      myTreeView->update(aIndex1);
+      myTreeView->update(aIndex2);
+    }
+  }
+  aSelectModel->setCurrentIndex(aCurrent, QItemSelectionModel::NoUpdate);
+  aSelectModel->blockSignals(aIsBlock);
+}
+
+//***************************************************
+void XGUI_ObjectsBrowser::ensureVisible(const ObjectPtr theObject)
+{
+  QModelIndex aIndex = myDocModel->objectIndex(theObject);
+  if (aIndex.isValid())  {
+    QModelIndex aParent = aIndex.parent();
+    while (aParent.isValid()) {
+      myTreeView->expand(aParent);
+      aParent = aParent.parent();
     }
+    myTreeView->scrollTo(aIndex);
   }
 }
 
@@ -502,25 +617,33 @@ void XGUI_ObjectsBrowser::clearContent()
   myTreeView->clear();
 }
 
-void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected,
-                                       const QItemSelection& theDeselected)
+//***************************************************
+void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& /*theSelected*/,
+                                             const QItemSelection& /*theDeselected*/)
+{
+  onSelectionChanged();
+}
+
+//***************************************************
+void XGUI_ObjectsBrowser::onSelectionChanged()
 {
   emit selectionChanged();
 }
 
+//***************************************************
 QObjectPtrList XGUI_ObjectsBrowser::selectedObjects(QModelIndexList* theIndexes) const
 {
   QObjectPtrList aList;
   QModelIndexList aIndexes = selectedIndexes();
   XGUI_DataModel* aModel = dataModel();
-  QModelIndexList::const_iterator aIt;
-  for (aIt = aIndexes.constBegin(); aIt != aIndexes.constEnd(); ++aIt) {
-    if ((*aIt).column() == 0) {
-      ObjectPtr aObject = aModel->object(*aIt);
+
+  foreach(QModelIndex aIdx, aIndexes) {
+    if (aIdx.column() == 1) {
+      ObjectPtr aObject = aModel->object(aIdx);
       if (aObject) {
         aList.append(aObject);
         if (theIndexes)
-          theIndexes->append(*aIt);
+          theIndexes->append(aIdx);
       }
     }
   }
@@ -534,9 +657,16 @@ void XGUI_ObjectsBrowser::onBeforeReset()
 
 void XGUI_ObjectsBrowser::onAfterModelReset()
 {
-  foreach(QModelIndex aIndex, myExpandedItems) {
-    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<bool> XGUI_ObjectsBrowser::getStateForDoc(DocumentPtr theDoc) const
@@ -569,3 +699,46 @@ void XGUI_ObjectsBrowser::setStateForDoc(DocumentPtr theDoc, const std::list<boo
     myTreeView->setExpanded(aIdx, (*aIt));
   }
 }
+
+void XGUI_ObjectsBrowser::updateAllIndexes(int theColumn, const QModelIndex& theParent)
+{
+  int aNb = myDocModel->rowCount(theParent);
+  for (int i = 0; i < aNb; i++) {
+    QModelIndex aIdx = myDocModel->index(i, theColumn, theParent);
+    if (aIdx.isValid() && myDocModel->hasIndex(aIdx)) {
+      myTreeView->update(aIdx);
+      if (myTreeView->isExpanded(aIdx))
+        updateAllIndexes(theColumn, aIdx);
+    }
+  }
+}
+
+QMap<ObjectPtr, bool> XGUI_ObjectsBrowser::getFoldersState(DocumentPtr theDoc) const
+{
+  QMap<ObjectPtr, bool> aMap;
+
+  int aNb = theDoc->size(ModelAPI_Folder::group());
+  ObjectPtr aObj;
+  for (int i = 0; i < aNb; i++) {
+    aObj = theDoc->object(ModelAPI_Folder::group(), i);
+    QModelIndex aIdx = myDocModel->objectIndex(aObj, 0);
+    aMap[aObj] = myTreeView->isExpanded(aIdx);
+  }
+  return aMap;
+}
+
+void XGUI_ObjectsBrowser::setFoldersState(const QMap<ObjectPtr, bool>& theStates)
+{
+  QMap<ObjectPtr, bool>::const_iterator aIt;
+  for (aIt = theStates.constBegin(); aIt != theStates.constEnd(); aIt++) {
+    QModelIndex aIdx = myDocModel->objectIndex(aIt.key(), 0);
+    myTreeView->setExpanded(aIdx, aIt.value());
+  }
+}
+
+
+void XGUI_ObjectsBrowser::resizeEvent(QResizeEvent* theEvent)
+{
+  QWidget::resizeEvent(theEvent);
+  emit sizeChanged();
+}