28 QList<QVariant> rootData;
30 rootData <<
"Station Name"
47 int row,
int column,
const QModelIndex& parent )
const
49 if (!hasIndex(row, column,
parent))
68 QModelIndex newIndex = createIndex(row, column, childItem);
70 BaseItem* item = childItem->getItem();
88 QString& listName)
const
94 listName = parentItem->
data(0).toString();
95 return treeItem->getStation();
103 std::size_t nLists =
_lists.size();
104 for (std::size_t i = 0; i < nLists; i++)
106 if (name ==
_lists[i]->
data(0).toString().toStdString())
115 std::size_t
const id,
116 std::string
const& item_name)
118 auto const stn_list = find_if(
122 { return (stn_vec_name == item->data(0).toString().toStdString()); });
124 if (stn_list ==
_lists.end() ||
125 id >=
static_cast<std::size_t
>((*stn_list)->childCount()))
130 item->
setData(0, QString::fromStdString(item_name));
140 QString listName,
const std::vector<GeoLib::Point*>* stations)
144 QList<QVariant> grpName;
145 if (listName.compare(
"") ==
149 listName.append(QString::number(
rowCount() + 1));
151 grpName << listName <<
""
158 int vectorSize = stations->size();
160 for (
int i = 0; i < vectorSize; i++)
163 stn << QString::fromStdString(
165 << QString::number((*(*stations)[i])[0],
'f')
166 << QString::number((*(*stations)[i])[1],
'f')
167 << QString::number((*(*stations)[i])[2],
'f');
171 group->appendChild(child);
174 qDebug() <<
"List" << listName <<
"loaded, " << stations->size()
190 for (std::size_t i = 0; i <
_lists.size(); i++)
210 if (name == list->data(0).toString().toStdString())
Definition of the BaseItem class.
Definition of the OGSError class.
Definition of the StationTreeModel class.
Definition of the Station class.
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.
void appendChild(TreeItem *item)
TreeItem * parentItem() const
TreeItem * child(int row) const
virtual bool setData(int column, const QVariant &value)
virtual QVariant data(int column) const
A hierarchical model for a tree implemented as a double-linked list.
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