CAF: Move keyword aliases from PdmXmlFieldHandle to PdmFieldHandle

This commit is contained in:
Gaute Lindkvist
2020-02-25 15:52:10 +01:00
parent 7a304deecb
commit 1353835bd8
9 changed files with 34 additions and 45 deletions

View File

@@ -89,7 +89,7 @@ Rim3dView::Rim3dView( void )
CAF_PDM_InitObject( "3d View", "", "", "" );
RICF_InitField( &m_id, "Id", -1, "View ID", "", "", "" );
m_id.xmlCapability()->registerKeywordAlias( "ViewId" );
m_id.registerKeywordAlias( "ViewId" );
m_id.uiCapability()->setUiReadOnly( true );
m_id.uiCapability()->setUiHidden( true );
m_id.capability<RicfFieldHandle>()->setIOWriteable( false );
@@ -114,7 +114,7 @@ Rim3dView::Rim3dView( void )
cvf::Color3f defBackgColor = preferences->defaultViewerBackgroundColor();
RICF_InitField( &m_backgroundColor, "BackgroundColor", defBackgColor, "Background", "", "", "" );
m_backgroundColor.xmlCapability()->registerKeywordAlias( "ViewBackgroundColor" );
m_backgroundColor.registerKeywordAlias( "ViewBackgroundColor" );
CAF_PDM_InitField( &maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", "" );
maximumFrameRate.uiCapability()->setUiHidden( true );

View File

@@ -46,16 +46,16 @@ RimCase::RimCase()
RICF_InitObjectWithScriptNameAndComment( "Case", ":/Case48x48.png", "", "", "Case", "The ResInsight base class for Cases" );
RICF_InitField( &caseUserDescription, "Name", QString(), "Case Name", "", "", "" );
caseUserDescription.xmlCapability()->registerKeywordAlias( "CaseUserDescription" );
caseUserDescription.registerKeywordAlias( "CaseUserDescription" );
RICF_InitField( &caseId, "Id", -1, "Case ID", "", "", "" );
caseId.xmlCapability()->registerKeywordAlias( "CaseId" );
caseId.registerKeywordAlias( "CaseId" );
caseId.uiCapability()->setUiReadOnly( true );
caseId.capability<RicfFieldHandle>()->setIOWriteable( false );
RICF_InitFieldNoDefault( &m_caseFileName, "FilePath", "Case File Name", "", "", "" );
m_caseFileName.xmlCapability()->registerKeywordAlias( "CaseFileName" );
m_caseFileName.xmlCapability()->registerKeywordAlias( "GridFileName" );
m_caseFileName.registerKeywordAlias( "CaseFileName" );
m_caseFileName.registerKeywordAlias( "GridFileName" );
m_caseFileName.uiCapability()->setUiReadOnly( true );

View File

@@ -45,7 +45,7 @@ RimPlotWindow::RimPlotWindow()
"The Abstract base class for all MDI Windows in the Plot Window" );
RICF_InitField( &m_id, "Id", -1, "View ID", "", "", "" );
m_id.xmlCapability()->registerKeywordAlias( "ViewId" );
m_id.registerKeywordAlias( "ViewId" );
m_id.uiCapability()->setUiReadOnly( true );
m_id.uiCapability()->setUiHidden( true );
m_id.capability<RicfFieldHandle>()->setIOWriteable( false );

View File

@@ -65,7 +65,7 @@ RimSimWellInView::RimSimWellInView()
RICF_InitObjectWithScriptNameAndComment( "Simulation Well", ":/Well.png", "", "", "SimulationWell", "An Eclipse Simulation Well" );
RICF_InitFieldNoDefault( &name, "Name", "Name", "", "", "" );
name.xmlCapability()->registerKeywordAlias( "WellName" );
name.registerKeywordAlias( "WellName" );
CAF_PDM_InitField( &showWell, "ShowWell", true, "Show well ", "", "", "" );

View File

@@ -76,7 +76,7 @@ RimWellPath::RimWellPath()
RICF_InitObject( "WellPath", ":/Well.png", "", "The Base class for Well Paths" );
RICF_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" );
m_name.xmlCapability()->registerKeywordAlias( "WellPathName" );
m_name.registerKeywordAlias( "WellPathName" );
m_name.uiCapability()->setUiReadOnly( true );
m_name.uiCapability()->setUiHidden( true );
m_name.xmlCapability()->disableIO();

View File

@@ -104,6 +104,26 @@ bool PdmFieldHandle::hasPtrReferencedObjects()
return (ptrReffedObjs.size() > 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmFieldHandle::registerKeywordAlias(const QString& alias)
{
m_keywordAliases.push_back(alias);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PdmFieldHandle::matchesKeywordAlias(const QString& keyword) const
{
for (const QString& alias : m_keywordAliases)
{
if (alias == keyword) return true;
}
return false;
}
// These two functions can be used when PdmCore is used standalone without PdmUi/PdmXml
/*
PdmUiFieldHandle* PdmFieldHandle::uiCapability()

View File

@@ -27,6 +27,9 @@ public:
PdmObjectHandle* ownerObject();
QString ownerClass() const;
void registerKeywordAlias(const QString& alias);
bool matchesKeywordAlias(const QString& keyword) const;
// Child objects
bool hasChildObjects();
virtual void childObjects(std::vector<PdmObjectHandle*>*) { }
@@ -55,14 +58,13 @@ protected:
private:
PDM_DISABLE_COPY_AND_ASSIGN(PdmFieldHandle);
bool matchesKeywordAlias(const QString& keyword) const;
friend class PdmObjectHandle; // Give access to m_ownerObject and set Keyword
void setKeyword(const QString& keyword);
PdmObjectHandle* m_ownerObject;
QString m_ownerClass;
QString m_keyword;
std::vector<QString> m_keywordAliases;
std::vector<std::pair<PdmFieldCapability*, bool> > m_capabilities;
};

View File

@@ -61,26 +61,6 @@ QString PdmXmlFieldHandle::childClassKeyword()
return m_childClassKeyword;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmXmlFieldHandle::registerKeywordAlias(const QString& alias)
{
m_keywordAliases.push_back(alias);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PdmXmlFieldHandle::matchesKeywordAlias(const QString& keyword) const
{
for (const QString& alias : m_keywordAliases)
{
if (alias == keyword) return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
/// Implementation of uiCapability() defined in cafPdmFieldHandle.h
//--------------------------------------------------------------------------------------------------
@@ -92,14 +72,5 @@ PdmXmlFieldHandle* PdmFieldHandle::xmlCapability()
return xmlField;
}
bool PdmFieldHandle::matchesKeywordAlias(const QString& keyword) const
{
const PdmXmlFieldHandle* xmlField = capability<PdmXmlFieldHandle>();
if (xmlField)
{
return xmlField->matchesKeywordAlias(keyword);
}
return false;
}
} // End of namespace caf

View File

@@ -40,9 +40,6 @@ public:
QString childClassKeyword();
void registerKeywordAlias(const QString& alias);
bool matchesKeywordAlias(const QString& keyword) const;
virtual void readFieldData(QXmlStreamReader& xmlStream, PdmObjectFactory* objectFactory) = 0;
virtual void writeFieldData(QXmlStreamWriter& xmlStream) const = 0;
@@ -58,7 +55,6 @@ private:
bool m_isIOReadable;
bool m_isIOWritable;
bool m_isCopyable;
std::vector<QString> m_keywordAliases;
PdmFieldHandle* m_owner;
};