From c065b8350cd3380e9b446f17a71aed14980afd57 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 31 Aug 2015 07:53:03 +0200 Subject: [PATCH] (#406) Created a combined docking widget for additional project trees and property views --- ApplicationCode/CMakeLists.txt | 2 + .../UserInterface/RiuMainWindow.cpp | 73 ++++----------- ApplicationCode/UserInterface/RiuMainWindow.h | 3 +- .../UserInterface/RiuProjectPropertyView.cpp | 90 +++++++++++++++++++ .../UserInterface/RiuProjectPropertyView.h | 44 +++++++++ 5 files changed, 155 insertions(+), 57 deletions(-) create mode 100644 ApplicationCode/UserInterface/RiuProjectPropertyView.cpp create mode 100644 ApplicationCode/UserInterface/RiuProjectPropertyView.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 2e8b9152fd..b81408854d 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -83,6 +83,8 @@ set( USER_INTERFACE_FILES UserInterface/RiuWellLogPlot.h UserInterface/RiuWellLogTracePlot.cpp UserInterface/RiuWellLogTracePlot.h + UserInterface/RiuProjectPropertyView.h + UserInterface/RiuProjectPropertyView.cpp ) set( SOCKET_INTERFACE_FILES diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 3ebab3281f..a1f932dd29 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -76,6 +76,7 @@ #include "cvfTimer.h" #include "RimTreeViewStateSerializer.h" #include "RiuTreeViewEventFilter.h" +#include "RiuProjectPropertyView.h" //================================================================================================== @@ -175,14 +176,12 @@ void RiuMainWindow::cleanupGuiBeforeProjectClose() m_pdmUiPropertyView->showProperties(NULL); } - for (size_t i = 0; i < additionalPropertyEditors.size(); i++) + for (size_t i = 0; i < additionalProjectViews.size(); i++) { - if (!additionalPropertyEditors[i]) continue; - - caf::PdmUiPropertyView* propertyView = dynamic_cast(additionalPropertyEditors[i]->widget()); - if (propertyView) + RiuProjectAndPropertyView* projPropView = dynamic_cast(additionalProjectViews[i]->widget()); + if (projPropView) { - propertyView->showProperties(NULL); + projPropView->showProperties(NULL); } } m_processMonitor->startMonitorWorkProcess(NULL); @@ -1304,14 +1303,14 @@ void RiuMainWindow::setPdmRoot(caf::PdmObject* pdmRoot) // For debug only : m_projectTreeView->treeView()->expandAll(); m_projectTreeView->setDragDropHandle(m_dragDrop); - for (size_t i = 0; i < additionalProjectTrees.size(); i++) + for (size_t i = 0; i < additionalProjectViews.size(); i++) { - if (!additionalProjectTrees[i]) continue; + if (!additionalProjectViews[i]) continue; - caf::PdmUiTreeView* treeView = dynamic_cast(additionalProjectTrees[i]->widget()); - if (treeView) + RiuProjectAndPropertyView* projPropView = dynamic_cast(additionalProjectViews[i]->widget()); + if (projPropView) { - treeView->setPdmItem(pdmRoot); + projPropView->setPdmItem(pdmRoot); } } @@ -1654,53 +1653,17 @@ void RiuMainWindow::selectedObjectsChanged() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotNewObjectPropertyView() { + QDockWidget* dockWidget = new QDockWidget("Project with Property Editor " + QString::number(additionalProjectViews.size() + 1), this); + dockWidget->setObjectName("dockWidget"); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - caf::PdmUiTreeView* pdmTreeView = NULL; - - { - QDockWidget* dockWidget = new QDockWidget("Additional Project Tree " + QString::number(additionalProjectTrees.size() + 1), this); - dockWidget->setObjectName("dockWidget"); - dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + RiuProjectAndPropertyView* projPropView = new RiuProjectAndPropertyView(dockWidget); + dockWidget->setWidget(projPropView); + projPropView->setPdmItem(m_pdmRoot); - pdmTreeView = new caf::PdmUiTreeView(dockWidget); - pdmTreeView->treeView()->setSelectionMode(QAbstractItemView::ExtendedSelection); - pdmTreeView->enableSelectionManagerUpdating(true); + addDockWidget(Qt::RightDockWidgetArea, dockWidget); - // Install event filter used to handle key press events - RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter(this); - pdmTreeView->treeView()->installEventFilter(treeViewEventFilter); - - // Drag and drop configuration - pdmTreeView->treeView()->setDragEnabled(true); - pdmTreeView->treeView()->viewport()->setAcceptDrops(true); - pdmTreeView->treeView()->setDropIndicatorShown(true); - pdmTreeView->treeView()->setDragDropMode(QAbstractItemView::DragDrop); - - dockWidget->setWidget(pdmTreeView); - - addDockWidget(Qt::RightDockWidgetArea, dockWidget); - additionalProjectTrees.push_back(dockWidget); - - pdmTreeView->setPdmItem(m_pdmRoot); - - pdmTreeView->treeView()->setContextMenuPolicy(Qt::CustomContextMenu); - connect(pdmTreeView->treeView(), SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(customMenuRequested(const QPoint&))); - } - - - { - QDockWidget* dockWidget = new QDockWidget("Additional Property Editor " + QString::number(additionalPropertyEditors.size() + 1), this); - dockWidget->setObjectName("dockWidget"); - dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); - - caf::PdmUiPropertyView* propView = new caf::PdmUiPropertyView(dockWidget); - dockWidget->setWidget(propView); - - addDockWidget(Qt::RightDockWidgetArea, dockWidget); - - connect(pdmTreeView, SIGNAL(selectedObjectChanged( caf::PdmObjectHandle* )), propView, SLOT(showProperties( caf::PdmObjectHandle* ))); - additionalPropertyEditors.push_back(dockWidget); - } + additionalProjectViews.push_back(dockWidget); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h index 5018248635..7fa9a6dc7b 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.h +++ b/ApplicationCode/UserInterface/RiuMainWindow.h @@ -307,6 +307,5 @@ private: QAction* m_drawStyleSurfOnlyAction; QAction* m_addWellCellsToRangeFilterAction; - std::vector > additionalProjectTrees; - std::vector > additionalPropertyEditors; + std::vector > additionalProjectViews; }; diff --git a/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp b/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp new file mode 100644 index 0000000000..15e13bf40b --- /dev/null +++ b/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp @@ -0,0 +1,90 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuProjectPropertyView.h" + +#include "RiuMainWindow.h" +#include "RiuTreeViewEventFilter.h" + +#include "cafPdmUiPropertyView.h" +#include "cafPdmUiTreeView.h" + +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuProjectAndPropertyView::RiuProjectAndPropertyView(QWidget* parent, Qt::WindowFlags f) + : QWidget(parent, f) +{ + + // Tree View + + m_projectTreeView = new caf::PdmUiTreeView; + m_projectTreeView->treeView()->setHeaderHidden(true); + m_projectTreeView->treeView()->setSelectionMode(QAbstractItemView::ExtendedSelection); + m_projectTreeView->enableSelectionManagerUpdating(true); + + // Install event filter used to handle key press events + RiuTreeViewEventFilter* treeViewEventFilter = new RiuTreeViewEventFilter(this); + m_projectTreeView->treeView()->installEventFilter(treeViewEventFilter); + + // Drag and drop configuration + m_projectTreeView->treeView()->setDragEnabled(true); + m_projectTreeView->treeView()->viewport()->setAcceptDrops(true); + m_projectTreeView->treeView()->setDropIndicatorShown(true); + m_projectTreeView->treeView()->setDragDropMode(QAbstractItemView::DragDrop); + + m_projectTreeView->treeView()->setContextMenuPolicy(Qt::CustomContextMenu); + connect(m_projectTreeView->treeView(), SIGNAL(customContextMenuRequested(const QPoint&)), RiuMainWindow::instance(), SLOT(customMenuRequested(const QPoint&))); + + + // Property view + m_propertyView = new caf::PdmUiPropertyView; + + connect(m_projectTreeView, SIGNAL(selectedObjectChanged(caf::PdmObjectHandle*)), m_propertyView, SLOT(showProperties(caf::PdmObjectHandle*))); + + QSplitter *splitter = new QSplitter(Qt::Vertical); + splitter->addWidget(m_projectTreeView); + splitter->addWidget(m_propertyView); + + QVBoxLayout* layout = new QVBoxLayout; + layout->addWidget(splitter); + + setLayout(layout); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuProjectAndPropertyView::setPdmItem(caf::PdmUiItem* object) +{ + m_propertyView->showProperties(NULL); + m_projectTreeView->setPdmItem(object); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuProjectAndPropertyView::showProperties(caf::PdmObjectHandle* object) +{ + m_propertyView->showProperties(object); +} diff --git a/ApplicationCode/UserInterface/RiuProjectPropertyView.h b/ApplicationCode/UserInterface/RiuProjectPropertyView.h new file mode 100644 index 0000000000..eb2b2ea501 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuProjectPropertyView.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// Copyright (C) 2015- Ceetron Solutions AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + + +#include + +namespace caf { + class PdmUiItem; + class PdmUiTreeView; + class PdmUiPropertyView; + class PdmObjectHandle; +} + +//-------------------------------------------------------------------------------------------------- +class RiuProjectAndPropertyView : public QWidget +{ +public: + RiuProjectAndPropertyView(QWidget* parent = 0, Qt::WindowFlags f = 0); + + void setPdmItem(caf::PdmUiItem* object); + void showProperties(caf::PdmObjectHandle* object); + +private: + caf::PdmUiTreeView* m_projectTreeView; + caf::PdmUiPropertyView* m_propertyView; +}; \ No newline at end of file