-
Notifications
You must be signed in to change notification settings - Fork 0
/
labelNameDialog.cpp
64 lines (56 loc) · 1.72 KB
/
labelNameDialog.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
#include "labelNameDialog.h"
#include <QMessageBox>
/*!
\brief Implicitni konstruktor
*/
LabelNameDialog::LabelNameDialog(QList<QString> labelList, QWidget* parent) : QDialog(parent) {
ui.setupUi(this);
ui.labelName->hide();
ui.labelLabelName->hide();
ui.labelComboBox->addItems(labelList);
connect(ui.labelComboBox, SIGNAL(activated(int)),
this, SLOT(showNewLabel(int)));
}
/*!
\brief Zkontroluje zadane informace
*/
void LabelNameDialog::done(int ready) {
//pokud je stisknuto tlacitko OK
if (ready == QDialog::Accepted) {
//zkontroluji povinne udaje
if (ui.labelName->text().isEmpty() && ui.labelComboBox->currentIndex() == 1) {
QMessageBox::information(0, trUtf8("Error"), trUtf8("Please fill up label name!"));
return;
}
else {
//odeslu udaje
if (ui.labelName->isHidden()) {
if (ui.labelComboBox->currentIndex() == 1)
emit signalLabelName(ui.labelName->text());
else if (ui.labelComboBox->currentIndex() == 0)
emit signalLabelName("");
else
emit signalLabelName(ui.labelComboBox->currentText());
}
else
emit signalLabelName(ui.labelName->text());
}
QDialog::done(ready);
}
else
QDialog::done(ready);
}
/*!
\brief Pokud je zvolena moznost pridat novy stitek zobrazi pole pro jeho zadani
*/
void LabelNameDialog::showNewLabel(int index) {
if (index == 1) {
ui.labelLabelName->show();
ui.labelName->show();
}
else {
ui.labelLabelName->hide();
ui.labelName->hide();
ui.labelName->clear();
}
}