From 86e638f1cea515707ab0d03396661b584985a0c9 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 24 Aug 2015 10:59:26 +0300 Subject: [PATCH] Create DataModel in object browser constructor --- src/XGUI/XGUI_ObjectsBrowser.cpp | 15 +++++++++++---- src/XGUI/XGUI_ObjectsBrowser.h | 2 ++ src/XGUI/XGUI_Workshop.cpp | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 58e5fb3de..4846e2237 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -221,6 +221,14 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) aLabelWgt->setFrameShape(myTreeView->frameShape()); aLabelWgt->setFrameShadow(myTreeView->frameShadow()); +#ifndef ModuleDataModel + myDocModel = new XGUI_DataModel(this); + myTreeView->setModel(myDocModel); + QItemSelectionModel* aSelMod = myTreeView->selectionModel(); + connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), + this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&))); +#endif + connect(myActiveDocLbl, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(onLabelContextMenuRequested(const QPoint&))); connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this, @@ -376,18 +384,17 @@ void XGUI_ObjectsBrowser::clearContent() myTreeView->clear(); } +#ifdef ModuleDataModel void XGUI_ObjectsBrowser::setDataModel(ModuleBase_IDocumentDataModel* theModel) { -#ifdef ModuleDataModel myDocModel = theModel; -#else - myDocModel = new XGUI_DataModel(this); -#endif + //myDocModel = new XGUI_DataModel(this); myTreeView->setModel(myDocModel); QItemSelectionModel* aSelMod = myTreeView->selectionModel(); connect(aSelMod, SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&))); } +#endif void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected) diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index 2c36641bc..d92788abe 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -114,7 +114,9 @@ Q_OBJECT void clearContent(); /// Set Data Model for the Object Browser +#ifdef ModuleDataModel void setDataModel(ModuleBase_IDocumentDataModel* theModel); +#endif public slots: //! Called on Edit command request diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index bdfd1b2d5..933c8f395 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -900,7 +900,9 @@ QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent) aObjDock->setStyleSheet( "::title { position: relative; padding-left: 5px; text-align: left center }"); myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock); +#ifdef ModuleDataModel myObjectBrowser->setDataModel(myModule->dataModel()); +#endif myModule->customizeObjectBrowser(myObjectBrowser); aObjDock->setWidget(myObjectBrowser); -- 2.39.2