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 <QCheckBox>
27#include <QComboBox>
28#include <QHBoxLayout>
29#include <QLineEdit>
30#include <QWidget>
31
32namespace 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
49 focusInEvent(QFocusEvent* event) override
50 {
51 oldValue = currentText();
52 QComboBox::focusInEvent(event);
53 }
54
55 void focusOutEvent(QFocusEvent* event) override;
56 QString oldValue;
57 };
58
59 class OptionalEdit : public QWidget
60 {
61 Q_OBJECT
62 public:
63 explicit OptionalEdit(const QString& elementName,
64 const QString& propertyName,
65 QWidget* parent = 0);
66 void setPossibleValues(const QStringList& values);
67 signals:
68 void enabledChanged(const bool& enabled);
69 void valueChanged(const QString& value);
70
71 public slots:
72 void setPropertyEnabled(const bool& enabled = true);
73 void setReadOnly(bool readOnly);
74 void setValue(const QString& value);
75 void updateHistory(const QString& value);
76
77 protected:
78 void focusInEvent(QFocusEvent* e) override;
79 void focusOutEvent(QFocusEvent* e) override;
80 void keyPressEvent(QKeyEvent* e) override;
81 void keyReleaseEvent(QKeyEvent* e) override;
82
83 private slots:
84 void slotEnabledChanged(int state);
85
86 private:
87 bool fixComboboxValues = false;
88 QHBoxLayout* layout = nullptr;
89
90 QComboBox* combo = nullptr;
91 QLineEdit* readOnlyLineEdit = nullptr;
92
93 QCheckBox* checkbox = nullptr;
94 QString elementName;
95 QString propertyName;
96 QStringList valueList;
97 };
98
99} // namespace armarx
void focusOutEvent(QFocusEvent *event) override
CustomComboBox(QWidget *parent)
void valueChanged(const QString &value)
void focusInEvent(QFocusEvent *event) override
OptionalEdit(const QString &elementName, const QString &propertyName, QWidget *parent=0)
void focusInEvent(QFocusEvent *e) override
void keyReleaseEvent(QKeyEvent *e) override
void setPossibleValues(const QStringList &values)
void keyPressEvent(QKeyEvent *e) override
void enabledChanged(const bool &enabled)
void focusOutEvent(QFocusEvent *e) override
void valueChanged(const QString &value)
void updateHistory(const QString &value)
void setValue(const QString &value)
void setPropertyEnabled(const bool &enabled=true)
void setReadOnly(bool readOnly)
This file offers overloads of toIce() and fromIce() functions for STL container types.