Пример #1
0
/// <summary>
/// Returns what index the specified item would be if the entire scene was
/// represented in a linear list.
/// </summary>
int Scene::listIndexOfItem(SceneItem *item) const
{
	int index = 0;
	for(int i = 0; i < m_groups.count(); i++) {
		const GroupInfo &group = m_groups.at(i);
		if(item == group.sceneItem)
			return index;
		index++;
		LayerList layers = group.group->getLayers();
		for(int j = 0; j < layers.count(); j++) {
			if(item == itemForLayer(layers.at(j)))
				return index;
			index++;
		}
	}
	return -1; // Not found
}
Пример #2
0
/// <summary>
/// Returns the item at the specified index if the entire scene was represented
/// in a linear list.
/// </summary>
SceneItem *Scene::itemAtListIndex(int index) const
{
	int item = 0;
	for(int i = 0; i < m_groups.count(); i++) {
		const GroupInfo &group = m_groups.at(i);
		if(item == index)
			return group.sceneItem;
		item++;
		LayerList layers = group.group->getLayers();
		for(int j = 0; j < layers.count(); j++) {
			Layer *layer = layers.at(j);
			if(item == index)
				return itemForLayer(layer);
			item++;
		}
	}
	return NULL; // Not found
}