mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#11844 Quick Access adjustments
Show the Quick Access menu only for objects that implements RimFieldQuickAccessInterface Show the fields made available by RimFieldQuickAccessInterface
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "RicAddFieldToQuickAccessFeature.h"
|
#include "RicAddFieldToQuickAccessFeature.h"
|
||||||
|
|
||||||
|
#include "QuickAccess/RimFieldQuickAccessInterface.h"
|
||||||
#include "QuickAccess/RimFieldReference.h"
|
#include "QuickAccess/RimFieldReference.h"
|
||||||
#include "QuickAccess/RimQuickAccessCollection.h"
|
#include "QuickAccess/RimQuickAccessCollection.h"
|
||||||
|
|
||||||
@@ -30,6 +31,15 @@
|
|||||||
|
|
||||||
CAF_CMD_SOURCE_INIT( RicAddFieldToQuickAccessFeature, "RicAddFieldToQuickAccessFeature" );
|
CAF_CMD_SOURCE_INIT( RicAddFieldToQuickAccessFeature, "RicAddFieldToQuickAccessFeature" );
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicAddFieldToQuickAccessFeature::isCommandEnabled() const
|
||||||
|
{
|
||||||
|
auto objects = caf::selectedObjectsByType<RimFieldQuickAccessInterface*>();
|
||||||
|
return !objects.empty();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class RicAddFieldToQuickAccessFeature : public caf::CmdFeature
|
|||||||
CAF_CMD_HEADER_INIT;
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
bool isCommandEnabled() const override;
|
||||||
void onActionTriggered( bool isChecked ) override;
|
void onActionTriggered( bool isChecked ) override;
|
||||||
void setupActionLook( QAction* actionToSetup ) override;
|
void setupActionLook( QAction* actionToSetup ) override;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ void RimFieldQuickAccessGroup::addFields( const std::vector<caf::PdmFieldHandle*
|
|||||||
|
|
||||||
for ( auto field : fields )
|
for ( auto field : fields )
|
||||||
{
|
{
|
||||||
if ( findField( field ) ) continue;
|
|
||||||
|
|
||||||
addField( field );
|
addField( field );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,8 +71,8 @@ void RimFieldQuickAccessGroup::addField( caf::PdmFieldHandle* field )
|
|||||||
{
|
{
|
||||||
if ( !field ) return;
|
if ( !field ) return;
|
||||||
if ( !m_ownerView ) return;
|
if ( !m_ownerView ) return;
|
||||||
|
|
||||||
if ( !isOwnerViewMatching( field ) ) return;
|
if ( !isOwnerViewMatching( field ) ) return;
|
||||||
|
if ( findField( field ) ) return;
|
||||||
|
|
||||||
auto fieldReference = new RimFieldQuickAccess();
|
auto fieldReference = new RimFieldQuickAccess();
|
||||||
fieldReference->setField( field );
|
fieldReference->setField( field );
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "RimFieldReference.h"
|
#include "RimFieldReference.h"
|
||||||
|
#include "RimFieldQuickAccessInterface.h"
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT( RimFieldReference, "RimFieldReference" );
|
CAF_PDM_SOURCE_INIT( RimFieldReference, "RimFieldReference" );
|
||||||
|
|
||||||
@@ -36,10 +37,19 @@ void RimFieldReference::setObject( caf::PdmObject* object )
|
|||||||
{
|
{
|
||||||
m_object = object;
|
m_object = object;
|
||||||
|
|
||||||
auto keywordAndNames = RimFieldReference::fieldKeywordAndNames( object );
|
if ( auto quickInterface = dynamic_cast<RimFieldQuickAccessInterface*>( m_object() ) )
|
||||||
if ( !keywordAndNames.empty() )
|
|
||||||
{
|
{
|
||||||
m_fieldKeyword = keywordAndNames[0].first;
|
for ( const auto& [groupName, fields] : quickInterface->quickAccessFields() )
|
||||||
|
{
|
||||||
|
for ( auto field : fields )
|
||||||
|
{
|
||||||
|
if ( field )
|
||||||
|
{
|
||||||
|
m_fieldKeyword = field->keyword();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,29 +141,30 @@ QList<caf::PdmOptionItemInfo> RimFieldReference::calculateValueOptions( const ca
|
|||||||
|
|
||||||
if ( fieldNeedingOptions == &m_fieldKeyword )
|
if ( fieldNeedingOptions == &m_fieldKeyword )
|
||||||
{
|
{
|
||||||
auto keywordAndNames = RimFieldReference::fieldKeywordAndNames( m_object );
|
if ( auto quickInterface = dynamic_cast<RimFieldQuickAccessInterface*>( m_object() ) )
|
||||||
for ( const auto& [keyword, name] : keywordAndNames )
|
|
||||||
{
|
{
|
||||||
options.push_back( caf::PdmOptionItemInfo( name, keyword ) );
|
for ( const auto& [groupName, fields] : quickInterface->quickAccessFields() )
|
||||||
|
{
|
||||||
|
for ( auto field : fields )
|
||||||
|
{
|
||||||
|
auto text = field->keyword();
|
||||||
|
|
||||||
|
if ( auto uiCapability = field->uiCapability() )
|
||||||
|
{
|
||||||
|
text = uiCapability->uiName();
|
||||||
|
}
|
||||||
|
|
||||||
|
options.push_back( caf::PdmOptionItemInfo( text, field->keyword() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( fieldNeedingOptions == &m_object )
|
else if ( fieldNeedingOptions == &m_object )
|
||||||
{
|
{
|
||||||
if ( m_objectsForSelection.empty() )
|
if ( m_object )
|
||||||
{
|
{
|
||||||
if ( m_object )
|
QString text = m_object()->uiName();
|
||||||
{
|
options.push_back( caf::PdmOptionItemInfo( text, m_object ) );
|
||||||
QString text = m_object()->uiName();
|
|
||||||
options.push_back( caf::PdmOptionItemInfo( text, m_object ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for ( auto obj : m_objectsForSelection )
|
|
||||||
{
|
|
||||||
QString text = obj->uiName();
|
|
||||||
options.push_back( caf::PdmOptionItemInfo( text, obj ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,14 +189,6 @@ caf::PdmObject* RimFieldReference::object() const
|
|||||||
return m_object;
|
return m_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimFieldReference::setObjectsForSelection( const std::vector<caf::PdmObject*>& objectsForSelection )
|
|
||||||
{
|
|
||||||
m_objectsForSelection = objectsForSelection;
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public:
|
|||||||
caf::PdmFieldHandle* field() const;
|
caf::PdmFieldHandle* field() const;
|
||||||
|
|
||||||
caf::PdmObject* object() const;
|
caf::PdmObject* object() const;
|
||||||
void setObjectsForSelection( const std::vector<caf::PdmObject*>& objectsForSelection );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||||
@@ -57,6 +56,4 @@ private:
|
|||||||
private:
|
private:
|
||||||
caf::PdmPtrField<caf::PdmObject*> m_object;
|
caf::PdmPtrField<caf::PdmObject*> m_object;
|
||||||
caf::PdmField<QString> m_fieldKeyword;
|
caf::PdmField<QString> m_fieldKeyword;
|
||||||
|
|
||||||
std::vector<caf::PdmObject*> m_objectsForSelection;
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user