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