mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#372) First step in Reimplemented drag and drop support
This commit is contained in:
parent
eadf1ca300
commit
302f46b61b
@ -75,6 +75,8 @@ set( USER_INTERFACE_FILES
|
||||
UserInterface/RiuCadNavigation.cpp
|
||||
UserInterface/RiuRmsNavigation.cpp
|
||||
UserInterface/RiuGeoQuestNavigation.cpp
|
||||
UserInterface/RiuDragDrop.cpp
|
||||
UserInterface/RiuDragDrop.h
|
||||
)
|
||||
|
||||
set( SOCKET_INTERFACE_FILES
|
||||
|
@ -76,9 +76,6 @@ bool RicPasteEclipseCasesFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteEclipseCasesFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
CVF_ASSERT(proj);
|
||||
|
||||
PdmObjectHandle* destinationObject = dynamic_cast<PdmObjectHandle*>(SelectionManager::instance()->selectedItem());
|
||||
|
||||
RimIdenticalGridCaseGroup* gridCaseGroup = RicPasteFeatureImpl::findGridCaseGroup(destinationObject);
|
||||
@ -89,96 +86,9 @@ void RicPasteEclipseCasesFeature::onActionTriggered(bool isChecked)
|
||||
|
||||
if (objectGroup.objects.size() == 0) return;
|
||||
|
||||
{
|
||||
std::vector<caf::PdmPointer<RimEclipseResultCase> > typedObjects;
|
||||
objectGroup.createCopyByType(&typedObjects, PdmDefaultObjectFactory::instance());
|
||||
|
||||
if (typedObjects.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RimEclipseResultCase* mainResultCase = NULL;
|
||||
std::vector< std::vector<int> > mainCaseGridDimensions;
|
||||
|
||||
// Read out main grid and main grid dimensions if present in case group
|
||||
if (gridCaseGroup->mainCase())
|
||||
{
|
||||
mainResultCase = dynamic_cast<RimEclipseResultCase*>(gridCaseGroup->mainCase());
|
||||
CVF_ASSERT(mainResultCase);
|
||||
|
||||
mainResultCase->readGridDimensions(mainCaseGridDimensions);
|
||||
}
|
||||
|
||||
std::vector<RimEclipseResultCase*> insertedCases;
|
||||
|
||||
// Add cases to case group
|
||||
for (size_t i = 0; i < typedObjects.size(); i++)
|
||||
{
|
||||
RimEclipseResultCase* rimResultReservoir = typedObjects[i];
|
||||
|
||||
proj->assignCaseIdToCase(rimResultReservoir);
|
||||
|
||||
if (gridCaseGroup->contains(rimResultReservoir))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
insertedCases.push_back(rimResultReservoir);
|
||||
}
|
||||
|
||||
// Initialize the new objects
|
||||
for (size_t i = 0; i < insertedCases.size(); i++)
|
||||
{
|
||||
RimEclipseResultCase* rimResultReservoir = insertedCases[i];
|
||||
caf::PdmDocument::initAfterReadTraversal(rimResultReservoir);
|
||||
}
|
||||
|
||||
// Load stuff
|
||||
for (size_t i = 0; i < insertedCases.size(); i++)
|
||||
{
|
||||
RimEclipseResultCase* rimResultReservoir = insertedCases[i];
|
||||
|
||||
|
||||
if (!mainResultCase)
|
||||
{
|
||||
rimResultReservoir->openEclipseGridFile();
|
||||
rimResultReservoir->readGridDimensions(mainCaseGridDimensions);
|
||||
|
||||
mainResultCase = rimResultReservoir;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector< std::vector<int> > caseGridDimensions;
|
||||
rimResultReservoir->readGridDimensions(caseGridDimensions);
|
||||
|
||||
bool identicalGrid = RigGridManager::isGridDimensionsEqual(mainCaseGridDimensions, caseGridDimensions);
|
||||
if (!identicalGrid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rimResultReservoir->openAndReadActiveCellData(mainResultCase->reservoirData()))
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
RimOilField* activeOilField = proj ? proj->activeOilField() : NULL;
|
||||
RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL;
|
||||
if (analysisModels) analysisModels->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir);
|
||||
|
||||
caf::PdmDocument::updateUiIconStateRecursively(rimResultReservoir);
|
||||
|
||||
gridCaseGroup->updateConnectedEditors();
|
||||
|
||||
for (size_t rvIdx = 0; rvIdx < rimResultReservoir->reservoirViews.size(); rvIdx++)
|
||||
{
|
||||
RimEclipseView* riv = rimResultReservoir->reservoirViews()[rvIdx];
|
||||
riv->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
addCasesToGridCaseGroup(objectGroup, gridCaseGroup);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -189,5 +99,103 @@ void RicPasteEclipseCasesFeature::setupActionLook(QAction* actionToSetup)
|
||||
actionToSetup->setText("Paste (Eclipse Cases)");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup)
|
||||
{
|
||||
RimProject* proj = RiaApplication::instance()->project();
|
||||
CVF_ASSERT(proj);
|
||||
|
||||
std::vector<caf::PdmPointer<RimEclipseResultCase> > typedObjects;
|
||||
objectGroup.createCopyByType(&typedObjects, PdmDefaultObjectFactory::instance());
|
||||
|
||||
if (typedObjects.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RimEclipseResultCase* mainResultCase = NULL;
|
||||
std::vector< std::vector<int> > mainCaseGridDimensions;
|
||||
|
||||
// Read out main grid and main grid dimensions if present in case group
|
||||
if (gridCaseGroup->mainCase())
|
||||
{
|
||||
mainResultCase = dynamic_cast<RimEclipseResultCase*>(gridCaseGroup->mainCase());
|
||||
CVF_ASSERT(mainResultCase);
|
||||
|
||||
mainResultCase->readGridDimensions(mainCaseGridDimensions);
|
||||
}
|
||||
|
||||
std::vector<RimEclipseResultCase*> insertedCases;
|
||||
|
||||
// Add cases to case group
|
||||
for (size_t i = 0; i < typedObjects.size(); i++)
|
||||
{
|
||||
RimEclipseResultCase* rimResultReservoir = typedObjects[i];
|
||||
|
||||
proj->assignCaseIdToCase(rimResultReservoir);
|
||||
|
||||
if (gridCaseGroup->contains(rimResultReservoir))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
insertedCases.push_back(rimResultReservoir);
|
||||
}
|
||||
|
||||
// Initialize the new objects
|
||||
for (size_t i = 0; i < insertedCases.size(); i++)
|
||||
{
|
||||
RimEclipseResultCase* rimResultReservoir = insertedCases[i];
|
||||
caf::PdmDocument::initAfterReadTraversal(rimResultReservoir);
|
||||
}
|
||||
|
||||
// Load stuff
|
||||
for (size_t i = 0; i < insertedCases.size(); i++)
|
||||
{
|
||||
RimEclipseResultCase* rimResultReservoir = insertedCases[i];
|
||||
|
||||
|
||||
if (!mainResultCase)
|
||||
{
|
||||
rimResultReservoir->openEclipseGridFile();
|
||||
rimResultReservoir->readGridDimensions(mainCaseGridDimensions);
|
||||
|
||||
mainResultCase = rimResultReservoir;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector< std::vector<int> > caseGridDimensions;
|
||||
rimResultReservoir->readGridDimensions(caseGridDimensions);
|
||||
|
||||
bool identicalGrid = RigGridManager::isGridDimensionsEqual(mainCaseGridDimensions, caseGridDimensions);
|
||||
if (!identicalGrid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rimResultReservoir->openAndReadActiveCellData(mainResultCase->reservoirData()))
|
||||
{
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
}
|
||||
|
||||
RimOilField* activeOilField = proj ? proj->activeOilField() : NULL;
|
||||
RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL;
|
||||
if (analysisModels) analysisModels->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir);
|
||||
|
||||
caf::PdmDocument::updateUiIconStateRecursively(rimResultReservoir);
|
||||
|
||||
gridCaseGroup->updateConnectedEditors();
|
||||
|
||||
for (size_t rvIdx = 0; rvIdx < rimResultReservoir->reservoirViews.size(); rvIdx++)
|
||||
{
|
||||
RimEclipseView* riv = rimResultReservoir->reservoirViews()[rvIdx];
|
||||
riv->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
@ -22,8 +22,12 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
|
||||
class RimIdenticalGridCaseGroup;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmObjectGroup;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -32,12 +36,14 @@ class RicPasteEclipseCasesFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void addCasesToGridCaseGroup(PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered(bool isChecked);
|
||||
virtual void setupActionLook(QAction* actionToSetup);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
176
ApplicationCode/UserInterface/RiuDragDrop.cpp
Normal file
176
ApplicationCode/UserInterface/RiuDragDrop.cpp
Normal file
@ -0,0 +1,176 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RiuDragDrop.h"
|
||||
|
||||
#include "cafPdmObjectGroup.h"
|
||||
#include "cafPdmUiTreeView.h"
|
||||
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimCaseCollection.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimMimeData.h"
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "OperationsUsingObjReferences/RicPasteEclipseCasesFeature.h"
|
||||
#include <QAbstractItemModel>
|
||||
#include <QModelIndex>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuDragDrop::RiuDragDrop()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuDragDrop::~RiuDragDrop()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Qt::DropActions RiuDragDrop::supportedDropActions() const
|
||||
{
|
||||
return Qt::CopyAction | Qt::MoveAction;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
|
||||
{
|
||||
if (index.isValid())
|
||||
{
|
||||
caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView();
|
||||
caf::PdmUiItem* uiItem = uiTreeView->uiItemFromModelIndex(index);
|
||||
|
||||
if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem) ||
|
||||
dynamic_cast<RimCaseCollection*>(uiItem))
|
||||
{
|
||||
return Qt::ItemIsDropEnabled;
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseCase*>(uiItem))
|
||||
{
|
||||
// TODO: Remember to handle reservoir holding the main grid
|
||||
return Qt::ItemIsDragEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags itemflags;
|
||||
return itemflags;
|
||||
/*
|
||||
Qt::ItemFlags defaultFlags = caf::UiTreeModelPdm::flags(index);
|
||||
if (index.isValid())
|
||||
{
|
||||
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(index);
|
||||
CVF_ASSERT(currentItem);
|
||||
|
||||
if (dynamic_cast<RimIdenticalGridCaseGroup*>(currentItem->dataObject().p()) ||
|
||||
dynamic_cast<RimCaseCollection*>(currentItem->dataObject().p()))
|
||||
{
|
||||
return Qt::ItemIsDropEnabled | defaultFlags;
|
||||
}
|
||||
else if (dynamic_cast<RimEclipseCase*>(currentItem->dataObject().p()))
|
||||
{
|
||||
// TODO: Remember to handle reservoir holding the main grid
|
||||
return Qt::ItemIsDragEnabled | defaultFlags;
|
||||
}
|
||||
}
|
||||
|
||||
return itemFlags;
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuDragDrop::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
caf::PdmUiTreeView* uiTreeView = RiuMainWindow::instance()->projectTreeView();
|
||||
RimIdenticalGridCaseGroup* gridCaseGroup = NULL;
|
||||
|
||||
{
|
||||
caf::PdmUiItem* dropTarget = uiTreeView->uiItemFromModelIndex(parent);
|
||||
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(dropTarget);
|
||||
if (objHandle)
|
||||
{
|
||||
objHandle->firstAnchestorOrThisOfType(gridCaseGroup);
|
||||
}
|
||||
}
|
||||
|
||||
if (!gridCaseGroup) return false;
|
||||
|
||||
const MimeDataWithIndexes* myMimeData = qobject_cast<const MimeDataWithIndexes*>(data);
|
||||
if (myMimeData && parent.isValid())
|
||||
{
|
||||
caf::PdmObjectGroup pog;
|
||||
|
||||
for (int i = 0; i < myMimeData->indexes().size(); i++)
|
||||
{
|
||||
QModelIndex mi = myMimeData->indexes().at(i);
|
||||
caf::PdmUiItem* currentItem = uiTreeView->uiItemFromModelIndex(mi);
|
||||
caf::PdmObjectHandle* pdmObj = dynamic_cast<caf::PdmObjectHandle*>(currentItem);
|
||||
|
||||
if (pdmObj)
|
||||
{
|
||||
pog.objects.push_back(pdmObj);
|
||||
}
|
||||
}
|
||||
|
||||
if (action == Qt::CopyAction)
|
||||
{
|
||||
caf::RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(pog, gridCaseGroup);
|
||||
|
||||
//addObjects(parent, pog);
|
||||
}
|
||||
else if (action == Qt::MoveAction)
|
||||
{
|
||||
assert(false);
|
||||
//moveObjects(parent, pog);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QMimeData* RiuDragDrop::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
MimeDataWithIndexes* myObj = new MimeDataWithIndexes();
|
||||
myObj->setIndexes(indexes);
|
||||
return myObj;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList RiuDragDrop::mimeTypes() const
|
||||
{
|
||||
QStringList types;
|
||||
types << MimeDataWithIndexes::formatName();
|
||||
return types;
|
||||
}
|
40
ApplicationCode/UserInterface/RiuDragDrop.h
Normal file
40
ApplicationCode/UserInterface/RiuDragDrop.h
Normal file
@ -0,0 +1,40 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2015- Statoil ASA
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmUiDragDropHandle.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class RiuDragDrop : public caf::PdmUiDragDropHandle
|
||||
{
|
||||
public:
|
||||
RiuDragDrop();
|
||||
virtual ~RiuDragDrop();
|
||||
|
||||
virtual Qt::DropActions supportedDropActions() const;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
||||
virtual QMimeData* mimeData(const QModelIndexList &indexes) const;
|
||||
virtual QStringList mimeTypes() const;
|
||||
};
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "RiuResultInfoPanel.h"
|
||||
#include "RiuViewer.h"
|
||||
#include "RiuWellImportWizard.h"
|
||||
#include "RiuDragDrop.h"
|
||||
|
||||
#include "cafAboutDialog.h"
|
||||
#include "cafAnimationToolBar.h"
|
||||
@ -128,6 +129,8 @@ RiuMainWindow::RiuMainWindow()
|
||||
slotRefreshFileActions();
|
||||
slotRefreshEditActions();
|
||||
|
||||
m_dragDrop = new RiuDragDrop;
|
||||
|
||||
// Set pdm root so scripts are displayed
|
||||
setPdmRoot(RiaApplication::instance()->project());
|
||||
|
||||
@ -188,9 +191,9 @@ void RiuMainWindow::closeEvent(QCloseEvent* event)
|
||||
return;
|
||||
}
|
||||
|
||||
delete m_dragDrop;
|
||||
|
||||
saveWinGeoAndDockToolBarLayout();
|
||||
|
||||
|
||||
|
||||
event->accept();
|
||||
}
|
||||
@ -568,10 +571,10 @@ void RiuMainWindow::createDockPanels()
|
||||
m_projectTreeView->treeView()->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
// TODO :Drag and drop configuration
|
||||
// m_projectTreeView->treeView()->setDragEnabled(true);
|
||||
// m_projectTreeView->treeView()->viewport()->setAcceptDrops(true);
|
||||
// m_projectTreeView->treeView()->setDropIndicatorShown(true);
|
||||
// m_projectTreeView->treeView()->setDragDropMode(QAbstractItemView::DragDrop);
|
||||
m_projectTreeView->treeView()->setDragEnabled(true);
|
||||
m_projectTreeView->treeView()->viewport()->setAcceptDrops(true);
|
||||
m_projectTreeView->treeView()->setDropIndicatorShown(true);
|
||||
m_projectTreeView->treeView()->setDragDropMode(QAbstractItemView::DragDrop);
|
||||
|
||||
addDockWidget(Qt::RightDockWidgetArea, dockWidget);
|
||||
|
||||
@ -1298,6 +1301,8 @@ void RiuMainWindow::setPdmRoot(caf::PdmObject* pdmRoot)
|
||||
|
||||
m_projectTreeView->treeView()->expandAll();
|
||||
|
||||
m_projectTreeView->setDragDropHandle(m_dragDrop);
|
||||
|
||||
caf::SelectionManager::instance()->setPdmRootObject(pdmRoot);
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ namespace caf
|
||||
class UiPropertyCreatorPdm;
|
||||
class UiTreeModelPdm;
|
||||
class PdmUiItem;
|
||||
class PdmUiDragDropHandle;
|
||||
}
|
||||
|
||||
namespace ssihub
|
||||
@ -295,7 +296,11 @@ private:
|
||||
RimUiTreeView* m_OBSOLETE_treeView;
|
||||
RimUiTreeModelPdm* m_OBSOLETE_treeModelPdm;
|
||||
|
||||
|
||||
caf::PdmUiTreeView* m_projectTreeView;
|
||||
|
||||
caf::PdmUiDragDropHandle* m_dragDrop;
|
||||
|
||||
QUndoView* m_undoView;
|
||||
|
||||
caf::PdmObject* m_pdmRoot;
|
||||
|
@ -62,6 +62,7 @@ set( PROJECT_FILES
|
||||
cafPdmUiComboBoxEditor.h
|
||||
cafPdmUiDoubleSliderEditor.cpp
|
||||
cafPdmUiDoubleSliderEditor.h
|
||||
cafPdmUiDragDropHandle.h
|
||||
cafPdmUiFilePathEditor.cpp
|
||||
cafPdmUiFilePathEditor.h
|
||||
cafPdmUiLineEditor.cpp
|
||||
|
64
Fwk/AppFwk/cafUserInterface/cafPdmUiDragDropHandle.h
Normal file
64
Fwk/AppFwk/cafUserInterface/cafPdmUiDragDropHandle.h
Normal file
@ -0,0 +1,64 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) 2015- Ceetron Solutions AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||
// for more details.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QModelIndexList>
|
||||
|
||||
class QMimeData;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
class PdmUiDragDropHandle
|
||||
{
|
||||
public:
|
||||
virtual ~PdmUiDragDropHandle() = 0;
|
||||
|
||||
virtual Qt::DropActions supportedDropActions() const = 0;
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const = 0;
|
||||
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) = 0;
|
||||
virtual QMimeData* mimeData(const QModelIndexList &indexes) const = 0;
|
||||
virtual QStringList mimeTypes() const = 0;
|
||||
};
|
||||
|
||||
inline PdmUiDragDropHandle::~PdmUiDragDropHandle() { }
|
||||
|
||||
} // end namespace caf
|
@ -171,5 +171,13 @@ QModelIndex PdmUiTreeView::findModelIndex(const PdmUiItem* object) const
|
||||
return m_treeViewEditor->findModelIndex(object);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTreeView::setDragDropHandle(PdmUiDragDropHandle* dragDropHandle)
|
||||
{
|
||||
m_treeViewEditor->setDragDropHandle(dragDropHandle);
|
||||
}
|
||||
|
||||
} //End of namespace caf
|
||||
|
||||
|
@ -50,6 +50,7 @@ namespace caf
|
||||
|
||||
class PdmUiItem;
|
||||
class PdmUiTreeViewEditor;
|
||||
class PdmUiDragDropHandle;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -77,6 +78,8 @@ public:
|
||||
PdmUiItem* uiItemFromModelIndex(const QModelIndex& index) const;
|
||||
QModelIndex findModelIndex(const PdmUiItem* object) const;
|
||||
|
||||
void setDragDropHandle(PdmUiDragDropHandle* dragDropHandle);
|
||||
|
||||
|
||||
signals:
|
||||
void selectionChanged();
|
||||
|
@ -290,5 +290,13 @@ QModelIndex PdmUiTreeViewEditor::findModelIndex(const PdmUiItem* object) const
|
||||
return m_treeViewModel->findModelIndex(object);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTreeViewEditor::setDragDropHandle(PdmUiDragDropHandle* dragDropHandle)
|
||||
{
|
||||
m_treeViewModel->setDragDropHandle(dragDropHandle);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
@ -59,6 +59,7 @@ namespace caf
|
||||
class PdmUiItem;
|
||||
class PdmUiTreeViewModel;
|
||||
class PdmChildArrayFieldHandle;
|
||||
class PdmUiDragDropHandle;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
@ -96,6 +97,8 @@ public:
|
||||
|
||||
QWidget* createWidget(QWidget* parent);
|
||||
|
||||
void setDragDropHandle(PdmUiDragDropHandle* dragDropHandle);
|
||||
|
||||
signals:
|
||||
void selectionChanged();
|
||||
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmUiDragDropHandle.h"
|
||||
#include "cafPdmUiTreeItemEditor.h"
|
||||
#include "cafPdmUiTreeOrdering.h"
|
||||
#include "cafPdmUiTreeViewEditor.h"
|
||||
@ -54,6 +55,8 @@ namespace caf
|
||||
PdmUiTreeViewModel::PdmUiTreeViewModel(PdmUiTreeViewEditor* treeViewEditor)
|
||||
{
|
||||
m_treeOrderingRoot = NULL;
|
||||
m_dragDropHandle = NULL;
|
||||
|
||||
m_treeViewEditor = treeViewEditor;
|
||||
}
|
||||
|
||||
@ -658,6 +661,12 @@ Qt::ItemFlags PdmUiTreeViewModel::flags(const QModelIndex &index) const
|
||||
}
|
||||
}
|
||||
|
||||
if (m_dragDropHandle)
|
||||
{
|
||||
Qt::ItemFlags dragDropFlags = m_dragDropHandle->flags(index);
|
||||
flagMask |= dragDropFlags;
|
||||
}
|
||||
|
||||
return flagMask;
|
||||
}
|
||||
|
||||
@ -692,5 +701,73 @@ PdmUiItem* PdmUiTreeViewModel::uiItemFromModelIndex(const QModelIndex& index) co
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiTreeViewModel::setDragDropHandle(PdmUiDragDropHandle* dragDropHandle)
|
||||
{
|
||||
m_dragDropHandle = dragDropHandle;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList PdmUiTreeViewModel::mimeTypes() const
|
||||
{
|
||||
if (m_dragDropHandle)
|
||||
{
|
||||
return m_dragDropHandle->mimeTypes();
|
||||
}
|
||||
else
|
||||
{
|
||||
return QAbstractItemModel::mimeTypes();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QMimeData * PdmUiTreeViewModel::mimeData(const QModelIndexList &indexes) const
|
||||
{
|
||||
if (m_dragDropHandle)
|
||||
{
|
||||
return m_dragDropHandle->mimeData(indexes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QAbstractItemModel::mimeData(indexes);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool PdmUiTreeViewModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
if (m_dragDropHandle)
|
||||
{
|
||||
return m_dragDropHandle->dropMimeData(data, action, row, column, parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
return QAbstractItemModel::dropMimeData(data, action, row, column, parent);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Qt::DropActions PdmUiTreeViewModel::supportedDropActions() const
|
||||
{
|
||||
if (m_dragDropHandle)
|
||||
{
|
||||
return m_dragDropHandle->supportedDropActions();
|
||||
}
|
||||
else
|
||||
{
|
||||
return QAbstractItemModel::supportedDropActions();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end namespace caf
|
||||
|
@ -49,6 +49,7 @@ class PdmObjectHandle;
|
||||
class PdmUiItem;
|
||||
class PdmUiTreeViewEditor;
|
||||
class PdmUiTreeOrdering;
|
||||
class PdmUiDragDropHandle;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@ -73,6 +74,8 @@ public:
|
||||
PdmUiItem* uiItemFromModelIndex(const QModelIndex& index) const;
|
||||
QModelIndex findModelIndex(const PdmUiItem* object) const;
|
||||
|
||||
void setDragDropHandle(PdmUiDragDropHandle* dragDropHandle);
|
||||
|
||||
private:
|
||||
void updateSubTreeRecursive(const QModelIndex& uiSubTreeRootModelIdx, PdmUiTreeOrdering* uiModelSubTreeRoot, PdmUiTreeOrdering* updatedPdmSubTreeRoot);
|
||||
|
||||
@ -90,6 +93,8 @@ private:
|
||||
|
||||
PdmUiTreeViewEditor* m_treeViewEditor;
|
||||
|
||||
PdmUiDragDropHandle* m_dragDropHandle;
|
||||
|
||||
private:
|
||||
|
||||
// Overrides from QAbstractItemModel
|
||||
@ -105,6 +110,11 @@ private:
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
|
||||
|
||||
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
|
||||
virtual QStringList mimeTypes() const;
|
||||
virtual QMimeData* mimeData(const QModelIndexList &indexes) const;
|
||||
virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
|
||||
virtual Qt::DropActions supportedDropActions() const;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user