-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Tools.h>
+#include <ModelAPI_ResultField.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_ITreeNode.h>
#include <XGUI_Workshop.h>
+#include <XGUI_Displayer.h>
#include <QLayout>
#include <QLineEdit>
#define FIRST_COL_WIDTH 20
#define SECOND_COL_WIDTH 30
-
/**
* \ingroup GUI
* Tree item delegate for definition of data in column items editor
XGUI_DataModel* aModel = myTreedView->dataModel();
ObjectPtr aObj = aModel->object(index);
if (aObj.get() != NULL) {
- aEditor->setText(aObj->data()->name().c_str());
+ aEditor->setText(QString::fromStdWString(aObj->data()->name()));
return;
}
}
if (XGUI_Tools::canRename(aObj, aName)) {
SessionPtr aMgr = ModelAPI_Session::get();
aMgr->startOperation("Rename");
- aObj->data()->setName(qPrintable(aName));
+ aObj->data()->setName(aName.toStdWString());
aMgr->finishOperation();
}
}
update(aModel->index(i, 1, aParent));
update(aModel->index(i, 2, aParent));
}
+ XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
+ aObjBrowser->workshop()->displayer()->updateViewer();
}
void XGUI_DataTree::processEyeClick(const QModelIndex& theIndex)
{
+ XGUI_ObjectsBrowser* aObjBrowser = qobject_cast<XGUI_ObjectsBrowser*>(parent());
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);
-
- bool hasHiddenState = aModel->hasHiddenState(theIndex);
- if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects))
- return;
- if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem)
- if (aResObj->isDisplayed())
- aResObj->setDisplayed(false);
- aResObj->setDisplayed(true);
- }
- else
- aResObj->setDisplayed(!aResObj->isDisplayed());
- Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- update(theIndex);
+ std::set<ObjectPtr> anObjects;
+ anObjects.insert(aObj);
+
+ bool hasHiddenState = aModel->hasHiddenState(theIndex);
+ if (aObjBrowser && hasHiddenState && !aObjBrowser->workshop()->prepareForDisplay(anObjects))
+ return;
+ if (hasHiddenState) { // #issue 2335(hide all faces then show solid problem)
+ if (aObj->isDisplayed())
+ aObj->setDisplayed(false);
+ aObj->setDisplayed(true);
}
+ else
+ aObj->setDisplayed(!aObj->isDisplayed());
+
// Update list of selected objects because this event happens after
// selection event in object browser
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ update(theIndex);
if (aObjBrowser) {
aObjBrowser->onSelectionChanged();
}
aLabelWgt->setPalette(aPalet);
myDocModel = new XGUI_DataModel(this);
- connect(myDocModel, SIGNAL(modelAboutToBeReset()), SLOT(onBeforeReset()));
+ connect(myDocModel, SIGNAL(beforeTreeRebuild()), SLOT(onBeforeReset()));
connect(myDocModel, SIGNAL(treeRebuilt()), SLOT(onAfterModelReset()));
connect(myTreeView, SIGNAL(contextMenuRequested(QContextMenuEvent*)), this,
}
//***************************************************
-QModelIndexList XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent) const
+QList<ModuleBase_ITreeNode*> XGUI_ObjectsBrowser::expandedItems(const QModelIndex& theParent) const
{
- QModelIndexList aIndexes;
+ QList<ModuleBase_ITreeNode*> aIndexes;
QModelIndex aIndex;
- for (int i = 0; i < myDocModel->rowCount(theParent); i++) {
+ int aCount = myDocModel->rowCount(theParent);
+ for (int i = 0; i < aCount; i++) {
aIndex = myDocModel->index(i, 0, theParent);
if (myDocModel->hasChildren(aIndex)) {
if (myTreeView->isExpanded(aIndex)) {
- aIndexes.append(aIndex);
- QModelIndexList aSubIndexes = expandedItems(aIndex);
+ aIndexes.append((ModuleBase_ITreeNode*)aIndex.internalPointer());
+ QList<ModuleBase_ITreeNode*> aSubIndexes = expandedItems(aIndex);
if (!aSubIndexes.isEmpty())
aIndexes.append(aSubIndexes);
}
}
//***************************************************
-void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& theSelected,
- const QItemSelection& theDeselected)
+void XGUI_ObjectsBrowser::onSelectionChanged(const QItemSelection& /*theSelected*/,
+ const QItemSelection& /*theDeselected*/)
{
onSelectionChanged();
}
void XGUI_ObjectsBrowser::onAfterModelReset()
{
- foreach(QModelIndex aIndex, myExpandedItems) {
- if (myTreeView->dataModel()->hasIndex(aIndex))
- myTreeView->setExpanded(aIndex, true);
+ XGUI_DataModel* aModel = myTreeView->dataModel();
+ QModelIndex aIndex;
+ foreach(ModuleBase_ITreeNode* aNode, myExpandedItems) {
+ if (aModel->hasNode(aNode)) {
+ aIndex = aModel->getIndex(aNode, 0);
+ if (aIndex.isValid() && (myTreeView->dataModel()->hasIndex(aIndex)))
+ myTreeView->setExpanded(aIndex, true);
+ }
}
+ myExpandedItems.clear();
}
std::list<bool> XGUI_ObjectsBrowser::getStateForDoc(DocumentPtr theDoc) const