Simplify PdmDocument class and move fileName to private

Remove resolveReferencesRecursively() and initAfterReadRecursively() from PdmDocument::readFile(). These functions will be called in RiaApplication::loadProject after the file paths modifications are done. This will ensure that file paths can be used in initAfterRead() functions.
This commit is contained in:
Magne Sjaastad
2024-06-05 11:00:55 +02:00
parent beccd2454e
commit 41d5e498d7
9 changed files with 66 additions and 48 deletions

View File

@@ -48,7 +48,23 @@ CAF_PDM_SOURCE_INIT( PdmDocument, "PdmDocument" );
//--------------------------------------------------------------------------------------------------
PdmDocument::PdmDocument()
{
CAF_PDM_InitFieldNoDefault( &fileName, "DocumentFileName", "File Name" );
CAF_PDM_InitFieldNoDefault( &m_fileName, "DocumentFileName", "File Name" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString PdmDocument::fileName() const
{
return m_fileName;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmDocument::setFileName( const QString& fileName )
{
m_fileName = fileName;
}
//--------------------------------------------------------------------------------------------------
@@ -56,7 +72,7 @@ PdmDocument::PdmDocument()
//--------------------------------------------------------------------------------------------------
void PdmDocument::readFile()
{
QFile xmlFile( fileName );
QFile xmlFile( m_fileName );
if ( !xmlFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) return;
readFile( &xmlFile );
@@ -76,19 +92,11 @@ void PdmDocument::readFile( QIODevice* xmlFile )
{
if ( !matchesClassKeyword( xmlStream.name().toString() ) )
{
// Error: This is not a Ceetron Pdm based xml document
return;
}
readFields( xmlStream, PdmDefaultObjectFactory::instance(), false );
}
}
// Ask all objects to initialize and set up internal data structures and pointers
// after everything is read from file
resolveReferencesRecursively();
beforeInitAfterRead();
initAfterReadRecursively();
}
//--------------------------------------------------------------------------------------------------
@@ -96,7 +104,7 @@ void PdmDocument::readFile( QIODevice* xmlFile )
//--------------------------------------------------------------------------------------------------
bool PdmDocument::writeFile()
{
QFile xmlFile( fileName );
QFile xmlFile( m_fileName );
if ( !xmlFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) return false;
writeFile( &xmlFile );
@@ -161,13 +169,6 @@ void PdmDocument::updateUiIconStateRecursively( PdmObjectHandle* object )
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmDocument::beforeInitAfterRead()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------