1 // Copyright (C) 2014-2023 CEA, EDF
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "XGUI_ObjectsBrowser.h"
21 #include "XGUI_Tools.h"
22 #include "XGUI_DataModel.h"
24 #include <ModelAPI_Data.h>
25 #include <ModelAPI_Session.h>
26 #include <ModelAPI_Document.h>
27 #include <ModelAPI_Tools.h>
28 #include <ModelAPI_ResultField.h>
30 #include <ModuleBase_Tools.h>
31 #include <ModuleBase_ITreeNode.h>
33 #include <XGUI_Workshop.h>
34 #include <XGUI_Displayer.h>
40 #include <QMouseEvent>
42 #include <QStyledItemDelegate>
43 #include <QMessageBox>
44 #include <QApplication>
50 /// Width of second column (minimum acceptable = 27)
51 #define FIRST_COL_WIDTH 20
52 #define SECOND_COL_WIDTH 30
56 * Tree item delegate for definition of data in column items editor
58 class XGUI_TreeViewItemDelegate: public QStyledItemDelegate
62 /// \param theParent a parent of the delegate
63 XGUI_TreeViewItemDelegate(XGUI_DataTree* theParent):QStyledItemDelegate(theParent),
64 myTreedView(theParent) {}
66 /// Set data for item editor (name of the item)
67 /// \param editor a widget of editor
68 /// \param index the tree item index
69 virtual void setEditorData ( QWidget* editor, const QModelIndex& index ) const
71 QLineEdit* aEditor = dynamic_cast<QLineEdit*>(editor);
73 XGUI_DataModel* aModel = myTreedView->dataModel();
74 ObjectPtr aObj = aModel->object(index);
75 if (aObj.get() != NULL) {
76 aEditor->setText(QString::fromStdWString(aObj->data()->name()));
80 QStyledItemDelegate::setEditorData(editor, index);
84 XGUI_DataTree* myTreedView;
88 XGUI_DataTree::XGUI_DataTree(QWidget* theParent)
89 : QTreeView(theParent)
91 setHeaderHidden(true);
93 setEditTriggers(QAbstractItemView::NoEditTriggers);
94 setSelectionBehavior(QAbstractItemView::SelectRows);
95 setSelectionMode(QAbstractItemView::ExtendedSelection);
100 viewport()->setAcceptDrops(true);
101 setDropIndicatorShown(true);
102 setDragDropMode(QAbstractItemView::InternalMove);
104 setItemDelegateForColumn(1, new XGUI_TreeViewItemDelegate(this));
106 connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
107 SLOT(onDoubleClick(const QModelIndex&)));
110 XGUI_DataTree::~XGUI_DataTree()
114 XGUI_DataModel* XGUI_DataTree::dataModel() const
116 return static_cast<XGUI_DataModel*>(model());
119 void XGUI_DataTree::contextMenuEvent(QContextMenuEvent* theEvent)
121 emit contextMenuRequested(theEvent);
124 void XGUI_DataTree::commitData(QWidget* theEditor)
126 static int aEntrance = 0;
127 if (aEntrance == 0) {
128 // We have to check number of enter and exit of this function because it can be called
129 // recursively by Qt in order to avoid double modifying of a data
131 QLineEdit* aEditor = dynamic_cast<QLineEdit*>(theEditor);
133 QString aName = aEditor->text();
134 QModelIndexList aIndexList = selectionModel()->selectedIndexes();
135 XGUI_DataModel* aModel = dataModel();
136 ObjectPtr aObj = aModel->object(aIndexList.first());
138 if (XGUI_Tools::canRename(aObj, aName)) {
139 SessionPtr aMgr = ModelAPI_Session::get();
140 aMgr->startOperation("Rename");
141 aObj->data()->setName(aName.toStdWString());
142 aMgr->finishOperation();
149 void XGUI_DataTree::clear()
151 dataModel()->clear();
155 void XGUI_DataTree::resizeEvent(QResizeEvent* theEvent)
157 QTreeView::resizeEvent(theEvent);
158 QSize aSize = theEvent->size();
159 if (aSize.isValid()) {
160 setColumnWidth(0, FIRST_COL_WIDTH);
161 setColumnWidth(1, aSize.width() - SECOND_COL_WIDTH - FIRST_COL_WIDTH - 10);
162 setColumnWidth(2, SECOND_COL_WIDTH);
167 void XGUI_DataTree::mousePressEvent(QMouseEvent* theEvent)
169 QTreeView::mousePressEvent(theEvent);
170 if (theEvent->button() != Qt::MidButton)
172 QModelIndex aInd = indexAt(theEvent->pos());
174 QString("r=%1 c=%2 p=%3").arg(aInd.row()).arg(aInd.column()).arg((long)aInd.internalPointer());
176 QModelIndex aPar = aInd.parent();
178 QString("r=%1 c=%2 p=%3").arg(aPar.row()).arg(aPar.column()).arg((long)aPar.internalPointer());
179 QToolTip::showText(theEvent->globalPos(), aTxt + '\n' + aTxt1);
183 void XGUI_DataTree::mouseReleaseEvent(QMouseEvent* theEvent)
185 QTreeView::mouseReleaseEvent(theEvent);
187 if (theEvent->button() != Qt::MidButton)
189 QToolTip::hideText();
191 if (theEvent->button() == Qt::LeftButton) {
192 QModelIndex aInd = indexAt(theEvent->pos());
193 if (aInd.column() == 0)
194 processEyeClick(aInd);
198 void XGUI_DataTree::processHistoryChange(const QModelIndex& theIndex)
200 SessionPtr aMgr = ModelAPI_Session::get();
201 // When operation is opened then we can not change history
202 if (aMgr->isOperation())
204 XGUI_DataModel* aModel = dataModel();
205 if (aModel->flags(theIndex) == 0)
207 ObjectPtr aObj = aModel->object(theIndex);
209 DocumentPtr aDoc = aMgr->activeDocument();
211 std::string aOpName = tr("History change").toStdString();
213 if (aObj->document() != aDoc)
215 aMgr->startOperation(aOpName);
216 aDoc->setCurrentFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(aObj), true);
217 aMgr->finishOperation();
219 // Ignore clicks on folders outside current document
220 if ((theIndex.internalId() == 0) && (aDoc != aMgr->moduleDocument()))
221 // Clicked folder under root but active document is another
223 if ((theIndex.internalId() != 0) && (aDoc != aModel->document(theIndex)))
224 // Cliced not on active document folder
227 aMgr->startOperation(aOpName);
228 aDoc->setCurrentFeature(FeaturePtr(), true);
229 aMgr->finishOperation();
231 QModelIndex aParent = theIndex.parent();
232 int aSize = aModel->rowCount(aParent);
233 for (int i = 0; i < aSize; i++) {
234 update(aModel->index(i, 0, aParent));
235 update(aModel->index(i, 1, aParent));
236 update(aModel->index(i, 2, aParent));
238 XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
239 aObjBrowser->workshop()->displayer()->updateViewer();
242 void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
244 XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
245 XGUI_DataModel* aModel = dataModel();
246 ObjectPtr aObj = aModel->object(theIndex);
248 std::set<ObjectPtr> anObjects;
249 anObjects.insert(aObj);
251 bool hasHiddenState = aModel->hasHiddenState(theIndex);
252 if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects))
254 if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem)
255 if (aObj->isDisplayed())
256 aObj->setDisplayed(false);
257 aObj->setDisplayed(true);
260 aObj->setDisplayed(!aObj->isDisplayed());
262 // Update list of selected objects because this event happens after
263 // selection event in object browser
264 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
267 aObjBrowser->onSelectionChanged();
272 void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
274 switch (theIndex.column()) {
276 processHistoryChange(theIndex);
282 //********************************************************************
283 //********************************************************************
284 //********************************************************************
285 XGUI_ActiveDocLbl::XGUI_ActiveDocLbl(const QString& theText, QWidget* theParent )
286 : QLabel(theText, theParent),
287 myPreSelectionStyle(""),
289 mySelectionStyle(""),
294 void XGUI_ActiveDocLbl::setTreeView(QTreeView* theView)
296 myTreeView = theView;
297 setFont(myTreeView->font());
299 QPalette aPalet = myTreeView->palette();
300 QColor aHighlight = aPalet.highlight().color();
301 QColor aHighlightText = aPalet.highlightedText().color();
303 myPreSelectionStyle = "QLabel {background-color: ";
304 myPreSelectionStyle += aHighlight.lighter(170).name() + "}";
305 //myPreSelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:1 " +
306 // aHighlight.lighter(170).name() + ");";
307 //myPreSelectionStyle += "border: 1px solid lightblue; border-radius: 2px }";
309 QString aName = aPalet.color(QPalette::Base).name();
310 myNeutralStyle = "QLabel { border: 1px solid " + aName + " }";
313 #if (!defined HAVE_SALOME) && (defined WIN32)
314 mySelectionStyle = "QLabel {background-color: ";
315 mySelectionStyle += "rgb(205, 232, 255); ";
316 //mySelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(236, 245, 255)";
317 //mySelectionStyle += ", stop:1 rgb(208, 229, 255));";
318 //mySelectionStyle += "border: 1px solid rgb(132, 172, 221); border-radius: 2px }";
319 mySelectionStyle += "border: 1px solid rgb(153, 209, 255) }";
321 mySelectionStyle = "QLabel {background-color: " + aHighlight.name();
322 mySelectionStyle += "; color : " + aHighlightText.name() + "}";
325 myTreeView->viewport()->installEventFilter(this);
329 #if (!defined HAVE_SALOME) && (defined WIN32)
330 bool XGUI_ActiveDocLbl::event(QEvent* theEvent)
332 switch (theEvent->type()) {
335 setStyleSheet(myPreSelectionStyle);
339 setStyleSheet(myNeutralStyle);
342 return QLabel::event(theEvent);
346 bool XGUI_ActiveDocLbl::eventFilter(QObject* theObj, QEvent* theEvent)
348 if (theObj == myTreeView->viewport()) {
349 if (theEvent->type() == QEvent::MouseButtonRelease)
352 return QLabel::eventFilter(theObj, theEvent);
355 static bool MYClearing = false;
356 void XGUI_ActiveDocLbl::mouseReleaseEvent( QMouseEvent* e)
360 setStyleSheet(mySelectionStyle);
361 // We can not block signals because on
362 // clear selection the View state will not be updated
363 myTreeView->clearSelection();
364 QLabel::mouseReleaseEvent(e);
368 void XGUI_ActiveDocLbl::unselect()
371 myIsSelected = false;
372 setStyleSheet(myNeutralStyle);
377 //********************************************************************
378 //********************************************************************
379 //********************************************************************
380 XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent, XGUI_Workshop* theWorkshop)
381 : QWidget(theParent), myDocModel(0), myWorkshop(theWorkshop)
383 QVBoxLayout* aLayout = new QVBoxLayout(this);
384 ModuleBase_Tools::zeroMargins(aLayout);
385 aLayout->setSpacing(0);
387 QWidget* aLabelWgt = new QWidget(this);
388 aLabelWgt->setAutoFillBackground(true);
390 aLayout->addWidget(aLabelWgt);
391 QHBoxLayout* aLabelLay = new QHBoxLayout(aLabelWgt);
392 ModuleBase_Tools::zeroMargins(aLabelLay);
393 aLabelLay->setSpacing(0);
395 QLabel* aLbl = new QLabel(aLabelWgt);
396 aLbl->setPixmap(QPixmap(":pictures/assembly.png"));
398 // Do not paint background of the label (in order to show icon)
399 aLbl->setAutoFillBackground(false);
401 aLabelLay->addWidget(aLbl);
403 SessionPtr aMgr = ModelAPI_Session::get();
404 DocumentPtr aDoc = aMgr->moduleDocument();
406 myActiveDocLbl = new XGUI_ActiveDocLbl(tr("Part set"), aLabelWgt);
407 // myActiveDocLbl->setReadOnly(true);
408 // myActiveDocLbl->setFrame(false);
409 myActiveDocLbl->setContextMenuPolicy(Qt::CustomContextMenu);
411 aLabelLay->addWidget(myActiveDocLbl);
412 aLabelLay->setStretch(1, 1);
414 myTreeView = new XGUI_DataTree(this);
415 myTreeView->setFrameShape(QFrame::NoFrame);
416 aLayout->addWidget(myTreeView);
418 QPalette aTreePalet = myTreeView->palette();
419 QColor aTreeBack = aTreePalet.color(QPalette::Base);
422 aPalet.setColor(QPalette::Base, aTreeBack);
423 aPalet.setColor(QPalette::Window, aTreeBack);
424 aLabelWgt->setPalette(aPalet);
426 myDocModel = new XGUI_DataModel(this);
427 connect(myDocModel, SIGNAL(beforeTreeRebuild()), SLOT(onBeforeReset()));
428 connect(myDocModel, SIGNAL(treeRebuilt()), SLOT(onAfterModelReset()));
430 connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
431 SLOT(onContextMenuRequested(QContextMenuEvent*)));
434 //***************************************************
435 XGUI_ObjectsBrowser::~XGUI_ObjectsBrowser()
439 void XGUI_ObjectsBrowser::initialize(ModuleBase_ITreeNode* theRoot)
441 //myDocModel->setXMLReader(theReader);
442 myDocModel->setRoot(theRoot);
443 myTreeView->setModel(myDocModel);
445 // It has to be done after setting of model
446 myActiveDocLbl->setTreeView(myTreeView);
448 QItemSelectionModel* aSelMod = myTreeView->selectionModel();
449 connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
450 this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
453 //***************************************************
454 void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent)
456 QModelIndexList aIndexes;
457 QObjectPtrList aSelectedData = selectedObjects(&aIndexes);
458 bool toEnable = false;
460 if (aSelectedData.size() == 1) {
461 QModelIndex aSelected = myTreeView->indexAt(theEvent->pos());
462 if (!aIndexes.contains(aSelected))
463 return; // menu is called on non selected item
465 Qt::ItemFlags aFlags = dataModel()->flags(aIndexes.first());
466 toEnable = ((aFlags & Qt::ItemIsEditable) != 0);
468 foreach(QAction* aCmd, actions()) {
469 aCmd->setEnabled(toEnable);
471 emit contextMenuRequested(theEvent);
474 //***************************************************
475 void XGUI_ObjectsBrowser::onLabelContextMenuRequested(const QPoint& thePnt)
477 myTreeView->selectionModel()->clearSelection();
478 //Empty feature pointer means that selected root document
479 foreach(QAction* aCmd, actions()) {
480 aCmd->setEnabled(true);
482 QContextMenuEvent aEvent(QContextMenuEvent::Mouse, thePnt, myActiveDocLbl->mapToGlobal(thePnt));
483 emit contextMenuRequested(&aEvent);
486 //***************************************************
487 void XGUI_ObjectsBrowser::onEditItem()
489 QObjectPtrList aSelectedData = selectedObjects();
490 if (aSelectedData.size() > 0) {
491 ObjectPtr anObject = aSelectedData.first();
492 if (anObject.get()) { // Selection happens in TreeView
493 // check whether the object can be renamed. There should not be parts which are not loaded
494 std::set<FeaturePtr> aFeatures;
495 aFeatures.insert(ModelAPI_Feature::feature(anObject));
496 if (!XGUI_Tools::canRemoveOrRename((QWidget*)parent(), aFeatures))
499 // Find index which corresponds the feature
501 foreach(QModelIndex aIdx, selectedIndexes()) {
502 if (aIdx.column() == 1) {
503 ObjectPtr aFea = dataModel()->object(aIdx);
504 if (dataModel()->object(aIdx)->isSame(anObject)) {
510 if (aIndex.isValid()) {
511 myTreeView->setCurrentIndex(aIndex);
512 myTreeView->edit(aIndex);
519 //***************************************************
520 QList<ModuleBase_ITreeNode*> XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent) const
522 QList<ModuleBase_ITreeNode*> aIndexes;
524 int aCount = myDocModel->rowCount(theParent);
525 for (int i = 0; i < aCount; i++) {
526 aIndex = myDocModel->index(i, 0, theParent);
527 if (myDocModel->hasChildren(aIndex)) {
528 if (myTreeView->isExpanded(aIndex)) {
529 aIndexes.append((ModuleBase_ITreeNode*)aIndex.internalPointer());
530 QList<ModuleBase_ITreeNode*> aSubIndexes = expandedItems(aIndex);
531 if (!aSubIndexes.isEmpty())
532 aIndexes.append(aSubIndexes);
539 //***************************************************
540 void XGUI_ObjectsBrowser::rebuildDataTree()
542 myDocModel->root()->update();
543 myDocModel->rebuildDataTree();
547 //***************************************************
548 void XGUI_ObjectsBrowser::setObjectsSelected(const QObjectPtrList& theObjects)
550 QItemSelectionModel* aSelectModel = myTreeView->selectionModel();
551 QModelIndexList aIndexes = aSelectModel->selectedIndexes();
552 if (theObjects.size() == 0) {
553 bool aIsBlock = aSelectModel->blockSignals(true);
554 aSelectModel->clear();
555 aSelectModel->blockSignals(aIsBlock);
556 foreach(QModelIndex aIdx, aIndexes) {
557 myTreeView->update(aIdx);
563 QModelIndexList aUnselect;
564 QObjectPtrList aToSelect = theObjects;
565 QHash<qint64, ObjectPtr> aNotChanged;
566 foreach(QModelIndex aIdx, aIndexes) {
567 aObject = myDocModel->object(aIdx);
569 if (aToSelect.contains(aObject)) {
570 aNotChanged.insert((qint64)aObject.get(), aObject);
572 aUnselect.append(aIdx);
576 aUnselect.append(aIdx);
580 foreach(ObjectPtr aObj, aNotChanged)
581 aToSelect.removeAll(aObj);
583 bool aIsBlock = aSelectModel->blockSignals(true);
584 foreach(QModelIndex aIdx, aUnselect) {
585 aSelectModel->select(aIdx, QItemSelectionModel::Deselect);
586 myTreeView->update(aIdx);
589 QModelIndex aIndex0, aIndex1, aIndex2, aCurrent;
590 foreach(ObjectPtr aFeature, aToSelect) {
591 aIndex1 = myDocModel->objectIndex(aFeature, 1);
592 if (aIndex1.isValid()) {
593 if (!aCurrent.isValid())
595 aIndex0 = myDocModel->objectIndex(aFeature, 0);
596 aIndex2 = myDocModel->objectIndex(aFeature, 2);
597 aSelectModel->select(aIndex1, QItemSelectionModel::Select | QItemSelectionModel::Rows);
598 myTreeView->update(aIndex0);
599 myTreeView->update(aIndex1);
600 myTreeView->update(aIndex2);
603 aSelectModel->setCurrentIndex(aCurrent, QItemSelectionModel::NoUpdate);
604 aSelectModel->blockSignals(aIsBlock);
607 //***************************************************
608 void XGUI_ObjectsBrowser::ensureVisible(const ObjectPtr theObject)
610 QModelIndex aIndex = myDocModel->objectIndex(theObject);
611 if (aIndex.isValid()) {
612 QModelIndex aParent = aIndex.parent();
613 while (aParent.isValid()) {
614 myTreeView->expand(aParent);
615 aParent = aParent.parent();
617 myTreeView->scrollTo(aIndex);
621 //***************************************************
622 void XGUI_ObjectsBrowser::clearContent()
627 //***************************************************
628 void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& /*theSelected*/,
629 const QItemSelection& /*theDeselected*/)
631 onSelectionChanged();
634 //***************************************************
635 void XGUI_ObjectsBrowser::onSelectionChanged()
637 emit selectionChanged();
640 //***************************************************
641 QObjectPtrList XGUI_ObjectsBrowser::selectedObjects(QModelIndexList* theIndexes) const
643 QObjectPtrList aList;
644 QModelIndexList aIndexes = selectedIndexes();
645 XGUI_DataModel* aModel = dataModel();
647 foreach(QModelIndex aIdx, aIndexes) {
648 if (aIdx.column() == 1) {
649 ObjectPtr aObject = aModel->object(aIdx);
651 aList.append(aObject);
653 theIndexes->append(aIdx);
660 void XGUI_ObjectsBrowser::onBeforeReset()
662 myExpandedItems = expandedItems();
665 void XGUI_ObjectsBrowser::onAfterModelReset()
667 XGUI_DataModel* aModel = myTreeView->dataModel();
669 foreach(ModuleBase_ITreeNode* aNode, myExpandedItems) {
670 if (aModel->hasNode(aNode)) {
671 aIndex = aModel->getIndex(aNode, 0);
672 if (aIndex.isValid() && (myTreeView->dataModel()->hasIndex(aIndex)))
673 myTreeView->setExpanded(aIndex, true);
676 myExpandedItems.clear();
679 std::list<bool> XGUI_ObjectsBrowser::getStateForDoc(DocumentPtr theDoc) const
681 std::list<bool> aStates;
682 XGUI_DataModel* aModel = dataModel();
683 QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
684 int aNbChild = aModel->rowCount(aRootIdx);
685 for (int i = 0; i < aNbChild; i++) {
686 QModelIndex aIdx = aModel->index(i, 0, aRootIdx);
687 aStates.push_back(myTreeView->isExpanded(aIdx));
692 void XGUI_ObjectsBrowser::setStateForDoc(DocumentPtr theDoc, const std::list<bool>& theStates)
694 if (theStates.size() == 0)
696 XGUI_DataModel* aModel = dataModel();
697 QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
698 int aNbChild = aModel->rowCount(aRootIdx);
700 std::list<bool>::const_iterator aIt;
702 for (aIt = theStates.cbegin(); aIt != theStates.cend(); aIt++, i++) {
705 QModelIndex aIdx = aModel->index(i, 0, aRootIdx);
706 myTreeView->setExpanded(aIdx, (*aIt));
710 void XGUI_ObjectsBrowser::updateAllIndexes(int theColumn, const QModelIndex& theParent)
712 int aNb = myDocModel->rowCount(theParent);
713 for (int i = 0; i < aNb; i++) {
714 QModelIndex aIdx = myDocModel->index(i, theColumn, theParent);
715 if (aIdx.isValid() && myDocModel->hasIndex(aIdx)) {
716 myTreeView->update(aIdx);
717 if (myTreeView->isExpanded(aIdx))
718 updateAllIndexes(theColumn, aIdx);
723 QMap<ObjectPtr, bool> XGUI_ObjectsBrowser::getFoldersState(DocumentPtr theDoc) const
725 QMap<ObjectPtr, bool> aMap;
727 int aNb = theDoc->size(ModelAPI_Folder::group());
729 for (int i = 0; i < aNb; i++) {
730 aObj = theDoc->object(ModelAPI_Folder::group(), i);
731 QModelIndex aIdx = myDocModel->objectIndex(aObj, 0);
732 aMap[aObj] = myTreeView->isExpanded(aIdx);
737 void XGUI_ObjectsBrowser::setFoldersState(const QMap<ObjectPtr, bool>& theStates)
739 QMap<ObjectPtr, bool>::const_iterator aIt;
740 for (aIt = theStates.constBegin(); aIt != theStates.constEnd(); aIt++) {
741 QModelIndex aIdx = myDocModel->objectIndex(aIt.key(), 0);
742 myTreeView->setExpanded(aIdx, aIt.value());
747 void XGUI_ObjectsBrowser::resizeEvent(QResizeEvent* theEvent)
749 QWidget::resizeEvent(theEvent);