blob: bbffc582144b2811381998a307f12b3374c29ebd (
plain)
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
|
#include "dbconnector.h"
#include "ui_dbconnector.h"
#include "main.h"
#include "mainwindow.h"
dbConnector::dbConnector(QWidget *parent) :
QDialog(parent),
ui(new Ui::dbConnector)
{
ui->setupUi(this);
ui->lineEdit_espAdress->setText(_espHost);
ui->lineEdit_database->setText(_dbName);
ui->lineEdit_adress->setText(_dbHost);
}
dbConnector::~dbConnector()
{
delete ui;
}
void dbConnector::on_pushButton_cancel_clicked()
{
close();
}
void dbConnector::on_pushButton_login_clicked()
{
_espHost = ui->lineEdit_espAdress->text();
_dbHost = ui->lineEdit_adress->text();
_dbName = ui->lineEdit_database->text();
QString username = ui->lineEdit_username->text();
QString password = ui->lineEdit_password->text();
// Extract possible port (default if not provided)
QStringList dbAdress = _dbHost.split(":");
if (dbAdress.size() > 1){
dbRef.setPort(dbAdress[1].toInt());
qDebug() << dbAdress[1];
}
dbRef.setHostName(dbAdress[0]);
dbRef.setUserName(username);
dbRef.setPassword(password);
dbRef.setDatabaseName(_dbName);
if(dbRef.open()){
QMessageBox::information(this, "Connection", "GREAT SUCCES!");
close();
} else {
QMessageBox::warning(this, "No connection", "Failed to connect");
}
}
QString dbConnector::getdbName(){
return _dbName;
}
QString dbConnector::getEspHost(){
return _espHost;
}
|