-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.cpp
53 lines (49 loc) · 1.72 KB
/
config.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
#include "config.h"
#include <QtCore/QtCore>
#include <QDebug>
Config::Config(QString qstrfilename)
{
if (qstrfilename.isEmpty())
{
m_qstrFileName = QCoreApplication::applicationDirPath() + "/Config.ini";
}
else
{
m_qstrFileName = qstrfilename;
}
m_psetting = new QSettings(m_qstrFileName, QSettings::IniFormat);
qDebug() << m_qstrFileName;
}
Config::~Config()
{
delete m_psetting;
m_psetting = 0;
}
void Config::Set(QStringList info)
{
QString dbAdd = info.at(0);
QString dbPort = info.at(1);
QString dbName = info.at(2);
QString preFix = info.at(3);
QString dbUser = info.at(4);
QString dbPass = info.at(5);
QString outPath = info.at(6);
m_psetting->setValue("/MySql/ipAddress", dbAdd.isEmpty() ? "localhost" : dbAdd);
m_psetting->setValue("/MySql/dbPort", dbPort.isEmpty() ? "3306" : dbPort);
m_psetting->setValue("/MySql/dbName", dbName.isEmpty() ? "dbName" : dbName);
m_psetting->setValue("/MySql/preFix", preFix.isEmpty() ? "typecho_" : preFix);
m_psetting->setValue("/MySql/dbUser", dbUser.isEmpty() ? "dbUser" : dbUser);
m_psetting->setValue("/MySql/dbPass", dbPass.isEmpty() ? "password" : dbPass);
if(!outPath.isEmpty()) {
m_psetting->setValue("/OUT/outPath", outPath);
}
}
QStringList Config::Get()
{
QStringList info;
info << m_psetting->value("/MySql/ipAddress").toString() << m_psetting->value("/MySql/dbPort").toString()
<< m_psetting->value("/MySql/dbName").toString() << m_psetting->value("/MySql/preFix").toString()
<< m_psetting->value("/MySql/dbUser").toString() << m_psetting->value("/MySql/dbPass").toString()
<< m_psetting->value("/OUT/outPath").toString();
return info;
}