forked from mirror/openmw-tes3mp
Tablemimedata able to handle vector of objects and return icon.
parent
423b2906be
commit
3439940a8e
@ -1,22 +1,64 @@
|
||||
#include "tablemimedata.hpp"
|
||||
#include "universalid.hpp"
|
||||
#include <string>
|
||||
|
||||
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<UniversalId>::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
|
||||
{
|
||||
if (mUniversalId.empty())
|
||||
{
|
||||
throw("TableMimeData holds no UniversalId");
|
||||
}
|
||||
return mUniversalId[index];
|
||||
}
|
||||
|
||||
std::string CSMWorld::TableMimeData::getIcon() const
|
||||
{
|
||||
return mUniversalId;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue