1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-23 02:23:54 +00:00
openmw/apps/opencs/view/widget/droplineedit.cpp

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

46 lines
1.2 KiB
C++
Raw Normal View History

#include "droplineedit.hpp"
2022-10-10 11:41:36 +00:00
#include <string>
#include <QDropEvent>
#include "../../model/world/tablemimedata.hpp"
2015-06-21 14:16:13 +00:00
#include "../../model/world/universalid.hpp"
2022-10-10 11:41:36 +00:00
#include <apps/opencs/model/world/columnbase.hpp>
2015-06-21 14:16:13 +00:00
#include "../world/dragdroputils.hpp"
2015-06-21 14:16:13 +00:00
CSVWidget::DropLineEdit::DropLineEdit(CSMWorld::ColumnBase::Display type, QWidget* parent)
: QLineEdit(parent)
, mDropType(type)
{
setAcceptDrops(true);
}
void CSVWidget::DropLineEdit::dragEnterEvent(QDragEnterEvent* event)
{
2015-06-21 14:16:13 +00:00
if (CSVWorld::DragDropUtils::canAcceptData(*event, mDropType))
{
event->acceptProposedAction();
}
}
void CSVWidget::DropLineEdit::dragMoveEvent(QDragMoveEvent* event)
{
2015-06-21 14:16:13 +00:00
if (CSVWorld::DragDropUtils::canAcceptData(*event, mDropType))
{
event->accept();
}
}
void CSVWidget::DropLineEdit::dropEvent(QDropEvent* event)
{
2015-06-21 14:16:13 +00:00
if (CSVWorld::DragDropUtils::canAcceptData(*event, mDropType))
{
2015-06-21 14:16:13 +00:00
CSMWorld::UniversalId id = CSVWorld::DragDropUtils::getAcceptedData(*event, mDropType);
setText(QString::fromUtf8(id.getId().c_str()));
2015-06-21 14:16:13 +00:00
emit tableMimeDataDropped(id, CSVWorld::DragDropUtils::getTableMimeData(*event)->getDocumentPtr());
}
}