mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 22:53:50 +00:00
Tablemimedata able to handle vector of objects and return icon.
This commit is contained in:
parent
423b2906be
commit
3439940a8e
2 changed files with 56 additions and 12 deletions
|
@ -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
|
||||
{
|
||||
return mUniversalId;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -4,27 +4,29 @@
|
|||
#ifndef TABLEMIMEDATA_H
|
||||
#define TABLEMIMEDATA_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <qt4/QtCore/QMimeData>
|
||||
#include <QStringList>
|
||||
|
||||
#include "universalid.hpp"
|
||||
|
||||
class QStringList;
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
class UniversalId;
|
||||
class TableMimeData : public QMimeData
|
||||
{
|
||||
public:
|
||||
TableMimeData(UniversalId id);
|
||||
TableMimeData(std::vector<UniversalId>& 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<UniversalId> mUniversalId;
|
||||
QStringList mObjectsFormats;
|
||||
};
|
||||
}
|
||||
#endif // TABLEMIMEDATA_H
|
||||
|
|
Loading…
Reference in a new issue