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
28namespace armarx
29{
30
31 VariantItem::VariantItem(const QString& name, const VariantPtr& value) :
32 QStandardItem(name), value(value)
33 {
34 JSONObjectPtr json = new JSONObject();
35 auto values = JSONObject::ConvertToBasicVariantMap(json, value);
36
37 for (auto& value : values)
38 {
39 VariantPtr var = VariantPtr::dynamicCast(value.second);
40 QList<QStandardItem*> list;
41 auto name = QString::fromStdString(value.first);
42 name.remove("value.");
43
44 if (name.contains("typeName"))
45 {
46 continue;
47 }
48
49 list << new QStandardItem(name)
50 << new QStandardItem(QString::fromStdString(var->getOutputValueOnly()));
51
52 appendRow(list);
53 }
54 }
55
56 int
58 {
59 return TYPE;
60 }
61
62} // namespace armarx
The JSONObject class is used to represent and (de)serialize JSON objects.
Definition JSONObject.h:44
static StringVariantBaseMap ConvertToBasicVariantMap(const JSONObjectPtr &serializer, const VariantBasePtr &variant)
int type() const override
static const int TYPE
Definition VariantItem.h:47
VariantItem(const QString &name, const VariantPtr &value)
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< Variant > VariantPtr
Definition Variant.h:41
IceInternal::Handle< JSONObject > JSONObjectPtr
Definition JSONObject.h:34