2015-06-21 14:08:10 +00:00
|
|
|
#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>
|
|
|
|
|
2015-06-21 14:08:10 +00:00
|
|
|
#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);
|
2015-06-21 14:08:10 +00:00
|
|
|
}
|
|
|
|
|
2023-01-14 18:36:49 +00:00
|
|
|
bool CSVWorld::DragDropUtils::isTopicOrJournal(const QDropEvent& event, CSMWorld::ColumnBase::Display type)
|
|
|
|
{
|
|
|
|
const CSMWorld::TableMimeData* data = getTableMimeData(event);
|
|
|
|
return data != nullptr
|
|
|
|
&& (data->holdsType(CSMWorld::UniversalId::Type_Topic)
|
|
|
|
|| data->holdsType(CSMWorld::UniversalId::Type_Journal));
|
|
|
|
}
|
|
|
|
|
2021-01-13 13:38:29 +00:00
|
|
|
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(
|
2015-06-21 14:08:10 +00:00
|
|
|
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);
|
2015-06-21 14:08:10 +00:00
|
|
|
}
|
|
|
|
return CSMWorld::UniversalId::Type_None;
|
|
|
|
}
|