mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-23 10:09:43 +00:00
better fix
This commit is contained in:
parent
e3a9daf921
commit
2a26ff2299
3 changed files with 131 additions and 19 deletions
|
@ -64,55 +64,138 @@ std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getData() const
|
|||
return mUniversalId;
|
||||
}
|
||||
|
||||
bool CSMWorld::TableMimeData::isReferencable(CSMWorld::ColumnBase::Display type) const
|
||||
{
|
||||
return ( type == CSMWorld::ColumnBase::Display_Activator
|
||||
|| type == CSMWorld::ColumnBase::Display_Potion
|
||||
|| type == CSMWorld::ColumnBase::Display_Apparatus
|
||||
|| type == CSMWorld::ColumnBase::Display_Armor
|
||||
|| type == CSMWorld::ColumnBase::Display_Book
|
||||
|| type == CSMWorld::ColumnBase::Display_Clothing
|
||||
|| type == CSMWorld::ColumnBase::Display_Container
|
||||
|| type == CSMWorld::ColumnBase::Display_Creature
|
||||
|| type == CSMWorld::ColumnBase::Display_Door
|
||||
|| type == CSMWorld::ColumnBase::Display_Ingredient
|
||||
|| type == CSMWorld::ColumnBase::Display_CreatureLevelledList
|
||||
|| type == CSMWorld::ColumnBase::Display_ItemLevelledList
|
||||
|| type == CSMWorld::ColumnBase::Display_Light
|
||||
|| type == CSMWorld::ColumnBase::Display_Lockpick
|
||||
|| type == CSMWorld::ColumnBase::Display_Miscellaneous
|
||||
|| type == CSMWorld::ColumnBase::Display_Npc
|
||||
|| type == CSMWorld::ColumnBase::Display_Probe
|
||||
|| type == CSMWorld::ColumnBase::Display_Repair
|
||||
|| type == CSMWorld::ColumnBase::Display_Static
|
||||
|| type == CSMWorld::ColumnBase::Display_Weapon);
|
||||
}
|
||||
bool CSMWorld::TableMimeData::isReferencable(CSMWorld::UniversalId::Type type) const
|
||||
{
|
||||
return ( type == CSMWorld::UniversalId::Type_Activator
|
||||
|| type == CSMWorld::UniversalId::Type_Potion
|
||||
|| type == CSMWorld::UniversalId::Type_Apparatus
|
||||
|| type == CSMWorld::UniversalId::Type_Armor
|
||||
|| type == CSMWorld::UniversalId::Type_Book
|
||||
|| type == CSMWorld::UniversalId::Type_Clothing
|
||||
|| type == CSMWorld::UniversalId::Type_Container
|
||||
|| type == CSMWorld::UniversalId::Type_Creature
|
||||
|| type == CSMWorld::UniversalId::Type_Door
|
||||
|| type == CSMWorld::UniversalId::Type_Ingredient
|
||||
|| type == CSMWorld::UniversalId::Type_CreatureLevelledList
|
||||
|| type == CSMWorld::UniversalId::Type_ItemLevelledList
|
||||
|| type == CSMWorld::UniversalId::Type_Light
|
||||
|| type == CSMWorld::UniversalId::Type_Lockpick
|
||||
|| type == CSMWorld::UniversalId::Type_Miscellaneous
|
||||
|| type == CSMWorld::UniversalId::Type_Npc
|
||||
|| type == CSMWorld::UniversalId::Type_Probe
|
||||
|| type == CSMWorld::UniversalId::Type_Repair
|
||||
|| type == CSMWorld::UniversalId::Type_Static
|
||||
|| type == CSMWorld::UniversalId::Type_Weapon);
|
||||
}
|
||||
|
||||
bool CSMWorld::TableMimeData::holdsType (CSMWorld::UniversalId::Type type) const
|
||||
{
|
||||
bool referencable = (type == CSMWorld::UniversalId::Type_Referenceable);
|
||||
for (std::vector<UniversalId>::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it)
|
||||
{
|
||||
if (referencable)
|
||||
{
|
||||
if (isReferencable(it->getType()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (it->getType() == type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSMWorld::TableMimeData::holdsType (CSMWorld::ColumnBase::Display type) const
|
||||
{
|
||||
bool referencable = (type == CSMWorld::ColumnBase::Display_Referenceable);
|
||||
for (std::vector<UniversalId>::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it)
|
||||
{
|
||||
if (referencable)
|
||||
{
|
||||
if (isReferencable(it->getType()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (it->getType() == convertEnums (type))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::UniversalId::Type type) const
|
||||
{
|
||||
bool referencable = (type == CSMWorld::UniversalId::Type_Referenceable);
|
||||
for (std::vector<UniversalId>::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it)
|
||||
{
|
||||
if (referencable)
|
||||
{
|
||||
if (isReferencable(it->getType()))
|
||||
{
|
||||
return *it;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (it->getType() == type)
|
||||
{
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw ("TableMimeData object does not hold object of the seeked type");
|
||||
}
|
||||
|
||||
CSMWorld::UniversalId CSMWorld::TableMimeData::returnMatching (CSMWorld::ColumnBase::Display type) const
|
||||
{
|
||||
bool referencable = (type == CSMWorld::ColumnBase::Display_Referenceable);
|
||||
for (std::vector<UniversalId>::const_iterator it = mUniversalId.begin(); it != mUniversalId.end(); ++it)
|
||||
{
|
||||
if (referencable)
|
||||
{
|
||||
if (isReferencable(it->getType()))
|
||||
{
|
||||
return *it;
|
||||
}
|
||||
} else {
|
||||
if (it->getType() == convertEnums (type))
|
||||
{
|
||||
return *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw ("TableMimeData object does not hold object of the seeked type");
|
||||
}
|
||||
|
|
|
@ -27,6 +27,9 @@ namespace CSMWorld
|
|||
|
||||
class TableMimeData : public QMimeData
|
||||
{
|
||||
std::vector<UniversalId> mUniversalId;
|
||||
QStringList mObjectsFormats;
|
||||
const CSMDoc::Document& mDocument;
|
||||
public:
|
||||
TableMimeData(UniversalId id, const CSMDoc::Document& document);
|
||||
|
||||
|
@ -56,9 +59,8 @@ namespace CSMWorld
|
|||
static CSMWorld::ColumnBase::Display convertEnums(CSMWorld::UniversalId::Type type);
|
||||
|
||||
private:
|
||||
std::vector<UniversalId> mUniversalId;
|
||||
QStringList mObjectsFormats;
|
||||
const CSMDoc::Document& mDocument;
|
||||
bool isReferencable(CSMWorld::UniversalId::Type type) const;
|
||||
bool isReferencable(CSMWorld::ColumnBase::Display type) const;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -129,7 +129,34 @@ void CSVWorld::DialogueDelegateDispatcherProxy::tableMimeDataDropped(const std::
|
|||
}
|
||||
for (unsigned i = 0; i < data.size(); ++i)
|
||||
{
|
||||
if (mDisplay == CSMWorld::TableMimeData::convertEnums(data[i].getType()))
|
||||
CSMWorld::UniversalId::Type type = data[i].getType();
|
||||
if (mDisplay == CSMWorld::ColumnBase::Display_Referenceable)
|
||||
{
|
||||
if ( type == CSMWorld::UniversalId::Type_Activator
|
||||
|| type == CSMWorld::UniversalId::Type_Potion
|
||||
|| type == CSMWorld::UniversalId::Type_Apparatus
|
||||
|| type == CSMWorld::UniversalId::Type_Armor
|
||||
|| type == CSMWorld::UniversalId::Type_Book
|
||||
|| type == CSMWorld::UniversalId::Type_Clothing
|
||||
|| type == CSMWorld::UniversalId::Type_Container
|
||||
|| type == CSMWorld::UniversalId::Type_Creature
|
||||
|| type == CSMWorld::UniversalId::Type_Door
|
||||
|| type == CSMWorld::UniversalId::Type_Ingredient
|
||||
|| type == CSMWorld::UniversalId::Type_CreatureLevelledList
|
||||
|| type == CSMWorld::UniversalId::Type_ItemLevelledList
|
||||
|| type == CSMWorld::UniversalId::Type_Light
|
||||
|| type == CSMWorld::UniversalId::Type_Lockpick
|
||||
|| type == CSMWorld::UniversalId::Type_Miscellaneous
|
||||
|| type == CSMWorld::UniversalId::Type_Npc
|
||||
|| type == CSMWorld::UniversalId::Type_Probe
|
||||
|| type == CSMWorld::UniversalId::Type_Repair
|
||||
|| type == CSMWorld::UniversalId::Type_Static
|
||||
|| type == CSMWorld::UniversalId::Type_Weapon)
|
||||
{
|
||||
type = CSMWorld::UniversalId::Type_Referenceable;
|
||||
}
|
||||
}
|
||||
if (mDisplay == CSMWorld::TableMimeData::convertEnums(type))
|
||||
{
|
||||
emit tableMimeDataDropped(mEditor, mIndexWrapper->mIndex, data[i], document);
|
||||
emit editorDataCommited(mEditor, mIndexWrapper->mIndex, mDisplay);
|
||||
|
|
Loading…
Reference in a new issue