-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathoptions.cpp
More file actions
742 lines (668 loc) · 19.6 KB
/
options.cpp
File metadata and controls
742 lines (668 loc) · 19.6 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
#include "options.h"
#include <definitions/version.h>
#include <QFile>
#include <QRect>
#include <QSettings>
#include <QDataStream>
#include <QStringList>
#include <QKeySequence>
#include <QCryptographicHash>
QDomElement findChildElement(const QDomElement &AParent, const QString &APath, const QString &ANSpace,
QString &ChildName, QString &SubPath, QString &NSpace)
{
int dotIndex = APath.indexOf('.');
ChildName = dotIndex>0 ? APath.left(dotIndex) : APath;
SubPath = dotIndex>0 ? APath.mid(dotIndex+1) : QString::null;
int nsStart = ChildName.indexOf('[');
NSpace = nsStart>0 ? ChildName.mid(nsStart+1, ChildName.lastIndexOf(']')-nsStart-1) : QString::null;
NSpace = dotIndex>0 ? NSpace : (ANSpace.isNull() ? NSpace : ANSpace);
ChildName = nsStart>0 ? ChildName.left(nsStart) : ChildName;
QDomElement childElem = AParent.firstChildElement(ChildName);
while (!childElem.isNull() && childElem.attribute("ns")!=NSpace)
childElem = childElem.nextSiblingElement(ChildName);
return childElem;
}
QDomText findChildText(const QDomElement &AParent)
{
for (QDomNode node = AParent.firstChild(); !node.isNull(); node=node.nextSibling())
if (node.isText())
return node.toText();
return QDomText();
}
QString fullOptionsPath(const QString &APath, const QString &ASubPath)
{
if (ASubPath.isEmpty())
return APath;
else if (APath.isEmpty())
return ASubPath;
else
return APath+ "." +ASubPath;
}
QString fullFileName(const QString &APath, const QString &ANSpace)
{
QString fileKey = APath + (!ANSpace.isEmpty() ? "["+ANSpace+"]" : QString::null);
return Options::filesPath() + "/" + QCryptographicHash::hash(fileKey.toUtf8(), QCryptographicHash::Sha1).toHex();
}
QString variantToString(const QVariant &AVariant)
{
if (AVariant.type() == QVariant::Rect)
{
QRect rect = AVariant.toRect();
return QString("%1;%2;%3;%4").arg(rect.left()).arg(rect.top()).arg(rect.width()).arg(rect.height());
}
else if (AVariant.type() == QVariant::RectF)
{
QRectF rect = AVariant.toRectF();
return QString("%1;%2;%3;%4").arg(rect.left()).arg(rect.top()).arg(rect.width()).arg(rect.height());
}
else if (AVariant.type() == QVariant::Point)
{
QPoint point = AVariant.toPoint();
return QString("%1;%2").arg(point.x()).arg(point.y());
}
else if (AVariant.type() == QVariant::PointF)
{
QPointF point = AVariant.toPoint();
return QString("%1;%2").arg(point.x()).arg(point.y());
}
else if (AVariant.type() == QVariant::Size)
{
QSize size = AVariant.toSize();
return QString("%1;%2").arg(size.width()).arg(size.height());
}
else if (AVariant.type() == QVariant::SizeF)
{
QSizeF size = AVariant.toSize();
return QString("%1;%2").arg(size.width()).arg(size.height());
}
else if (AVariant.type() == QVariant::ByteArray)
{
return AVariant.toByteArray().toBase64();
}
else if (AVariant.type() == QVariant::StringList)
{
return AVariant.toStringList().join(" ;; ");
}
else if (AVariant.type() == QVariant::KeySequence)
{
return AVariant.value<QKeySequence>().toString(QKeySequence::PortableText);
}
return AVariant.toString();
}
QVariant stringToVariant(const QString &AString, QVariant::Type AType)
{
if (AType == QVariant::Rect)
{
QList<QString> parts = AString.split(";",QString::SkipEmptyParts);
if (parts.count() == 4)
return QRect(parts.at(0).toInt(),parts.at(1).toInt(),parts.at(2).toInt(),parts.at(3).toInt());
}
else if (AType == QVariant::RectF)
{
QList<QString> parts = AString.split(";",QString::SkipEmptyParts);
if (parts.count() == 4)
return QRectF(parts.at(0).toFloat(),parts.at(1).toFloat(),parts.at(2).toFloat(),parts.at(3).toFloat());
}
else if (AType == QVariant::Point)
{
QList<QString> parts = AString.split(";",QString::SkipEmptyParts);
if (parts.count() == 2)
return QPoint(parts.at(0).toInt(),parts.at(1).toInt());
}
else if (AType == QVariant::PointF)
{
QList<QString> parts = AString.split(";",QString::SkipEmptyParts);
if (parts.count() == 2)
return QPointF(parts.at(0).toFloat(),parts.at(1).toFloat());
}
else if (AType == QVariant::Size)
{
QList<QString> parts = AString.split(";",QString::SkipEmptyParts);
if (parts.count() == 2)
return QSize(parts.at(0).toInt(),parts.at(1).toInt());
}
else if (AType == QVariant::SizeF)
{
QList<QString> parts = AString.split(";",QString::SkipEmptyParts);
if (parts.count() == 2)
return QSizeF(parts.at(0).toFloat(),parts.at(1).toFloat());
}
else if (AType == QVariant::ByteArray)
{
return QByteArray::fromBase64(AString.toLatin1());
}
else if (AType == QVariant::StringList)
{
return !AString.isEmpty() ? AString.split(" ;; ") : QStringList();
}
else if(AType == QVariant::KeySequence)
{
return QKeySequence::fromString(AString,QKeySequence::PortableText);
}
else
{
QVariant var = QVariant(AString);
if (var.convert(AType))
return var;
}
return QVariant();
}
void exportOptionNode(const OptionsNode &ANode, QDomElement &AToElem)
{
QVariant value = ANode.value();
if (!value.isNull())
{
QDomText text = findChildText(AToElem);
if (!text.isNull())
text.setData(variantToString(value));
else
AToElem.appendChild(AToElem.ownerDocument().createTextNode(variantToString(value)));
AToElem.setAttribute("type",value.type());
}
else if (AToElem.hasAttribute("type"))
{
AToElem.removeAttribute("type");
AToElem.removeChild(findChildText(AToElem));
}
QString cname, spath, nspace;
foreach(QString childName, ANode.childNames())
{
foreach (QString childNSpace, ANode.childNSpaces(childName))
{
QDomElement childElem = findChildElement(AToElem,childName,childNSpace,cname,spath,nspace);
if (childElem.isNull())
{
childElem = AToElem.appendChild(AToElem.ownerDocument().createElement(cname)).toElement();
if (!nspace.isEmpty())
childElem.setAttribute("ns",nspace);
}
exportOptionNode(ANode.node(childName,childNSpace),childElem);
}
}
}
void importOptionNode(OptionsNode &ANode, const QDomElement &AFromElem)
{
if (AFromElem.hasAttribute("type"))
{
QString stringValue = findChildText(AFromElem).data();
ANode.setValue(stringToVariant(!stringValue.isNull() ? stringValue : QString(""), (QVariant::Type)AFromElem.attribute("type").toInt()));
}
else
ANode.setValue(QVariant());
QDomElement childElem = AFromElem.firstChildElement();
while (!childElem.isNull())
{
OptionsNode node = ANode.node(childElem.tagName(), childElem.attribute("ns"));
importOptionNode(node,childElem);
childElem = childElem.nextSiblingElement();
}
}
#define XTEA_ITERATIONS 64
#define rol(N, R) (((N) << (R)) | ((N) >> (32 - (R))))
void xtea2_encipher(unsigned int num_rounds, quint32 *v, quint32 const *k)
{
quint32 i;
quint32 a, b, c, d, sum=0, t,delta=0x9E3779B9;
a = v[0];
b = v[1] + k[0];
c = v[2];
d = v[3] + k[1];
for (i = 0; i < num_rounds; i++)
{
a += ((b << 4) ^ (b >> 5)) + (d ^ sum) + rol(k[sum & 3], b);
sum += delta;
c += ((d << 4) ^ (d >> 5)) + (b ^ sum) + rol(k[(sum >> 11) & 3], d);
t = a;
a = b;
b = c;
c = d;
d = t;
}
v[0] = a ^ k[2];
v[1] = b;
v[2] = c ^ k[3];
v[3] = d;
}
void xtea2_decipher(unsigned int num_rounds, quint32 *v, quint32 const *k)
{
quint32 i;
quint32 a, b, c, d, t, delta=0x9E3779B9, sum=delta*num_rounds;
d = v[3];
c = v[2] ^ k[3];
b = v[1];
a = v[0] ^ k[2];
for (i = 0; i < num_rounds; i++)
{
t = d;
d = c;
c = b;
b = a;
a = t;
c -= ((d << 4) ^ (d >> 5)) + (b ^ sum) + rol(k[(sum >> 11) & 3], d);
sum -= delta;
a -= ((b << 4) ^ (b >> 5)) + (d ^ sum) + rol(k[sum & 3], b);
}
v[0] = a;
v[1] = b - k[0];
v[2] = c;
v[3] = d - k[1];
}
//OptionNode
struct OptionsNode::OptionsNodeData
{
int refCount;
QString path;
QDomElement node;
};
const OptionsNode OptionsNode::null = OptionsNode(QDomElement());
OptionsNode::OptionsNode()
{
d = NULL;
operator=(OptionsNode::null);
}
OptionsNode::OptionsNode(const OptionsNode &ANode)
{
d = NULL;
operator=(ANode);
}
OptionsNode::OptionsNode(const QDomElement &ANode)
{
d = new OptionsNodeData;
d->refCount = 1;
d->node = ANode;
}
OptionsNode::~OptionsNode()
{
if (!(--d->refCount))
delete d;
}
bool OptionsNode::isNull() const
{
return d->node.isNull();
}
QString OptionsNode::path() const
{
if (d->path.isEmpty())
d->path = Options::node(QString::null).childPath(*this);
return d->path;
}
QString OptionsNode::name() const
{
return d->node.tagName();
}
QString OptionsNode::nspace() const
{
return d->node.attribute("ns");
}
OptionsNode OptionsNode::parent() const
{
return OptionsNode(d->node.parentNode().toElement());
}
QList<QString> OptionsNode::parentNSpaces() const
{
QList<QString> nspaces;
QDomElement parentElem = d->node.parentNode().toElement();
while (parentElem.parentNode().isElement())
{
nspaces.prepend(parentElem.attribute("ns"));
parentElem = parentElem.parentNode().toElement();
}
return nspaces;
}
QList<QString> OptionsNode::childNames() const
{
QList<QString> names;
QDomElement childElem = d->node.firstChildElement();
while (!childElem.isNull())
{
if (!names.contains(childElem.tagName()))
names.append(childElem.tagName());
childElem = childElem.nextSiblingElement();
}
return names;
}
QList<QString> OptionsNode::childNSpaces(const QString &AName) const
{
QList<QString> nspaces;
QDomElement childElem = d->node.firstChildElement(AName);
while (!childElem.isNull())
{
nspaces.append(childElem.attribute("ns"));
childElem = childElem.nextSiblingElement(AName);
}
return nspaces;
}
bool OptionsNode::isChildNode(const OptionsNode &ANode) const
{
QDomElement childElem = ANode.d->node;
while (!childElem.isNull())
{
if (d->node == childElem)
return true;
childElem = childElem.parentNode().toElement();
}
return false;
}
QString OptionsNode::childPath(const OptionsNode &ANode) const
{
QString result;
QDomElement childElem = ANode.d->node;
while (!childElem.isNull() && childElem!=d->node)
{
QString pathItem = !childElem.hasAttribute("ns") ? childElem.tagName() : childElem.tagName()+"["+childElem.attribute("ns")+"]";
if (result.isEmpty())
result = pathItem;
else
result.prepend(pathItem + ".");
childElem = childElem.parentNode().toElement();
}
return childElem==d->node ? result : QString::null;
}
void OptionsNode::removeChilds(const QString &AName, const QString &ANSpace) const
{
QDomElement childElem = d->node.firstChildElement();
while (!childElem.isNull())
{
QDomElement nextChild = childElem.nextSiblingElement();
if ((AName.isNull() || childElem.tagName()==AName) && (ANSpace.isNull() || childElem.attribute("ns")==ANSpace))
{
OptionsNode(childElem).removeChilds();
emit Options::instance()->optionsRemoved(OptionsNode(childElem));
d->node.removeChild(childElem);
}
childElem = nextChild;
}
}
OptionsNode OptionsNode::node(const QString &APath, const QString &ANSpace) const
{
QString cname, spath, nspace;
QDomElement childElem = findChildElement(d->node,APath,ANSpace,cname,spath,nspace);
if (!isNull() && childElem.isNull())
{
childElem = d->node.appendChild(d->node.ownerDocument().createElement(cname)).toElement();
if (!nspace.isEmpty())
childElem.setAttribute("ns",nspace);
emit Options::instance()->optionsCreated(OptionsNode(childElem));
}
return spath.isEmpty() || childElem.isNull() ? OptionsNode(childElem) : OptionsNode(childElem).node(spath, ANSpace);
}
bool OptionsNode::hasValue(const QString &APath, const QString &ANSpace) const
{
return APath.isEmpty() ? d->node.hasAttribute("type") : node(APath,ANSpace).hasValue();
}
QVariant OptionsNode::value(const QString &APath, const QString &ANSpace) const
{
if (APath.isEmpty())
{
if (d->node.hasAttribute("type"))
{
QString stringValue = findChildText(d->node).data();
return stringToVariant(!stringValue.isNull() ? stringValue : QString(""), (QVariant::Type)d->node.attribute("type").toInt());
}
return Options::defaultValue(path());
}
return node(APath,ANSpace).value();
}
void OptionsNode::setValue(const QVariant &AValue, const QString &APath, const QString &ANSpace)
{
if (!isNull())
{
if (APath.isEmpty())
{
if (value()!=AValue || d->node.hasAttribute("type")==AValue.isNull())
{
if (!AValue.isNull() && AValue!=Options::defaultValue(path()))
{
QDomText text = findChildText(d->node);
if (!text.isNull())
text.setData(variantToString(AValue));
else
d->node.appendChild(d->node.ownerDocument().createTextNode(variantToString(AValue)));
d->node.setAttribute("type",AValue.type());
emit Options::instance()->optionsChanged(*this);
}
else if (d->node.hasAttribute("type"))
{
d->node.removeChild(findChildText(d->node));
d->node.removeAttribute("type");
emit Options::instance()->optionsChanged(*this);
}
}
}
else
{
node(APath,ANSpace).setValue(AValue);
}
}
}
bool OptionsNode::operator==(const OptionsNode &AOther) const
{
return d->node == AOther.d->node;
}
bool OptionsNode::operator!=(const OptionsNode &AOther) const
{
return !operator==(AOther);
}
OptionsNode &OptionsNode::operator=(const OptionsNode &AOther)
{
if (d && !(--d->refCount))
delete d;
d = AOther.d;
d->refCount++;
return *this;
}
//Options
struct OptionItem
{
QVariant defValue;
};
struct Options::OptionsData
{
OptionsData() : globalSettings(QSettings::IniFormat, QSettings::UserScope, CLIENT_ORGANIZATION_NAME, CLIENT_NAME){}
QString filesPath;
QByteArray cryptKey;
QDomDocument options;
QHash<QString, OptionItem> items;
QSettings globalSettings;
};
Options::OptionsData *Options::d = new Options::OptionsData;
Options *Options::instance()
{
static Options *options = NULL;
if (!options)
options = new Options;
return options;
}
bool Options::isNull()
{
return d->options.isNull();
}
QString Options::filesPath()
{
return d->filesPath;
}
QByteArray Options::cryptKey()
{
return d->cryptKey;
}
QString Options::cleanNSpaces(const QString &APath)
{
QString cleanPath = APath;
for (int nsStart = cleanPath.indexOf('['); nsStart>=0; nsStart = cleanPath.indexOf('['))
cleanPath.remove(nsStart,cleanPath.indexOf(']',nsStart)-nsStart+1);
return cleanPath;
}
bool Options::hasNode(const QString &APath, const QString &ANSpace)
{
QString path = APath;
QString cname, spath, nspace;
QDomElement nodeElem = d->options.documentElement();
while (!nodeElem.isNull() && !path.isEmpty())
{
QDomElement childElem = findChildElement(nodeElem,path,ANSpace,cname,spath,nspace);
path = spath;
nodeElem = childElem;
}
return !nodeElem.isNull();
}
OptionsNode Options::node(const QString &APath, const QString &ANSpace)
{
return APath.isEmpty() ? OptionsNode(d->options.documentElement()) : OptionsNode(d->options.documentElement()).node(APath,ANSpace);
}
QVariant Options::fileValue(const QString &APath, const QString &ANSpace)
{
if (!Options::filesPath().isEmpty())
{
QFile file(fullFileName(APath,ANSpace));
if (file.open(QFile::ReadOnly))
{
QVariant value;
QDataStream stream(&file);
stream >> value;
file.close();
return value;
}
}
return Options::defaultValue(APath);
}
void Options::setFileValue(const QVariant &AValue, const QString &APath, const QString &ANSpace)
{
if (!Options::filesPath().isEmpty())
{
if (!AValue.isNull())
{
QFile file(fullFileName(APath,ANSpace));
if (file.open(QFile::WriteOnly|QFile::Truncate))
{
QDataStream stream(&file);
stream << AValue;
file.close();
}
}
else
{
QFile::remove(fullFileName(APath,ANSpace));
}
}
}
void Options::setOptions(QDomDocument AOptions, const QString &AFilesPath, const QByteArray &ACryptKey)
{
if (!d->options.isNull())
emit instance()->optionsClosed();
d->options = AOptions;
d->filesPath = AFilesPath;
d->cryptKey = ACryptKey;
if (!d->options.isNull())
emit instance()->optionsOpened();
}
QVariant Options::defaultValue(const QString &APath)
{
return d->items.value(cleanNSpaces(APath)).defValue;
}
void Options::setDefaultValue(const QString &APath, const QVariant &ADefault)
{
OptionItem &item = d->items[cleanNSpaces(APath)];
item.defValue = ADefault;
emit instance()->defaultValueChanged(APath,ADefault);
}
QByteArray Options::encrypt(const QVariant &AValue, const QByteArray &AKey)
{
if (AValue.type()>QVariant::Invalid && AValue.type()<QVariant::UserType && !AKey.isEmpty())
{
QByteArray cryptData = variantToString(AValue).toUtf8();
if (cryptData.size() % 16)
cryptData.append(QByteArray(16-(cryptData.size()%16),'\0'));
QByteArray cryptKey = AKey;
if (cryptKey.size() < 16)
{
int startSize = cryptKey.size();
cryptKey.resize(16);
for (int i = startSize; i < 16; i++)
cryptKey[i] = cryptKey[i % startSize];
}
for (int i = 0; i<cryptData.size(); i+=16)
xtea2_encipher(XTEA_ITERATIONS,(quint32 *)(cryptData.data()+i),(const quint32 *)cryptKey.constData());
return QByteArray::number(AValue.type()) + QByteArray(1,';') + cryptData.toBase64();
}
return QByteArray();
}
QVariant Options::decrypt(const QByteArray &AData, const QByteArray &AKey)
{
if (!AData.isEmpty() && !AKey.isEmpty())
{
QList<QByteArray> parts = AData.split(';');
QVariant::Type valType = parts.count()>1 ? (QVariant::Type)parts.value(0).toInt() : QVariant::String;
QByteArray cryptData = QByteArray::fromBase64(parts.value(parts.count()>1 ? 1 : 0));
if ((cryptData.size() % 16) == 0)
{
QByteArray cryptKey = AKey;
if (cryptKey.size() < 16)
{
int startSize = cryptKey.size();
cryptKey.resize(16);
for (int i = startSize; i < 16; i++)
cryptKey[i] = cryptKey[i % startSize];
}
for (int i = 0; i<cryptData.size(); i+=16)
xtea2_decipher(XTEA_ITERATIONS,(quint32 *)(cryptData.data()+i),(const quint32 *)cryptKey.constData());
return stringToVariant(QString::fromUtf8(cryptData),valType);
}
}
return QVariant();
}
void Options::exportNode(const QString &APath, QDomElement &AToElem)
{
if (hasNode(APath))
{
QString path = APath;
QString cname, spath, nspace;
QDomElement nodeElem = AToElem;
while (!path.isEmpty())
{
QDomElement childElem = findChildElement(nodeElem,path,QString::null,cname,spath,nspace);
if (childElem.isNull())
{
childElem = nodeElem.appendChild(nodeElem.ownerDocument().createElement(cname)).toElement();
if (!nspace.isEmpty())
childElem.setAttribute("ns",nspace);
}
path = spath;
nodeElem = childElem;
}
exportOptionNode(Options::node(APath), nodeElem);
}
}
void Options::importNode(const QString &APath, const QDomElement &AFromElem)
{
QString path = APath;
QString cname, spath, nspace;
QDomElement nodeElem = AFromElem;
while (!nodeElem.isNull() && !path.isEmpty())
{
QDomElement childElem = findChildElement(nodeElem,path,QString::null,cname,spath,nspace);
path = spath;
nodeElem = childElem;
}
if (!nodeElem.isNull())
{
OptionsNode node = Options::node(APath);
importOptionNode(node,nodeElem);
}
}
void Options::setGlobalValue(const QString &key, const QVariant &value)
{
d->globalSettings.setValue(key, value);
d->globalSettings.sync();
}
QVariant Options::globalValue(const QString &key, const QVariant &defaultValue)
{
return d->globalSettings.value(key, defaultValue);
}
bool Options::hasGlobalValue(const QString &key)
{
return d->globalSettings.contains(key);
}
void Options::removeGlobalValue(const QString &key)
{
d->globalSettings.remove(key);
}