VAPOR3 3.9.4
VLineEdit_Deprecated.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4
5#include <QWidget>
6#include <QLabel>
7#include <QLineEdit>
8#include <QSpinBox>
9#include <QCheckBox>
10#include <QWidgetAction>
11
12#include "VHBoxWidget.h"
13
19
21 Q_OBJECT
22
23public:
24 VLineEdit_Deprecated(const std::string &value = "");
25
26 void SetValue(double value);
27 void SetValue(const std::string &value);
28 std::string GetValue() const;
29
30 // Note: VLineEdit_Deprecated does NOT support an integer type at this point.
31 // When isDouble == false, it represents a string.
32 void SetIsDouble(bool isDouble);
34 void SetReadOnly(bool b);
35
37
38private:
39 QLineEdit *_lineEdit;
40
41 std::string _value;
42 bool _isDouble;
43 bool _scientific;
44 bool _menuEnabled;
45 int _decDigits;
46
47public slots:
49
50 void ShowContextMenu(const QPoint &);
51
52private slots:
53 void _decimalDigitsChanged(int value);
54 void _scientificClicked(bool value);
55
56signals:
57 void ValueChanged(const std::string &value);
58};
59
60class SpinBoxAction : public QWidgetAction {
61 Q_OBJECT
62
63public:
64 SpinBoxAction(const QString &title, int value) : QWidgetAction(NULL)
65 {
66 QWidget * widget = new QWidget(NULL);
67 QHBoxLayout *layout = new QHBoxLayout();
68 QLabel * label = new QLabel(title); // bug fixed here, pointer was missing
69 _spinBox = new QSpinBox(NULL);
70
71 _spinBox->setValue(value);
72 layout->setContentsMargins(-1, 0, -1, 0);
73 layout->addWidget(label);
74 layout->addWidget(_spinBox);
75 widget->setLayout(layout);
76
77 // We need to use SIGNAL/SLOT macros here because the arguments
78 // of the signal and slot do not match
79 connect(_spinBox, SIGNAL(valueChanged(int)), this, SLOT(spinBoxChanged()));
80
81 setDefaultWidget(widget);
82 }
83
84private:
85 QSpinBox *_spinBox;
86
87private slots:
88 void spinBoxChanged()
89 {
90 int value = _spinBox->value();
91 emit editingFinished(value);
92 }
93
94signals:
95 void editingFinished(int);
96};
97
98class CheckBoxAction : public QWidgetAction {
99 Q_OBJECT
100
101public:
102 CheckBoxAction(const QString &title, bool value) : QWidgetAction(NULL)
103 {
104 QWidget * widget = new QWidget(NULL);
105 QHBoxLayout *layout = new QHBoxLayout();
106 QLabel * label = new QLabel(title);
107 _checkBox = new QCheckBox(NULL);
108 _checkBox->setChecked(value);
109
110 layout->setContentsMargins(-1, 0, 20, 0);
111 layout->addWidget(label);
112 layout->addStretch();
113 layout->addWidget(_checkBox);
114 widget->setLayout(layout);
115
116 connect(_checkBox, &QCheckBox::clicked, this, &CheckBoxAction::checkBoxChanged);
117
118 setDefaultWidget(widget);
119 }
120
121private:
122 QCheckBox *_checkBox;
123
124private slots:
125 void checkBoxChanged(bool value) { emit clicked(value); }
126
127signals:
128 void clicked(bool);
129};
CheckBoxAction(const QString &title, bool value)
void clicked(bool)
SpinBoxAction(const QString &title, int value)
void editingFinished(int)
void ValueChanged(const std::string &value)
void ShowContextMenu(const QPoint &)
VLineEdit_Deprecated(const std::string &value="")
void SetIsDouble(bool isDouble)
void SetValue(const std::string &value)
void SetValue(double value)
void SetReadOnly(bool b)
Sets the line edit to read-only based on the value of b.
std::string GetValue() const