mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
(#406) Created a combined docking widget for additional project trees and property views
This commit is contained in:
parent
ca06e8a307
commit
c065b8350c
@ -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
|
||||
|
@ -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<caf::PdmUiPropertyView*>(additionalPropertyEditors[i]->widget());
|
||||
if (propertyView)
|
||||
RiuProjectAndPropertyView* projPropView = dynamic_cast<RiuProjectAndPropertyView*>(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<caf::PdmUiTreeView*>(additionalProjectTrees[i]->widget());
|
||||
if (treeView)
|
||||
RiuProjectAndPropertyView* projPropView = dynamic_cast<RiuProjectAndPropertyView*>(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);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -307,6 +307,5 @@ private:
|
||||
QAction* m_drawStyleSurfOnlyAction;
|
||||
QAction* m_addWellCellsToRangeFilterAction;
|
||||
|
||||
std::vector<QPointer<QDockWidget> > additionalProjectTrees;
|
||||
std::vector<QPointer<QDockWidget> > additionalPropertyEditors;
|
||||
std::vector<QPointer<QDockWidget> > additionalProjectViews;
|
||||
};
|
||||
|
90
ApplicationCode/UserInterface/RiuProjectPropertyView.cpp
Normal file
90
ApplicationCode/UserInterface/RiuProjectPropertyView.cpp
Normal file
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuProjectPropertyView.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuTreeViewEventFilter.h"
|
||||
|
||||
#include "cafPdmUiPropertyView.h"
|
||||
#include "cafPdmUiTreeView.h"
|
||||
|
||||
#include <QSplitter>
|
||||
#include <QTreeView>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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);
|
||||
}
|
44
ApplicationCode/UserInterface/RiuProjectPropertyView.h
Normal file
44
ApplicationCode/UserInterface/RiuProjectPropertyView.h
Normal file
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
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;
|
||||
};
|
Loading…
Reference in New Issue
Block a user