+ setColumnWidth(0, FIRST_COL_WIDTH);
+ setColumnWidth(1, aSize.width() - SECOND_COL_WIDTH - FIRST_COL_WIDTH - 10);
+ setColumnWidth(2, SECOND_COL_WIDTH);
+ }
+}
+
+#ifdef DEBUG_INDXES
+void XGUI_DataTree::mousePressEvent(QMouseEvent* theEvent)
+{
+ 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())
+ return;
+ XGUI_DataModel* aModel = dataModel();
+ if (aModel->flags(theIndex) == 0)
+ return;
+ ObjectPtr aObj = aModel->object(theIndex);
+
+ DocumentPtr aDoc = aMgr->activeDocument();
+
+ std::string aOpName = tr("History change").toStdString();
+ if (aObj.get()) {
+ if (aObj->document() != aDoc)
+ return;
+ aMgr->startOperation(aOpName);
+ aDoc->setCurrentFeature(std::dynamic_pointer_cast<ModelAPI_Feature>(aObj), true);
+ aMgr->finishOperation();
+ } else {
+ // Ignore clicks on folders outside current document
+ if ((theIndex.internalId() == 0) && (aDoc != aMgr->moduleDocument()))
+ // Clicked folder under root but active document is another
+ return;
+ if ((theIndex.internalId() != 0) && (aDoc.get() != theIndex.internalPointer()))
+ // Cliced not on active document folder
+ return;
+
+ aMgr->startOperation(aOpName);
+ 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));
+ }
+}
+
+void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
+{
+ XGUI_DataModel* aModel = dataModel();
+ ObjectPtr aObj = aModel->object(theIndex);
+ if (aObj.get()) {
+ ResultPtr aResObj = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
+ if (aResObj.get()) {
+ std::set<ObjectPtr> anObjects;
+ anObjects.insert(aResObj);
+ if (aObjBrowser && !aResObj->isDisplayed() &&
+ !aObjBrowser->workshop()->prepareForDisplay(anObjects))
+ return;
+ aResObj->setDisplayed(!aResObj->isDisplayed());
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ update(theIndex);
+ }
+ // Update list of selected objects because this event happens after
+ // selection event in object browser
+ if (aObjBrowser) {
+ aObjBrowser->onSelectionChanged();
+ }
+ }
+}
+
+void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
+{
+ switch (theIndex.column()) {
+ case 2:
+ processHistoryChange(theIndex);
+ break;