-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimportdatabase.cpp
More file actions
70 lines (62 loc) · 1.55 KB
/
importdatabase.cpp
File metadata and controls
70 lines (62 loc) · 1.55 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
61
62
63
64
65
66
67
68
69
#include "importdatabase.h"
#include "ui_importdatabase.h"
#include <QFileDialog>
#include <QDir>
#include <QFile>
#include <QMessageBox>
importDatabase::importDatabase(QWidget *parent) :
QDialog(parent),
ui(new Ui::importDatabase)
{
ui->setupUi(this);
this->setWindowTitle("Import database");
}
importDatabase::~importDatabase()
{
delete ui;
}
void importDatabase::on_cmdBrowse_clicked()
{
QString fileName = QFileDialog::getOpenFileName(this,tr("Open Database"), QDir::homePath(), tr("SQLite Files (*.sqlite)"));
if (fileName != "")
ui->txtpath->setText(fileName);
}
void importDatabase::on_buttonBox_accepted()
{
if (QFile::exists(ui->txtpath->text()))
{
if (ui->txtcode->text() != "")
{
if (ui->txtname->text() != "")
{
this->db_name = ui->txtname->text();
this->db_code = ui->txtcode->text();
this->db_path = ui->txtpath->text();
this->close();
}
else
{
QMessageBox msgBox;
msgBox.setText("You need to provide a name");
msgBox.exec();
}
}
else
{
QMessageBox msgBox;
msgBox.setText("You need to provide a code");
msgBox.exec();
}
}
else
{
QMessageBox msgBox;
msgBox.setText("The database file does not exist");
msgBox.exec();
}
}
void importDatabase::on_buttonBox_rejected()
{
this->db_code = "";
this->close();
}