diff --git a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt index 88a88765d2..ccf03f7af0 100644 --- a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt @@ -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 diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.cpp deleted file mode 100644 index 6631f294ff..0000000000 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.cpp +++ /dev/null @@ -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 <> -// 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 <> -// for more details. -// -//################################################################################################## - -#include "cafPdmUiListView.h" - -#include "cafPdmObjectGroup.h" -#include "cafPdmObjectHandle.h" -#include "cafPdmUiListViewEditor.h" - -#include - -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 diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h deleted file mode 100644 index e374cb84ab..0000000000 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h +++ /dev/null @@ -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 <> -// 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 <> -// for more details. -// -//################################################################################################## - -#pragma once -#include -#include - -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 diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp deleted file mode 100644 index df407865a9..0000000000 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp +++ /dev/null @@ -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 <> -// 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 <> -// for more details. -// -//################################################################################################## - -#include "cafPdmUiListViewEditor.h" - -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmObjectGroup.h" -#include "cafPdmUiEditorHandle.h" - -#include -#include -#include - -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( 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 fields = m_pdmObjectGroup->objects[i]->fields(); - - if ( m_columnCount < static_cast( fields.size() ) ) - { - m_columnCount = static_cast( 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( m_pdmObjectGroup->objects.size() ) ) - { - PdmObjectHandle* pdmObject = m_pdmObjectGroup->objects[index.row()]; - if ( pdmObject ) - { - std::vector fields = pdmObject->fields(); - if ( index.column() < static_cast( 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( pdmObject() ); - m_tableModelPdm->setPdmData( objectGroup, uiConfigName ); - - m_tableView->resizeColumnsToContents(); -} - -} // end namespace caf diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.h deleted file mode 100644 index 4a42459e71..0000000000 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.h +++ /dev/null @@ -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 <> -// 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 <> -// for more details. -// -//################################################################################################## - -#pragma once - -#include "cafPdmUiFieldEditorHandle.h" -#include "cafPdmUiWidgetObjectEditorHandle.h" - -#include -#include -#include - -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 m_tableView; - UiListViewModelPdm* m_tableModelPdm; -}; - -} // end namespace caf