/** * Inserts a subtree under _rootItem. * \param listName Name of the new subtree. If no name is given a default name is assigned. * \param stations The list with stations to be added as children of that subtree */ void StationTreeModel::addStationList(QString listName, const std::vector<GeoLib::Point*>* stations) { QList<QVariant> grpName; if (listName.compare("") == 0) // if no name is given a default name is assigned { listName = "List"; listName.append(QString::number(rowCount() + 1)); } grpName << listName << "" << "" << ""; ModelTreeItem* group = new ModelTreeItem(grpName, _rootItem, new BaseItem(listName, stations)); _lists.push_back(group); _rootItem->appendChild(group); int vectorSize = stations->size(); for (int i = 0; i < vectorSize; i++) { QList<QVariant> stn; stn << QString::fromStdString(static_cast<GeoLib::Station*>((*stations)[i])->getName()) << QString::number((*(*stations)[i])[0],'f') << QString::number((*(*stations)[i])[1],'f') << QString::number((*(*stations)[i])[2],'f'); ModelTreeItem* child = new ModelTreeItem(stn, group); child->setStation(static_cast<GeoLib::Station*>((*stations)[i])); group->appendChild(child); } qDebug() << "List" << listName << "loaded, " << stations->size() << "items added."; reset(); }