-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlabeldialog.cpp
89 lines (76 loc) · 2.05 KB
/
labeldialog.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
#include "labeldialog.h"
#include "ui_labeldialog.h"
#include <QMessageBox>
#include <QListWidget>
#include <QLabel>
#include <QDialog>
LabelDialog::LabelDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::LabelDialog)
{
ui->setupUi(this);
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(labelAccept()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(labelReject()));
connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(doubleClickLabel(QListWidgetItem*)));
connect(ui->listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(sigleClickLabel(QListWidgetItem*)));
}
LabelDialog::~LabelDialog()
{
delete ui;
}
void LabelDialog::dialogShow()
{
this->show();
}
void LabelDialog::getLabel(QString label)
{
ui->lineEdit->setText("");
emit dialoglabelAdded(label);
}
void LabelDialog::getLabelFromManager(QString label)
{
ui->listWidget->addItem(label);
}
void LabelDialog::deleteLabelFromManager(QString label)
{
QListWidgetItem* item = ui->listWidget->findItems(label, Qt::MatchExactly)[0];
ui->listWidget->removeItemWidget(item);
delete item;
}
void LabelDialog::clearLabelFromManager()
{
ui->listWidget->clear();
}
void LabelDialog::doubleClickLabel(QListWidgetItem *item)
{
label_to_Annotation = item->text();
getLabel(label_to_Annotation);
this->close();
}
void LabelDialog::sigleClickLabel(QListWidgetItem *item)
{
ui->lineEdit->setText(item->text());
}
void LabelDialog::labelAccept()
{
label_to_Annotation = ui->lineEdit->text();
if (label_to_Annotation == "")
{
QMessageBox::about(NULL, "ERROR", "Please select a label name");
emit dialoglabelCanceled();
this->close();
return;
}
if (ui->listWidget->findItems(label_to_Annotation, Qt::MatchExactly).empty())
{
ui->listWidget->addItem(label_to_Annotation);
}
getLabel(label_to_Annotation);
this->close();
}
void LabelDialog::labelReject()
{
ui->lineEdit->setText("");
emit dialoglabelCanceled();
this->close();
}