OptionalEdit.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 <QWidget>
27 #include <QLineEdit>
28 #include <QCheckBox>
29 #include <QHBoxLayout>
30 #include <QComboBox>
31 
32 namespace armarx
33 {
34 
35 
36  class CustomComboBox : public QComboBox
37  {
38  Q_OBJECT
39  public:
40  CustomComboBox(QWidget* parent) : QComboBox(parent)
41  {
42 
43  }
44  signals:
45  void valueChanged(const QString& value);
46  // QWidget interface
47  protected:
48  void focusInEvent(QFocusEvent* event) override
49  {
50  oldValue = currentText();
51  QComboBox::focusInEvent(event);
52  }
53  void focusOutEvent(QFocusEvent* event) override;
54  QString oldValue;
55  };
56 
57 
58  class OptionalEdit : public QWidget
59  {
60  Q_OBJECT
61  public:
62  explicit OptionalEdit(const QString& elementName, const QString& propertyName, QWidget* parent = 0);
63  void setPossibleValues(const QStringList& values);
64  signals:
65  void enabledChanged(const bool& enabled);
66  void valueChanged(const QString& value);
67 
68  public slots:
69  void setPropertyEnabled(const bool& enabled = true);
70  void setReadOnly(bool readOnly);
71  void setValue(const QString& value);
72  void updateHistory(const QString& value);
73 
74  protected:
75  void focusInEvent(QFocusEvent* e) override;
76  void focusOutEvent(QFocusEvent* e) override;
77  void keyPressEvent(QKeyEvent* e) override;
78  void keyReleaseEvent(QKeyEvent* e) override;
79 
80  private slots:
81  void slotEnabledChanged(int state);
82 
83  private:
84  bool fixComboboxValues = false;
85  QHBoxLayout* layout = nullptr;
86 
87  QComboBox* combo = nullptr;
88  QLineEdit* readOnlyLineEdit = nullptr;
89 
90  QCheckBox* checkbox = nullptr;
91  QString elementName;
92  QString propertyName;
93  QStringList valueList;
94  };
95 
96 }
97 
armarx::OptionalEdit::enabledChanged
void enabledChanged(const bool &enabled)
armarx::OptionalEdit
Definition: OptionalEdit.h:58
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::OptionalEdit::keyPressEvent
void keyPressEvent(QKeyEvent *e) override
Definition: OptionalEdit.cpp:170
armarx::CustomComboBox::focusInEvent
void focusInEvent(QFocusEvent *event) override
Definition: OptionalEdit.h:48
armarx::OptionalEdit::focusOutEvent
void focusOutEvent(QFocusEvent *e) override
Definition: OptionalEdit.cpp:165
armarx::OptionalEdit::focusInEvent
void focusInEvent(QFocusEvent *e) override
Definition: OptionalEdit.cpp:160
armarx::OptionalEdit::keyReleaseEvent
void keyReleaseEvent(QKeyEvent *e) override
Definition: OptionalEdit.cpp:175
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::CustomComboBox::focusOutEvent
void focusOutEvent(QFocusEvent *event) override
Definition: OptionalEdit.cpp:181
enabled
std::atomic< bool > * enabled
Definition: RemoteGuiWidgetController.cpp:75
armarx::OptionalEdit::setValue
void setValue(const QString &value)
Definition: OptionalEdit.cpp:119
armarx::OptionalEdit::OptionalEdit
OptionalEdit(const QString &elementName, const QString &propertyName, QWidget *parent=0)
Definition: OptionalEdit.cpp:38
armarx::OptionalEdit::setPossibleValues
void setPossibleValues(const QStringList &values)
Definition: OptionalEdit.cpp:86
armarx::CustomComboBox::CustomComboBox
CustomComboBox(QWidget *parent)
Definition: OptionalEdit.h:40
armarx::OptionalEdit::updateHistory
void updateHistory(const QString &value)
Definition: OptionalEdit.cpp:137
armarx::OptionalEdit::setReadOnly
void setReadOnly(bool readOnly)
Definition: OptionalEdit.cpp:110
armarx::CustomComboBox::oldValue
QString oldValue
Definition: OptionalEdit.h:54
armarx::OptionalEdit::setPropertyEnabled
void setPropertyEnabled(const bool &enabled=true)
Definition: OptionalEdit.cpp:99
armarx::OptionalEdit::valueChanged
void valueChanged(const QString &value)
armarx::CustomComboBox::valueChanged
void valueChanged(const QString &value)
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::CustomComboBox
Definition: OptionalEdit.h:36