Merge branch 'drop'

openmw-38
Marc Zinnschlag 9 years ago
commit 2162f21550

@ -179,7 +179,7 @@ CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::Univers
}
}
throw std::runtime_error ("TableMimeData object does not hold object of the seeked type");
throw std::runtime_error ("TableMimeData object does not hold object of the sought type");
}
CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnBase::Display type) const
@ -201,7 +201,7 @@ CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnB
}
}
throw std::runtime_error ("TableMimeData object does not hold object of the seeked type");
throw std::runtime_error ("TableMimeData object does not hold object of the sought type");
}
bool CSMWorld::TableMimeData::fromDocument (const CSMDoc::Document& document) const

@ -64,3 +64,9 @@ void CSVRender::EditMode::dragCompleted() {}
void CSVRender::EditMode::dragAborted() {}
void CSVRender::EditMode::dragWheel (int diff, double speedFactor) {}
void CSVRender::EditMode::dragEnterEvent (QDragEnterEvent *event) {}
void CSVRender::EditMode::dropEvent (QDropEvent* event) {}
void CSVRender::EditMode::dragMoveEvent (QDragMoveEvent *event) {}

@ -5,6 +5,10 @@
#include "../widget/modebutton.hpp"
class QDragEnterEvent;
class QDropEvent;
class QDragMoveEvent;
namespace CSVRender
{
class WorldspaceWidget;
@ -79,6 +83,15 @@ namespace CSVRender
/// Default-implementation: ignored
virtual void dragWheel (int diff, double speedFactor);
/// Default-implementation: ignored
virtual void dragEnterEvent (QDragEnterEvent *event);
/// Default-implementation: ignored
virtual void dropEvent (QDropEvent* event);
/// Default-implementation: ignored
virtual void dragMoveEvent (QDragMoveEvent *event);
};
}

@ -317,15 +317,44 @@ CSMDoc::Document& CSVRender::WorldspaceWidget::getDocument()
void CSVRender::WorldspaceWidget::dragEnterEvent (QDragEnterEvent* event)
{
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();
}
else
dynamic_cast<EditMode&> (*mEditMode->getCurrent()).dragEnterEvent (event);
}
}
void CSVRender::WorldspaceWidget::dragMoveEvent(QDragMoveEvent *event)
{
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();
}
else
dynamic_cast<EditMode&> (*mEditMode->getCurrent()).dragMoveEvent (event);
}
}
bool CSVRender::WorldspaceWidget::storeMappingSetting (const CSMPrefs::Setting *setting)
{
if (setting->getParent()->getKey()!="3D Scene Input")
@ -427,9 +456,16 @@ void CSVRender::WorldspaceWidget::dropEvent (QDropEvent* event)
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))
{
emit dataDropped(mime->getData());
} //not handling drops from different documents at the moment
}
else
dynamic_cast<EditMode&> (*mEditMode->getCurrent()).dropEvent (event);
}
}
void CSVRender::WorldspaceWidget::runRequest (const std::string& profile)

Loading…
Cancel
Save