-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathqsw.cpp
More file actions
44 lines (37 loc) · 1.22 KB
/
qsw.cpp
File metadata and controls
44 lines (37 loc) · 1.22 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
#include <QDomDocument>
#include <QFile>
#include "qsw.h"
QSettings& QSW::settings()
{
static QSettings m_settings("QSW.ini", QSettings::IniFormat);
m_settings.sync();
return m_settings;
}
EnumHash QSW::loadEnumFile(QString fileName)
{
QFile xmlFile(fileName);
xmlFile.open(QIODevice::ReadOnly);
QDomDocument xmlData;
xmlData.setContent(&xmlFile);
xmlFile.close();
EnumHash enums;
QDomNodeList enumNodes = xmlData.firstChild().childNodes();
for (qint32 i = 0; i < enumNodes.count(); ++i)
{
QDomNodeList valuesNodes = enumNodes.item(i).toElement().childNodes();
Enumerator enumerator;
for (qint32 j = 0; j < valuesNodes.count(); ++j)
{
QDomElement valueElement = valuesNodes.item(j).toElement();
if (valueElement.attribute("key").contains("0x"))
{
bool ok;
enumerator[valueElement.attribute("key").toLongLong(&ok, 16)]= valueElement.attribute("value");
}
else
enumerator[valueElement.attribute("key").toLongLong()]= valueElement.attribute("value");
}
enums[enumNodes.item(i).toElement().tagName()] = enumerator;
}
return enums;
}