+void XGUI_DataTree::resizeEvent(QResizeEvent* theEvent)
+{
+ QSize aSize = theEvent->size();
+ if (aSize.isValid()) {
+ setColumnWidth(0, aSize.width() - SECOND_COL_WIDTH);
+ setColumnWidth(1, SECOND_COL_WIDTH);
+ }
+ QTreeView::resizeEvent(theEvent);
+}
+
+void XGUI_DataTree::onDoubleClick(const QModelIndex& theIndex)
+{
+ if (theIndex.column() != 1)
+ return;
+ 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() == -1) && (aDoc != aMgr->moduleDocument()))
+ // Clicked folder under root but active document is another
+ return;
+ if ((theIndex.internalId() != -1) && (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));
+ }
+}
+
+#if (!defined HAVE_SALOME) && (defined WIN32)
+void XGUI_DataTree::drawRow(QPainter* thePainter,
+ const QStyleOptionViewItem& theOptions,
+ const QModelIndex& theIndex) const
+{
+ QStyleOptionViewItemV4 aOptions = theOptions;
+ myStyle->setIndex(theIndex);
+ QTreeView::drawRow(thePainter, aOptions, theIndex);
+}
+
+//********************************************************************
+//********************************************************************
+//********************************************************************
+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;
+ QWindowsVistaStyle::drawPrimitive(theElement, aOpt, thePainter, theWidget);