From b5006c5dbd7f2840b3907ae59f367bc4a19b87ad Mon Sep 17 00:00:00 2001 From: gus Date: Sun, 9 Feb 2014 15:33:00 +0100 Subject: [PATCH 1/4] compile fix --- apps/opencs/model/world/tablemimedata.hpp | 2 +- apps/opencs/view/world/table.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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.hpp b/apps/opencs/view/world/table.hpp index ec08e4e2b4..db45a96328 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" From df46218acc9132e034e54af788b1f2c2b83f4084 Mon Sep 17 00:00:00 2001 From: gus Date: Mon, 10 Feb 2014 16:48:04 +0100 Subject: [PATCH 2/4] try droping --- apps/opencs/view/world/table.cpp | 32 +++++++++++++++++++++++++------- apps/opencs/view/world/table.hpp | 4 ++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index ff0eabf27e..1a9499f52b 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; } } } @@ -445,6 +447,22 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) drag->setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); - drag->start(); - } + 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(); } \ No newline at end of file diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index db45a96328..44d72f7fb3 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -52,6 +52,10 @@ namespace CSVWorld void mouseMoveEvent(QMouseEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + + void dropEvent(QDropEvent *event); + public: Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, bool sorting); From 2e33ab3a13b61e846155e9b8bf889c8725d4f015 Mon Sep 17 00:00:00 2001 From: gus Date: Wed, 12 Feb 2014 11:16:12 +0100 Subject: [PATCH 3/4] droping somewhat works --- apps/opencs/view/world/table.cpp | 5 +++++ apps/opencs/view/world/table.hpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 1a9499f52b..15f946f718 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -465,4 +465,9 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) { std::cout << "drop"; event->acceptProposedAction(); +} + +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 44d72f7fb3..fd28396880 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -56,6 +56,9 @@ namespace CSVWorld void dropEvent(QDropEvent *event); + void dragMoveEvent(QDragMoveEvent *event); + + public: Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, bool sorting); From 6cf561f713d54ede7e4e4d5ffb34da962c097bb0 Mon Sep 17 00:00:00 2001 From: gus Date: Wed, 12 Feb 2014 11:32:01 +0100 Subject: [PATCH 4/4] get index to where we are dropping --- apps/opencs/view/world/table.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 15f946f718..fe79ab2ff6 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -465,6 +465,8 @@ 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)