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

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"
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);
}
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));
}
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;
}