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