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

36 lines
1.2 KiB
C++
Raw Normal View History

#include "dragdroputils.hpp"
#include <QDropEvent>
#include "../../model/world/tablemimedata.hpp"
2022-09-22 18:26:05 +00:00
const CSMWorld::TableMimeData* CSVWorld::DragDropUtils::getTableMimeData(const QDropEvent& event)
{
2022-09-22 18:26:05 +00:00
return dynamic_cast<const CSMWorld::TableMimeData*>(event.mimeData());
}
2022-09-22 18:26:05 +00:00
bool CSVWorld::DragDropUtils::canAcceptData(const QDropEvent& event, CSMWorld::ColumnBase::Display type)
{
2022-09-22 18:26:05 +00:00
const CSMWorld::TableMimeData* data = getTableMimeData(event);
2018-10-09 06:21:12 +00:00
return data != nullptr && data->holdsType(type);
}
2022-09-22 18:26:05 +00:00
bool CSVWorld::DragDropUtils::isInfo(const QDropEvent& event, CSMWorld::ColumnBase::Display type)
{
2022-09-22 18:26:05 +00:00
const CSMWorld::TableMimeData* data = getTableMimeData(event);
return data != nullptr
&& (data->holdsType(CSMWorld::UniversalId::Type_TopicInfo)
|| data->holdsType(CSMWorld::UniversalId::Type_JournalInfo));
}
2022-09-22 18:26:05 +00:00
CSMWorld::UniversalId CSVWorld::DragDropUtils::getAcceptedData(
const QDropEvent& event, CSMWorld::ColumnBase::Display type)
{
if (canAcceptData(event, type))
{
2022-09-22 18:26:05 +00:00
if (const CSMWorld::TableMimeData* data = getTableMimeData(event))
2021-01-09 10:24:04 +00:00
return data->returnMatching(type);
}
return CSMWorld::UniversalId::Type_None;
}