+void XGUI_ObjectsBrowser::clearContent()
+{
+ myTreeView->clear();
+}
+
+//***************************************************
+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() == 1) {
+ ObjectPtr aObject = aModel->object(*aIt);
+ if (aObject) {
+ aList.append(aObject);
+ if (theIndexes)
+ theIndexes->append(*aIt);
+ }
+ }
+ }
+ return aList;
+}
+
+void XGUI_ObjectsBrowser::onBeforeReset()
+{
+ myExpandedItems = expandedItems();
+}
+
+void XGUI_ObjectsBrowser::onAfterModelReset()
+{
+ foreach(QModelIndex aIndex, myExpandedItems) {
+ myTreeView->setExpanded(aIndex, true);
+ }
+}
+
+std::list<bool> XGUI_ObjectsBrowser::getStateForDoc(DocumentPtr theDoc) const
+{
+ std::list<bool> aStates;
+ XGUI_DataModel* aModel = dataModel();
+ QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
+ int aNbChild = aModel->rowCount(aRootIdx);
+ for (int i = 0; i < aNbChild; i++) {
+ QModelIndex aIdx = aModel->index(i, 1, aRootIdx);
+ aStates.push_back(myTreeView->isExpanded(aIdx));
+ }
+ return aStates;
+}
+
+void XGUI_ObjectsBrowser::setStateForDoc(DocumentPtr theDoc, const std::list<bool>& theStates)
+{
+ if (theStates.size() == 0)
+ return;
+ XGUI_DataModel* aModel = dataModel();
+ QModelIndex aRootIdx = aModel->documentRootIndex(theDoc);
+ int aNbChild = aModel->rowCount(aRootIdx);
+
+ std::list<bool>::const_iterator aIt;
+ int i = 0;
+ for (aIt = theStates.cbegin(); aIt != theStates.cend(); aIt++, i++) {
+ if (i >= aNbChild )
+ break;
+ QModelIndex aIdx = aModel->index(i, 0, aRootIdx);
+ 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()) {
+ myTreeView->update(aIdx);
+ updateAllIndexes(theColumn, aIdx);
+ }
+ }