#1840: Summary case: Drag and drop between folders

This commit is contained in:
Rebecca Cox 2017-09-11 14:39:21 +02:00
parent 31d753ca36
commit 6dc14c09b1
2 changed files with 112 additions and 8 deletions

View File

@ -29,6 +29,9 @@
#include "RimEclipseResultCase.h"
#include "RimIdenticalGridCaseGroup.h"
#include "RimMimeData.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h"
#include "RimWellAllocationPlot.h"
#include "RimWellLogCurve.h"
#include "RimWellLogFileChannel.h"
@ -158,7 +161,8 @@ Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
if (dynamic_cast<RimEclipseCase*>(uiItem) ||
dynamic_cast<RimWellLogCurve*>(uiItem) ||
dynamic_cast<RimWellLogFileChannel*>(uiItem) ||
dynamic_cast<RimWellLogTrack*>(uiItem))
dynamic_cast<RimWellLogTrack*>(uiItem) ||
dynamic_cast<RimSummaryCase*>(uiItem))
{
// TODO: Remember to handle reservoir holding the main grid
itemflags |= Qt::ItemIsDragEnabled;
@ -198,6 +202,27 @@ Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (dynamic_cast<RimSummaryCase*>(uiItem))
{
if (RiuTypedPdmObjects<RimSummaryCase>::containsTypedObjects(m_dragItems))
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (dynamic_cast<RimSummaryCaseCollection*>(uiItem))
{
if (RiuTypedPdmObjects<RimSummaryCase>::containsTypedObjects(m_dragItems))
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (dynamic_cast<RimSummaryCaseMainCollection*>(uiItem))
{
if (RiuTypedPdmObjects<RimSummaryCase>::containsTypedObjects(m_dragItems))
{
itemflags |= Qt::ItemIsDropEnabled;
}
}
}
else if (m_proposedDropAction == Qt::CopyAction)
{
@ -269,6 +294,20 @@ bool RiuDragDrop::dropMimeData(const QMimeData *data, Qt::DropAction action, int
{
return handleWellLogPlotDrop(action, draggedObjects, wellLogPlot);
}
RimSummaryCaseCollection* summaryCaseCollection;
dropTarget->firstAncestorOrThisOfType(summaryCaseCollection);
if (summaryCaseCollection)
{
return handleSummaryCaseCollectionDrop(action, draggedObjects, summaryCaseCollection);
}
RimSummaryCaseMainCollection* summaryCaseMainCollection;
dropTarget->firstAncestorOrThisOfType(summaryCaseMainCollection);
if (summaryCaseMainCollection)
{
return handleSummaryCaseMainCollectionDrop(action, draggedObjects, summaryCaseMainCollection);
}
}
return false;
@ -378,6 +417,24 @@ bool RiuDragDrop::handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObje
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGroup& draggedObjects, RimWellLogPlot* wellLogPlotTarget)
{
std::vector<RimWellLogTrack*> wellLogPlotTracks = RiuTypedPdmObjects<RimWellLogTrack>::typedObjectsFromGroup(draggedObjects);
if (wellLogPlotTracks.size() > 0)
{
if (action == Qt::MoveAction)
{
RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(wellLogPlotTarget, wellLogPlotTracks, NULL);
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -402,19 +459,62 @@ bool RiuDragDrop::handleWellLogPlotCurveDrop(Qt::DropAction action, caf::PdmObje
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGroup& draggedObjects, RimWellLogPlot* wellLogPlotTarget)
bool RiuDragDrop::handleSummaryCaseCollectionDrop(Qt::DropAction action, caf::PdmObjectGroup& draggedObjects, RimSummaryCaseCollection* summaryCaseDropTarget)
{
std::vector<RimWellLogTrack*> wellLogPlotTracks = RiuTypedPdmObjects<RimWellLogTrack>::typedObjectsFromGroup(draggedObjects);
if (wellLogPlotTracks.size() > 0)
std::vector<RimSummaryCase*> summaryCases = RiuTypedPdmObjects<RimSummaryCase>::typedObjectsFromGroup(draggedObjects);
if (action != Qt::MoveAction || summaryCases.size() == 0) return false;
for (RimSummaryCase* summaryCase : summaryCases)
{
if (action == Qt::MoveAction)
RimSummaryCaseCollection* summaryCaseCollection;
summaryCase->firstAncestorOrThisOfType(summaryCaseCollection);
if (summaryCaseCollection)
{
RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(wellLogPlotTarget, wellLogPlotTracks, NULL);
return true;
summaryCaseCollection->removeCase(summaryCase);
summaryCaseDropTarget->addCase(summaryCase);
summaryCaseCollection->updateConnectedEditors();
continue;
}
RimSummaryCaseMainCollection* summaryCaseMainCollection;
summaryCase->firstAncestorOrThisOfType(summaryCaseMainCollection);
if (summaryCaseMainCollection)
{
summaryCaseMainCollection->removeCase(summaryCase);
summaryCaseDropTarget->addCase(summaryCase);
summaryCaseMainCollection->updateConnectedEditors();
}
}
summaryCaseDropTarget->updateConnectedEditors();
return true;
}
return false;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuDragDrop::handleSummaryCaseMainCollectionDrop(Qt::DropAction action, caf::PdmObjectGroup& draggedObjects, RimSummaryCaseMainCollection* summaryCaseDropTarget)
{
std::vector<RimSummaryCase*> summaryCases = RiuTypedPdmObjects<RimSummaryCase>::typedObjectsFromGroup(draggedObjects);
if (action != Qt::MoveAction || summaryCases.size() == 0 ) return false;
for (RimSummaryCase* summaryCase : summaryCases)
{
RimSummaryCaseCollection* summaryCaseCollection;
summaryCase->firstAncestorOrThisOfType(summaryCaseCollection);
if (summaryCaseCollection)
{
summaryCaseCollection->removeCase(summaryCase);
summaryCaseDropTarget->addCase(summaryCase);
summaryCaseCollection->updateConnectedEditors();
continue;
}
}
summaryCaseDropTarget->updateConnectedEditors();
return true;
}
//--------------------------------------------------------------------------------------------------

View File

@ -31,6 +31,8 @@ namespace caf
}
class RimIdenticalGridCaseGroup;
class RimSummaryCaseCollection;
class RimSummaryCaseMainCollection;
class RimWellLogPlot;
class RimWellLogTrack;
class RimWellLogCurve;
@ -60,6 +62,8 @@ private:
bool handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogTrack* wellLogPlotTrack);
bool handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlot* wellLogPlot);
bool handleWellLogPlotCurveDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogCurve* wellLogPlotCurve);
bool handleSummaryCaseCollectionDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimSummaryCaseCollection* summaryCaseCollection);
bool handleSummaryCaseMainCollectionDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimSummaryCaseMainCollection* summaryCaseMainCollection);
static void objectGroupFromModelIndexes(caf::PdmObjectGroup* objectGroup, const QModelIndexList &indexes);
static std::vector<caf::PdmPointer<caf::PdmObjectHandle> > objectHandlesFromSelection();