mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#467) Implemented drag & drop for moving tracks between plots
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include "RimWellLogFileChannel.h"
|
||||
#include "RimWellLogPlotTrack.h"
|
||||
#include "RimWellLogPlotCurve.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
|
||||
#include "RimWellLogPlotTrack.h"
|
||||
#include "RiuMainWindow.h"
|
||||
@@ -69,6 +70,8 @@ Qt::DropActions RiuDragDrop::supportedDropActions() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags itemflags = 0;
|
||||
|
||||
if (index.isValid())
|
||||
{
|
||||
caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView();
|
||||
@@ -76,20 +79,22 @@ Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
|
||||
|
||||
if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem) ||
|
||||
dynamic_cast<RimCaseCollection*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlot*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlotTrack*>(uiItem))
|
||||
{
|
||||
return Qt::ItemIsDropEnabled;
|
||||
itemflags |= Qt::ItemIsDropEnabled;
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseCase*>(uiItem) ||
|
||||
|
||||
if (dynamic_cast<RimEclipseCase*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlotCurve*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogPlotTrack*>(uiItem) ||
|
||||
dynamic_cast<RimWellLogFileChannel*>(uiItem))
|
||||
{
|
||||
// TODO: Remember to handle reservoir holding the main grid
|
||||
return Qt::ItemIsDragEnabled;
|
||||
itemflags |= Qt::ItemIsDragEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags itemflags;
|
||||
return itemflags;
|
||||
}
|
||||
|
||||
@@ -137,6 +142,13 @@ bool RiuDragDrop::dropMimeData(const QMimeData *data, Qt::DropAction action, int
|
||||
{
|
||||
return handleWellLogPlotTrackDrop(action, objectGroup, wellLogPlotTrack);
|
||||
}
|
||||
|
||||
RimWellLogPlot* wellLogPlot;
|
||||
objHandle->firstAnchestorOrThisOfType(wellLogPlot);
|
||||
if (wellLogPlot)
|
||||
{
|
||||
return handleWellLogPlotDrop(action, objectGroup, wellLogPlot);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -252,7 +264,34 @@ bool RiuDragDrop::handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObje
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuDragDrop::handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlot* wellLogPlot)
|
||||
{
|
||||
std::vector<caf::PdmPointer<RimWellLogPlotTrack> > typedObjects;
|
||||
objectGroup.objectsByType(&typedObjects);
|
||||
if (typedObjects.size() > 0)
|
||||
{
|
||||
std::vector<RimWellLogPlotTrack*> wellLogPlotTracks;
|
||||
for (size_t cIdx = 0; cIdx < typedObjects.size(); cIdx++)
|
||||
{
|
||||
wellLogPlotTracks.push_back(typedObjects[cIdx]);
|
||||
}
|
||||
|
||||
if (wellLogPlotTracks.size() > 0)
|
||||
{
|
||||
if (action == Qt::CopyAction)
|
||||
{
|
||||
RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(wellLogPlot, wellLogPlotTracks);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
class RimIdenticalGridCaseGroup;
|
||||
class RimWellLogPlotTrack;
|
||||
class RimWellLogPlot;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
@@ -48,5 +49,6 @@ private:
|
||||
void moveCasesToGridGroup(caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
|
||||
bool handleGridCaseGroupDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
|
||||
bool handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlotTrack* wellLogPlotTrack);
|
||||
bool handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGroup& objectGroup, RimWellLogPlot* wellLogPlot);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user