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:
@@ -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 )
|
||||
{
|
||||
QString mimeType = caf::PdmUiDragDropInterface::mimeTypeForObjectReferenceList();
|
||||
|
||||
auto data = mimeData->data( mimeType );
|
||||
QByteArray data = mimeData->data( mimeType );
|
||||
if ( data.isEmpty() ) return {};
|
||||
|
||||
QStringList objectReferences;
|
||||
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 );
|
||||
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 std::vector<caf::PdmObjectHandle*> convertToObjects( const QMimeData* mimeData );
|
||||
|
||||
protected:
|
||||
Qt::DropActions supportedDropActions() const override;
|
||||
Qt::ItemFlags flags( const QModelIndex& index ) const override;
|
||||
|
||||
Reference in New Issue
Block a user