diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTableCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTableCollection.cpp index af063c553a..3c5c725ce7 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTableCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTableCollection.cpp @@ -33,8 +33,8 @@ RimSummaryTableCollection::RimSummaryTableCollection() { CAF_PDM_InitObject( "Summary Tables", ":/CorrelationMatrixPlot16x16.png" ); - CAF_PDM_InitFieldNoDefault( &m_summaryTables, "SummaryTables", "Summary Tables" ); - caf::PdmFieldReorderCapability::addToField( &m_summaryTables ); + CAF_PDM_InitFieldNoDefault( &m_items, "SummaryTables", "Summary Tables" ); + caf::PdmFieldReorderCapability::addToField( &m_items ); } //-------------------------------------------------------------------------------------------------- @@ -49,7 +49,7 @@ RimSummaryTableCollection::~RimSummaryTableCollection() //-------------------------------------------------------------------------------------------------- void RimSummaryTableCollection::deleteAllPlots() { - m_summaryTables.deleteChildren(); + deleteAllItems(); } //-------------------------------------------------------------------------------------------------- @@ -57,7 +57,7 @@ void RimSummaryTableCollection::deleteAllPlots() //-------------------------------------------------------------------------------------------------- void RimSummaryTableCollection::loadDataAndUpdateAllPlots() { - for ( RimSummaryTable* table : m_summaryTables ) + for ( RimSummaryTable* table : items() ) { if ( !table ) continue; @@ -70,7 +70,7 @@ void RimSummaryTableCollection::loadDataAndUpdateAllPlots() //-------------------------------------------------------------------------------------------------- size_t RimSummaryTableCollection::plotCount() const { - return tableCount(); + return count(); } //-------------------------------------------------------------------------------------------------- @@ -78,28 +78,15 @@ size_t RimSummaryTableCollection::plotCount() const //-------------------------------------------------------------------------------------------------- std::vector RimSummaryTableCollection::tables() const { - return m_summaryTables.childrenByType(); + return items(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RimSummaryTableCollection::tableCount() const -{ - return m_summaryTables.size(); -} - void RimSummaryTableCollection::addTable( RimSummaryTable* table ) { - insertTable( table, tableCount() ); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryTableCollection::insertTable( RimSummaryTable* table, size_t index ) -{ - m_summaryTables.insert( index, table ); + addItem( table ); } //-------------------------------------------------------------------------------------------------- @@ -107,8 +94,7 @@ void RimSummaryTableCollection::insertTable( RimSummaryTable* table, size_t inde //-------------------------------------------------------------------------------------------------- void RimSummaryTableCollection::removeTable( RimSummaryTable* table ) { - m_summaryTables.removeChild( table ); - updateAllRequiredEditors(); + deleteItem( table ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTableCollection.h b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTableCollection.h index eaaca4f85d..0f1c77837d 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTableCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryTableCollection.h @@ -23,16 +23,16 @@ #include "RimAbstractPlotCollection.h" #include "RimSummaryTable.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmObject.h" +#include "cafPdmObjectCollection.h" class RimSummaryCase; //================================================================================================== /// +/// Collection for managing summary tables /// //================================================================================================== -class RimSummaryTableCollection : public caf::PdmObject, public RimPlotCollection +class RimSummaryTableCollection : public caf::PdmObjectCollection, public RimPlotCollection { CAF_PDM_HEADER_INIT; @@ -40,21 +40,19 @@ public: RimSummaryTableCollection(); ~RimSummaryTableCollection() override; + // RimPlotCollection interface void deleteAllPlots() override; void loadDataAndUpdateAllPlots() override; size_t plotCount() const override; + // Convenience accessors (delegate to base class) std::vector tables() const; - size_t tableCount() const; void addTable( RimSummaryTable* table ); - void insertTable( RimSummaryTable* table, size_t index ); void removeTable( RimSummaryTable* table ); + // Domain-specific creation methods RimSummaryTable* createDefaultSummaryTable(); RimSummaryTable* createSummaryTableFromCategoryAndVectorName( RimSummaryCase* summaryCase, RifEclipseSummaryAddressDefines::SummaryCategory category, const QString& vectorName ); - -private: - caf::PdmChildArrayField m_summaryTables; };