@@ -1,28 +1,105 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright 2013 Canonical Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
5+ * it under the terms of the GNU Lesser General Public License as published by
66 * the Free Software Foundation; version 3.
77 *
88 * This program is distributed in the hope that it will be useful,
99 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
11+ * GNU Lesser General Public License for more details.
1212 *
13− * You should have received a copy of the GNU General Public License
13+ * You should have received a copy of the GNU Lesser General Public License
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
1717#include "fake_gsettings.h"
18−#include "fake_schema.h"
1918
20−GSettings::GSettings(QObject *parent) :
21− QObject(parent)
22−{
23− m_schema = new Schema();
19+struct GSettingsSchemaQmlPrivate {
20+ QByteArray id;
21+ QByteArray path;
22+};
23+
24+struct GSettingsQmlPrivate {
25+ GSettingsSchemaQml *schema;
26+};
27+
28+bool GSettingsControllerQml::instance_exists;
29+GSettingsControllerQml* GSettingsControllerQml::_controllerInstance;
30+
31+GSettingsControllerQml::GSettingsControllerQml() {
32+}
33+
34+GSettingsControllerQml::~GSettingsControllerQml() {
35+ instance_exists = false;
36+}
37+
38+GSettingsControllerQml* GSettingsControllerQml::getInstance() {
39+ if(!instance_exists) {
40+ _controllerInstance = new GSettingsControllerQml();
41+ instance_exists = true;
42+ return _controllerInstance;
43+ } else {
44+ return _controllerInstance;
45+ }
46+}
47+
48+GSettingsSchemaQml::GSettingsSchemaQml(QObject *parent): QObject(parent) {
49+ priv = new GSettingsSchemaQmlPrivate;
50+}
51+
52+GSettingsSchemaQml::~GSettingsSchemaQml() {
53+ delete priv;
54+}
55+
56+QByteArray GSettingsSchemaQml::id() const {
57+ return priv->id;
58+}
59+
60+void GSettingsSchemaQml::setId(const QByteArray &id) {
61+ if (!priv->id.isEmpty()) {
62+ qWarning("GSettings.schema.id may only be set on construction");
63+ return;
64+ }
65+
66+ priv->id = id;
67+}
68+
69+QByteArray GSettingsSchemaQml::path() const {
70+ return priv->path;
71+}
72+
73+void GSettingsSchemaQml::setPath(const QByteArray &path) {
74+ if (!priv->path.isEmpty()) {
75+ qWarning("GSettings.schema.path may only be set on construction");
76+ return;
77+ }
78+
79+ priv->path = path;
80+}
81+
82+GSettingsQml::GSettingsQml(QObject *parent): QObject(parent) {
83+ GSettingsControllerQml::getInstance();
84+ priv = new GSettingsQmlPrivate;
85+ priv->schema = new GSettingsSchemaQml(this);
86+}
87+
88+GSettingsQml::~GSettingsQml() {
89+ delete priv;
90+}
91+
92+GSettingsSchemaQml * GSettingsQml::schema() const {
93+ return priv->schema;
94+}
95+
96+QString GSettingsQml::pictureUri() const {
97+ return m_pictureUri;
2498}
2599
26−QObject GSettings::schema() const {
27− return m_schema;
100+void GSettingsQml::setPictureUri(const QString &str) {
101+ if (str != m_pictureUri) {
102+ m_pictureUri = str;
103+ Q_EMIT pictureUriChanged(m_pictureUri);
104+ }
28105}