+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
#include "XGUI_ObjectsBrowser.h"
#include "XGUI_DocumentDataModel.h"
#include "XGUI_Tools.h"
#include <ModelAPI_Data.h>
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
+#include <ModuleBase_Tools.h>
+
#include <QLayout>
#include <QLabel>
#include <QLineEdit>
if (theEvent->button() == Qt::LeftButton) {
QModelIndex aIndex = currentIndex();
XGUI_DocumentDataModel* aModel = dataModel();
-
- if ((aModel->activePartIndex() != aIndex) && aModel->activePartIndex().isValid()) {
- setExpanded(aModel->activePartIndex(), false);
- }
- bool isChanged = aModel->activatedIndex(aIndex);
- QTreeView::mouseDoubleClickEvent(theEvent);
- if (isChanged) {
- if (aModel->activePartIndex().isValid())
- setExpanded(aIndex, true);
- emit activePartChanged(aModel->activePart());
+ ObjectPtr aObject = aModel->object(aIndex);
+ ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(aObject);
+ if (aPart) {
+ aPart->activate();
}
} else
QTreeView::mouseDoubleClickEvent(theEvent);
if (aEditor) {
QString aRes = aEditor->text();
ObjectPtr aFeature = mySelectedData.first();
- PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
- aMgr->rootDocument()->startOperation();
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->startOperation("Rename");
aFeature->data()->setName(qPrintable(aRes));
- aMgr->rootDocument()->finishOperation();
+ aMgr->finishOperation();
}
}
+void XGUI_DataTree::clear()
+{
+ mySelectedData.clear();
+ XGUI_DocumentDataModel* aModel = dataModel();
+ aModel->clear();
+ reset();
+}
+
//********************************************************************
//********************************************************************
//********************************************************************
: QWidget(theParent)
{
QVBoxLayout* aLayout = new QVBoxLayout(this);
- aLayout->setContentsMargins(0, 0, 0, 0);
+ ModuleBase_Tools::zeroMargins(aLayout);
aLayout->setSpacing(0);
QFrame* aLabelWgt = new QFrame(this);
aLayout->addWidget(aLabelWgt);
QHBoxLayout* aLabelLay = new QHBoxLayout(aLabelWgt);
- aLabelLay->setContentsMargins(0, 0, 0, 0);
+ ModuleBase_Tools::zeroMargins(aLabelLay);
aLabelLay->setSpacing(0);
QLabel* aLbl = new QLabel(aLabelWgt);
aLabelLay->addWidget(aLbl);
- PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
- DocumentPtr aDoc = aMgr->rootDocument();
+ SessionPtr aMgr = ModelAPI_Session::get();
+ DocumentPtr aDoc = aMgr->moduleDocument();
// TODO: Find a name of the root document
myActiveDocLbl = new QLineEdit(tr("Part set"), aLabelWgt);
myActiveDocLbl->setReadOnly(true);
if (toSave) {
// TODO: Save the name of root document
- PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
- DocumentPtr aDoc = aMgr->rootDocument();
+ SessionPtr aMgr = ModelAPI_Session::get();
+ DocumentPtr aDoc = aMgr->moduleDocument();
} else {
myActiveDocLbl->setText(myActiveDocLbl->property("OldText").toString());
}
void XGUI_ObjectsBrowser::onContextMenuRequested(QContextMenuEvent* theEvent)
{
myObjectsList = myTreeView->selectedObjects();
- bool toEnable = myObjectsList.size() > 0;
+ bool toEnable = myObjectsList.size() == 1;
foreach(QAction* aCmd, actions())
{
aCmd->setEnabled(toEnable);
}
//***************************************************
-void XGUI_ObjectsBrowser::setObjectsSelected(const QList<ObjectPtr>& theObjects)
+void XGUI_ObjectsBrowser::setObjectsSelected(const QObjectPtrList& theObjects)
{
QList<QModelIndex> theIndexes;
QItemSelectionModel* aSelectModel = myTreeView->selectionModel();
}
}
}
+
+//***************************************************
+void XGUI_ObjectsBrowser::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+ myDocModel->processEvent(theMessage);
+}
+
+
+//***************************************************
+void XGUI_ObjectsBrowser::clearContent()
+{
+ myObjectsList.clear();
+ myTreeView->clear();
+}