mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#8859 Add drop target for calculation variables
This commit is contained in:
parent
feb1c417c5
commit
bb6ca0848d
@ -37,6 +37,7 @@
|
|||||||
#include "RiuExpressionContextMenuManager.h"
|
#include "RiuExpressionContextMenuManager.h"
|
||||||
|
|
||||||
#include "cafPdmUiLineEditor.h"
|
#include "cafPdmUiLineEditor.h"
|
||||||
|
#include "cafPdmUiTableViewEditor.h"
|
||||||
#include "cafPdmUiTextEditor.h"
|
#include "cafPdmUiTextEditor.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -465,6 +466,14 @@ void RimSummaryCalculation::defineEditorAttribute( const caf::PdmFieldHandle* fi
|
|||||||
myAttr->heightHint = -1;
|
myAttr->heightHint = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( field == &m_variables )
|
||||||
|
{
|
||||||
|
auto* myAttr = dynamic_cast<caf::PdmUiTableViewEditorAttribute*>( attribute );
|
||||||
|
if ( myAttr )
|
||||||
|
{
|
||||||
|
myAttr->enableDropTarget = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
#include "RiaSummaryCurveDefinition.h"
|
#include "RiaSummaryCurveDefinition.h"
|
||||||
|
#include "RiaSummaryTools.h"
|
||||||
|
|
||||||
#include "RifEclipseSummaryAddressQMetaType.h"
|
#include "RifEclipseSummaryAddressQMetaType.h"
|
||||||
|
|
||||||
@ -29,6 +30,7 @@
|
|||||||
#include "RimSummaryCase.h"
|
#include "RimSummaryCase.h"
|
||||||
#include "RimSummaryCurve.h"
|
#include "RimSummaryCurve.h"
|
||||||
|
|
||||||
|
#include "RiuDragDrop.h"
|
||||||
#include "RiuSummaryVectorSelectionDialog.h"
|
#include "RiuSummaryVectorSelectionDialog.h"
|
||||||
|
|
||||||
#include "cafPdmUiPushButtonEditor.h"
|
#include "cafPdmUiPushButtonEditor.h"
|
||||||
@ -153,6 +155,33 @@ RimSummaryAddress* RimSummaryCalculationVariable::summaryAddress()
|
|||||||
return m_summaryAddress();
|
return m_summaryAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryCalculationVariable::setSummaryAddress( const RimSummaryAddress& address )
|
||||||
|
{
|
||||||
|
m_summaryAddress()->setAddress( address.address() );
|
||||||
|
|
||||||
|
auto summaryCase = RiaSummaryTools::summaryCaseById( address.caseId() );
|
||||||
|
|
||||||
|
if ( summaryCase ) m_case = summaryCase;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RimSummaryCalculationVariable::handleDroppedMimeData( const QMimeData* data,
|
||||||
|
Qt::DropAction action,
|
||||||
|
caf::PdmFieldHandle* destinationField )
|
||||||
|
{
|
||||||
|
auto objects = RiuDragDrop::convertToObjects( data );
|
||||||
|
if ( !objects.empty() )
|
||||||
|
{
|
||||||
|
auto address = dynamic_cast<RimSummaryAddress*>( objects.front() );
|
||||||
|
if ( address ) setSummaryAddress( *address );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -49,6 +49,10 @@ public:
|
|||||||
RimSummaryCase* summaryCase();
|
RimSummaryCase* summaryCase();
|
||||||
RimSummaryAddress* summaryAddress();
|
RimSummaryAddress* summaryAddress();
|
||||||
|
|
||||||
|
void setSummaryAddress( const RimSummaryAddress& address );
|
||||||
|
|
||||||
|
void handleDroppedMimeData( const QMimeData* data, Qt::DropAction action, caf::PdmFieldHandle* destinationField ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||||
|
@ -138,7 +138,7 @@ void RimSummaryAddress::setAddress( const RifEclipseSummaryAddress& addr )
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RifEclipseSummaryAddress RimSummaryAddress::address()
|
RifEclipseSummaryAddress RimSummaryAddress::address() const
|
||||||
{
|
{
|
||||||
return RifEclipseSummaryAddress( m_category(),
|
return RifEclipseSummaryAddress( m_category(),
|
||||||
m_quantityName().toStdString(),
|
m_quantityName().toStdString(),
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
wrapFileReaderAddress( const RifEclipseSummaryAddress& addr, int caseId = -1, int ensembleId = -1 );
|
wrapFileReaderAddress( const RifEclipseSummaryAddress& addr, int caseId = -1, int ensembleId = -1 );
|
||||||
|
|
||||||
void setAddress( const RifEclipseSummaryAddress& addr );
|
void setAddress( const RifEclipseSummaryAddress& addr );
|
||||||
RifEclipseSummaryAddress address();
|
RifEclipseSummaryAddress address() const;
|
||||||
|
|
||||||
void setCaseId( int caseId );
|
void setCaseId( int caseId );
|
||||||
int caseId() const;
|
int caseId() const;
|
||||||
|
@ -808,11 +808,29 @@ bool RiuDragDrop::handleGenericDropEvent( QEvent* event, std::vector<caf::PdmObj
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( mimeData )
|
||||||
|
{
|
||||||
|
auto objects = convertToObjects( mimeData );
|
||||||
|
droppedObjects.insert( droppedObjects.end(), objects.begin(), objects.end() );
|
||||||
|
|
||||||
|
bResult = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<caf::PdmObjectHandle*> RiuDragDrop::convertToObjects( const QMimeData* mimeData )
|
||||||
|
{
|
||||||
|
std::vector<caf::PdmObjectHandle*> droppedObjects;
|
||||||
if ( mimeData )
|
if ( mimeData )
|
||||||
{
|
{
|
||||||
QString mimeType = caf::PdmUiDragDropInterface::mimeTypeForObjectReferenceList();
|
QString mimeType = caf::PdmUiDragDropInterface::mimeTypeForObjectReferenceList();
|
||||||
|
|
||||||
auto data = mimeData->data( mimeType );
|
QByteArray data = mimeData->data( mimeType );
|
||||||
|
if ( data.isEmpty() ) return {};
|
||||||
|
|
||||||
QStringList objectReferences;
|
QStringList objectReferences;
|
||||||
QDataStream in( &data, QIODevice::ReadOnly );
|
QDataStream in( &data, QIODevice::ReadOnly );
|
||||||
@ -824,9 +842,7 @@ bool RiuDragDrop::handleGenericDropEvent( QEvent* event, std::vector<caf::PdmObj
|
|||||||
auto obj = caf::PdmReferenceHelper::objectFromReference( proj, objRef );
|
auto obj = caf::PdmReferenceHelper::objectFromReference( proj, objRef );
|
||||||
if ( obj ) droppedObjects.push_back( obj );
|
if ( obj ) droppedObjects.push_back( obj );
|
||||||
}
|
}
|
||||||
|
|
||||||
bResult = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bResult;
|
return droppedObjects;
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,8 @@ public:
|
|||||||
|
|
||||||
static bool handleGenericDropEvent( QEvent* event, std::vector<caf::PdmObjectHandle*>& droppedObjects );
|
static bool handleGenericDropEvent( QEvent* event, std::vector<caf::PdmObjectHandle*>& droppedObjects );
|
||||||
|
|
||||||
|
static std::vector<caf::PdmObjectHandle*> convertToObjects( const QMimeData* mimeData );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Qt::DropActions supportedDropActions() const override;
|
Qt::DropActions supportedDropActions() const override;
|
||||||
Qt::ItemFlags flags( const QModelIndex& index ) const override;
|
Qt::ItemFlags flags( const QModelIndex& index ) const override;
|
||||||
|
Loading…
Reference in New Issue
Block a user