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