reject unsuitable drops to WorldspaceWidget earlier

This commit is contained in:
Marc Zinnschlag 2015-12-18 12:38:45 +01:00
parent 6b626c2954
commit 37a72d1ea6

View file

@ -317,12 +317,38 @@ CSMDoc::Document& CSVRender::WorldspaceWidget::getDocument()
void CSVRender::WorldspaceWidget::dragEnterEvent (QDragEnterEvent* event)
{
event->accept();
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
if (!mime) // May happen when non-records (e.g. plain text) are dragged and dropped
return;
if (mime->fromDocument (mDocument))
{
if (mime->holdsType (CSMWorld::UniversalId::Type_Cell) ||
mime->holdsType (CSMWorld::UniversalId::Type_Cell_Missing) ||
mime->holdsType (CSMWorld::UniversalId::Type_DebugProfile))
{
// These drops are handled through the subview object.
event->accept();
}
}
}
void CSVRender::WorldspaceWidget::dragMoveEvent(QDragMoveEvent *event)
{
event->accept();
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
if (!mime) // May happen when non-records (e.g. plain text) are dragged and dropped
return;
if (mime->fromDocument (mDocument))
{
if (mime->holdsType (CSMWorld::UniversalId::Type_Cell) ||
mime->holdsType (CSMWorld::UniversalId::Type_Cell_Missing) ||
mime->holdsType (CSMWorld::UniversalId::Type_DebugProfile))
{
// These drops are handled through the subview object.
event->accept();
}
}
}
@ -428,8 +454,13 @@ void CSVRender::WorldspaceWidget::dropEvent (QDropEvent* event)
if (mime->fromDocument (mDocument))
{
emit dataDropped(mime->getData());
} //not handling drops from different documents at the moment
if (mime->holdsType (CSMWorld::UniversalId::Type_Cell) ||
mime->holdsType (CSMWorld::UniversalId::Type_Cell_Missing) ||
mime->holdsType (CSMWorld::UniversalId::Type_DebugProfile))
{
emit dataDropped(mime->getData());
}
}
}
void CSVRender::WorldspaceWidget::runRequest (const std::string& profile)