For bug #1710. Change the ID type of mime data for filterbox drop events to Referenceable rather than using the ID's native type.

This commit is contained in:
cc9cii 2014-09-07 06:29:09 +10:00
parent e315a72582
commit 4a8fe39b2c
3 changed files with 25 additions and 3 deletions

View file

@ -68,6 +68,26 @@ std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getData() const
return mUniversalId; return mUniversalId;
} }
std::vector< CSMWorld::UniversalId > CSMWorld::TableMimeData::getRefTypeData() const
{
std::vector<CSMWorld::UniversalId> ref_data;
std::vector<CSMWorld::UniversalId>::const_iterator it = mUniversalId.begin();
for(; it != mUniversalId.end(); ++it)
{
if(isReferencable(it->getType()))
{
// change the type
ref_data.push_back(CSMWorld::UniversalId(
CSMWorld::UniversalId::Type_Referenceable, it->getId()));
}
else
ref_data.push_back(*it);
}
return ref_data;
}
bool CSMWorld::TableMimeData::isReferencable(CSMWorld::ColumnBase::Display type) const bool CSMWorld::TableMimeData::isReferencable(CSMWorld::ColumnBase::Display type) const
{ {
return ( type == CSMWorld::ColumnBase::Display_Activator return ( type == CSMWorld::ColumnBase::Display_Activator
@ -222,7 +242,6 @@ namespace
{ CSMWorld::UniversalId::Type_Race, CSMWorld::ColumnBase::Display_Race }, { CSMWorld::UniversalId::Type_Race, CSMWorld::ColumnBase::Display_Race },
{ CSMWorld::UniversalId::Type_Skill, CSMWorld::ColumnBase::Display_Skill }, { CSMWorld::UniversalId::Type_Skill, CSMWorld::ColumnBase::Display_Skill },
{ CSMWorld::UniversalId::Type_Class, CSMWorld::ColumnBase::Display_Class }, { CSMWorld::UniversalId::Type_Class, CSMWorld::ColumnBase::Display_Class },
{ CSMWorld::UniversalId::Type_Class, CSMWorld::ColumnBase::Display_Class },
{ CSMWorld::UniversalId::Type_Faction, CSMWorld::ColumnBase::Display_Faction }, { CSMWorld::UniversalId::Type_Faction, CSMWorld::ColumnBase::Display_Faction },
{ CSMWorld::UniversalId::Type_Sound, CSMWorld::ColumnBase::Display_Sound }, { CSMWorld::UniversalId::Type_Sound, CSMWorld::ColumnBase::Display_Sound },
{ CSMWorld::UniversalId::Type_Region, CSMWorld::ColumnBase::Display_Region }, { CSMWorld::UniversalId::Type_Region, CSMWorld::ColumnBase::Display_Region },

View file

@ -43,6 +43,9 @@ namespace CSMWorld
std::vector<UniversalId> getData() const; std::vector<UniversalId> getData() const;
// change Id type to Type_Referenceable where possible
std::vector<UniversalId> getRefTypeData() const;
bool holdsType(UniversalId::Type type) const; bool holdsType(UniversalId::Type type) const;
bool holdsType(CSMWorld::ColumnBase::Display type) const; bool holdsType(CSMWorld::ColumnBase::Display type) const;
@ -65,4 +68,4 @@ namespace CSMWorld
}; };
} }
#endif // TABLEMIMEDATA_H #endif // TABLEMIMEDATA_H

View file

@ -39,7 +39,7 @@ void CSVFilter::FilterBox::dropEvent (QDropEvent* event)
if (!mime) // May happen when non-records (e.g. plain text) are dragged and dropped if (!mime) // May happen when non-records (e.g. plain text) are dragged and dropped
return; return;
std::vector<CSMWorld::UniversalId> data = mime->getData(); std::vector<CSMWorld::UniversalId> data = mime->getRefTypeData();
emit recordDropped(data, event->proposedAction()); emit recordDropped(data, event->proposedAction());
} }