From a36cc264349584a1c0f6abfa1669d109843aadb3 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Sat, 1 Feb 2014 19:06:41 +0100 Subject: [PATCH 01/28] Created new files for TableMimeData class. --- apps/opencs/model/world/tablemimedata.cpp | 1 + apps/opencs/model/world/tablemimedata.hpp | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 apps/opencs/model/world/tablemimedata.cpp create mode 100644 apps/opencs/model/world/tablemimedata.hpp diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp new file mode 100644 index 0000000000..a8947394a8 --- /dev/null +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -0,0 +1 @@ +#include "tablemimedata.hpp" diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp new file mode 100644 index 0000000000..d96263ae2f --- /dev/null +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -0,0 +1,10 @@ +#ifndef TABLEMIMEDATA_H +#define TABLEMIMEDATA_H + +#include + +class TableMimeData : public QMimeData +{ +}; + +#endif // TABLEMIMEDATA_H From dc80bfff554404fa998d5b762da9afc62ed50f1d Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 4 Feb 2014 09:13:40 +0100 Subject: [PATCH 02/28] Attempt to get basic tablemimedata subclass. --- apps/opencs/model/world/tablemimedata.cpp | 21 +++++++++++++++++++++ apps/opencs/model/world/tablemimedata.hpp | 20 ++++++++++++++++++-- apps/opencs/view/world/table.cpp | 1 + 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index a8947394a8..457f5af1b8 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -1 +1,22 @@ #include "tablemimedata.hpp" +#include "universalid.hpp" + +CSMWorld::TableMimeData::TableMimeData (CSMWorld::UniversalId& UniversalId) : +mUniversalId(UniversalId) +{ + mSupportedFormats << UniversalId.toString().c_str(); +} + +QStringList CSMWorld::TableMimeData::formats() const +{ + return QMimeData::formats(); +} + +CSMWorld::TableMimeData::~TableMimeData() +{ +} + +CSMWorld::UniversalId& CSMWorld::TableMimeData::getId() +{ + return mUniversalId; +} diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index d96263ae2f..d142c66c1c 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -1,10 +1,26 @@ +/*This class provides way to construct mimedata object holding the reference to the +* universalid. universalid is used in the majority of the tables to store type, id, argument types*/ + #ifndef TABLEMIMEDATA_H #define TABLEMIMEDATA_H #include +#include -class TableMimeData : public QMimeData +namespace CSMWorld { -}; + class UniversalId; + class TableMimeData : public QMimeData + { + public: + TableMimeData(UniversalId& UniversalId); + ~TableMimeData(); + virtual QStringList formats() const; + UniversalId& getId(); + private: + QStringList mSupportedFormats; + UniversalId& mUniversalId; + }; +} #endif // TABLEMIMEDATA_H diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 71bdb9000e..7d02555292 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -13,6 +13,7 @@ #include "../../model/world/idtable.hpp" #include "../../model/world/record.hpp" #include "../../model/world/columns.hpp" +#include "../../model/world/tablemimedata.hpp" #include "recordstatusdelegate.hpp" #include "util.hpp" From 423b2906be19ad6a448fd9fda1e338972090510b Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 4 Feb 2014 11:40:48 +0100 Subject: [PATCH 03/28] Yes, you can drag. But not drop. --- CMakeLists.txt | 2 +- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/model/world/tablemimedata.cpp | 8 ++++---- apps/opencs/model/world/tablemimedata.hpp | 10 +++++++--- apps/opencs/view/world/table.cpp | 21 +++++++++++++++++++++ apps/opencs/view/world/table.hpp | 3 +++ 6 files changed, 37 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cb2fd5b2d..c4981841a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,7 +324,7 @@ configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg configure_file(${OpenMW_SOURCE_DIR}/files/opencs.cfg "${OpenMW_BINARY_DIR}/opencs.cfg") - + configure_file(${OpenMW_SOURCE_DIR}/files/opencs/defaultfilters "${OpenMW_BINARY_DIR}/resources/defaultfilters" COPYONLY) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index e2dffdbde4..2c53e2fdd1 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -24,7 +24,7 @@ opencs_units (model/world opencs_units_noqt (model/world universalid record commands columnbase scriptcontext cell refidcollection - refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection + refidadapter refiddata refidadapterimp ref collectionbase refcollection columns infocollection tablemimedata ) opencs_hdrs_noqt (model/world diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 457f5af1b8..5f04d316ab 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -1,10 +1,10 @@ #include "tablemimedata.hpp" #include "universalid.hpp" -CSMWorld::TableMimeData::TableMimeData (CSMWorld::UniversalId& UniversalId) : -mUniversalId(UniversalId) +CSMWorld::TableMimeData::TableMimeData (UniversalId id) : +mUniversalId(id) { - mSupportedFormats << UniversalId.toString().c_str(); + mSupportedFormats << QString::fromStdString("application/Type_" + id.getTypeName()); } QStringList CSMWorld::TableMimeData::formats() const @@ -19,4 +19,4 @@ CSMWorld::TableMimeData::~TableMimeData() CSMWorld::UniversalId& CSMWorld::TableMimeData::getId() { return mUniversalId; -} +} \ No newline at end of file diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index d142c66c1c..5883966cd0 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -5,7 +5,11 @@ #define TABLEMIMEDATA_H #include -#include +#include + +#include "universalid.hpp" + +class QStringList; namespace CSMWorld { @@ -13,14 +17,14 @@ namespace CSMWorld class TableMimeData : public QMimeData { public: - TableMimeData(UniversalId& UniversalId); + TableMimeData(UniversalId id); ~TableMimeData(); virtual QStringList formats() const; UniversalId& getId(); private: QStringList mSupportedFormats; - UniversalId& mUniversalId; + UniversalId mUniversalId; }; } #endif // TABLEMIMEDATA_H diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 7d02555292..450af191e8 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -412,3 +412,24 @@ void CSVWorld::Table::recordFilterChanged (boost::shared_ptr fi { mProxyModel->setFilter (filter); } + +void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) +{ + if (event->buttons() & Qt::LeftButton) + { + QModelIndexList selectedRows = selectionModel()->selectedRows(); + + if (selectedRows.size() == 0) + { + return; + } + + if (selectedRows.size() == 1) //tmp solution + { + CSMWorld::TableMimeData *mime = new CSMWorld::TableMimeData(getUniversalId(selectedRows.begin()->row())); + QDrag *drag = new QDrag(this); + drag->setMimeData(mime); + drag->start(); + } + } +} \ No newline at end of file diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 889e2847ac..ec08e4e2b4 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -5,6 +5,7 @@ #include #include +#include #include "../../model/filter/node.hpp" @@ -49,6 +50,8 @@ namespace CSVWorld std::vector listDeletableSelectedIds() const; + void mouseMoveEvent(QMouseEvent *event); + public: Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete, bool sorting); From 3439940a8e3fd63e594ca631f30e3390c1bb45d2 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 4 Feb 2014 18:30:47 +0100 Subject: [PATCH 04/28] Tablemimedata able to handle vector of objects and return icon. --- apps/opencs/model/world/tablemimedata.cpp | 56 ++++++++++++++++++++--- apps/opencs/model/world/tablemimedata.hpp | 12 +++-- 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 5f04d316ab..b501ce2ea0 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -1,22 +1,64 @@ #include "tablemimedata.hpp" #include "universalid.hpp" +#include -CSMWorld::TableMimeData::TableMimeData (UniversalId id) : -mUniversalId(id) +CSMWorld::TableMimeData::TableMimeData (UniversalId id) { - mSupportedFormats << QString::fromStdString("application/Type_" + id.getTypeName()); + mUniversalId.push_back(id); + mObjectsFormats << QString::fromStdString("application/Type_" + id.getTypeName()); +} + +CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id) +{ + mUniversalId = id; + for (std::vector::iterator it(mUniversalId.begin()); it != mUniversalId.end(); ++it) + { + mObjectsFormats << QString::fromStdString("application/Type_" + it->getTypeName()); + } } QStringList CSMWorld::TableMimeData::formats() const { - return QMimeData::formats(); + return mObjectsFormats; } CSMWorld::TableMimeData::~TableMimeData() { } -CSMWorld::UniversalId& CSMWorld::TableMimeData::getId() +CSMWorld::UniversalId CSMWorld::TableMimeData::getId(unsigned int index) const { - return mUniversalId; -} \ No newline at end of file + if (mUniversalId.empty()) + { + throw("TableMimeData holds no UniversalId"); + } + return mUniversalId[index]; +} + +std::string CSMWorld::TableMimeData::getIcon() const +{ + if (mUniversalId.empty()) + { + throw("TableMimeData holds no UniversalId"); + } + + std::string tmpIcon; + bool firstIteration = true; + for (unsigned i = 0; i < mUniversalId.size(); ++i) + { + if (firstIteration) + { + firstIteration = false; + tmpIcon = mUniversalId[i].getIcon(); + continue; + } + + if (tmpIcon != mUniversalId[i].getIcon()) + { + return ""; //should return multiple types icon, but at the moment we don't have one + } + + tmpIcon = mUniversalId[i].getIcon(); + } + return mUniversalId.begin()->getIcon(); //All objects are of the same type; +} diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 5883966cd0..789f4b524b 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -4,27 +4,29 @@ #ifndef TABLEMIMEDATA_H #define TABLEMIMEDATA_H +#include + #include #include #include "universalid.hpp" -class QStringList; namespace CSMWorld { - class UniversalId; class TableMimeData : public QMimeData { public: TableMimeData(UniversalId id); + TableMimeData(std::vector& id); ~TableMimeData(); virtual QStringList formats() const; - UniversalId& getId(); + UniversalId getId(unsigned int index) const; + std::string getIcon() const; private: - QStringList mSupportedFormats; - UniversalId mUniversalId; + std::vector mUniversalId; + QStringList mObjectsFormats; }; } #endif // TABLEMIMEDATA_H From 8b799683c1e41dd87d2af6bfaa7fe6ed74e44133 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 4 Feb 2014 18:48:18 +0100 Subject: [PATCH 05/28] Display QPixMap with dragged object. --- apps/opencs/view/world/table.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 450af191e8..e7ae62e024 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -421,7 +421,7 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) if (selectedRows.size() == 0) { - return; + return; } if (selectedRows.size() == 1) //tmp solution @@ -429,6 +429,7 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) CSMWorld::TableMimeData *mime = new CSMWorld::TableMimeData(getUniversalId(selectedRows.begin()->row())); QDrag *drag = new QDrag(this); drag->setMimeData(mime); + drag->setPixmap(QString::fromStdString(mime->getIcon())); drag->start(); } } From 04287cb87ab01b7458d842b26ae289887c798ca8 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 4 Feb 2014 19:42:52 +0100 Subject: [PATCH 06/28] Provide method to return whole data vector from tablemimedata. --- apps/opencs/model/world/tablemimedata.cpp | 5 +++++ apps/opencs/model/world/tablemimedata.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index b501ce2ea0..7ca287521f 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -62,3 +62,8 @@ std::string CSMWorld::TableMimeData::getIcon() const } return mUniversalId.begin()->getIcon(); //All objects are of the same type; } + +std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getData() const +{ + return mUniversalId; +} \ No newline at end of file diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 789f4b524b..90f7aefe2c 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -23,6 +23,7 @@ namespace CSMWorld virtual QStringList formats() const; UniversalId getId(unsigned int index) const; std::string getIcon() const; + std::vector getData() const; private: std::vector mUniversalId; From 76b729ac9baf57049e8b1e50ba7ca67e7a9371bc Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 5 Feb 2014 11:19:55 +0100 Subject: [PATCH 07/28] Removed getUniversalid interface. --- apps/opencs/model/world/tablemimedata.cpp | 9 --------- apps/opencs/model/world/tablemimedata.hpp | 3 +-- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 7ca287521f..1be694dac4 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -26,15 +26,6 @@ CSMWorld::TableMimeData::~TableMimeData() { } -CSMWorld::UniversalId CSMWorld::TableMimeData::getId(unsigned int index) const -{ - if (mUniversalId.empty()) - { - throw("TableMimeData holds no UniversalId"); - } - return mUniversalId[index]; -} - std::string CSMWorld::TableMimeData::getIcon() const { if (mUniversalId.empty()) diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 90f7aefe2c..193c621221 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -21,7 +21,6 @@ namespace CSMWorld TableMimeData(std::vector& id); ~TableMimeData(); virtual QStringList formats() const; - UniversalId getId(unsigned int index) const; std::string getIcon() const; std::vector getData() const; @@ -30,4 +29,4 @@ namespace CSMWorld QStringList mObjectsFormats; }; } -#endif // TABLEMIMEDATA_H +#endif // TABLEMIMEDATA_H \ No newline at end of file From f01b02c42d2272e0596e31e72bd6113a1d2e2253 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 5 Feb 2014 11:24:33 +0100 Subject: [PATCH 08/28] Changed format. --- apps/opencs/model/world/tablemimedata.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 1be694dac4..0cdcdba3ae 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -5,7 +5,7 @@ CSMWorld::TableMimeData::TableMimeData (UniversalId id) { mUniversalId.push_back(id); - mObjectsFormats << QString::fromStdString("application/Type_" + id.getTypeName()); + mObjectsFormats << QString::fromStdString("tabledata/" + id.getTypeName()); } CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id) @@ -13,7 +13,7 @@ CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id mUniversalId = id; for (std::vector::iterator it(mUniversalId.begin()); it != mUniversalId.end(); ++it) { - mObjectsFormats << QString::fromStdString("application/Type_" + it->getTypeName()); + mObjectsFormats << QString::fromStdString("tabledata/" + it->getTypeName()); } } From 3b8f04c0f345ddd4588321d2e43b6ff132774f40 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 5 Feb 2014 11:44:08 +0100 Subject: [PATCH 09/28] Allow multi-item drag. --- apps/opencs/view/world/table.cpp | 42 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index e7ae62e024..ff0eabf27e 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -415,22 +415,36 @@ void CSVWorld::Table::recordFilterChanged (boost::shared_ptr fi void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) { - if (event->buttons() & Qt::LeftButton) - { - QModelIndexList selectedRows = selectionModel()->selectedRows(); + if (event->buttons() & Qt::LeftButton) + { + QModelIndexList selectedRows = selectionModel()->selectedRows(); - if (selectedRows.size() == 0) - { - return; - } + if (selectedRows.size() == 0) + { + return; + } - if (selectedRows.size() == 1) //tmp solution - { - CSMWorld::TableMimeData *mime = new CSMWorld::TableMimeData(getUniversalId(selectedRows.begin()->row())); - QDrag *drag = new QDrag(this); - drag->setMimeData(mime); - drag->setPixmap(QString::fromStdString(mime->getIcon())); + QDrag* drag = new QDrag (this); + CSMWorld::TableMimeData* mime = NULL; + + if (selectedRows.size() == 1) + { + mime = new CSMWorld::TableMimeData (getUniversalId (selectedRows.begin()->row())); + } + else + { + std::vector idToDrag; + + foreach (QModelIndex it, selectedRows) + { + idToDrag.push_back (getUniversalId (it.row())); + } + + mime = new CSMWorld::TableMimeData (idToDrag); + } + + drag->setMimeData (mime); + drag->setPixmap (QString::fromStdString (mime->getIcon())); drag->start(); - } } } \ No newline at end of file From b5006c5dbd7f2840b3907ae59f367bc4a19b87ad Mon Sep 17 00:00:00 2001 From: gus Date: Sun, 9 Feb 2014 15:33:00 +0100 Subject: [PATCH 10/28] 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 11/28] 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 53e2e8415d9c6d0c61d87d09b93a18f575f255b5 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Tue, 11 Feb 2014 12:25:21 +0100 Subject: [PATCH 12/28] replaced start with exec --- apps/opencs/view/world/table.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index ff0eabf27e..d343440f13 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -435,7 +435,7 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) { std::vector idToDrag; - foreach (QModelIndex it, selectedRows) + foreach (QModelIndex it, selectedRows) //I had a dream. Dream where you could use C++11 in OpenMW. { idToDrag.push_back (getUniversalId (it.row())); } @@ -445,6 +445,6 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) drag->setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); - drag->start(); + drag->exec(); } } \ No newline at end of file From fc135fbfee090ae37f89b8cfd80d4668dd968624 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 12 Feb 2014 09:04:52 +0100 Subject: [PATCH 13/28] Added new Display types --- apps/opencs/model/world/columnbase.hpp | 65 ++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index 70f38c5341..be5a427b80 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -27,6 +27,71 @@ namespace CSMWorld enum Display { Display_String, + + //CONCRETE TYPES STARTS HERE + Display_Globals, + Display_Global, + Display_VerificationResults, + Display_Gmsts, + Display_Gmst, + Display_Skills, + Display_Skill, + Display_Classes, + Display_Class, + Display_Factions, + Display_Faction, + Display_Races, + Display_Race, + Display_Sounds, + Display_Sound, + Display_Scripts, + Display_Script, + Display_Regions, + Display_Region, + Display_Birthsigns, + Display_Birthsign, + Display_Spells, + Display_Spell, + Display_Cells, + Display_Cell, + Display_Referenceables, + Display_Referenceable, + Display_Activator, + Display_Potion, + Display_Apparatus, + Display_Armor, + Display_Book, + Display_Clothing, + Display_Container, + Display_Creature, + Display_Door, + Display_Ingredient, + Display_CreatureLevelledList, + Display_ItemLevelledList, + Display_Light, + Display_Lockpick, + Display_Miscellaneous, + Display_Npc, + Display_Probe, + Display_Repair, + Display_Static, + Display_Weapon, + Display_References, + Display_Reference, + Display_RegionMap, + Display_Filter, + Display_Filters, + Display_Topics, + Display_Topic, + Display_Journals, + Display_Journal, + Display_TopicInfos, + Display_TopicInfo, + Display_JournalInfos, + Display_JournalInfo, + Display_Scene, + //CONCRETE TYPES ENDS HERE + Display_Integer, Display_Float, Display_Var, From e1a39b83884cfd9ac45025533cb9af9adfeb0fcd Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 12 Feb 2014 09:24:08 +0100 Subject: [PATCH 14/28] Replaced some display_string with specific type. Damn, i wish this is correct ;-) --- apps/opencs/model/world/columnimp.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 18aac9e0be..0490421092 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -373,7 +373,7 @@ namespace CSMWorld SkillsColumn (int index, bool typePrefix = false, bool major = false) : Column ((typePrefix ? ( major ? Columns::ColumnId_MajorSkill1 : Columns::ColumnId_MinorSkill1) : - Columns::ColumnId_Skill1) + index, ColumnBase::Display_String), + Columns::ColumnId_Skill1) + index, ColumnBase::Display_Skills), mIndex (index), mMajor (major) {} @@ -598,7 +598,7 @@ namespace CSMWorld struct SoundFileColumn : public Column { SoundFileColumn() - : Column (Columns::ColumnId_SoundFile, ColumnBase::Display_String) + : Column (Columns::ColumnId_SoundFile, ColumnBase::Display_Sound) {} virtual QVariant get (const Record& record) const @@ -811,7 +811,7 @@ namespace CSMWorld template struct CellColumn : public Column { - CellColumn() : Column (Columns::ColumnId_Cell, ColumnBase::Display_String) {} + CellColumn() : Column (Columns::ColumnId_Cell, ColumnBase::Display_Cell) {} virtual QVariant get (const Record& record) const { @@ -890,7 +890,7 @@ namespace CSMWorld template struct OwnerColumn : public Column { - OwnerColumn() : Column (Columns::ColumnId_Owner, ColumnBase::Display_String) {} + OwnerColumn() : Column (Columns::ColumnId_Owner, ColumnBase::Display_Npc) {} virtual QVariant get (const Record& record) const { @@ -915,7 +915,7 @@ namespace CSMWorld template struct SoulColumn : public Column { - SoulColumn() : Column (Columns::ColumnId_Soul, ColumnBase::Display_String) {} + SoulColumn() : Column (Columns::ColumnId_Soul, ColumnBase::Display_Creature) {} virtual QVariant get (const Record& record) const { @@ -940,7 +940,7 @@ namespace CSMWorld template struct FactionColumn : public Column { - FactionColumn() : Column (Columns::ColumnId_Faction, ColumnBase::Display_String) {} + FactionColumn() : Column (Columns::ColumnId_Faction, ColumnBase::Display_Faction) {} virtual QVariant get (const Record& record) const { @@ -1090,7 +1090,7 @@ namespace CSMWorld struct TeleportCellColumn : public Column { TeleportCellColumn() - : Column (Columns::ColumnId_TeleportCell, ColumnBase::Display_String) + : Column (Columns::ColumnId_TeleportCell, ColumnBase::Display_Cell) {} virtual QVariant get (const Record& record) const @@ -1146,7 +1146,7 @@ namespace CSMWorld template struct KeyColumn : public Column { - KeyColumn() : Column (Columns::ColumnId_Key, ColumnBase::Display_String) {} + KeyColumn() : Column (Columns::ColumnId_Key, ColumnBase::Display_Miscellaneous) {} virtual QVariant get (const Record& record) const { @@ -1510,7 +1510,7 @@ namespace CSMWorld template struct ClassColumn : public Column { - ClassColumn() : Column (Columns::ColumnId_Class, ColumnBase::Display_String) {} + ClassColumn() : Column (Columns::ColumnId_Class, ColumnBase::Display_Class) {} virtual QVariant get (const Record& record) const { @@ -1535,7 +1535,7 @@ namespace CSMWorld template struct PcFactionColumn : public Column { - PcFactionColumn() : Column (Columns::ColumnId_PcFaction, ColumnBase::Display_String) {} + PcFactionColumn() : Column (Columns::ColumnId_PcFaction, ColumnBase::Display_Faction) {} virtual QVariant get (const Record& record) const { From 2e33ab3a13b61e846155e9b8bf889c8725d4f015 Mon Sep 17 00:00:00 2001 From: gus Date: Wed, 12 Feb 2014 11:16:12 +0100 Subject: [PATCH 15/28] 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 16/28] 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) From 62c9c77ddf734b0f4cbb97842d855e776e4fc0f2 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 12 Feb 2014 11:42:19 +0100 Subject: [PATCH 17/28] Compiles now. --- apps/opencs/model/world/columnbase.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index be5a427b80..d0419289fe 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -44,8 +44,6 @@ namespace CSMWorld Display_Race, Display_Sounds, Display_Sound, - Display_Scripts, - Display_Script, Display_Regions, Display_Region, Display_Birthsigns, From c00834a8de88e1042b2f046c9532270dc5da1ddc Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Wed, 12 Feb 2014 13:12:58 +0100 Subject: [PATCH 18/28] added some iostream garbage. --- apps/opencs/model/world/universalid.cpp | 3 ++- apps/opencs/view/world/table.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index e633f4f696..88674c4ce1 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace { @@ -186,7 +187,7 @@ CSMWorld::UniversalId::UniversalId (Type type, const std::string& id) mClass = sIdArg[i].mClass; return; } - + std::cout<setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); drag->exec(); - std::cout << "startdrag"; + std::cout << "startdrag\n"; } } @@ -456,14 +456,14 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event) { //if (event->mimeData()->hasFormat("text/plain")) - std::cout << "accept drag event"; + std::cout << "accept drag event\n"; event->acceptProposedAction(); } void CSVWorld::Table::dropEvent(QDropEvent *event) { - std::cout << "drop"; + std::cout << "drop\n"; event->acceptProposedAction(); QModelIndex index = indexAt(event->pos()); std::cout << index.row(); From 5f3f867a10cde649afd4d749680e12aba180da83 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 10:21:49 +0100 Subject: [PATCH 19/28] Implemented convertEnums function --- apps/opencs/model/world/columnbase.hpp | 22 -- apps/opencs/model/world/columnimp.hpp | 2 +- apps/opencs/model/world/tablemimedata.cpp | 234 +++++++++++++++++++++- apps/opencs/model/world/tablemimedata.hpp | 9 +- apps/opencs/view/world/table.cpp | 6 - 5 files changed, 234 insertions(+), 39 deletions(-) diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index d0419289fe..e689c6a3f5 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -29,30 +29,15 @@ namespace CSMWorld Display_String, //CONCRETE TYPES STARTS HERE - Display_Globals, - Display_Global, - Display_VerificationResults, - Display_Gmsts, - Display_Gmst, - Display_Skills, Display_Skill, - Display_Classes, Display_Class, - Display_Factions, Display_Faction, - Display_Races, Display_Race, - Display_Sounds, Display_Sound, - Display_Regions, Display_Region, - Display_Birthsigns, Display_Birthsign, - Display_Spells, Display_Spell, - Display_Cells, Display_Cell, - Display_Referenceables, Display_Referenceable, Display_Activator, Display_Potion, @@ -74,18 +59,11 @@ namespace CSMWorld Display_Repair, Display_Static, Display_Weapon, - Display_References, Display_Reference, - Display_RegionMap, Display_Filter, - Display_Filters, - Display_Topics, Display_Topic, - Display_Journals, Display_Journal, - Display_TopicInfos, Display_TopicInfo, - Display_JournalInfos, Display_JournalInfo, Display_Scene, //CONCRETE TYPES ENDS HERE diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 0490421092..9e9bedcf87 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -373,7 +373,7 @@ namespace CSMWorld SkillsColumn (int index, bool typePrefix = false, bool major = false) : Column ((typePrefix ? ( major ? Columns::ColumnId_MajorSkill1 : Columns::ColumnId_MinorSkill1) : - Columns::ColumnId_Skill1) + index, ColumnBase::Display_Skills), + Columns::ColumnId_Skill1) + index, ColumnBase::Display_Skill), mIndex (index), mMajor (major) {} diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 0cdcdba3ae..45305431e4 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -1,19 +1,21 @@ #include "tablemimedata.hpp" -#include "universalid.hpp" #include +#include "universalid.hpp" +#include "columnbase.hpp" + CSMWorld::TableMimeData::TableMimeData (UniversalId id) { - mUniversalId.push_back(id); - mObjectsFormats << QString::fromStdString("tabledata/" + id.getTypeName()); + mUniversalId.push_back (id); + mObjectsFormats << QString::fromStdString ("tabledata/" + id.getTypeName()); } -CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id) +CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id) : + mUniversalId (id) { - mUniversalId = id; - for (std::vector::iterator it(mUniversalId.begin()); it != mUniversalId.end(); ++it) + for (std::vector::iterator it (mUniversalId.begin()); it != mUniversalId.end(); ++it) { - mObjectsFormats << QString::fromStdString("tabledata/" + it->getTypeName()); + mObjectsFormats << QString::fromStdString ("tabledata/" + it->getTypeName()); } } @@ -30,11 +32,12 @@ std::string CSMWorld::TableMimeData::getIcon() const { if (mUniversalId.empty()) { - throw("TableMimeData holds no UniversalId"); + throw ("TableMimeData holds no UniversalId"); } std::string tmpIcon; bool firstIteration = true; + for (unsigned i = 0; i < mUniversalId.size(); ++i) { if (firstIteration) @@ -51,10 +54,223 @@ std::string CSMWorld::TableMimeData::getIcon() const tmpIcon = mUniversalId[i].getIcon(); } + return mUniversalId.begin()->getIcon(); //All objects are of the same type; } std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getData() const { return mUniversalId; -} \ No newline at end of file +} + +bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const +{ + for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) + { + if (it->getType() == type) + { + return true; + } + } + + return false; +} + +bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type) +{ + for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) + { + if (it->getType() == convertEnums (type)) + { + return true; + } + } + + return false; +} + +CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::UniversalId::Type type) const +{ + for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) + { + if (it->getType() == type) + { + return *it; + } + } + + throw ("TableMimeData object does not hold object of the seeked type"); +} + +CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnBase::Display type) +{ + for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) + { + if (it->getType() == convertEnums (type)) + { + return *it; + } + } + + throw ("TableMimeData object does not hold object of the seeked type"); +} + +CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) +{ + switch (type) + { + default: + throw ("This type is not handled"); + return CSMWorld::UniversalId::Type_None; + break; + + case CSMWorld::ColumnBase::Display_Race: + return CSMWorld::UniversalId::Type_Race; + break; + + case CSMWorld::ColumnBase::Display_Skill: + return CSMWorld::UniversalId::Type_Skill; + break; + + case CSMWorld::ColumnBase::Display_Class: + return CSMWorld::UniversalId::Type_Class; + break; + + case CSMWorld::ColumnBase::Display_Faction: + return CSMWorld::UniversalId::Type_Faction; + break; + + case CSMWorld::ColumnBase::Display_Sound: + return CSMWorld::UniversalId::Type_Sound; + break; + + case CSMWorld::ColumnBase::Display_Region: + return CSMWorld::UniversalId::Type_Region; + break; + + case CSMWorld::ColumnBase::Display_Birthsign: + return CSMWorld::UniversalId::Type_Birthsign; + break; + + case CSMWorld::ColumnBase::Display_Spell: + return CSMWorld::UniversalId::Type_Spell; + break; + + case CSMWorld::ColumnBase::Display_Cell: + return CSMWorld::UniversalId::Type_Cell; + break; + + case CSMWorld::ColumnBase::Display_Referenceable: + return CSMWorld::UniversalId::Type_Referenceable; + break; + + case CSMWorld::ColumnBase::Display_Activator: + return CSMWorld::UniversalId::Type_Activator; + break; + + case CSMWorld::ColumnBase::Display_Potion: + return CSMWorld::UniversalId::Type_Potion; + break; + + case CSMWorld::ColumnBase::Display_Apparatus: + return CSMWorld::UniversalId::Type_Apparatus; + break; + + case CSMWorld::ColumnBase::Display_Armor: + return CSMWorld::UniversalId::Type_Armor; + break; + + case CSMWorld::ColumnBase::Display_Book: + return CSMWorld::UniversalId::Type_Book; + break; + + case CSMWorld::ColumnBase::Display_Clothing: + return CSMWorld::UniversalId::Type_Clothing; + break; + + case CSMWorld::ColumnBase::Display_Container: + return CSMWorld::UniversalId::Type_Container; + break; + + case CSMWorld::ColumnBase::Display_Creature: + return CSMWorld::UniversalId::Type_Creature; + break; + + case CSMWorld::ColumnBase::Display_Door: + return CSMWorld::UniversalId::Type_Door; + break; + + case CSMWorld::ColumnBase::Display_Ingredient: + return CSMWorld::UniversalId::Type_Ingredient; + break; + + case CSMWorld::ColumnBase::Display_CreatureLevelledList: + return CSMWorld::UniversalId::Type_CreatureLevelledList; + break; + + case CSMWorld::ColumnBase::Display_ItemLevelledList: + return CSMWorld::UniversalId::Type_ItemLevelledList; + break; + + case CSMWorld::ColumnBase::Display_Light: + return CSMWorld::UniversalId::Type_Light; + break; + + case CSMWorld::ColumnBase::Display_Lockpick: + return CSMWorld::UniversalId::Type_Lockpick; + break; + + case CSMWorld::ColumnBase::Display_Miscellaneous: + return CSMWorld::UniversalId::Type_Miscellaneous; + break; + + case CSMWorld::ColumnBase::Display_Npc: + return CSMWorld::UniversalId::Type_Npc; + break; + + case CSMWorld::ColumnBase::Display_Probe: + return CSMWorld::UniversalId::Type_Probe; + break; + + case CSMWorld::ColumnBase::Display_Repair: + return CSMWorld::UniversalId::Type_Repair; + break; + + case CSMWorld::ColumnBase::Display_Static: + return CSMWorld::UniversalId::Type_Static; + break; + + case CSMWorld::ColumnBase::Display_Weapon: + return CSMWorld::UniversalId::Type_Weapon; + break; + + case CSMWorld::ColumnBase::Display_Reference: + return CSMWorld::UniversalId::Type_Reference; + break; + + case CSMWorld::ColumnBase::Display_Filter: + return CSMWorld::UniversalId::Type_Filter; + break; + + case CSMWorld::ColumnBase::Display_Topic: + return CSMWorld::UniversalId::Type_Topic; + break; + + case CSMWorld::ColumnBase::Display_Journal: + return CSMWorld::UniversalId::Type_Journal; + break; + + case CSMWorld::ColumnBase::Display_TopicInfo: + return CSMWorld::UniversalId::Type_TopicInfo; + break; + + case CSMWorld::ColumnBase::Display_JournalInfo: + return CSMWorld::UniversalId::Type_JournalInfo; + break; + + case CSMWorld::ColumnBase::Display_Scene: + return CSMWorld::UniversalId::Type_Scene; + break; + } +} +// kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 7509bd905d..d2e5d3ecb0 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -10,6 +10,7 @@ #include #include "universalid.hpp" +#include "columnbase.hpp" namespace CSMWorld @@ -23,10 +24,16 @@ namespace CSMWorld virtual QStringList formats() const; std::string getIcon() const; std::vector getData() const; + bool holdsType(UniversalId::Type type) const; + bool holdsType(CSMWorld::ColumnBase::Display type); + UniversalId returnMatching(UniversalId::Type type) const; + UniversalId returnMatching(CSMWorld::ColumnBase::Display type); private: std::vector mUniversalId; QStringList mObjectsFormats; + + CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type); }; } -#endif // TABLEMIMEDATA_H \ No newline at end of file +#endif // TABLEMIMEDATA_H diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 7ac5946c85..c39ed34690 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -469,25 +469,19 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) drag->setMimeData (mime); drag->setPixmap (QString::fromStdString (mime->getIcon())); drag->exec(); - std::cout << "startdrag\n"; } } void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event) { - //if (event->mimeData()->hasFormat("text/plain")) - std::cout << "accept drag event\n"; event->acceptProposedAction(); - } void CSVWorld::Table::dropEvent(QDropEvent *event) { - std::cout << "drop\n"; event->acceptProposedAction(); QModelIndex index = indexAt(event->pos()); - std::cout << index.row(); } void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) From 71b2fc1c7024242209022e646b0cfe1ac9be65da Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 10:54:39 +0100 Subject: [PATCH 20/28] Introduced method to access display type. --- apps/opencs/model/world/idtable.cpp | 5 +++++ apps/opencs/model/world/idtable.hpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index bea307aa21..b509f6b9d5 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -188,4 +188,9 @@ void CSMWorld::IdTable::reorderRows (int baseIndex, const std::vector& newO CSMWorld::IdTable::Reordering CSMWorld::IdTable::getReordering() const { return mReordering; +} + +CSMWorld::ColumnBase::Display CSMWorld::IdTable::getColumnDisplay (int index) const +{ + return mIdCollection->getColumn(index).mDisplayType; } \ No newline at end of file diff --git a/apps/opencs/model/world/idtable.hpp b/apps/opencs/model/world/idtable.hpp index 74923867d6..aee49a961e 100644 --- a/apps/opencs/model/world/idtable.hpp +++ b/apps/opencs/model/world/idtable.hpp @@ -11,6 +11,7 @@ namespace CSMWorld { class CollectionBase; + class ColumnsBase; class RecordBase; class IdTable : public QAbstractItemModel @@ -86,6 +87,8 @@ namespace CSMWorld /// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex). Reordering getReordering() const; + + CSMWorld::ColumnBase::Display getColumnDisplay(int index) const; }; } From 09d3c7a44659a4ca466d88124628791227287074 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 13:54:09 +0100 Subject: [PATCH 21/28] Attempt to match types. Does not work at the moment. --- apps/opencs/model/world/columnimp.hpp | 2 +- apps/opencs/model/world/idtable.cpp | 5 ----- apps/opencs/model/world/idtable.hpp | 3 --- apps/opencs/model/world/tablemimedata.cpp | 21 +++++++++++++-------- apps/opencs/model/world/tablemimedata.hpp | 6 +++--- apps/opencs/view/world/table.cpp | 19 ++++++++++++++++--- 6 files changed, 33 insertions(+), 23 deletions(-) diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 9e9bedcf87..def225018f 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -1485,7 +1485,7 @@ namespace CSMWorld template struct RaceColumn : public Column { - RaceColumn() : Column (Columns::ColumnId_Race, ColumnBase::Display_String) {} + RaceColumn() : Column (Columns::ColumnId_Race, ColumnBase::Display_Race) {} virtual QVariant get (const Record& record) const { diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index b509f6b9d5..bea307aa21 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -188,9 +188,4 @@ void CSMWorld::IdTable::reorderRows (int baseIndex, const std::vector& newO CSMWorld::IdTable::Reordering CSMWorld::IdTable::getReordering() const { return mReordering; -} - -CSMWorld::ColumnBase::Display CSMWorld::IdTable::getColumnDisplay (int index) const -{ - return mIdCollection->getColumn(index).mDisplayType; } \ No newline at end of file diff --git a/apps/opencs/model/world/idtable.hpp b/apps/opencs/model/world/idtable.hpp index aee49a961e..74923867d6 100644 --- a/apps/opencs/model/world/idtable.hpp +++ b/apps/opencs/model/world/idtable.hpp @@ -11,7 +11,6 @@ namespace CSMWorld { class CollectionBase; - class ColumnsBase; class RecordBase; class IdTable : public QAbstractItemModel @@ -87,8 +86,6 @@ namespace CSMWorld /// given in \a newOrder (baseIndex+newOrder[0] specifies the new index of row baseIndex). Reordering getReordering() const; - - CSMWorld::ColumnBase::Display getColumnDisplay(int index) const; }; } diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 45305431e4..07c9999b98 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -3,6 +3,7 @@ #include "universalid.hpp" #include "columnbase.hpp" +#include CSMWorld::TableMimeData::TableMimeData (UniversalId id) { @@ -76,8 +77,9 @@ bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const return false; } -bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type) +bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type) const { + std::cout<::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) { if (it->getType() == convertEnums (type)) @@ -102,7 +104,7 @@ CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::Univers throw ("TableMimeData object does not hold object of the seeked type"); } -CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnBase::Display type) +CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnBase::Display type) const { for (std::vector::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) { @@ -115,15 +117,10 @@ CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnB throw ("TableMimeData object does not hold object of the seeked type"); } -CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) +CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::ColumnBase::Display type) const { switch (type) { - default: - throw ("This type is not handled"); - return CSMWorld::UniversalId::Type_None; - break; - case CSMWorld::ColumnBase::Display_Race: return CSMWorld::UniversalId::Type_Race; break; @@ -271,6 +268,14 @@ CSMWorld::UniversalId::Type CSMWorld::TableMimeData::convertEnums (CSMWorld::Col case CSMWorld::ColumnBase::Display_Scene: return CSMWorld::UniversalId::Type_Scene; break; + + case CSMWorld::ColumnBase::Display_Script: + return CSMWorld::UniversalId::Type_Script; + break; + + default: + return CSMWorld::UniversalId::Type_None; + break; } } // kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index d2e5d3ecb0..1b6c5e635e 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -25,15 +25,15 @@ namespace CSMWorld std::string getIcon() const; std::vector getData() const; bool holdsType(UniversalId::Type type) const; - bool holdsType(CSMWorld::ColumnBase::Display type); + bool holdsType(CSMWorld::ColumnBase::Display type) const; UniversalId returnMatching(UniversalId::Type type) const; - UniversalId returnMatching(CSMWorld::ColumnBase::Display type); + UniversalId returnMatching(CSMWorld::ColumnBase::Display type) const; private: std::vector mUniversalId; QStringList mObjectsFormats; - CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type); + CSMWorld::UniversalId::Type convertEnums(CSMWorld::ColumnBase::Display type) const; }; } #endif // TABLEMIMEDATA_H diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index c39ed34690..bfd58fb864 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -17,6 +17,8 @@ #include "recordstatusdelegate.hpp" #include "util.hpp" +#include +#include "../../model/world/tablemimedata.hpp" void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) { @@ -475,13 +477,24 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event) { - event->acceptProposedAction(); +// QModelIndex index = indexAt (event->pos()); + +// if (dynamic_cast (event->mimeData())->holdsType (mModel->getColumnDisplay (index.column()))) +// { + event->acceptProposedAction(); +// } } void CSVWorld::Table::dropEvent(QDropEvent *event) { - event->acceptProposedAction(); - QModelIndex index = indexAt(event->pos()); + QModelIndex index = indexAt (event->pos()); + + CSMWorld::ColumnBase::Display display = static_cast(mModel->headerData(index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + if (dynamic_cast(event->mimeData())->holdsType(display)) + { + event->acceptProposedAction(); + std::cout<<"Dropped/n"; + } else {std::cout<<"Not Dropped\n";} } void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) From 6662560cbca7d892dd774da29f5fcf067222a379 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 15:43:19 +0100 Subject: [PATCH 22/28] new displays for referencable table columns --- apps/opencs/model/world/refidcollection.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index 8a1af35092..89a917139b 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -59,7 +59,7 @@ CSMWorld::RefIdCollection::RefIdCollection() mColumns.push_back (RefIdColumn (Columns::ColumnId_Name, ColumnBase::Display_String)); nameColumns.mName = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Script, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Script, ColumnBase::Display_Script)); nameColumns.mScript = &mColumns.back(); InventoryColumns inventoryColumns (nameColumns); @@ -214,10 +214,10 @@ CSMWorld::RefIdCollection::RefIdCollection() creatureColumns.mFlags.insert (std::make_pair (respawn, ESM::Creature::Respawn)); - mColumns.push_back (RefIdColumn (Columns::ColumnId_OpenSound, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_OpenSound, ColumnBase::Display_Sound)); const RefIdColumn *openSound = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_CloseSound, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_CloseSound, ColumnBase::Display_Sound)); const RefIdColumn *closeSound = &mColumns.back(); LightColumns lightColumns (inventoryColumns); @@ -231,7 +231,7 @@ CSMWorld::RefIdCollection::RefIdCollection() mColumns.push_back (RefIdColumn (Columns::ColumnId_Colour, ColumnBase::Display_Integer)); lightColumns.mColor = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Sound, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Sound, ColumnBase::Display_Sound)); lightColumns.mSound = &mColumns.back(); static const struct @@ -263,13 +263,13 @@ CSMWorld::RefIdCollection::RefIdCollection() NpcColumns npcColumns (actorsColumns); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Race, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Race, ColumnBase::Display_Race)); npcColumns.mRace = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Class, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Class, ColumnBase::Display_Class)); npcColumns.mClass = &mColumns.back(); - mColumns.push_back (RefIdColumn (Columns::ColumnId_Faction, ColumnBase::Display_String)); + mColumns.push_back (RefIdColumn (Columns::ColumnId_Faction, ColumnBase::Display_Faction)); npcColumns.mFaction = &mColumns.back(); mColumns.push_back (RefIdColumn (Columns::Columnid_Hair, ColumnBase::Display_String)); From 2afe3f3e5735bb369826e2ad8542dc661f47ae24 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 19:00:35 +0100 Subject: [PATCH 23/28] Introduced multitype icon. --- apps/opencs/model/world/tablemimedata.cpp | 2 -- apps/opencs/view/world/genericcreator.cpp | 4 ++-- apps/opencs/view/world/table.cpp | 22 ++++++++++++---------- files/opencs/multitype.png | Bin 0 -> 1708 bytes files/opencs/resources.qrc | 1 + 5 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 files/opencs/multitype.png diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 07c9999b98..87bd67ce91 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -3,7 +3,6 @@ #include "universalid.hpp" #include "columnbase.hpp" -#include CSMWorld::TableMimeData::TableMimeData (UniversalId id) { @@ -79,7 +78,6 @@ bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type) const { - std::cout<::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it) { if (it->getType() == convertEnums (type)) diff --git a/apps/opencs/view/world/genericcreator.cpp b/apps/opencs/view/world/genericcreator.cpp index cd7a5fa189..31c216e2cb 100644 --- a/apps/opencs/view/world/genericcreator.cpp +++ b/apps/opencs/view/world/genericcreator.cpp @@ -133,9 +133,9 @@ void CSVWorld::GenericCreator::create() std::string id = getId(); std::auto_ptr command (new CSMWorld::CloneCommand ( dynamic_cast (*mData.getTableModel(mListId)), mClonedId, id, mClonedType)); - + mUndoStack.push(command.release()); - + emit done(); emit requestFocus(id); } else { diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index bfd58fb864..48b5339924 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "../../model/world/data.hpp" #include "../../model/world/commands.hpp" @@ -477,27 +478,28 @@ void CSVWorld::Table::mouseMoveEvent (QMouseEvent* event) void CSVWorld::Table::dragEnterEvent(QDragEnterEvent *event) { -// QModelIndex index = indexAt (event->pos()); - -// if (dynamic_cast (event->mimeData())->holdsType (mModel->getColumnDisplay (index.column()))) -// { event->acceptProposedAction(); -// } } void CSVWorld::Table::dropEvent(QDropEvent *event) { QModelIndex index = indexAt (event->pos()); - CSMWorld::ColumnBase::Display display = static_cast(mModel->headerData(index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + CSMWorld::ColumnBase::Display display = static_cast + (mModel->headerData(index.column(), Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); + if (dynamic_cast(event->mimeData())->holdsType(display)) { - event->acceptProposedAction(); - std::cout<<"Dropped/n"; - } else {std::cout<<"Not Dropped\n";} + const CSMWorld::TableMimeData* mime = dynamic_cast(event->mimeData()); + CSMWorld::UniversalId record(mime->returnMatching(display)); + mUndoStack.push (new CSMWorld::ModifyCommand ( *mModel, + index, + QVariant(record.getId().c_str()) + )); + } } void CSVWorld::Table::dragMoveEvent(QDragMoveEvent *event) { - event->accept(); + event->accept(); } diff --git a/files/opencs/multitype.png b/files/opencs/multitype.png new file mode 100644 index 0000000000000000000000000000000000000000..05676e2de06f52ed563842c0d8d5fe888e771a70 GIT binary patch literal 1708 zcmV;d22=ToP)Ekc{Xm)1$i(h%(W|y+oEr<7?dfwtd#j#`W=aP>d z{Klc7H5<=7{e+;hy*X@yKVZUq?i4 zwO3e@!G|P^!(or}?!k~`kEAO{$F}cz#3sg{3&0P1(d=|*h1f=?&#>o%AFaH$e$%&( zCcpYbeo!8L>X@CoEdYlP$VMk_e_E;SmyycuyWV|&ckAwbwN+#9acONB=QAe%`g85g zH&E@iod6;bn-{oqZ9N@%@ZheOe*Kfv-#ZvS|D|L3b4wE8w?86b)mZh-T_4^*G%~g$ zYpfX~Bq?T~8c|g$Bb#~Y@B^Is*HscP?7XYa=6&BGojHTWoS3(ZU(D&M1C7<|2DaS${;V-n#adHzn{ShMW>FI)Q~}3ey~f9%Ji_B&dzPWK zTZmWA5(YOQJ|NB^;t?Qdi|sq#n|cZRmn6b8Ngv;K--l|2#|kb1pCO@A7*DDgAeu8f z^-tQD|IXUGKfvTGFYw0rPl>*cq_qNsbBH(^!-K(v{_7~09e%z5%qC6DP1+f;|v)6^AAy?KhWT4UYl2y54^&(gnT2X6_$JOAlM zqY+M>_!B2zyF^81@e)xSleP&p2O_Mh3{a5_!=VIBk|G(47@`O&fp%EUwdr>_e(D?# z@7+z_?e2c&A<3S4!P*Pd0b5n8X576Y<({$4xFkh`+!8k(t3f2FBiuD-Sav3;*upcBMI}oUzpb00mn@`^GyL18u-r*S=7+t zfR-MD|0e#6fK%<<`a~om0t!CNqd(3QWSnrDo zP6WmEW+KjEIE)goD41YkD2k~s!)Il&fMy3LB4TD1ZuB09h&Z1i&f_DP12I9=VNSs! z4#Pw+bAY1iu7|DY;g~nX6y}ImPym_jTxUMa^FCmRgcK2nx&pB?K}$ZwT;Yi*Vg{y& z7>Xh0vEp!69?}fM3h|lt1O85n(BpJIfPSKi^GIpb6uei=9EO#Ki_Iy|1me zH!ISwq&|qlK(4k(04E{^fRcUzQbPpI5pg&dzzp$L9K}S6%?yfuXGn>mXT+h!6tf~6 zW_`su?=eHJG^vyc5a%-Bfr=Rp%jshhK?Iz+UZcPSyjmZSi2yoBt%{j|7;~`Uo$qNN zEA8cBUP>nIs1`d-sv}!5F)YSDomea@RV+iHn3maMiii?b3bCnTQnW}ZQ#y89#2Ed= zH0@pq2sidYy1#ohKjVM!-5uA7TfQL}uU_XFlKfBGWrvVStfP3p1E6w$lx?ICV zh*z6j0Zs!`K;HjjA|kE?k(A6VKLv%?InV_nVE+cordT0F3*6fP0000spell.png static.png weapon.png + multitype.png raster/startup/big/create-addon.png raster/startup/big/new-game.png raster/startup/big/edit-content.png From 1bcc6d6918e323834552d68c8e4023908e4566d2 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 19:14:17 +0100 Subject: [PATCH 24/28] using new icon. --- apps/opencs/model/world/tablemimedata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/opencs/model/world/tablemimedata.cpp b/apps/opencs/model/world/tablemimedata.cpp index 87bd67ce91..b0cf0abcc2 100644 --- a/apps/opencs/model/world/tablemimedata.cpp +++ b/apps/opencs/model/world/tablemimedata.cpp @@ -49,7 +49,7 @@ std::string CSMWorld::TableMimeData::getIcon() const if (tmpIcon != mUniversalId[i].getIcon()) { - return ""; //should return multiple types icon, but at the moment we don't have one + return ":/multitype.png"; //icon stolen from gnome } tmpIcon = mUniversalId[i].getIcon(); From 40cc108e54e09ddee979c9296637c592d6c800a7 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Thu, 13 Feb 2014 20:19:51 +0100 Subject: [PATCH 25/28] drag and drop works. --- apps/opencs/view/world/table.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 48b5339924..4d5554d863 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -490,12 +490,11 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) if (dynamic_cast(event->mimeData())->holdsType(display)) { - const CSMWorld::TableMimeData* mime = dynamic_cast(event->mimeData()); - CSMWorld::UniversalId record(mime->returnMatching(display)); - mUndoStack.push (new CSMWorld::ModifyCommand ( *mModel, - index, - QVariant(record.getId().c_str()) - )); + const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + CSMWorld::UniversalId record (mime->returnMatching (display)); + std::auto_ptr command (new CSMWorld::ModifyCommand + (*mProxyModel, index, QVariant (QString::fromStdString (record.getId())))); + mUndoStack.push (command.release()); } } From ace42520138b4d8280fab3a0f421b4d8d806bf57 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 14 Feb 2014 12:46:15 +0100 Subject: [PATCH 26/28] nicer formatting --- apps/opencs/view/world/table.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 4d5554d863..32d692be64 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -490,10 +490,14 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) if (dynamic_cast(event->mimeData())->holdsType(display)) { - const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + const CSMWorld::TableMimeData* mime = dynamic_cast + (event->mimeData()); + CSMWorld::UniversalId record (mime->returnMatching (display)); + std::auto_ptr command (new CSMWorld::ModifyCommand (*mProxyModel, index, QVariant (QString::fromStdString (record.getId())))); + mUndoStack.push (command.release()); } } From ae418f2538435484f852da126baaf21c85667a1d Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 14 Feb 2014 12:46:15 +0100 Subject: [PATCH 27/28] nicer formatting --- apps/opencs/view/world/table.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 4d5554d863..7819a75c08 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -410,10 +410,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; } } } @@ -490,10 +490,14 @@ void CSVWorld::Table::dropEvent(QDropEvent *event) if (dynamic_cast(event->mimeData())->holdsType(display)) { - const CSMWorld::TableMimeData* mime = dynamic_cast (event->mimeData()); + const CSMWorld::TableMimeData* mime = dynamic_cast + (event->mimeData()); + CSMWorld::UniversalId record (mime->returnMatching (display)); + std::auto_ptr command (new CSMWorld::ModifyCommand (*mProxyModel, index, QVariant (QString::fromStdString (record.getId())))); + mUndoStack.push (command.release()); } } From aafde926d34008e0413c2c16178f4c144b8c7f73 Mon Sep 17 00:00:00 2001 From: Marek Kochanowicz Date: Fri, 14 Feb 2014 14:04:36 +0100 Subject: [PATCH 28/28] Documentation, corrections. --- apps/opencs/model/world/tablemimedata.hpp | 10 ++++++++-- apps/opencs/model/world/universalid.cpp | 1 - apps/opencs/view/world/table.cpp | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/opencs/model/world/tablemimedata.hpp b/apps/opencs/model/world/tablemimedata.hpp index 1b6c5e635e..2829a07547 100644 --- a/apps/opencs/model/world/tablemimedata.hpp +++ b/apps/opencs/model/world/tablemimedata.hpp @@ -1,5 +1,3 @@ -/*This class provides way to construct mimedata object holding the reference to the -* universalid. universalid is used in the majority of the tables to store type, id, argument types*/ #ifndef TABLEMIMEDATA_H #define TABLEMIMEDATA_H @@ -15,6 +13,14 @@ namespace CSMWorld { + +/// \brief Subclass of QmimeData, augmented to contain and transport UniversalIds. +/// +/// This class provides way to construct mimedata object holding the universalid copy +/// Universalid is used in the majority of the tables to store type, id, argument types. +/// This way universalid grants a way to retrive record from the concrete table. +/// Please note, that tablemimedata object can hold multiple universalIds in the vector. + class TableMimeData : public QMimeData { public: diff --git a/apps/opencs/model/world/universalid.cpp b/apps/opencs/model/world/universalid.cpp index 88674c4ce1..8301ebfd36 100644 --- a/apps/opencs/model/world/universalid.cpp +++ b/apps/opencs/model/world/universalid.cpp @@ -187,7 +187,6 @@ CSMWorld::UniversalId::UniversalId (Type type, const std::string& id) mClass = sIdArg[i].mClass; return; } - std::cout< #include #include +#include #include "../../model/world/data.hpp" #include "../../model/world/commands.hpp" @@ -15,11 +16,10 @@ #include "../../model/world/record.hpp" #include "../../model/world/columns.hpp" #include "../../model/world/tablemimedata.hpp" +#include "../../model/world/tablemimedata.hpp" #include "recordstatusdelegate.hpp" #include "util.hpp" -#include -#include "../../model/world/tablemimedata.hpp" void CSVWorld::Table::contextMenuEvent (QContextMenuEvent *event) {