17 QList<QVariant> rootData;
19 rootData <<
"Station Name"
36 int row,
int column,
const QModelIndex&
parent )
const
38 if (!hasIndex(row, column,
parent))
57 QModelIndex newIndex = createIndex(row, column, childItem);
59 BaseItem* item = childItem->getItem();
77 QString& listName)
const
83 listName = parentItem->
data(0).toString();
84 return treeItem->getStation();
92 std::size_t nLists =
_lists.size();
93 for (std::size_t i = 0; i < nLists; i++)
95 if (name ==
_lists[i]->
data(0).toString().toStdString())
104 std::size_t
const id,
105 std::string
const& item_name)
107 auto const stn_list = find_if(
111 { return (stn_vec_name == item->data(0).toString().toStdString()); });
113 if (stn_list ==
_lists.end() ||
114 id >=
static_cast<std::size_t
>((*stn_list)->childCount()))
119 item->
setData(0, QString::fromStdString(item_name));
129 QString listName,
const std::vector<GeoLib::Point*>* stations)
133 QList<QVariant> grpName;
134 if (listName.compare(
"") ==
138 listName.append(QString::number(
rowCount() + 1));
140 grpName << listName <<
""
147 int vectorSize = stations->size();
149 for (
int i = 0; i < vectorSize; i++)
152 stn << QString::fromStdString(
154 << QString::number((*(*stations)[i])[0],
'f')
155 << QString::number((*(*stations)[i])[1],
'f')
156 << QString::number((*(*stations)[i])[2],
'f');
160 group->appendChild(child);
163 qDebug() <<
"List" << listName <<
"loaded, " << stations->size()
179 for (std::size_t i = 0; i <
_lists.size(); i++)
199 if (name == list->data(0).toString().toStdString())
A BaseItem contains additional Information about a subtree in the StationTreeModel.
vtkPolyDataAlgorithm * vtkSource() const
Returns the Vtk polydata source object.
void setModelIndex(QModelIndex index)
Sets the model index.
A Station (observation site) is basically a Point with some additional information.
A TreeItem containing some additional information used in the StationModel.
void addStationList(QString listName, const std::vector< GeoLib::Point * > *stations)
void setNameForItem(const std::string &stn_vec_name, std::size_t id, std::string const &item_name)
~StationTreeModel() override
void removeStationList(QModelIndex index)
StationTreeModel(QObject *parent=nullptr)
std::vector< ModelTreeItem * > _lists
vtkPolyDataAlgorithm * vtkSource(const std::string &name) const
GeoLib::Station * stationFromIndex(const QModelIndex &index, QString &listName) const
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Objects nodes for the TreeModel.
TreeItem * parentItem() const
TreeItem * child(int row) const
virtual bool setData(int column, const QVariant &value)
virtual QVariant data(int column) const
bool removeRows(int position, int count, const QModelIndex &parent) override
TreeItem * getItem(const QModelIndex &index) const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
QModelIndex parent(const QModelIndex &index) const override
TreeModel(QObject *parent=nullptr)