System : Renamed classes and function names relaed to drag and drop

This commit is contained in:
Magne Sjaastad 2015-10-23 11:03:23 +02:00
parent d2b5d7ae92
commit 5a1e244b2a
12 changed files with 99 additions and 100 deletions

View File

@ -105,7 +105,7 @@ private:
//--------------------------------------------------------------------------------------------------
RiuDragDrop::RiuDragDrop()
{
m_proposedAction = Qt::MoveAction;
m_proposedDropAction = Qt::MoveAction;
}
//--------------------------------------------------------------------------------------------------
@ -163,7 +163,7 @@ Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
itemflags |= Qt::ItemIsDropEnabled;
}
}
else if (m_proposedAction == Qt::MoveAction)
else if (m_proposedDropAction == Qt::MoveAction)
{
if (dynamic_cast<RimWellLogPlot*>(uiItem))
{
@ -191,7 +191,7 @@ Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const
}
}
}
else if (m_proposedAction == Qt::CopyAction)
else if (m_proposedDropAction == Qt::CopyAction)
{
if (dynamic_cast<RimWellLogPlotTrack*>(uiItem))
{
@ -290,7 +290,7 @@ QStringList RiuDragDrop::mimeTypes() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuDragDrop::endDrag()
void RiuDragDrop::onDragCanceled()
{
m_dragItems.clear();
}
@ -449,7 +449,7 @@ std::vector<caf::PdmPointer<caf::PdmObjectHandle> > RiuDragDrop::objectHandlesFr
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuDragDrop::setProposedAction(Qt::DropAction action)
void RiuDragDrop::onProposedDropActionUpdated(Qt::DropAction action)
{
m_proposedAction = action;
m_proposedDropAction = action;
}

View File

@ -19,7 +19,7 @@
#pragma once
#include "cafPdmUiDragDropHandle.h"
#include "cafPdmUiDragDropInterface.h"
#include "cafPdmPointer.h"
#include "cafPdmObjectGroup.h"
@ -38,19 +38,21 @@ class RimWellLogPlotCurve;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RiuDragDrop : public caf::PdmUiDragDropHandle
class RiuDragDrop : public caf::PdmUiDragDropInterface
{
public:
RiuDragDrop();
virtual ~RiuDragDrop();
protected:
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;
virtual void endDrag();
virtual void setProposedAction(Qt::DropAction action);
virtual void onDragCanceled();
virtual void onProposedDropActionUpdated(Qt::DropAction action);
private:
void moveCasesToGridGroup(caf::PdmObjectGroup& objectGroup, RimIdenticalGridCaseGroup* gridCaseGroup);
@ -64,6 +66,6 @@ private:
private:
mutable std::vector<caf::PdmPointer<caf::PdmObjectHandle> > m_dragItems;
Qt::DropAction m_proposedAction;
Qt::DropAction m_proposedDropAction;
};

View File

@ -138,7 +138,7 @@ RiuMainWindow::RiuMainWindow()
sm_mainWindowInstance = this;
m_dragDrop = new RiuDragDrop;
m_dragDropInterface = new RiuDragDrop;
initializeGuiNewProjectLoaded();
@ -209,7 +209,7 @@ void RiuMainWindow::closeEvent(QCloseEvent* event)
return;
}
delete m_dragDrop;
delete m_dragDropInterface;
saveWinGeoAndDockToolBarLayout();
@ -1319,7 +1319,7 @@ void RiuMainWindow::setPdmRoot(caf::PdmObject* pdmRoot)
m_projectTreeView->setPdmItem(pdmRoot);
// For debug only : m_projectTreeView->treeView()->expandAll();
m_projectTreeView->setDragDropHandle(m_dragDrop);
m_projectTreeView->setDragDropInterface(m_dragDropInterface);
for (size_t i = 0; i < additionalProjectViews.size(); i++)
{

View File

@ -55,7 +55,7 @@ namespace caf
class UiPropertyCreatorPdm;
class UiTreeModelPdm;
class PdmUiItem;
class PdmUiDragDropHandle;
class PdmUiDragDropInterface;
}
namespace ssihub
@ -289,7 +289,7 @@ public:
private:
caf::PdmUiTreeView* m_projectTreeView;
caf::PdmUiDragDropHandle* m_dragDrop;
caf::PdmUiDragDropInterface* m_dragDropInterface;
QUndoView* m_undoView;

View File

@ -62,7 +62,7 @@ set( PROJECT_FILES
cafPdmUiComboBoxEditor.h
cafPdmUiDoubleSliderEditor.cpp
cafPdmUiDoubleSliderEditor.h
cafPdmUiDragDropHandle.h
cafPdmUiDragDropInterface.h
cafPdmUiFilePathEditor.cpp
cafPdmUiFilePathEditor.h
cafPdmUiLineEditor.cpp

View File

@ -47,20 +47,28 @@ namespace caf
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmUiDragDropHandle
class PdmUiDragDropInterface
{
public:
virtual ~PdmUiDragDropHandle() = 0;
virtual ~PdmUiDragDropInterface() = 0;
protected:
friend class PdmUiTreeViewModel;
friend class PdmUiTreeViewWidget;
// Forwarding from Qt functions in QAbstractItemModel
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;
virtual void endDrag() = 0;
virtual void setProposedAction(Qt::DropAction action) = 0;
// Forwarding of tree view events
virtual void onDragCanceled() = 0;
virtual void onProposedDropActionUpdated(Qt::DropAction action) = 0;
};
inline PdmUiDragDropHandle::~PdmUiDragDropHandle() { }
inline PdmUiDragDropInterface::~PdmUiDragDropInterface() { }
} // end namespace caf

View File

@ -190,9 +190,9 @@ QModelIndex PdmUiTreeView::findModelIndex(const PdmUiItem* object) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeView::setDragDropHandle(PdmUiDragDropHandle* dragDropHandle)
void PdmUiTreeView::setDragDropInterface(PdmUiDragDropInterface* dragDropInterface)
{
m_treeViewEditor->setDragDropHandle(dragDropHandle);
m_treeViewEditor->setDragDropInterface(dragDropInterface);
}
//--------------------------------------------------------------------------------------------------

View File

@ -50,7 +50,7 @@ namespace caf
class PdmUiItem;
class PdmUiTreeViewEditor;
class PdmUiDragDropHandle;
class PdmUiDragDropInterface;
class PdmObjectHandle;
//==================================================================================================
@ -83,7 +83,7 @@ public:
PdmUiItem* uiItemFromModelIndex(const QModelIndex& index) const;
QModelIndex findModelIndex(const PdmUiItem* object) const;
void setDragDropHandle(PdmUiDragDropHandle* dragDropHandle);
void setDragDropInterface(PdmUiDragDropInterface* dragDropInterface);
signals:
void selectionChanged();

View File

@ -39,23 +39,59 @@
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmUiEditorHandle.h"
#include "cafPdmUiCommandSystemProxy.h"
#include "cafPdmUiDragDropInterface.h"
#include "cafPdmUiEditorHandle.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeViewModel.h"
#include "cafSelectionManager.h"
#include <QDragMoveEvent>
#include <QEvent>
#include <QGridLayout>
#include <QMenu>
#include <QModelIndexList>
#include <QSortFilterProxyModel>
#include <QTreeView>
#include <QWidget>
#include <QEvent>
namespace caf
{
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmUiTreeViewWidget : public QTreeView
{
public:
PdmUiTreeViewWidget(QWidget* parent = 0) : QTreeView(parent) {};
virtual ~PdmUiTreeViewWidget() {};
protected:
virtual void dragMoveEvent(QDragMoveEvent* event)
{
caf::PdmUiTreeViewModel* treeViewModel = dynamic_cast<caf::PdmUiTreeViewModel*>(model());
if (treeViewModel && treeViewModel->dragDropInterface())
{
treeViewModel->dragDropInterface()->onProposedDropActionUpdated(event->proposedAction());
}
QTreeView::dragMoveEvent(event);
}
virtual void dragLeaveEvent(QDragLeaveEvent* event)
{
caf::PdmUiTreeViewModel* treeViewModel = dynamic_cast<caf::PdmUiTreeViewModel*>(model());
if (treeViewModel && treeViewModel->dragDropInterface())
{
treeViewModel->dragDropInterface()->onDragCanceled();
}
QTreeView::dragLeaveEvent(event);
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -291,9 +327,9 @@ QModelIndex PdmUiTreeViewEditor::findModelIndex(const PdmUiItem* object) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewEditor::setDragDropHandle(PdmUiDragDropHandle* dragDropHandle)
void PdmUiTreeViewEditor::setDragDropInterface(PdmUiDragDropInterface* dragDropInterface)
{
m_treeViewModel->setDragDropHandle(dragDropHandle);
m_treeViewModel->setDragDropInterface(dragDropInterface);
}
//--------------------------------------------------------------------------------------------------

View File

@ -61,7 +61,7 @@ namespace caf
class PdmUiItem;
class PdmUiTreeViewModel;
class PdmChildArrayFieldHandle;
class PdmUiDragDropHandle;
class PdmUiDragDropInterface;
//--------------------------------------------------------------------------------------------------
///
@ -77,38 +77,6 @@ public:
QStringList columnHeaders;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class PdmUiTreeViewWidget : public QTreeView
{
public:
PdmUiTreeViewWidget(QWidget* parent = 0) : QTreeView(parent) {};
virtual ~PdmUiTreeViewWidget() {};
protected:
virtual void dragMoveEvent(QDragMoveEvent* event)
{
caf::PdmUiTreeViewModel* treeViewModel = dynamic_cast<caf::PdmUiTreeViewModel*>(model());
if (treeViewModel)
{
treeViewModel->updateDragDropHandleFromEvent(event);
}
QTreeView::dragMoveEvent(event);
}
virtual void dragLeaveEvent(QDragLeaveEvent* event)
{
caf::PdmUiTreeViewModel* treeViewModel = dynamic_cast<caf::PdmUiTreeViewModel*>(model());
if (treeViewModel)
{
treeViewModel->endDrag();
}
QTreeView::dragLeaveEvent(event);
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -136,7 +104,7 @@ public:
QWidget* createWidget(QWidget* parent);
void setDragDropHandle(PdmUiDragDropHandle* dragDropHandle);
void setDragDropInterface(PdmUiDragDropInterface* dragDropInterface);
signals:
void selectionChanged();
@ -165,7 +133,7 @@ private:
QPointer<QWidget> m_mainWidget;
QVBoxLayout* m_layout;
PdmUiTreeViewWidget* m_treeView;
QTreeView* m_treeView;
PdmUiTreeViewModel* m_treeViewModel;
PdmUiTreeViewEditorAttribute m_editorAttributes;

View File

@ -39,7 +39,7 @@
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmUiDragDropHandle.h"
#include "cafPdmUiDragDropInterface.h"
#include "cafPdmUiTreeItemEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeViewEditor.h"
@ -56,7 +56,7 @@ namespace caf
PdmUiTreeViewModel::PdmUiTreeViewModel(PdmUiTreeViewEditor* treeViewEditor)
{
m_treeOrderingRoot = NULL;
m_dragDropHandle = NULL;
m_dragDropInterface = NULL;
m_treeViewEditor = treeViewEditor;
}
@ -747,9 +747,9 @@ Qt::ItemFlags PdmUiTreeViewModel::flags(const QModelIndex &index) const
}
}
if (m_dragDropHandle)
if (m_dragDropInterface)
{
Qt::ItemFlags dragDropFlags = m_dragDropHandle->flags(index);
Qt::ItemFlags dragDropFlags = m_dragDropInterface->flags(index);
flagMask |= dragDropFlags;
}
@ -790,31 +790,17 @@ PdmUiItem* PdmUiTreeViewModel::uiItemFromModelIndex(const QModelIndex& index) co
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewModel::setDragDropHandle(PdmUiDragDropHandle* dragDropHandle)
void PdmUiTreeViewModel::setDragDropInterface(PdmUiDragDropInterface* dragDropInterface)
{
m_dragDropHandle = dragDropHandle;
m_dragDropInterface = dragDropInterface;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewModel::updateDragDropHandleFromEvent(const QDragMoveEvent* event)
PdmUiDragDropInterface* PdmUiTreeViewModel::dragDropInterface()
{
if (m_dragDropHandle && event)
{
m_dragDropHandle->setProposedAction(event->proposedAction());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeViewModel::endDrag()
{
if (m_dragDropHandle)
{
m_dragDropHandle->endDrag();
}
return m_dragDropInterface;
}
//--------------------------------------------------------------------------------------------------
@ -822,9 +808,9 @@ void PdmUiTreeViewModel::endDrag()
//--------------------------------------------------------------------------------------------------
QStringList PdmUiTreeViewModel::mimeTypes() const
{
if (m_dragDropHandle)
if (m_dragDropInterface)
{
return m_dragDropHandle->mimeTypes();
return m_dragDropInterface->mimeTypes();
}
else
{
@ -837,9 +823,9 @@ QStringList PdmUiTreeViewModel::mimeTypes() const
//--------------------------------------------------------------------------------------------------
QMimeData * PdmUiTreeViewModel::mimeData(const QModelIndexList &indexes) const
{
if (m_dragDropHandle)
if (m_dragDropInterface)
{
return m_dragDropHandle->mimeData(indexes);
return m_dragDropInterface->mimeData(indexes);
}
else
{
@ -852,9 +838,9 @@ QMimeData * PdmUiTreeViewModel::mimeData(const QModelIndexList &indexes) const
//--------------------------------------------------------------------------------------------------
bool PdmUiTreeViewModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
if (m_dragDropHandle)
if (m_dragDropInterface)
{
return m_dragDropHandle->dropMimeData(data, action, row, column, parent);
return m_dragDropInterface->dropMimeData(data, action, row, column, parent);
}
else
{
@ -867,9 +853,9 @@ bool PdmUiTreeViewModel::dropMimeData(const QMimeData *data, Qt::DropAction acti
//--------------------------------------------------------------------------------------------------
Qt::DropActions PdmUiTreeViewModel::supportedDropActions() const
{
if (m_dragDropHandle)
if (m_dragDropInterface)
{
return m_dragDropHandle->supportedDropActions();
return m_dragDropInterface->supportedDropActions();
}
else
{

View File

@ -50,7 +50,7 @@ class PdmObjectHandle;
class PdmUiItem;
class PdmUiTreeViewEditor;
class PdmUiTreeOrdering;
class PdmUiDragDropHandle;
class PdmUiDragDropInterface;
//==================================================================================================
//
@ -75,9 +75,8 @@ public:
PdmUiItem* uiItemFromModelIndex(const QModelIndex& index) const;
QModelIndex findModelIndex(const PdmUiItem* object) const;
void setDragDropHandle(PdmUiDragDropHandle* dragDropHandle);
void updateDragDropHandleFromEvent(const QDragMoveEvent* event);
void endDrag();
void setDragDropInterface(PdmUiDragDropInterface* dragDropInterface);
PdmUiDragDropInterface* dragDropInterface();
private:
void updateSubTreeRecursive(const QModelIndex& uiSubTreeRootModelIdx, PdmUiTreeOrdering* uiModelSubTreeRoot, PdmUiTreeOrdering* updatedPdmSubTreeRoot);
@ -95,7 +94,7 @@ private:
PdmUiTreeViewEditor* m_treeViewEditor;
PdmUiDragDropHandle* m_dragDropHandle;
PdmUiDragDropInterface* m_dragDropInterface;
private: