Use C++'s std::find_if algorithm to simplify code of RoomScene::mousePressEvent