VariantItem.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package
19  * @author
20  * @date
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 #include "VariantItem.h"
25 
27 
28 namespace armarx
29 {
30 
31  VariantItem::VariantItem(const QString& name, const VariantPtr& value) :
32  QStandardItem(name),
33  value(value)
34  {
35  JSONObjectPtr json = new JSONObject();
36  auto values = JSONObject::ConvertToBasicVariantMap(json, value);
37 
38  for (auto& value : values)
39  {
40  VariantPtr var = VariantPtr::dynamicCast(value.second);
41  QList<QStandardItem*> list;
42  auto name = QString::fromStdString(value.first);
43  name.remove("value.");
44 
45  if (name.contains("typeName"))
46  {
47  continue;
48  }
49 
50  list << new QStandardItem(name)
51  << new QStandardItem(QString::fromStdString(var->getOutputValueOnly()));
52 
53  appendRow(list);
54 
55  }
56  }
57 
58  int VariantItem::type() const
59  {
60  return TYPE;
61  }
62 
63 } // namespace armarx
64 
65 
JSONObject.h
armarx::JSONObject::ConvertToBasicVariantMap
static StringVariantBaseMap ConvertToBasicVariantMap(const JSONObjectPtr &serializer, const VariantBasePtr &variant)
Definition: JSONObject.cpp:523
list
list(APPEND SOURCES ${QT_RESOURCES}) set(COMPONENT_LIBS ArmarXGui ArmarXCoreObservers ArmarXCoreEigen3Variants PlotterController $
Definition: CMakeLists.txt:49
armarx::JSONObject
The JSONObject class is used to represent and (de)serialize JSON objects.
Definition: JSONObject.h:43
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
IceInternal::Handle< Variant >
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::VariantItem::TYPE
static const int TYPE
Definition: VariantItem.h:47
armarx::VariantItem::type
int type() const override
Definition: VariantItem.cpp:58
armarx::VariantItem::VariantItem
VariantItem(const QString &name, const VariantPtr &value)
Definition: VariantItem.cpp:31
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
VariantItem.h