StatechartEditorParameterEditor.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
25#pragma once
26#include <QComboBox>
27#include <QStyledItemDelegate>
28#include <QTableWidget>
29#include <QToolButton>
30
33
35
36namespace armarx
37{
38 class AnimatedToolButton : public QToolButton
39 {
40
41 Q_OBJECT
42 Q_PROPERTY(QColor color READ color WRITE setColor)
43
44 public:
45 AnimatedToolButton(QWidget* parent = 0) : QToolButton(parent)
46 {
47 }
48
49 void setColor(QColor color);
50
51 QColor
53 {
54 return Qt::black; // getter is not really needed for now
55 }
56 };
57
58 class StatechartEditorParameterEditor : public QTableWidget
59 {
60 Q_OBJECT
61 public:
64 QWidget* parent = 0,
68 // void buildFromMap(const statechartmodel::StateParameterMap& map);
69 protected slots:
70 void addCustomColumn(int row);
71 void fillCustomColumn(int row, const QString& key);
72 void showHelpDialog();
73 void addInputToParent();
74 void init(const statechartmodel::StateParameterMap& params);
75
76 protected:
79
80
81 // ###### StateParameterEditor: ######
82 public:
92
93 //explicit StateParameterEditor(QWidget *parent = 0, const StateParameterMap& params = StateParameterMap());
94
95 void
97 {
98 this->communicator = communicator;
99 }
100
101 void
103 {
104 this->variantInfo = variantInfo;
105 }
106
107 void
109 {
110 this->currentProfile = currentProfile;
111 setColumnCount(eEditableValue + getRelevantProfiles().size());
112 }
113
114 void setKeyBlackList(const QSet<QString>& keyBlackList);
115 QSet<QString> getKeys() const;
116 QSet<QString> getTypes() const;
119
120 QMap<QString, QString> getValuesAsString(int row) const;
121 QMap<QString, VariantContainerBasePtr> getProfileVariantContainerMap(int row) const;
122 QMap<QString, QString> getProfileJsonMap(QString key) const;
123 QString getKey(int row) const;
124 QString getType(int row) const;
125 QString getType(QString key) const;
126 int getRow(const QString& key) const;
127 bool getIsOptional(int row) const;
128
129 void addParameterRow(QString key,
130 QString variantIdStr,
131 QVector<QString> values,
132 bool optional = false);
133 void setHeaders();
134 Qt::CheckState getDefaultValueState() const;
135 void setDefaultValueState(const Qt::CheckState& value);
136 void hideValueColumns();
137
139 signals:
141 void rowAdded(int rowId);
142 void rowFilled(int rowId, const QString& key);
143 void typeChanged(int row, const QString& newType);
144 public slots:
146 int addParameterRow();
147 void typeCbChanged(const QString&);
148 void deleteRow();
149 void checkAndUpdateRowCount(int row, int column);
150 void refreshVariantTypes();
151 private slots:
152 void __buildFromMap(const statechartmodel::StateParameterMap& map);
153
154 private:
155 QVector<QString> getRelevantProfiles() const;
156 void connectUserEditSlots();
157 QStringList addVariantTypesToComboBox(QComboBox* combo);
158 QString getHumanNameFromBaseName(QString variantBaseTypeName) const;
159 QString getBaseNameFromHumanName(QString humanName) const;
160 static bool compareVariantNames(const QString& a, const QString& b);
161
162 class LineEditDelegate : public QStyledItemDelegate
163 {
164 QWidget* createEditor(QWidget* parent,
165 const QStyleOptionViewItem& option,
166 const QModelIndex& index) const override;
167 };
168
169 LineEditDelegate delegate;
170 Ice::CommunicatorPtr communicator;
171 VariantInfoPtr variantInfo;
172 Qt::CheckState defaultValueState;
173 QSet<QString> keyBlackList;
174 StatechartProfilePtr currentProfile;
175 };
176
177} // namespace armarx
uint8_t index
#define option(type, fn)
QMap< QString, VariantContainerBasePtr > getProfileVariantContainerMap(int row) const
statechartmodel::StateParameterPtr getStateParameter(int row) const
void setKeyBlackList(const QSet< QString > &keyBlackList)
QMap< QString, QString > getValuesAsString(int row) const
QMap< QString, QString > getProfileJsonMap(QString key) const
statechartmodel::StateParameterMap getStateParameters() const
void typeChanged(int row, const QString &newType)
void buildFromMap(const statechartmodel::StateParameterMap &map)
void buildRequested(const statechartmodel::StateParameterMap &map)
void rowFilled(int rowId, const QString &key)
StatechartEditorParameterEditor(QWidget *parent=0, statechartmodel::StateInstancePtr state=statechartmodel::StateInstancePtr(), const statechartmodel::StateParameterMap &params=statechartmodel::StateParameterMap())
statechartmodel::StateParameterMap getStateParametersWithoutValue() const
statechartmodel::StateParameterMap originalParamMap
void setCommunicator(Ice::CommunicatorPtr communicator)
void setCurrentProfile(StatechartProfilePtr currentProfile)
void setStateInstance(statechartmodel::StateInstancePtr state)
void init(const statechartmodel::StateParameterMap &params)
::IceInternal::Handle<::Ice::Communicator > CommunicatorPtr
Definition IceManager.h:49
QMap< QString, StateParameterPtr > StateParameterMap
std::shared_ptr< StateInstance > StateInstancePtr
std::shared_ptr< StateParameter > StateParameterPtr
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