JSONTreeModel.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <QAbstractItemModel>
4 
5 #include <SimoxUtility/json/json.hpp>
6 
7 namespace 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
GfxTL::Orientation
ScalarT Orientation(const VectorXD< 2, ScalarT > &p1, const VectorXD< 2, ScalarT > &p2, const VectorXD< 2, ScalarT > &c)
Definition: Orientation.h:10
armarx::JSONTreeModel::columnCount
int columnCount(const QModelIndex &parent) const override
Definition: JSONTreeModel.cpp:101
armarx::JSONTreeModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Definition: JSONTreeModel.cpp:158
armarx::JSONTreeModel::index
QModelIndex index(int row, int column, const QModelIndex &parent) const override
Definition: JSONTreeModel.cpp:21
armarx::JSONTreeModel::rowCount
int rowCount(const QModelIndex &parent) const override
Definition: JSONTreeModel.cpp:82
armarx::JSONTreeModel::parent
QModelIndex parent(const QModelIndex &index) const override
Definition: JSONTreeModel.cpp:57
armarx::JSONTreeModel
Definition: JSONTreeModel.h:10
armarx::JSONTreeModel::data
QVariant data(const QModelIndex &index, int role) const override
Definition: JSONTreeModel.cpp:107
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::JSONTreeModel::setRoot
void setRoot(nlohmann::json const &root)
Definition: JSONTreeModel.cpp:9