mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 22:50:25 -05:00
Get caf::FilePath for writable PdmFields
This commit is contained in:
1 parent
3c7e8ee120
commit
76b3b3009d
2 files changed
+14
-8
No files matched your search
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
#include "cafPdmXmlFieldHandle.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
@@ -37,16 +38,19 @@ public:
|
||||
static void decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId );
|
||||
|
||||
template <typename T>
|
||||
static void fieldContentsByType( const caf::PdmObjectHandle* object, std::vector<T*>& fieldContents )
|
||||
static std::vector<T*> writableFieldContent( const caf::PdmObjectHandle* object )
|
||||
{
|
||||
if ( !object ) return;
|
||||
if ( !object ) return {};
|
||||
|
||||
std::vector<caf::PdmFieldHandle*> allFieldsInObject = object->fields();
|
||||
std::vector<T*> fieldContents;
|
||||
|
||||
std::vector<caf::PdmObjectHandle*> children;
|
||||
|
||||
for ( const auto& field : allFieldsInObject )
|
||||
for ( const auto& field : object->fields() )
|
||||
{
|
||||
if ( !field ) continue;
|
||||
|
||||
if ( field->xmlCapability() && !field->xmlCapability()->isIOWritable() ) continue;
|
||||
|
||||
caf::PdmField<T>* typedField = dynamic_cast<caf::PdmField<T>*>( field );
|
||||
if ( typedField ) fieldContents.push_back( &typedField->v() );
|
||||
|
||||
@@ -65,8 +69,11 @@ public:
|
||||
|
||||
for ( const auto& child : children )
|
||||
{
|
||||
fieldContentsByType( child, fieldContents );
|
||||
auto childObjects = writableFieldContent<T>( child );
|
||||
fieldContents.insert( fieldContents.end(), childObjects.begin(), childObjects.end() );
|
||||
}
|
||||
|
||||
return fieldContents;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -1325,8 +1325,7 @@ RimPlotTemplateFolderItem* RimProject::rootPlotTemplateItem() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::FilePath*> RimProject::allFilePaths() const
|
||||
{
|
||||
std::vector<caf::FilePath*> filePaths;
|
||||
RiaProjectFileTools::fieldContentsByType( this, filePaths );
|
||||
std::vector<caf::FilePath*> filePaths = RiaProjectFileTools::writableFieldContent<caf::FilePath>( this );
|
||||
|
||||
return filePaths;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user