mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-25 18:06:48 +00:00
First draft of getting the exact drag start location
This commit is contained in:
parent
a7e37509de
commit
bc1027ee95
6 changed files with 19 additions and 5 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtCore/QMimeData>
|
#include <QtCore/QMimeData>
|
||||||
|
#include <QModelIndex>
|
||||||
|
|
||||||
#include "columnbase.hpp"
|
#include "columnbase.hpp"
|
||||||
#include "universalid.hpp"
|
#include "universalid.hpp"
|
||||||
|
@ -15,6 +16,11 @@ namespace CSMDoc
|
||||||
class Document;
|
class Document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace CSVWorld
|
||||||
|
{
|
||||||
|
class DragRecordTable;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -30,6 +36,8 @@ namespace CSMWorld
|
||||||
std::vector<UniversalId> mUniversalId;
|
std::vector<UniversalId> mUniversalId;
|
||||||
QStringList mObjectsFormats;
|
QStringList mObjectsFormats;
|
||||||
const CSMDoc::Document& mDocument;
|
const CSMDoc::Document& mDocument;
|
||||||
|
const CSVWorld::DragRecordTable* mTableOfDragStart;
|
||||||
|
QModelIndex mIndexAtDragStart;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TableMimeData(UniversalId id, const CSMDoc::Document& document);
|
TableMimeData(UniversalId id, const CSMDoc::Document& document);
|
||||||
|
@ -56,6 +64,10 @@ namespace CSMWorld
|
||||||
|
|
||||||
UniversalId returnMatching(CSMWorld::ColumnBase::Display type) 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);
|
static CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type);
|
||||||
|
|
||||||
static CSMWorld::ColumnBase::Display convertEnums(CSMWorld::UniversalId::Type type);
|
static CSMWorld::ColumnBase::Display convertEnums(CSMWorld::UniversalId::Type type);
|
||||||
|
|
|
@ -93,7 +93,7 @@ void CSVTools::ReportTable::contextMenuEvent(QContextMenuEvent* event)
|
||||||
void CSVTools::ReportTable::mouseMoveEvent(QMouseEvent* event)
|
void CSVTools::ReportTable::mouseMoveEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton)
|
if (event->buttons() & Qt::LeftButton)
|
||||||
startDragFromTable(*this);
|
startDragFromTable(*this, indexAt(event->pos()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVTools::ReportTable::mouseDoubleClickEvent(QMouseEvent* event)
|
void CSVTools::ReportTable::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "dragdroputils.hpp"
|
#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();
|
std::vector<CSMWorld::UniversalId> records = table.getDraggedRecords();
|
||||||
if (records.empty())
|
if (records.empty())
|
||||||
|
@ -25,6 +25,8 @@ void CSVWorld::DragRecordTable::startDragFromTable(const CSVWorld::DragRecordTab
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMWorld::TableMimeData* mime = new CSMWorld::TableMimeData(records, mDocument);
|
CSMWorld::TableMimeData* mime = new CSMWorld::TableMimeData(records, mDocument);
|
||||||
|
mime->setTableOfDragStart(&table);
|
||||||
|
mime->setIndexAtDragStart(index);
|
||||||
QDrag* drag = new QDrag(this);
|
QDrag* drag = new QDrag(this);
|
||||||
drag->setMimeData(mime);
|
drag->setMimeData(mime);
|
||||||
drag->setPixmap(QString::fromUtf8(mime->getIcon().c_str()));
|
drag->setPixmap(QString::fromUtf8(mime->getIcon().c_str()));
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace CSVWorld
|
||||||
void setEditLock(bool locked);
|
void setEditLock(bool locked);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void startDragFromTable(const DragRecordTable& table);
|
void startDragFromTable(const DragRecordTable& table, QModelIndex index);
|
||||||
|
|
||||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,7 @@ void CSVWorld::RegionMap::viewInTable()
|
||||||
|
|
||||||
void CSVWorld::RegionMap::mouseMoveEvent(QMouseEvent* event)
|
void CSVWorld::RegionMap::mouseMoveEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
startDragFromTable(*this);
|
startDragFromTable(*this, indexAt(event->pos()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CSMWorld::UniversalId> CSVWorld::RegionMap::getDraggedRecords() const
|
std::vector<CSMWorld::UniversalId> CSVWorld::RegionMap::getDraggedRecords() const
|
||||||
|
|
|
@ -871,7 +871,7 @@ void CSVWorld::Table::mouseMoveEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
if (event->buttons() & Qt::LeftButton)
|
if (event->buttons() & Qt::LeftButton)
|
||||||
{
|
{
|
||||||
startDragFromTable(*this);
|
startDragFromTable(*this, indexAt(event->pos()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue