-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcargo_gui.cpp
More file actions
60 lines (49 loc) · 1.23 KB
/
cargo_gui.cpp
File metadata and controls
60 lines (49 loc) · 1.23 KB
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
#include "cargo_gui.h"
CargoGui::CargoGui()
{}
CargoGui::CargoGui(QLabel *_pLbl, QLineEdit *_pPriceTxt, QLineEdit *_pQtyTxt, QPushButton *_pContraBtn)
: m_pLbl(_pLbl)
, m_pPriceTxt(_pPriceTxt)
, m_pQtyTxt(_pQtyTxt)
, m_pContraBtn(_pContraBtn)
{
m_pQtyTxt->setEnabled(false);
}
void CargoGui::setVisible(bool _isVisible)
{
m_pPriceTxt->setVisible(_isVisible);
m_pQtyTxt->setVisible(_isVisible);
m_pLbl->setVisible(_isVisible);
if (m_pContraBtn != nullptr)
m_pContraBtn->setVisible(_isVisible);
}
void CargoGui::enablePrice(bool _isEnabled)
{
m_pPriceTxt->setEnabled(_isEnabled);
}
void CargoGui::enableQty(bool _isEnabled)
{
m_pQtyTxt->setEnabled(_isEnabled);
}
bool CargoGui::isValid() const
{
if (!m_pPriceTxt->isVisible())
return true;
if (m_pPriceTxt->isEnabled() && m_pPriceTxt->text().size() == 0)
return false;
if (m_pQtyTxt->isEnabled() && m_pQtyTxt->text().size() == 0)
return false;
return true;
}
bool CargoGui::isPriceEnabled() const
{
return m_pPriceTxt->isEnabled();
}
unsigned int CargoGui::getPrice() const
{
return m_pPriceTxt->text().toUInt();
}
unsigned int CargoGui::getQty() const
{
return m_pQtyTxt->text().toUInt();
}