1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-23 03:53:53 +00:00
openmw/apps/opencs/view/world/dragdroputils.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.6 KiB
C++
Raw Normal View History

#include "dragdroputils.hpp"
#include <QDropEvent>
2022-10-19 17:02:00 +00:00
#include <apps/opencs/model/world/columnbase.hpp>
#include <apps/opencs/model/world/universalid.hpp>
#include "../../model/world/tablemimedata.hpp"
const CSMWorld::TableMimeData* CSVWorld::DragDropUtils::getTableMimeData(const QDropEvent& event)
{
return dynamic_cast<const CSMWorld::TableMimeData*>(event.mimeData());
}
bool CSVWorld::DragDropUtils::canAcceptData(const QDropEvent& event, CSMWorld::ColumnBase::Display type)
{
const CSMWorld::TableMimeData* data = getTableMimeData(event);
2018-10-09 06:21:12 +00:00
return data != nullptr && data->holdsType(type);
}
bool CSVWorld::DragDropUtils::isTopicOrJournal(const QDropEvent& event, CSMWorld::ColumnBase::Display type)
{
const CSMWorld::TableMimeData* data = getTableMimeData(event);
return data != nullptr
2023-01-14 19:42:33 +00:00
&& (data->holdsType(CSMWorld::UniversalId::Type_Topic) || data->holdsType(CSMWorld::UniversalId::Type_Journal));
}
bool CSVWorld::DragDropUtils::isInfo(const QDropEvent& event, CSMWorld::ColumnBase::Display type)
{
const CSMWorld::TableMimeData* data = getTableMimeData(event);
return data != nullptr
&& (data->holdsType(CSMWorld::UniversalId::Type_TopicInfo)
|| data->holdsType(CSMWorld::UniversalId::Type_JournalInfo));
}
CSMWorld::UniversalId CSVWorld::DragDropUtils::getAcceptedData(
const QDropEvent& event, CSMWorld::ColumnBase::Display type)
{
if (canAcceptData(event, type))
{
2021-01-09 10:24:04 +00:00
if (const CSMWorld::TableMimeData* data = getTableMimeData(event))
return data->returnMatching(type);
}
return CSMWorld::UniversalId::Type_None;
}