mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-03 12:50:52 -06: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 "cafPdmField.h"
|
||||||
#include "cafPdmObjectHandle.h"
|
#include "cafPdmObjectHandle.h"
|
||||||
|
#include "cafPdmXmlFieldHandle.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
@@ -37,16 +38,19 @@ public:
|
|||||||
static void decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId );
|
static void decodeVersionString( const QString& projectFileVersion, int* majorVersion, int* minorVersion, int* patch, int* developmentId );
|
||||||
|
|
||||||
template <typename T>
|
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;
|
std::vector<caf::PdmObjectHandle*> children;
|
||||||
|
for ( const auto& field : object->fields() )
|
||||||
for ( const auto& field : allFieldsInObject )
|
|
||||||
{
|
{
|
||||||
|
if ( !field ) continue;
|
||||||
|
|
||||||
|
if ( field->xmlCapability() && !field->xmlCapability()->isIOWritable() ) continue;
|
||||||
|
|
||||||
caf::PdmField<T>* typedField = dynamic_cast<caf::PdmField<T>*>( field );
|
caf::PdmField<T>* typedField = dynamic_cast<caf::PdmField<T>*>( field );
|
||||||
if ( typedField ) fieldContents.push_back( &typedField->v() );
|
if ( typedField ) fieldContents.push_back( &typedField->v() );
|
||||||
|
|
||||||
@@ -65,8 +69,11 @@ public:
|
|||||||
|
|
||||||
for ( const auto& child : children )
|
for ( const auto& child : children )
|
||||||
{
|
{
|
||||||
fieldContentsByType( child, fieldContents );
|
auto childObjects = writableFieldContent<T>( child );
|
||||||
|
fieldContents.insert( fieldContents.end(), childObjects.begin(), childObjects.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fieldContents;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -1325,8 +1325,7 @@ RimPlotTemplateFolderItem* RimProject::rootPlotTemplateItem() const
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
std::vector<caf::FilePath*> RimProject::allFilePaths() const
|
std::vector<caf::FilePath*> RimProject::allFilePaths() const
|
||||||
{
|
{
|
||||||
std::vector<caf::FilePath*> filePaths;
|
std::vector<caf::FilePath*> filePaths = RiaProjectFileTools::writableFieldContent<caf::FilePath>( this );
|
||||||
RiaProjectFileTools::fieldContentsByType( this, filePaths );
|
|
||||||
|
|
||||||
return filePaths;
|
return filePaths;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user