2015-06-20 14:33:36 +00:00
|
|
|
#include "droplineedit.hpp"
|
|
|
|
|
2022-10-10 11:41:36 +00:00
|
|
|
#include <string>
|
|
|
|
|
2015-06-20 14:33:36 +00:00
|
|
|
#include <QDropEvent>
|
|
|
|
|
|
|
|
#include "../../model/world/tablemimedata.hpp"
|
2015-06-21 14:16:13 +00:00
|
|
|
#include "../../model/world/universalid.hpp"
|
2015-06-20 14:33:36 +00:00
|
|
|
|
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-20 14:33:36 +00:00
|
|
|
|
2015-06-21 14:16:13 +00:00
|
|
|
CSVWidget::DropLineEdit::DropLineEdit(CSMWorld::ColumnBase::Display type, QWidget* parent)
|
2015-06-20 14:33:36 +00:00
|
|
|
: 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))
|
2015-06-20 14:33:36 +00:00
|
|
|
{
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSVWidget::DropLineEdit::dragMoveEvent(QDragMoveEvent* event)
|
|
|
|
{
|
2015-06-21 14:16:13 +00:00
|
|
|
if (CSVWorld::DragDropUtils::canAcceptData(*event, mDropType))
|
2015-06-20 14:33:36 +00:00
|
|
|
{
|
|
|
|
event->accept();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSVWidget::DropLineEdit::dropEvent(QDropEvent* event)
|
|
|
|
{
|
2015-06-21 14:16:13 +00:00
|
|
|
if (CSVWorld::DragDropUtils::canAcceptData(*event, mDropType))
|
2015-06-20 14:33:36 +00:00
|
|
|
{
|
2015-06-21 14:16:13 +00:00
|
|
|
CSMWorld::UniversalId id = CSVWorld::DragDropUtils::getAcceptedData(*event, mDropType);
|
2015-09-16 18:45:37 +00:00
|
|
|
setText(QString::fromUtf8(id.getId().c_str()));
|
2015-06-21 14:16:13 +00:00
|
|
|
emit tableMimeDataDropped(id, CSVWorld::DragDropUtils::getTableMimeData(*event)->getDocumentPtr());
|
2015-06-20 14:33:36 +00:00
|
|
|
}
|
|
|
|
}
|