-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuvDataBaseConnect.cpp
More file actions
49 lines (31 loc) · 1.47 KB
/
uvDataBaseConnect.cpp
File metadata and controls
49 lines (31 loc) · 1.47 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
#include "uvDataBaseConnect.h"
using namespace DATABASE;
UvDbConn::UvDbConn(QApplication* app):app(app),browser("uv",this){
this->setWindowTitle(QObject::tr("ADMINISTRATION : Edition de la Base de Données des UV / Portées / Types de Crédits"));
this->setCentralWidget(&browser);
QObject::connect(&browser, SIGNAL(statusMessage(QString)),
this->statusBar(), SLOT(showMessage(QString)));
}
void UvDbConn::addConnectionsFromCommandline(const QStringList &args, Browser *browser)
{
for (int i = 1; i < args.count(); ++i) {
QUrl url(args.at(i), QUrl::TolerantMode);
if (!url.isValid()) {
qWarning("Invalid URL: %s", qPrintable(args.at(i)));
continue;
}
QSqlError err = browser->addConnection(url.scheme(), url.path().mid(1), url.host(),
url.userName(), url.password(), url.port(-1));
if (err.type() != QSqlError::NoError)
qDebug() << "Unable to open connection:" << err;
}
}
void UvDbConn::connect(){
addConnectionsFromCommandline(app->arguments(), &browser);
if (QSqlDatabase::connectionNames().isEmpty())
QMetaObject::invokeMethod(&browser, "addConnection", Qt::QueuedConnection);
}
void UvDbConn::showEditor(const QString& nomTable){
browser.showTable(nomTable);
this->show();
}