-
Notifications
You must be signed in to change notification settings - Fork 6
/
QLabelEdit.cpp
115 lines (96 loc) · 1.82 KB
/
QLabelEdit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#include "QLabelEdit.h"
QLabelEdit::QLabelEdit(QWidget *parent)
: QWidget(parent)
,labelWidth_(80)
,unitsWidth_(40)
,showDefaultButton_(true)
{
ui.setupUi(this);
}
QLabelEdit::~QLabelEdit()
{
}
void QLabelEdit::setShowDefaultButton(bool l)
{
showDefaultButton_=l;
if(!showDefaultButton_||value_==defaultValue_)
ui.reset->setDisabled(true);
else
ui.reset->setDisabled(false);
}
bool QLabelEdit::showDefaultButton() const
{
return showDefaultButton_;
}
void QLabelEdit::setReadOnly(bool l)
{
ui.lineEdit->setReadOnly(l);
}
bool QLabelEdit::readOnly() const
{
return ui.lineEdit->isReadOnly();
}
void QLabelEdit::on_lineEdit_editingFinished()
{
value_=ui.lineEdit->text();
emit valueChanged();
}
void QLabelEdit::on_reset_clicked()
{
setValue(defaultValue_);
emit valueChanged();
}
void QLabelEdit::setValue(QString f)
{
value_=f;
setShowDefaultButton(showDefaultButton_);
blockSignals(true);
ui.lineEdit->setText(f);
blockSignals(false);
}
QString QLabelEdit::value() const
{
return value_;
}
void QLabelEdit::setTitle(QString f)
{
ui.label->setText(f);
}
QString QLabelEdit::title() const
{
return ui.label->text();
}
void QLabelEdit::setLabelWidth(int w)
{
labelWidth_=w;
ui.label->setMinimumWidth(w);
ui.label->setMaximumWidth(w);
QSize s=ui.label->minimumSize();
s.setWidth(w);
ui.label->setMinimumSize(s);
s=ui.label->maximumSize();
s.setWidth(w);
ui.label->setMaximumSize(s);
update();
}
void QLabelEdit::setUnitsWidth(int w)
{
unitsWidth_=w;
ui.units->setMinimumWidth(w);
ui.units->setMaximumWidth(w);
QSize s=ui.units->minimumSize();
s.setWidth(w);
ui.units->setMinimumSize(s);
s=ui.units->maximumSize();
s.setWidth(w);
ui.units->setMaximumSize(s);
update();
}
void QLabelEdit::setUnits(QString f)
{
ui.units->setText(f);
}
QString QLabelEdit::units() const
{
return ui.units->text();
}