diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 9e9bedcf8..def225018 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 b509f6b9d..bea307aa2 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 aee49a961..74923867d 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 45305431e..07c9999b9 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 d2e5d3ecb..1b6c5e635 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 c39ed3469..bfd58fb86 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)