Esempio n. 1
0
/**
 * Returns the Station-Object of the ModelTreeItem with the given index and the name of the list this station belongs to.
 * \param index Index of the requested item
 * \param listName Here, the method will put the name of the list this station belongs to.
 * \return The station object associated with the tree item
 */
GeoLib::Station* StationTreeModel::stationFromIndex( const QModelIndex& index,
                                                     QString &listName ) const
{
	if (index.isValid())
	{
		ModelTreeItem* treeItem = static_cast<ModelTreeItem*>(index.internalPointer());
		TreeItem* parentItem = treeItem->parentItem();
		listName = parentItem->data(0).toString();
		return treeItem->getStation();
	}
	else
		return nullptr;
}