From c3c50ae62eaba1e9ac1b48a08668d08c2e474735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Sat, 7 Sep 2013 10:18:28 +0200 Subject: [PATCH] Tree view Toggle Cmmands: Reimplemented to use PDM. Fixed missing update. p4#: 22342 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 25 ++++++++++++++++-- .../ProjectDataModel/RimUiTreeView.cpp | 26 ++++++++++--------- .../ProjectDataModel/RimUiTreeView.h | 2 +- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index aa329c7b2b..020962ced0 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -55,6 +55,7 @@ #include "RimWellPathCollection.h" #include "RimOilField.h" #include "RimAnalysisModels.h" +#include "RimUiTreeView.h" @@ -1009,6 +1010,8 @@ void RimUiTreeModelPdm::setObjectToggleStateForSelection(QModelIndexList selecte { bool toggleOn = (state == Qt::Checked); + std::set resViewsToUpdate; + foreach (QModelIndex index, selectedIndexes) { if (!index.isValid()) @@ -1028,11 +1031,29 @@ void RimUiTreeModelPdm::setObjectToggleStateForSelection(QModelIndexList selecte if (field) { // Does not use setValueFromUi(), so the caller must make sure dependencies are updated - field->v() = toggleOn; + if (state == RimUiTreeView::TOGGLE_ON) field->setValueFromUi(true); + if (state == RimUiTreeView::TOGGLE_OFF) field->setValueFromUi(false); + if (state == RimUiTreeView::TOGGLE) field->setValueFromUi(!(field->v())); - emitDataChanged(index); + //emitDataChanged(index); + //field->updateConnectedEditors(); + + /* caf::PdmObject* ownerObj = field->ownerObject(); + + RimReservoirView* resView = dynamic_cast(ownerObj); + if(resView) resViewsToUpdate.insert(resView); + else if (ownerObj) + { + ownerObj->firstAncestorOfType(resView); + if (resView) resViewsToUpdate.insert(resView); + }*/ } } } + + /* for (std::set::iterator it = resViewsToUpdate.begin(); it != resViewsToUpdate.end(); ++it) + { + (*it)->createDisplayModelAndRedraw(); + }*/ } diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index e80a847737..fc5df207d0 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -1495,6 +1495,7 @@ void RimUiTreeView::slotToggleItems() //-------------------------------------------------------------------------------------------------- void RimUiTreeView::executeSelectionToggleOperation(SelectionToggleType toggleState) { + /* int nextCheckBoxState = 0; if (toggleState == TOGGLE_ON) @@ -1528,28 +1529,28 @@ void RimUiTreeView::executeSelectionToggleOperation(SelectionToggleType toggleSt } } } - + */ RimUiTreeModelPdm* myModel = dynamic_cast(model()); - caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); + // caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); // Special handling for wells // Set toggle state for all wells without triggering model update, // and perform a single display model update at last - RimWell* well = dynamic_cast(uiItem->dataObject().p()); - if (well) + //RimWell* well = dynamic_cast(uiItem->dataObject().p()); + //if (well) { - myModel->setObjectToggleStateForSelection(selectionModel()->selectedIndexes(), nextCheckBoxState); + myModel->setObjectToggleStateForSelection(selectionModel()->selectedIndexes(), toggleState); - RimReservoirView* reservoirView = NULL; - well->firstAncestorOfType(reservoirView); - if (reservoirView) - { - reservoirView->createDisplayModelAndRedraw(); - } + //RimReservoirView* reservoirView = NULL; + //well->firstAncestorOfType(reservoirView); + //if (reservoirView) + //{ + // reservoirView->createDisplayModelAndRedraw(); + //} return; } - +/* foreach (QModelIndex index, selectionModel()->selectedIndexes()) { if (!index.isValid()) @@ -1559,6 +1560,7 @@ void RimUiTreeView::executeSelectionToggleOperation(SelectionToggleType toggleSt myModel->setData(index, nextCheckBoxState, Qt::CheckStateRole); } + */ } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index c1a15bbd8d..72c0691760 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -104,7 +104,7 @@ private slots: signals: void selectedObjectChanged( caf::PdmObject* pdmObject ); -private: +public: enum SelectionToggleType { TOGGLE_ON,