StateParameterEditor.h
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#pragma once
25
26#include <QStyledItemDelegate>
27#include <QTableWidget>
28
32
33class QComboBox;
34
35namespace armarx
36{
37
38 class StateParameterEditor : public QTableWidget
39 {
40 Q_OBJECT
41 public:
51
52 explicit StateParameterEditor(QWidget* parent = 0,
53 const StateParameterMap& params = StateParameterMap());
54
55 void
57 {
58 this->communicator = communicator;
59 }
60
61 void
63 {
64 this->variantInfo = variantInfo;
65 }
66
67 void
69 {
70 this->currentProfile = currentProfile;
71 }
72
73 void setKeyBlackList(const QSet<QString>& keyBlackList);
74 QSet<QString> getKeys() const;
75 StateParameterMap getStateParameters() const;
76 StringVariantContainerBaseMap getStringValueMap() const;
77 StateParameterMap getStateParametersWithoutValue() const;
78
79 QString getValueAsString(int row) const;
80 VariantContainerBasePtr getVariantContainer(int row) const;
81 QString getJson(QString key) const;
82 QString getKey(int row) const;
83 QString getType(int row) const;
84 QString getType(QString key) const;
85 int getRow(const QString& key) const;
86 bool getIsOptional(int row) const;
87
88 void
89 addParameterRow(QString key, QString variantIdStr, QString value, bool optional = false);
90 void createValueButton(int row, const QString& jsonValue);
91 void setHeaders();
92 Qt::CheckState getDefaultValueState() const;
93 void setDefaultValueState(const Qt::CheckState& value);
94
95 StateParameterIceBasePtr getStateParameter(int row) const;
96 signals:
97 void buildRequested(const StateParameterMap& map,
98 const std::map<QString, std::pair<QString, QString>>& jsonStringMap);
99 void rowAdded(int rowId);
100 void rowFilled(int rowId, const QString& key);
101 public slots:
102 void buildFromMap(const StateParameterMap& map,
103 const std::map<QString, std::pair<QString, QString>>& jsonStringMap =
104 std::map<QString, std::pair<QString, QString>>());
105 int addParameterRow();
106 void typeCbChanged(const QString& text);
107 void deleteRow();
108 void checkAndUpdateRowCount(int row, int column);
109 void refreshVariantTypes();
111 private slots:
112 void __buildFromMap(const StateParameterMap& map,
113 const std::map<QString, std::pair<QString, QString>>& jsonStringMap =
114 std::map<QString, std::pair<QString, QString>>());
115
116 private:
117 void connectUserEditSlots();
118 void addVariantTypesToComboBox(QComboBox* combo);
119 QString getHumanNameFromBaseName(QString variantBaseTypeName) const;
120 QString getBaseNameFromHumanName(QString humanName) const;
121 static bool compareVariantNames(const QString& a, const QString& b);
122
123 class LineEditDelegate : public QStyledItemDelegate
124 {
125 QWidget* createEditor(QWidget* parent,
126 const QStyleOptionViewItem& option,
127 const QModelIndex& index) const override;
128 };
129
130 LineEditDelegate delegate;
131 Ice::CommunicatorPtr communicator;
132 VariantInfoPtr variantInfo;
133 Qt::CheckState defaultValueState;
134 QSet<QString> keyBlackList;
135 StatechartProfilePtr currentProfile;
136 };
137
138} // namespace armarx
uint8_t index
#define option(type, fn)
QString getValueAsString(int row) const
void buildFromMap(const StateParameterMap &map, const std::map< QString, std::pair< QString, QString > > &jsonStringMap=std::map< QString, std::pair< QString, QString > >())
void setKeyBlackList(const QSet< QString > &keyBlackList)
int getRow(const QString &key) const
StateParameterEditor(QWidget *parent=0, const StateParameterMap &params=StateParameterMap())
void buildRequested(const StateParameterMap &map, const std::map< QString, std::pair< QString, QString > > &jsonStringMap)
VariantContainerBasePtr getVariantContainer(int row) const
StateParameterMap getStateParameters() const
void setDefaultValueState(const Qt::CheckState &value)
void createValueButton(int row, const QString &jsonValue)
StateParameterIceBasePtr getStateParameter(int row) const
StringVariantContainerBaseMap getStringValueMap() const
void checkAndUpdateRowCount(int row, int column)
void rowFilled(int rowId, const QString &key)
StateParameterMap getStateParametersWithoutValue() const
void setVariantInfo(VariantInfoPtr variantInfo)
Qt::CheckState getDefaultValueState() const
void setCommunicator(Ice::CommunicatorPtr communicator)
QString getJson(QString key) const
void setCurrentProfile(StatechartProfilePtr currentProfile)
void typeCbChanged(const QString &text)
::IceInternal::Handle<::Ice::Communicator > CommunicatorPtr
Definition IceManager.h:49
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition VariantInfo.h:39
std::shared_ptr< class StatechartProfile > StatechartProfilePtr