2014-02-01 18:06:41 +00:00
|
|
|
#include "tablemimedata.hpp"
|
2014-02-04 08:13:40 +00:00
|
|
|
#include "universalid.hpp"
|
2014-02-04 17:30:47 +00:00
|
|
|
#include <string>
|
2014-02-04 08:13:40 +00:00
|
|
|
|
2014-02-04 17:30:47 +00:00
|
|
|
CSMWorld::TableMimeData::TableMimeData (UniversalId id)
|
2014-02-04 08:13:40 +00:00
|
|
|
{
|
2014-02-04 17:30:47 +00:00
|
|
|
mUniversalId.push_back(id);
|
2014-02-05 10:24:33 +00:00
|
|
|
mObjectsFormats << QString::fromStdString("tabledata/" + id.getTypeName());
|
2014-02-04 17:30:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSMWorld::TableMimeData::TableMimeData (std::vector< CSMWorld::UniversalId >& id)
|
|
|
|
{
|
|
|
|
mUniversalId = id;
|
|
|
|
for (std::vector<UniversalId>::iterator it(mUniversalId.begin()); it != mUniversalId.end(); ++it)
|
|
|
|
{
|
2014-02-05 10:24:33 +00:00
|
|
|
mObjectsFormats << QString::fromStdString("tabledata/" + it->getTypeName());
|
2014-02-04 17:30:47 +00:00
|
|
|
}
|
2014-02-04 08:13:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QStringList CSMWorld::TableMimeData::formats() const
|
|
|
|
{
|
2014-02-04 17:30:47 +00:00
|
|
|
return mObjectsFormats;
|
2014-02-04 08:13:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CSMWorld::TableMimeData::~TableMimeData()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-04 17:30:47 +00:00
|
|
|
std::string CSMWorld::TableMimeData::getIcon() const
|
2014-02-04 08:13:40 +00:00
|
|
|
{
|
2014-02-04 17:30:47 +00:00
|
|
|
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;
|
|
|
|
}
|
2014-02-04 18:42:52 +00:00
|
|
|
|
|
|
|
std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getData() const
|
|
|
|
{
|
|
|
|
return mUniversalId;
|
|
|
|
}
|