added CellId role to RegionMap model

actorid
Marc Zinnschlag 11 years ago
parent 2f63eb7ca4
commit decd4270d9

@ -384,15 +384,22 @@ QVariant CSMWorld::RegionMap::data (const QModelIndex& index, int role) const
return QString::fromUtf8 (Misc::StringUtils::lowerCase (cell->second.mRegion).c_str());
}
if (role==Role_CellId)
{
CellCoordinates cellIndex = getIndex (index);
std::ostringstream stream;
stream << "#" << cellIndex.getX() << " " << cellIndex.getY();
return QString::fromUtf8 (stream.str().c_str());
}
return QVariant();
}
Qt::ItemFlags CSMWorld::RegionMap::flags (const QModelIndex& index) const
{
if (mMap.find (getIndex (index))!=mMap.end())
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
return 0;
return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
}
void CSMWorld::RegionMap::regionsAboutToBeRemoved (const QModelIndex& parent, int start, int end)

@ -26,7 +26,8 @@ namespace CSMWorld
enum Role
{
Role_Region = Qt::UserRole
Role_Region = Qt::UserRole,
Role_CellId = Qt::UserRole+1
};
private:
@ -93,6 +94,8 @@ namespace CSMWorld
virtual int columnCount (const QModelIndex& parent = QModelIndex()) const;
virtual QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const;
///< \note Calling this function with role==Role_CellId may return the ID of a cell
/// that does not exist.
virtual Qt::ItemFlags flags (const QModelIndex& index) const;

Loading…
Cancel
Save