First draft of getting the exact drag start location

7220-lua-add-a-general-purpose-lexical-parser
unelsson 2 years ago
parent a7e37509de
commit bc1027ee95

@ -6,6 +6,7 @@
#include <QStringList>
#include <QtCore/QMimeData>
#include <QModelIndex>
#include "columnbase.hpp"
#include "universalid.hpp"
@ -15,6 +16,11 @@ namespace CSMDoc
class Document;
}
namespace CSVWorld
{
class DragRecordTable;
}
namespace CSMWorld
{
@ -30,6 +36,8 @@ namespace CSMWorld
std::vector<UniversalId> mUniversalId;
QStringList mObjectsFormats;
const CSMDoc::Document& mDocument;
const CSVWorld::DragRecordTable* mTableOfDragStart;
QModelIndex mIndexAtDragStart;
public:
TableMimeData(UniversalId id, const CSMDoc::Document& document);
@ -55,6 +63,10 @@ namespace CSMWorld
const CSMDoc::Document* getDocumentPtr() const;
UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const;
void setIndexAtDragStart(QModelIndex index) {mIndexAtDragStart = index;}
void setTableOfDragStart(const CSVWorld::DragRecordTable* table) {mTableOfDragStart = table;}
static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type);

@ -93,7 +93,7 @@ void CSVTools::ReportTable::contextMenuEvent(QContextMenuEvent* event)
void CSVTools::ReportTable::mouseMoveEvent(QMouseEvent* event)
{
if (event->buttons() & Qt::LeftButton)
startDragFromTable(*this);
startDragFromTable(*this, indexAt(event->pos()));
}
void CSVTools::ReportTable::mouseDoubleClickEvent(QMouseEvent* event)

@ -16,7 +16,7 @@
#include "dragdroputils.hpp"
void CSVWorld::DragRecordTable::startDragFromTable(const CSVWorld::DragRecordTable& table)
void CSVWorld::DragRecordTable::startDragFromTable(const CSVWorld::DragRecordTable& table, QModelIndex index)
{
std::vector<CSMWorld::UniversalId> records = table.getDraggedRecords();
if (records.empty())
@ -25,6 +25,8 @@ void CSVWorld::DragRecordTable::startDragFromTable(const CSVWorld::DragRecordTab
}
CSMWorld::TableMimeData* mime = new CSMWorld::TableMimeData(records, mDocument);
mime->setTableOfDragStart(&table);
mime->setIndexAtDragStart(index);
QDrag* drag = new QDrag(this);
drag->setMimeData(mime);
drag->setPixmap(QString::fromUtf8(mime->getIcon().c_str()));

@ -42,7 +42,7 @@ namespace CSVWorld
void setEditLock(bool locked);
protected:
void startDragFromTable(const DragRecordTable& table);
void startDragFromTable(const DragRecordTable& table, QModelIndex index);
void dragEnterEvent(QDragEnterEvent* event) override;

@ -338,7 +338,7 @@ void CSVWorld::RegionMap::viewInTable()
void CSVWorld::RegionMap::mouseMoveEvent(QMouseEvent* event)
{
startDragFromTable(*this);
startDragFromTable(*this, indexAt(event->pos()));
}
std::vector<CSMWorld::UniversalId> CSVWorld::RegionMap::getDraggedRecords() const

@ -871,7 +871,7 @@ void CSVWorld::Table::mouseMoveEvent(QMouseEvent* event)
{
if (event->buttons() & Qt::LeftButton)
{
startDragFromTable(*this);
startDragFromTable(*this, indexAt(event->pos()));
}
}

Loading…
Cancel
Save