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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user