mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-30 17:10:19 -05:00
1 parent
8b13dbcef1
commit
c368b51061
5 files changed
-514
No files matched your search
@@ -74,10 +74,6 @@ set(PROJECT_FILES
|
||||
# object editors
|
||||
cafPdmUiDefaultObjectEditor.cpp
|
||||
cafPdmUiDefaultObjectEditor.h
|
||||
cafPdmUiListView.cpp
|
||||
cafPdmUiListView.h
|
||||
cafPdmUiListViewEditor.cpp
|
||||
cafPdmUiListViewEditor.h
|
||||
cafPdmUiTableRowEditor.cpp
|
||||
cafPdmUiTableRowEditor.h
|
||||
cafPdmUiTableView.cpp
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2011-2013 Ceetron AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
#include "cafPdmUiListView.h"
|
||||
|
||||
#include "cafPdmObjectGroup.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
#include "cafPdmUiListViewEditor.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiListView::PdmUiListView( QWidget* parent, Qt::WindowFlags f )
|
||||
: QWidget( parent, f )
|
||||
{
|
||||
m_layout = new QVBoxLayout( this );
|
||||
m_layout->insertStretch( 1, 1 );
|
||||
m_layout->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_layout->setSpacing( 0 );
|
||||
|
||||
setLayout( m_layout );
|
||||
|
||||
m_listViewEditor = new PdmUiListViewEditor();
|
||||
|
||||
QWidget* widget = m_listViewEditor->getOrCreateWidget( this );
|
||||
m_layout->addWidget( widget );
|
||||
|
||||
this->m_layout->setStretchFactor( widget, 10 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiListView::~PdmUiListView()
|
||||
{
|
||||
if ( m_listViewEditor ) delete m_listViewEditor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiListView::setPdmObject( caf::PdmObjectCollection* object )
|
||||
{
|
||||
CAF_ASSERT( m_listViewEditor );
|
||||
|
||||
m_listViewEditor->setPdmObject( object );
|
||||
}
|
||||
|
||||
} // End of namespace caf
|
||||
@@ -1,65 +0,0 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2011-2013 Ceetron AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
#pragma once
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
class QVBoxLayout;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmObjectCollection;
|
||||
class PdmUiListViewEditor;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class PdmUiListView : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
PdmUiListView( QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags() );
|
||||
~PdmUiListView() override;
|
||||
|
||||
void setPdmObject( caf::PdmObjectCollection* object );
|
||||
|
||||
private:
|
||||
PdmUiListViewEditor* m_listViewEditor;
|
||||
QVBoxLayout* m_layout;
|
||||
};
|
||||
|
||||
} // End of namespace caf
|
||||
@@ -1,247 +0,0 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2011-2013 Ceetron AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
#include "cafPdmUiListViewEditor.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmObjectGroup.h"
|
||||
#include "cafPdmUiEditorHandle.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QTableView>
|
||||
#include <QWidget>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
UiListViewModelPdm::UiListViewModelPdm( QObject* parent )
|
||||
: QAbstractTableModel( parent )
|
||||
{
|
||||
m_columnCount = 0;
|
||||
m_pdmObjectGroup = nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int UiListViewModelPdm::rowCount( const QModelIndex& parent /*= QModelIndex( ) */ ) const
|
||||
{
|
||||
if ( !m_pdmObjectGroup )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return static_cast<int>( m_pdmObjectGroup->objects.size() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int UiListViewModelPdm::columnCount( const QModelIndex& parent /*= QModelIndex( ) */ ) const
|
||||
{
|
||||
if ( !m_pdmObjectGroup )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( m_columnCount < 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return m_columnCount;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void UiListViewModelPdm::computeColumnCount()
|
||||
{
|
||||
if ( !m_editorAttribute.fieldNames.empty() )
|
||||
{
|
||||
m_columnCount = m_editorAttribute.fieldNames.size();
|
||||
}
|
||||
else if ( m_pdmObjectGroup )
|
||||
{
|
||||
m_columnCount = 0;
|
||||
|
||||
// Loop over all objects and find the object with largest number of fields
|
||||
for ( size_t i = 0; i < m_pdmObjectGroup->objects.size(); i++ )
|
||||
{
|
||||
std::vector<PdmFieldHandle*> fields = m_pdmObjectGroup->objects[i]->fields();
|
||||
|
||||
if ( m_columnCount < static_cast<int>( fields.size() ) )
|
||||
{
|
||||
m_columnCount = static_cast<int>( fields.size() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QVariant UiListViewModelPdm::headerData( int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole */ ) const
|
||||
{
|
||||
return QVariant( QString( "Header %1" ).arg( section ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QVariant caf::UiListViewModelPdm::data( const QModelIndex& index, int role /*= Qt::DisplayRole */ ) const
|
||||
{
|
||||
if ( m_pdmObjectGroup && ( role == Qt::DisplayRole || role == Qt::EditRole ) )
|
||||
{
|
||||
if ( index.row() < static_cast<int>( m_pdmObjectGroup->objects.size() ) )
|
||||
{
|
||||
PdmObjectHandle* pdmObject = m_pdmObjectGroup->objects[index.row()];
|
||||
if ( pdmObject )
|
||||
{
|
||||
std::vector<PdmFieldHandle*> fields = pdmObject->fields();
|
||||
if ( index.column() < static_cast<int>( fields.size() ) )
|
||||
{
|
||||
size_t fieldIndex = 0;
|
||||
|
||||
if ( !m_editorAttribute.fieldNames.empty() )
|
||||
{
|
||||
QString fieldName = m_editorAttribute.fieldNames[index.column()];
|
||||
for ( size_t i = 0; i < fields.size(); i++ )
|
||||
{
|
||||
if ( fields[i]->keyword() == fieldName )
|
||||
{
|
||||
fieldIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldIndex = index.column();
|
||||
}
|
||||
|
||||
PdmUiFieldHandle* uiFieldHandle = fields[fieldIndex]->uiCapability();
|
||||
if ( uiFieldHandle )
|
||||
{
|
||||
return uiFieldHandle->uiValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::UiListViewModelPdm::setPdmData( PdmObjectCollection* objectGroup, const QString& configName )
|
||||
{
|
||||
m_pdmObjectGroup = objectGroup;
|
||||
m_configName = configName;
|
||||
|
||||
if ( m_pdmObjectGroup )
|
||||
{
|
||||
caf::PdmUiObjectHandle* uiObject = uiObj( m_pdmObjectGroup );
|
||||
if ( uiObject )
|
||||
{
|
||||
uiObject->objectEditorAttribute( m_configName, &m_editorAttribute );
|
||||
}
|
||||
}
|
||||
|
||||
computeColumnCount();
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiListViewEditor::PdmUiListViewEditor()
|
||||
: m_tableView( nullptr )
|
||||
, m_tableModelPdm( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
PdmUiListViewEditor::~PdmUiListViewEditor()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* PdmUiListViewEditor::createWidget( QWidget* parent )
|
||||
{
|
||||
CAF_ASSERT( parent );
|
||||
|
||||
QWidget* mainWidget = new QWidget( parent );
|
||||
QVBoxLayout* layout = new QVBoxLayout();
|
||||
mainWidget->setLayout( layout );
|
||||
|
||||
m_tableModelPdm = new UiListViewModelPdm( mainWidget );
|
||||
|
||||
m_tableView = new QTableView( mainWidget );
|
||||
m_tableView->setShowGrid( false );
|
||||
m_tableView->setModel( m_tableModelPdm );
|
||||
|
||||
layout->addWidget( m_tableView );
|
||||
|
||||
return mainWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiListViewEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
{
|
||||
PdmObjectCollection* objectGroup = dynamic_cast<PdmObjectCollection*>( pdmObject() );
|
||||
m_tableModelPdm->setPdmData( objectGroup, uiConfigName );
|
||||
|
||||
m_tableView->resizeColumnsToContents();
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
@@ -1,112 +0,0 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2011-2013 Ceetron AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
#include "cafPdmUiWidgetObjectEditorHandle.h"
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
|
||||
class QTableView;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmUiFieldEditorHandle;
|
||||
class PdmUiItem;
|
||||
class PdmObjectCollection;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class PdmUiListViewEditorAttribute : public PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
PdmUiListViewEditorAttribute() {}
|
||||
|
||||
public:
|
||||
QStringList fieldNames;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class UiListViewModelPdm : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UiListViewModelPdm( QObject* parent );
|
||||
|
||||
void setPdmData( PdmObjectCollection* objectGroup, const QString& configName );
|
||||
|
||||
// Qt overrides
|
||||
int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
|
||||
int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
|
||||
QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
|
||||
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
|
||||
|
||||
private:
|
||||
void computeColumnCount();
|
||||
|
||||
private:
|
||||
PdmObjectCollection* m_pdmObjectGroup;
|
||||
QString m_configName;
|
||||
PdmUiListViewEditorAttribute m_editorAttribute;
|
||||
int m_columnCount;
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class PdmUiListViewEditor : public PdmUiWidgetObjectEditorHandle
|
||||
{
|
||||
public:
|
||||
PdmUiListViewEditor();
|
||||
~PdmUiListViewEditor() override;
|
||||
|
||||
protected:
|
||||
QWidget* createWidget( QWidget* parent ) override;
|
||||
void configureAndUpdateUi( const QString& uiConfigName ) override;
|
||||
|
||||
private:
|
||||
QPointer<QTableView> m_tableView;
|
||||
UiListViewModelPdm* m_tableModelPdm;
|
||||
};
|
||||
|
||||
} // end namespace caf
|
||||
Reference in new issue
Block a user