You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.4 KiB
67 lines
1.4 KiB
1 year ago
|
|
||
|
#include "database_config.h"
|
||
|
|
||
|
DatabaseConfig* DatabaseConfig::getIns() {
|
||
|
static DatabaseConfig dataBaseConfig;
|
||
|
return &dataBaseConfig;
|
||
|
}
|
||
|
|
||
|
DatabaseConfig::DatabaseConfig() {
|
||
|
_host = "localhost";
|
||
|
_port = 0;
|
||
|
_database = "";
|
||
|
_username = "root";
|
||
|
_password = "";
|
||
|
_driver = "QSQLITE";
|
||
|
}
|
||
|
|
||
|
void DatabaseConfig::load(QSettings *configs) {
|
||
|
if(configs->value("host").isValid()){
|
||
|
_host = configs->value("host").toString();
|
||
|
}
|
||
|
if(configs->value("port").isValid()){
|
||
|
_port = configs->value("port").toInt();
|
||
|
}
|
||
|
if(configs->value("database").isValid()){
|
||
|
_database = configs->value("database").toString();
|
||
|
}
|
||
|
if(configs->value("username").isValid()){
|
||
|
_username = configs->value("username").toString();
|
||
|
}
|
||
|
if(configs->value("password").isValid()){
|
||
|
_password = configs->value("password").toString();
|
||
|
}
|
||
|
if(configs->value("driver").isValid()){
|
||
|
_driver = configs->value("driver").toString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
QString DatabaseConfig::getHost() const {
|
||
|
return _host;
|
||
|
}
|
||
|
|
||
|
int DatabaseConfig::getPort() const {
|
||
|
return _port;
|
||
|
}
|
||
|
|
||
|
QString DatabaseConfig::getDatabase() const {
|
||
|
return _database;
|
||
|
}
|
||
|
|
||
|
QString DatabaseConfig::getUsername() const {
|
||
|
return _username;
|
||
|
}
|
||
|
|
||
|
QString DatabaseConfig::getPassword() const {
|
||
|
return _password;
|
||
|
}
|
||
|
|
||
|
QString DatabaseConfig::getDriver() const {
|
||
|
return _driver;
|
||
|
}
|
||
|
|
||
|
DatabaseConfig::~DatabaseConfig() = default;
|
||
|
|
||
|
|
||
|
|