settingsproviderqt.cpp
1 //------------------------------------------------------------------------------
2 // settingsproviderqt.cpp
3 //------------------------------------------------------------------------------
4 // Copyright 2011 - 2013 Zalewa <zalewapl@gmail.com>. All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 //
9 // 1. Redistributions of source code must retain the above copyright notice,
10 // this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in
14 // the documentation and/or other materials provided with
15 // the distribution.
16 //
17 // THIS SOFTWARE IS PROVIDED BY ZALEWA ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20 // EVENT SHALL ZALEWA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
26 // WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
27 // OF SUCH DAMAGE.
28 //
29 // The views and conclusions contained in the software and documentation are
30 // those of the authors and should not be interpreted as representing official
31 // policies, either expressed or implied, of Zalewa.
32 //------------------------------------------------------------------------------
33 // Copyright (C) 2013 "Zalewa" <zalewapl@gmail.com>
34 //------------------------------------------------------------------------------
35 #include "settingsproviderqt.h"
36 
37 #include <cassert>
38 
39 DClass<SettingsProviderQt>
40 {
41  public:
42  QSettings* target;
43 };
44 
45 DPointered(SettingsProviderQt)
46 
47 SettingsProviderQt::SettingsProviderQt(QSettings* target)
48 {
49  d->target = target;
50 }
51 
52 SettingsProviderQt::~SettingsProviderQt()
53 {
54 }
55 
56 QStringList SettingsProviderQt::allKeys() const
57 {
58  assert(d->target != NULL);
59  return d->target->allKeys();
60 }
61 
62 QStringList SettingsProviderQt::allSections() const
63 {
64  assert(d->target != NULL);
65  return d->target->childGroups();
66 }
67 
68 bool SettingsProviderQt::hasKey(const QString& key) const
69 {
70  return d->target->contains(key);
71 }
72 
73 void SettingsProviderQt::remove(const QString& key)
74 {
75  d->target->remove(key);
76 }
77 
78 void SettingsProviderQt::setValue(const QString& key, const QVariant& value)
79 {
80  assert(d->target != NULL);
81  d->target->setValue(key, value);
82 }
83 
84 QVariant SettingsProviderQt::value(const QString& key, QVariant defValue) const
85 {
86  assert(d->target != NULL);
87  return d->target->value(key, defValue);
88 }