JSONTreeModel.h
Go to the documentation of this file.
1#pragma once
2
3#include <QAbstractItemModel>
4
5#include <SimoxUtility/json/json.hpp>
6
7namespace armarx
8{
9
10 class JSONTreeModel : public QAbstractItemModel
11 {
12 public:
13 void setRoot(nlohmann::json const& root);
14
15 // QAbstractItemModel interface
16 QModelIndex index(int row, int column, const QModelIndex& parent) const override;
17 QModelIndex parent(const QModelIndex& index) const override;
18 int rowCount(const QModelIndex& parent) const override;
19 int columnCount(const QModelIndex& parent) const override;
20 QVariant data(const QModelIndex& index, int role) const override;
21 QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
22
23 private:
24 nlohmann::json* refFrom(QModelIndex const& index) const;
25
26 private:
27 mutable std::map<nlohmann::json*, int> rows;
28 mutable std::map<nlohmann::json*, nlohmann::json*> parents;
29 mutable std::map<nlohmann::json*, std::string> names;
30 mutable nlohmann::json root;
31 };
32
33} // namespace armarx
uint8_t index
int rowCount(const QModelIndex &parent) const override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
QModelIndex index(int row, int column, const QModelIndex &parent) const override
void setRoot(nlohmann::json const &root)
int columnCount(const QModelIndex &parent) const override
QModelIndex parent(const QModelIndex &index) const override
QVariant data(const QModelIndex &index, int role) const override
This file offers overloads of toIce() and fromIce() functions for STL container types.