From: vsv Date: Thu, 10 Sep 2015 14:22:30 +0000 (+0300) Subject: Issue #943: Process double click in Object Browser X-Git-Tag: V_1.4.0_beta4~35 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=69079e03b83563af9e3842f7cc2f5b3d67c102b5;p=modules%2Fshaper.git Issue #943: Process double click in Object Browser --- diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index a48258607..ea6124eb4 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -147,8 +147,10 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// \returns true if the action is processed virtual bool deleteObjects() { return false; }; +#ifdef ModuleDataModel /// Returns data model object for representation of data tree in Object browser virtual ModuleBase_IDocumentDataModel* dataModel() const = 0; +#endif /// Performs functionality on closing document virtual void closeDocument() = 0; diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index a027eb77a..9b82b66c3 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -477,16 +477,17 @@ void PartSet_MenuMgr::onActivatePartSet(bool) { if (myModule->workshop()->currentOperation()) return; + activatePartSet(); +} + +void PartSet_MenuMgr::activatePartSet() const +{ SessionPtr aMgr = ModelAPI_Session::get(); bool isNewTransaction = !aMgr->isOperation(); // activation may cause changes in current features in document, so it must be in transaction - if (isNewTransaction) { - aMgr->startOperation("Activation"); - } + if (isNewTransaction) aMgr->startOperation("Activation"); aMgr->setActiveDocument(aMgr->moduleDocument()); - if (isNewTransaction) { - aMgr->finishOperation(); - } + if (isNewTransaction) aMgr->finishOperation(); } void PartSet_MenuMgr::onEdit(bool) diff --git a/src/PartSet/PartSet_MenuMgr.h b/src/PartSet/PartSet_MenuMgr.h index 865bbccdc..7a94a0d9c 100644 --- a/src/PartSet/PartSet_MenuMgr.h +++ b/src/PartSet/PartSet_MenuMgr.h @@ -46,6 +46,9 @@ public: /// \param theStdActions - a map of standard actions void updateViewerMenu(const QMap& theStdActions); + /// Activates a PartSet document + void activatePartSet() const; + public slots: /// Processes the context menu action click /// \param isChecked a state of toggle if the action is checkable diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 1bc9bfbef..adb46118f 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -125,7 +125,9 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) new PartSet_IconFactory(); mySketchMgr = new PartSet_SketcherMgr(this); +#ifdef ModuleDataModel myDataModel = new PartSet_DocumentDataModel(this); +#endif XGUI_ModuleConnector* aConnector = dynamic_cast(theWshop); XGUI_Workshop* aWorkshop = aConnector->workshop(); @@ -841,9 +843,9 @@ void PartSet_Module::customizeObjectBrowser(QWidget* theObjectBrowser) //aPalet.setColor(QPalette::Text, QColor(0, 72, 140)); //aLabel->setPalette(aPalet); aOB->treeView()->setExpandsOnDoubleClick(false); -#ifdef ModuleDataModel connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)), SLOT(onTreeViewDoubleClick(const QModelIndex&))); +#ifdef ModuleDataModel connect(aOB, SIGNAL(headerMouseDblClicked(const QModelIndex&)), SLOT(onTreeViewDoubleClick(const QModelIndex&))); connect(aOB->treeView(), SIGNAL(doubleClicked(const QModelIndex&)), @@ -1005,7 +1007,18 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex) } if (theIndex.column() != 0) // Use only first column return; +#ifdef ModuleDataModel ObjectPtr aObj = myDataModel->object(theIndex); +#else + XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); + XGUI_Workshop* aWorkshop = aConnector->workshop(); + XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel(); + // De not use non editable Indexes + if ((aDataModel->flags(theIndex) & Qt::ItemIsSelectable) == 0) + return; + ObjectPtr aObj = aDataModel->object(theIndex); +#endif + ResultPartPtr aPart = std::dynamic_pointer_cast(aObj); if (!aPart.get()) { // Probably this is Feature FeaturePtr aPartFeature = std::dynamic_pointer_cast(aObj); @@ -1015,7 +1028,7 @@ void PartSet_Module::onTreeViewDoubleClick(const QModelIndex& theIndex) } if (aPart.get()) { // if this is a part if (aPart->partDoc() == aMgr->activeDocument()) { - aMgr->setActiveDocument(aMgr->moduleDocument()); + myMenuMgr->activatePartSet(); } else { aPart->activate(); } diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 87572db15..bdcbdd0ec 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -157,8 +157,10 @@ public: PartSet_SketcherMgr* sketchMgr() const { return mySketchMgr; } +#ifdef ModuleDataModel /// Returns data model object for representation of data tree in Object browser virtual ModuleBase_IDocumentDataModel* dataModel() const { return myDataModel; } +#endif /// Performs functionality on closing document virtual void closeDocument(); @@ -279,7 +281,9 @@ protected slots: PartSet_CustomPrs* myCustomPrs; int myVisualLayerId; +#ifdef ModuleDataModel PartSet_DocumentDataModel* myDataModel; +#endif QModelIndex aActivePartIndex; };