mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#406) Created a combined docking widget for additional project trees and property views
This commit is contained in:
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);
|
||||
}
|
||||
Reference in New Issue
Block a user