+ 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;
+ }
+}
+
+
+//********************************************************************
+//********************************************************************
+//********************************************************************
+XGUI_ActiveDocLbl::XGUI_ActiveDocLbl(const QString& theText, QWidget* theParent )
+ : QLabel(theText, theParent),
+ myPreSelectionStyle(""),
+ myNeutralStyle(""),
+ mySelectionStyle(""),
+ myIsSelected(false)
+{
+}
+
+void XGUI_ActiveDocLbl::setTreeView(QTreeView* theView)
+{
+ myTreeView = theView;
+ setFont(myTreeView->font());
+
+ QPalette aPalet = myTreeView->palette();
+ QColor aHighlight = aPalet.highlight().color();
+ QColor aHighlightText = aPalet.highlightedText().color();
+
+ myPreSelectionStyle = "QLabel {background-color: ";
+ myPreSelectionStyle += aHighlight.lighter(170).name() + "}";
+ //myPreSelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:1 " +
+ // aHighlight.lighter(170).name() + ");";
+ //myPreSelectionStyle += "border: 1px solid lightblue; border-radius: 2px }";
+
+ QString aName = aPalet.color(QPalette::Base).name();
+ myNeutralStyle = "QLabel { border: 1px solid " + aName + " }";
+
+
+#if (!defined HAVE_SALOME) && (defined WIN32)
+ mySelectionStyle = "QLabel {background-color: ";
+ mySelectionStyle += "rgb(205, 232, 255); ";
+ //mySelectionStyle += "qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgb(236, 245, 255)";
+ //mySelectionStyle += ", stop:1 rgb(208, 229, 255));";
+ //mySelectionStyle += "border: 1px solid rgb(132, 172, 221); border-radius: 2px }";
+ mySelectionStyle += "border: 1px solid rgb(153, 209, 255) }";
+#else
+ mySelectionStyle = "QLabel {background-color: " + aHighlight.name();
+ mySelectionStyle += "; color : " + aHighlightText.name() + "}";
+#endif
+
+ myTreeView->viewport()->installEventFilter(this);
+}
+
+
+#if (!defined HAVE_SALOME) && (defined WIN32)
+bool XGUI_ActiveDocLbl::event(QEvent* theEvent)
+{
+ switch (theEvent->type()) {
+ case QEvent::Enter:
+ if (!myIsSelected)
+ setStyleSheet(myPreSelectionStyle);
+ break;
+ case QEvent::Leave:
+ if (!myIsSelected)
+ setStyleSheet(myNeutralStyle);
+ break;
+ }
+ return QLabel::event(theEvent);
+}
+#endif
+
+bool XGUI_ActiveDocLbl::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+ if (theObj == myTreeView->viewport()) {
+ if (theEvent->type() == QEvent::MouseButtonRelease)
+ unselect();
+ }
+ return QLabel::eventFilter(theObj, theEvent);
+}
+
+static bool MYClearing = false;
+void XGUI_ActiveDocLbl::mouseReleaseEvent( QMouseEvent* e)
+{
+ MYClearing = true;
+ myIsSelected = true;
+ setStyleSheet(mySelectionStyle);
+ // We can not block signals because on
+ // clear selection the View state will not be updated
+ myTreeView->clearSelection();
+ QLabel::mouseReleaseEvent(e);
+ MYClearing = false;
+}
+
+void XGUI_ActiveDocLbl::unselect()
+{
+ if (!MYClearing) {
+ myIsSelected = false;
+ setStyleSheet(myNeutralStyle);
+ }
+}
+
+
+//********************************************************************
+//********************************************************************
+//********************************************************************
+XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent, XGUI_Workshop* theWorkshop)
+ : QWidget(theParent), myDocModel(0), myWorkshop(theWorkshop)
+{
+ QVBoxLayout* aLayout = new QVBoxLayout(this);
+ ModuleBase_Tools::zeroMargins(aLayout);
+ aLayout->setSpacing(0);
+
+ QWidget* aLabelWgt = new QWidget(this);
+ aLabelWgt->setAutoFillBackground(true);
+
+ aLayout->addWidget(aLabelWgt);
+ QHBoxLayout* aLabelLay = new QHBoxLayout(aLabelWgt);
+ ModuleBase_Tools::zeroMargins(aLabelLay);
+ aLabelLay->setSpacing(0);
+
+ QLabel* aLbl = new QLabel(aLabelWgt);
+ aLbl->setPixmap(QPixmap(":pictures/assembly.png"));
+ aLbl->setMargin(2);
+ // Do not paint background of the label (in order to show icon)
+ aLbl->setAutoFillBackground(false);
+
+ aLabelLay->addWidget(aLbl);
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ DocumentPtr aDoc = aMgr->moduleDocument();
+
+ myActiveDocLbl = new XGUI_ActiveDocLbl(tr("Part set"), aLabelWgt);
+// myActiveDocLbl->setReadOnly(true);
+// myActiveDocLbl->setFrame(false);
+ myActiveDocLbl->setContextMenuPolicy(Qt::CustomContextMenu);
+
+ aLabelLay->addWidget(myActiveDocLbl);
+ aLabelLay->setStretch(1, 1);
+
+ myTreeView = new XGUI_DataTree(this);
+ myTreeView->setFrameShape(QFrame::NoFrame);
+ aLayout->addWidget(myTreeView);
+
+ QPalette aTreePalet = myTreeView->palette();
+ QColor aTreeBack = aTreePalet.color(QPalette::Base);
+
+ QPalette aPalet;
+ aPalet.setColor(QPalette::Base, aTreeBack);
+ aPalet.setColor(QPalette::Window, aTreeBack);
+ aLabelWgt->setPalette(aPalet);
+
+ myDocModel = new XGUI_DataModel(this);
+ connect(myDocModel, SIGNAL(modelAboutToBeReset()), SLOT(onBeforeReset()));
+ connect(myDocModel, SIGNAL(treeRebuilt()), SLOT(onAfterModelReset()));
+
+ connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
+ SLOT(onContextMenuRequested(QContextMenuEvent*)));
+}
+
+//***************************************************