1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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);
97 setItemDelegateForColumn(1, new XGUI_TreeViewItemDelegate(this));
99 connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
100 SLOT(onDoubleClick(const QModelIndex&)));
103 XGUI_DataTree::~XGUI_DataTree()
107 XGUI_DataModel* XGUI_DataTree::dataModel() const
109 return static_cast<XGUI_DataModel*>(model());
112 void XGUI_DataTree::contextMenuEvent(QContextMenuEvent* theEvent)
114 emit contextMenuRequested(theEvent);
117 void XGUI_DataTree::commitData(QWidget* theEditor)
119 static int aEntrance = 0;
120 if (aEntrance == 0) {
121 // We have to check number of enter and exit of this function because it can be called
122 // recursively by Qt in order to avoid double modifying of a data
124 QLineEdit* aEditor = dynamic_cast<QLineEdit*>(theEditor);
126 QString aName = aEditor->text();
127 QModelIndexList aIndexList = selectionModel()->selectedIndexes();
128 XGUI_DataModel* aModel = dataModel();
129 ObjectPtr aObj = aModel->object(aIndexList.first());
131 if (XGUI_Tools::canRename(aObj, aName)) {
132 SessionPtr aMgr = ModelAPI_Session::get();
133 aMgr->startOperation("Rename");
134 std::wstring aaa = aName.toStdWString();
135 aObj->data()->setName(aName.toStdWString());
136 aMgr->finishOperation();
143 void XGUI_DataTree::clear()
145 dataModel()->clear();
149 void XGUI_DataTree::resizeEvent(QResizeEvent* theEvent)
151 QTreeView::resizeEvent(theEvent);
152 QSize aSize = theEvent->size();
153 if (aSize.isValid()) {
154 setColumnWidth(0, FIRST_COL_WIDTH);
155 setColumnWidth(1, aSize.width() - SECOND_COL_WIDTH - FIRST_COL_WIDTH - 10);
156 setColumnWidth(2, SECOND_COL_WIDTH);
161 void XGUI_DataTree::mousePressEvent(QMouseEvent* theEvent)
163 QTreeView::mousePressEvent(theEvent);
164 if (theEvent->button() != Qt::MidButton)
166 QModelIndex aInd = indexAt(theEvent->pos());
168 QString("r=%1 c=%2 p=%3").arg(aInd.row()).arg(aInd.column()).arg((long)aInd.internalPointer());
170 QModelIndex aPar = aInd.parent();
172 QString("r=%1 c=%2 p=%3").arg(aPar.row()).arg(aPar.column()).arg((long)aPar.internalPointer());
173 QToolTip::showText(theEvent->globalPos(), aTxt + '\n' + aTxt1);
177 void XGUI_DataTree::mouseReleaseEvent(QMouseEvent* theEvent)
179 QTreeView::mouseReleaseEvent(theEvent);
181 if (theEvent->button() != Qt::MidButton)
183 QToolTip::hideText();
185 if (theEvent->button() == Qt::LeftButton) {
186 QModelIndex aInd = indexAt(theEvent->pos());
187 if (aInd.column() == 0)
188 processEyeClick(aInd);
192 void XGUI_DataTree::processHistoryChange(const QModelIndex& theIndex)
194 SessionPtr aMgr = ModelAPI_Session::get();
195 // When operation is opened then we can not change history
196 if (aMgr->isOperation())
198 XGUI_DataModel* aModel = dataModel();
199 if (aModel->flags(theIndex) == 0)
201 ObjectPtr aObj = aModel->object(theIndex);
203 DocumentPtr aDoc = aMgr->activeDocument();
205 std::string aOpName = tr("History change").toStdString();
207 if (aObj->document() != aDoc)
209 aMgr->startOperation(aOpName);
210 aDoc->setCurrentFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(aObj), true);
211 aMgr->finishOperation();
213 // Ignore clicks on folders outside current document
214 if ((theIndex.internalId() == 0) && (aDoc != aMgr->moduleDocument()))
215 // Clicked folder under root but active document is another
217 if ((theIndex.internalId() != 0) && (aDoc != aModel->document(theIndex)))
218 // Cliced not on active document folder
221 aMgr->startOperation(aOpName);
222 aDoc->setCurrentFeature(FeaturePtr(), true);
223 aMgr->finishOperation();
225 QModelIndex aParent = theIndex.parent();
226 int aSize = aModel->rowCount(aParent);
227 for (int i = 0; i < aSize; i++) {
228 update(aModel->index(i, 0, aParent));
229 update(aModel->index(i, 1, aParent));
230 update(aModel->index(i, 2, aParent));
232 XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
233 aObjBrowser->workshop()->displayer()->updateViewer();
236 void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
238 XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
239 XGUI_DataModel* aModel = dataModel();
240 ObjectPtr aObj = aModel->object(theIndex);
242 std::set<ObjectPtr> anObjects;
243 anObjects.insert(aObj);
245 bool hasHiddenState = aModel->hasHiddenState(theIndex);
246 if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects))
248 if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem)
249 if (aObj->isDisplayed())
250 aObj->setDisplayed(false);
251 aObj->setDisplayed(true);
254 aObj->setDisplayed(!aObj->isDisplayed());
256 // Update list of selected objects because this event happens after
257 // selection event in object browser
258 Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
261 aObjBrowser->onSelectionChanged();
266 void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
268 switch (theIndex.column()) {
270 processHistoryChange(theIndex);
276 //********************************************************************
277 //********************************************************************
278 //********************************************************************
279 XGUI_ActiveDocLbl::XGUI_ActiveDocLbl(const QString& theText, QWidget* theParent )
280 : QLabel(theText, theParent),
281 myPreSelectionStyle(""),
283 mySelectionStyle(""),
288 void XGUI_ActiveDocLbl::setTreeView(QTreeView* theView)
290 myTreeView = theView;
291 setFont(myTreeView->font());
293 QPalette aPalet = myTreeView->palette();
294 QColor aHighlight = aPalet.highlight().color();
295 QColor aHighlightText = aPalet.highlightedText().color();
297 myPreSelectionStyle = "QLabel {background-color: ";
298 myPreSelectionStyle += aHighlight.lighter(170).name() + "}";
299 //myPreSelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:1 " +
300 // aHighlight.lighter(170).name() + ");";
301 //myPreSelectionStyle += "border: 1px solid lightblue; border-radius: 2px }";
303 QString aName = aPalet.color(QPalette::Base).name();
304 myNeutralStyle = "QLabel { border: 1px solid " + aName + " }";
307 #if (!defined HAVE_SALOME) && (defined WIN32)
308 mySelectionStyle = "QLabel {background-color: ";
309 mySelectionStyle += "rgb(205, 232, 255); ";
310 //mySelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(236, 245, 255)";
311 //mySelectionStyle += ", stop:1 rgb(208, 229, 255));";
312 //mySelectionStyle += "border: 1px solid rgb(132, 172, 221); border-radius: 2px }";
313 mySelectionStyle += "border: 1px solid rgb(153, 209, 255) }";
315 mySelectionStyle = "QLabel {background-color: " + aHighlight.name();
316 mySelectionStyle += "; color : " + aHighlightText.name() + "}";
319 myTreeView->viewport()->installEventFilter(this);
323 #if (!defined HAVE_SALOME) && (defined WIN32)
324 bool XGUI_ActiveDocLbl::event(QEvent* theEvent)
326 switch (theEvent->type()) {
329 setStyleSheet(myPreSelectionStyle);
333 setStyleSheet(myNeutralStyle);
336 return QLabel::event(theEvent);
340 bool XGUI_ActiveDocLbl::eventFilter(QObject* theObj, QEvent* theEvent)
342 if (theObj == myTreeView->viewport()) {
343 if (theEvent->type() == QEvent::MouseButtonRelease)
346 return QLabel::eventFilter(theObj, theEvent);
349 static bool MYClearing = false;
350 void XGUI_ActiveDocLbl::mouseReleaseEvent( QMouseEvent* e)
354 setStyleSheet(mySelectionStyle);
355 // We can not block signals because on
356 // clear selection the View state will not be updated
357 myTreeView->clearSelection();
358 QLabel::mouseReleaseEvent(e);
362 void XGUI_ActiveDocLbl::unselect()
365 myIsSelected = false;
366 setStyleSheet(myNeutralStyle);
371 //********************************************************************
372 //********************************************************************
373 //********************************************************************
374 XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent, XGUI_Workshop* theWorkshop)
375 : QWidget(theParent), myDocModel(0), myWorkshop(theWorkshop)
377 QVBoxLayout* aLayout = new QVBoxLayout(this);
378 ModuleBase_Tools::zeroMargins(aLayout);
379 aLayout->setSpacing(0);
381 QWidget* aLabelWgt = new QWidget(this);
382 aLabelWgt->setAutoFillBackground(true);
384 aLayout->addWidget(aLabelWgt);
385 QHBoxLayout* aLabelLay = new QHBoxLayout(aLabelWgt);
386 ModuleBase_Tools::zeroMargins(aLabelLay);
387 aLabelLay->setSpacing(0);
389 QLabel* aLbl = new QLabel(aLabelWgt);
390 aLbl->setPixmap(QPixmap(":pictures/assembly.png"));
392 // Do not paint background of the label (in order to show icon)
393 aLbl->setAutoFillBackground(false);
395 aLabelLay->addWidget(aLbl);
397 SessionPtr aMgr = ModelAPI_Session::get();
398 DocumentPtr aDoc = aMgr->moduleDocument();
400 myActiveDocLbl = new XGUI_ActiveDocLbl(tr("Part set"), aLabelWgt);
401 // myActiveDocLbl->setReadOnly(true);
402 // myActiveDocLbl->setFrame(false);
403 myActiveDocLbl->setContextMenuPolicy(Qt::CustomContextMenu);
405 aLabelLay->addWidget(myActiveDocLbl);
406 aLabelLay->setStretch(1, 1);
408 myTreeView = new XGUI_DataTree(this);
409 myTreeView->setFrameShape(QFrame::NoFrame);
410 aLayout->addWidget(myTreeView);
412 QPalette aTreePalet = myTreeView->palette();
413 QColor aTreeBack = aTreePalet.color(QPalette::Base);
416 aPalet.setColor(QPalette::Base, aTreeBack);
417 aPalet.setColor(QPalette::Window, aTreeBack);
418 aLabelWgt->setPalette(aPalet);
420 myDocModel = new XGUI_DataModel(this);
421 connect(myDocModel, SIGNAL(beforeTreeRebuild()), SLOT(onBeforeReset()));
422 connect(myDocModel, SIGNAL(treeRebuilt()), SLOT(onAfterModelReset()));
424 connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
425 SLOT(onContextMenuRequested(QContextMenuEvent*)));
428 //***************************************************
429 XGUI_ObjectsBrowser::~XGUI_ObjectsBrowser()
433 void XGUI_ObjectsBrowser::initialize(ModuleBase_ITreeNode* theRoot)
435 //myDocModel->setXMLReader(theReader);
436 myDocModel->setRoot(theRoot);
437 myTreeView->setModel(myDocModel);
439 // It has to be done after setting of model
440 myActiveDocLbl->setTreeView(myTreeView);
442 QItemSelectionModel* aSelMod = myTreeView->selectionModel();
443 connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
444 this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&)));
447 //***************************************************
448 void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent)
450 QModelIndexList aIndexes;
451 QObjectPtrList aSelectedData = selectedObjects(&aIndexes);
452 bool toEnable = false;
454 if (aSelectedData.size() == 1) {
455 QModelIndex aSelected = myTreeView->indexAt(theEvent->pos());
456 if (!aIndexes.contains(aSelected))
457 return; // menu is called on non selected item
459 Qt::ItemFlags aFlags = dataModel()->flags(aIndexes.first());
460 toEnable = ((aFlags & Qt::ItemIsEditable) != 0);
462 foreach(QAction* aCmd, actions()) {
463 aCmd->setEnabled(toEnable);
465 emit contextMenuRequested(theEvent);
468 //***************************************************
469 void XGUI_ObjectsBrowser::onLabelContextMenuRequested(const QPoint& thePnt)
471 myTreeView->selectionModel()->clearSelection();
472 //Empty feature pointer means that selected root document
473 foreach(QAction* aCmd, actions()) {
474 aCmd->setEnabled(true);
476 QContextMenuEvent aEvent(QContextMenuEvent::Mouse, thePnt, myActiveDocLbl->mapToGlobal(thePnt));
477 emit contextMenuRequested(&aEvent);
480 //***************************************************
481 void XGUI_ObjectsBrowser::onEditItem()
483 QObjectPtrList aSelectedData = selectedObjects();
484 if (aSelectedData.size() > 0) {
485 ObjectPtr anObject = aSelectedData.first();
486 if (anObject.get()) { // Selection happens in TreeView
487 // check whether the object can be renamed. There should not be parts which are not loaded
488 std::set<FeaturePtr> aFeatures;
489 aFeatures.insert(ModelAPI_Feature::feature(anObject));
490 if (!XGUI_Tools::canRemoveOrRename((QWidget*)parent(), aFeatures))
493 // Find index which corresponds the feature
495 foreach(QModelIndex aIdx, selectedIndexes()) {
496 if (aIdx.column() == 1) {
497 ObjectPtr aFea = dataModel()->object(aIdx);
498 if (dataModel()->object(aIdx)->isSame(anObject)) {
504 if (aIndex.isValid()) {
505 myTreeView->setCurrentIndex(aIndex);
506 myTreeView->edit(aIndex);
513 //***************************************************
514 QList<ModuleBase_ITreeNode*> XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent) const
516 QList<ModuleBase_ITreeNode*> aIndexes;
518 int aCount = myDocModel->rowCount(theParent);
519 for (int i = 0; i < aCount; i++) {
520 aIndex = myDocModel->index(i, 0, theParent);
521 if (myDocModel->hasChildren(aIndex)) {
522 if (myTreeView->isExpanded(aIndex)) {
523 aIndexes.append((ModuleBase_ITreeNode*)aIndex.internalPointer());
524 QList<ModuleBase_ITreeNode*> aSubIndexes = expandedItems(aIndex);
525 if (!aSubIndexes.isEmpty())
526 aIndexes.append(aSubIndexes);
533 //***************************************************
534 void XGUI_ObjectsBrowser::rebuildDataTree()
536 myDocModel->root()->update();
537 myDocModel->rebuildDataTree();
541 //***************************************************
542 void XGUI_ObjectsBrowser::setObjectsSelected(const QObjectPtrList& theObjects)
544 QItemSelectionModel* aSelectModel = myTreeView->selectionModel();
545 QModelIndexList aIndexes = aSelectModel->selectedIndexes();
546 if (theObjects.size() == 0) {
547 bool aIsBlock = aSelectModel->blockSignals(true);
548 aSelectModel->clear();
549 aSelectModel->blockSignals(aIsBlock);
550 foreach(QModelIndex aIdx, aIndexes) {
551 myTreeView->update(aIdx);
557 QModelIndexList aUnselect;
558 QObjectPtrList aToSelect = theObjects;
559 QHash<qint64, ObjectPtr> aNotChanged;
560 foreach(QModelIndex aIdx, aIndexes) {
561 aObject = myDocModel->object(aIdx);
563 if (aToSelect.contains(aObject)) {
564 aNotChanged.insert((qint64)aObject.get(), aObject);
566 aUnselect.append(aIdx);
570 aUnselect.append(aIdx);
574 foreach(ObjectPtr aObj, aNotChanged)
575 aToSelect.removeAll(aObj);
577 bool aIsBlock = aSelectModel->blockSignals(true);
578 foreach(QModelIndex aIdx, aUnselect) {
579 aSelectModel->select(aIdx, QItemSelectionModel::Deselect);
580 myTreeView->update(aIdx);
583 QModelIndex aIndex0, aIndex1, aIndex2, aCurrent;
584 foreach(ObjectPtr aFeature, aToSelect) {
585 aIndex1 = myDocModel->objectIndex(aFeature, 1);
586 if (aIndex1.isValid()) {
587 if (!aCurrent.isValid())
589 aIndex0 = myDocModel->objectIndex(aFeature, 0);
590 aIndex2 = myDocModel->objectIndex(aFeature, 2);
591 aSelectModel->select(aIndex1, QItemSelectionModel::Select | QItemSelectionModel::Rows);
592 myTreeView->update(aIndex0);
593 myTreeView->update(aIndex1);
594 myTreeView->update(aIndex2);
597 aSelectModel->setCurrentIndex(aCurrent, QItemSelectionModel::NoUpdate);
598 aSelectModel->blockSignals(aIsBlock);
601 //***************************************************
602 void XGUI_ObjectsBrowser::ensureVisible(const ObjectPtr theObject)
604 QModelIndex aIndex = myDocModel->objectIndex(theObject);
605 if (aIndex.isValid()) {
606 QModelIndex aParent = aIndex.parent();
607 while (aParent.isValid()) {
608 myTreeView->expand(aParent);
609 aParent = aParent.parent();
611 myTreeView->scrollTo(aIndex);
615 //***************************************************
616 void XGUI_ObjectsBrowser::clearContent()
621 //***************************************************
622 void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected,
623 const QItemSelection& theDeselected)
625 onSelectionChanged();
628 //***************************************************
629 void XGUI_ObjectsBrowser::onSelectionChanged()
631 emit selectionChanged();
634 //***************************************************
635 QObjectPtrList XGUI_ObjectsBrowser::selectedObjects(QModelIndexList* theIndexes) const
637 QObjectPtrList aList;
638 QModelIndexList aIndexes = selectedIndexes();
639 XGUI_DataModel* aModel = dataModel();
641 foreach(QModelIndex aIdx, aIndexes) {
642 if (aIdx.column() == 1) {
643 ObjectPtr aObject = aModel->object(aIdx);
645 aList.append(aObject);
647 theIndexes->append(aIdx);
654 void XGUI_ObjectsBrowser::onBeforeReset()
656 myExpandedItems = expandedItems();
659 void XGUI_ObjectsBrowser::onAfterModelReset()
661 XGUI_DataModel* aModel = myTreeView->dataModel();
663 foreach(ModuleBase_ITreeNode* aNode, myExpandedItems) {
664 if (aModel->hasNode(aNode)) {
665 aIndex = aModel->getIndex(aNode, 0);
666 if (aIndex.isValid() && (myTreeView->dataModel()->hasIndex(aIndex)))
667 myTreeView->setExpanded(aIndex, true);
670 myExpandedItems.clear();
673 std::list<bool> XGUI_ObjectsBrowser::getStateForDoc(DocumentPtr theDoc) const
675 std::list<bool> aStates;
676 XGUI_DataModel* aModel = dataModel();
677 QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
678 int aNbChild = aModel->rowCount(aRootIdx);
679 for (int i = 0; i < aNbChild; i++) {
680 QModelIndex aIdx = aModel->index(i, 0, aRootIdx);
681 aStates.push_back(myTreeView->isExpanded(aIdx));
686 void XGUI_ObjectsBrowser::setStateForDoc(DocumentPtr theDoc, const std::list<bool>& theStates)
688 if (theStates.size() == 0)
690 XGUI_DataModel* aModel = dataModel();
691 QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
692 int aNbChild = aModel->rowCount(aRootIdx);
694 std::list<bool>::const_iterator aIt;
696 for (aIt = theStates.cbegin(); aIt != theStates.cend(); aIt++, i++) {
699 QModelIndex aIdx = aModel->index(i, 0, aRootIdx);
700 myTreeView->setExpanded(aIdx, (*aIt));
704 void XGUI_ObjectsBrowser::updateAllIndexes(int theColumn, const QModelIndex& theParent)
706 int aNb = myDocModel->rowCount(theParent);
707 for (int i = 0; i < aNb; i++) {
708 QModelIndex aIdx = myDocModel->index(i, theColumn, theParent);
709 if (aIdx.isValid() && myDocModel->hasIndex(aIdx)) {
710 myTreeView->update(aIdx);
711 if (myTreeView->isExpanded(aIdx))
712 updateAllIndexes(theColumn, aIdx);
717 QMap<ObjectPtr, bool> XGUI_ObjectsBrowser::getFoldersState(DocumentPtr theDoc) const
719 QMap<ObjectPtr, bool> aMap;
721 int aNb = theDoc->size(ModelAPI_Folder::group());
723 for (int i = 0; i < aNb; i++) {
724 aObj = theDoc->object(ModelAPI_Folder::group(), i);
725 QModelIndex aIdx = myDocModel->objectIndex(aObj, 0);
726 aMap[aObj] = myTreeView->isExpanded(aIdx);
731 void XGUI_ObjectsBrowser::setFoldersState(const QMap<ObjectPtr, bool>& theStates)
733 QMap<ObjectPtr, bool>::const_iterator aIt;
734 for (aIt = theStates.constBegin(); aIt != theStates.constEnd(); aIt++) {
735 QModelIndex aIdx = myDocModel->objectIndex(aIt.key(), 0);
736 myTreeView->setExpanded(aIdx, aIt.value());
741 void XGUI_ObjectsBrowser::resizeEvent(QResizeEvent* theEvent)
743 QWidget::resizeEvent(theEvent);