This repository was archived by the owner on Apr 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapfolderdialog.cpp
executable file
·76 lines (64 loc) · 1.75 KB
/
mapfolderdialog.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
#include "mapfolderdialog.h"
#include "ui_mapfolderdialog.h"
#include "mapfoldervalidator.h"
#include <QDebug>
MapFolderDialog::MapFolderDialog(QWidget *parent) :
QDialog(parent, Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint),
ui(new Ui::MapFolderDialog)
{
ui->setupUi(this);
ui->lineEdit->setValidator(new MapFolderValidator(ui->lineEdit));
connect(ui->lineEdit, SIGNAL(textEdited(QString)), SLOT(onTextChanged(QString)));
}
void MapFolderDialog::onTextChanged(const QString& text)
{
if (itemExists(text))
{
ui->label_2->setText("<font color=red>" + tr("A pasta já existe.") + "</font>");
ui->pushButton->setEnabled(false);
}
else if (text.isEmpty())
{
ui->label_2->setText("<font color=red>" + tr("Digite um nome para a pasta.") + "</font>");
ui->pushButton->setEnabled(false);
}
else
{
ui->label_2->setText(QString());
ui->pushButton->setEnabled(true);
}
}
bool MapFolderDialog::itemExists(const QString& name)
{
for (int x = 0; x < m_item->childCount(); x++)
{
QTreeWidgetItem* it = m_item->child(x);
QString i = it->text(0);
if (name.toLower() == m_folder.toLower())
{
return false;
}
else if (name.toLower() == i.toLower())
{
return true;
}
}
return false;
}
void MapFolderDialog::setFolderName(const QString& name)
{
ui->lineEdit->setText(name);
m_folder = name;
}
QString MapFolderDialog::folderName()
{
return ui->lineEdit->text();
}
void MapFolderDialog::setParentItem(QTreeWidgetItem* item)
{
m_item = item;
}
MapFolderDialog::~MapFolderDialog()
{
delete ui;
}