mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Summary Multiplot: drag/drop updates (#8692)
Drag'n'drop improvements - accept drops in empty multiplot areas to create new plots
This commit is contained in:
@@ -244,56 +244,11 @@ bool RiuPlotWidget::handleDragDropEvent( QEvent* event )
|
||||
}
|
||||
}
|
||||
|
||||
const MimeDataWithIndexes* mimeData = nullptr;
|
||||
std::vector<caf::PdmObjectHandle*> objects;
|
||||
|
||||
if ( event->type() == QEvent::Drop )
|
||||
if ( RiuDragDrop::handleGenericDropEvent( event, objects ) )
|
||||
{
|
||||
// These drop events come from Qwt
|
||||
auto dropEvent = dynamic_cast<QDropEvent*>( event );
|
||||
if ( dropEvent )
|
||||
{
|
||||
mimeData = qobject_cast<const MimeDataWithIndexes*>( dropEvent->mimeData() );
|
||||
|
||||
dropEvent->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
if ( event->type() == QEvent::GraphicsSceneDrop )
|
||||
{
|
||||
// These drop events come from QtChart
|
||||
auto dropEvent = dynamic_cast<QGraphicsSceneDragDropEvent*>( event );
|
||||
if ( dropEvent )
|
||||
{
|
||||
mimeData = qobject_cast<const MimeDataWithIndexes*>( dropEvent->mimeData() );
|
||||
|
||||
dropEvent->acceptProposedAction();
|
||||
}
|
||||
}
|
||||
|
||||
if ( mimeData )
|
||||
{
|
||||
std::vector<caf::PdmObjectHandle*> objects;
|
||||
|
||||
QString mimeType = caf::PdmUiDragDropInterface::mimeTypeForObjectReferenceList();
|
||||
|
||||
auto data = mimeData->data( mimeType );
|
||||
|
||||
QStringList objectReferences;
|
||||
QDataStream in( &data, QIODevice::ReadOnly );
|
||||
in >> objectReferences;
|
||||
|
||||
auto proj = RimProject::current();
|
||||
for ( const auto& objRef : objectReferences )
|
||||
{
|
||||
auto obj = caf::PdmReferenceHelper::objectFromReference( proj, objRef );
|
||||
if ( obj ) objects.push_back( obj );
|
||||
}
|
||||
|
||||
if ( m_plotDefinition )
|
||||
{
|
||||
m_plotDefinition->handleDroppedObjects( objects );
|
||||
}
|
||||
|
||||
if ( m_plotDefinition ) m_plotDefinition->handleDroppedObjects( objects );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user