diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 193c621221..7509bd905d 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -6,7 +6,7 @@ #include -#include +#include #include #include "universalid.hpp" diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index d343440f13..3cf6d2ec98 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -85,7 +85,7 @@ std::vector CSVWorld::Table::listRevertableSelectedIds() const QModelIndexList selectedRows = selectionModel()->selectedRows(); for (QModelIndexList::const_iterator iter (selectedRows.begin()); iter!=selectedRows.end(); - ++iter) + ++iter) { QModelIndex index = mProxyModel->mapToSource (mProxyModel->index (iter->row(), 0)); @@ -228,6 +228,8 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, Q connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), this, SLOT (selectionSizeUpdate ())); + + setAcceptDrops(true); } void CSVWorld::Table::setEditLock (bool locked) @@ -384,10 +386,10 @@ void CSVWorld::Table::tableSizeUpdate() switch (state) { - case CSMWorld::RecordBase::State_BaseOnly: ++size; break; - case CSMWorld::RecordBase::State_Modified: ++size; ++modified; break; - case CSMWorld::RecordBase::State_ModifiedOnly: ++size; ++modified; break; - case CSMWorld::RecordBase:: State_Deleted: ++deleted; ++modified; break; + case CSMWorld::RecordBase::State_BaseOnly: ++size; break; + case CSMWorld::RecordBase::State_Modified: ++size; ++modified; break; + case CSMWorld::RecordBase::State_ModifiedOnly: ++size; ++modified; break; + case CSMWorld::RecordBase:: State_Deleted: ++deleted; ++modified; break; } } } @@ -446,5 +448,28 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) drag->setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); drag->exec(); - } + std::cout << "startdrag"; + } + +} + +void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event) +{ + //if (event->mimeData()->hasFormat("text/plain")) + std::cout << "accept drag event"; + event->acceptProposedAction(); + +} + +void CSVWorld::Table::dropEvent(QDropEvent *event) +{ + std::cout << "drop"; + event->acceptProposedAction(); + QModelIndex index = indexAt(event->pos()); + std::cout << index.row(); +} + +void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) +{ + event->accept(); } \ No newline at end of file diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index ec08e4e2b4..fd28396880 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include "../../model/filter/node.hpp" @@ -52,6 +52,13 @@ namespace CSVWorld void mouseMoveEvent(QMouseEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + + void dropEvent(QDropEvent *event); + + void dragMoveEvent(QDragMoveEvent *event); + + public: Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, bool sorting);