static unsigned short terrainId(const QString &name, const Tileset &tileset) { for (Terrain *terrain : tileset.terrains()) if (terrain->name() == name) return terrain->id(); return 0xFF; }
static bool hasTerrain(const Tileset &tileset, const QString &name) { for (Terrain *terrain : tileset.terrains()) if (terrain->name() == name) return true; return false; }
QModelIndex TerrainModel::index(Terrain *terrain, int column) const { Tileset *tileset = terrain->tileset(); int row = tileset->terrains().indexOf(terrain); return createIndex(row, column, tileset); }
QModelIndex TilesetTerrainModel::index(Terrain *terrain) const { Tileset *tileset = terrain->tileset(); int row = tileset->terrains().indexOf(terrain); return index(row, 0); }