Skip to content

An OpenMW mod that lets you play the whole Elder Scrolls III: Morrowind as a top-down isometric game — with full online co-op or MMO modes.

C++
1.2 KB
Raw Blame
#include "droplineedit.hpp"

#include <string>

#include <QDropEvent>

#include "../../model/world/tablemimedata.hpp"
#include "../../model/world/universalid.hpp"

#include <apps/opencs/model/world/columnbase.hpp>

#include "../world/dragdroputils.hpp"

CSVWidget::DropLineEdit::DropLineEdit(CSMWorld::ColumnBase::Display type, QWidget* parent)
    : QLineEdit(parent)
    , mDropType(type)
{
    setAcceptDrops(true);
}

void CSVWidget::DropLineEdit::dragEnterEvent(QDragEnterEvent* event)
{
    if (CSVWorld::DragDropUtils::canAcceptData(*event, mDropType))
    {
        event->acceptProposedAction();
    }
}

void CSVWidget::DropLineEdit::dragMoveEvent(QDragMoveEvent* event)
{
    if (CSVWorld::DragDropUtils::canAcceptData(*event, mDropType))
    {
        event->accept();
    }
}

void CSVWidget::DropLineEdit::dropEvent(QDropEvent* event)
{
    if (CSVWorld::DragDropUtils::canAcceptData(*event, mDropType))
    {
        CSMWorld::UniversalId id = CSVWorld::DragDropUtils::getAcceptedData(*event, mDropType);
        setText(QString::fromUtf8(id.getId().c_str()));
        emit tableMimeDataDropped(id, CSVWorld::DragDropUtils::getTableMimeData(*event)->getDocumentPtr());
    }
}