DtkCore
DTK Core module
dsettingsgroup.h
1/*
2 * Copyright (C) 2016 ~ 2017 Deepin Technology Co., Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <QObject>
21#include <QPointer>
22
23#include "dsettingsoption.h"
24
25#include "dtkcore_global.h"
26
27DCORE_BEGIN_NAMESPACE
28
29class DSettingsGroupPrivate;
30class LIBDTKCORESHARED_EXPORT DSettingsGroup : public QObject
31{
32 Q_OBJECT
33public:
34 explicit DSettingsGroup(QObject *parent = Q_NULLPTR);
36
37 QPointer<DSettingsGroup> parentGroup() const;
38 void setParentGroup(QPointer<DSettingsGroup> parentGroup);
39
40 QString key() const;
41 QString name() const;
42 bool isHidden() const;
43
44 QPointer<DSettingsGroup> childGroup(const QString &groupKey) const;
45 QPointer<DSettingsOption> option(const QString &key) const;
46
47 QList<QPointer<DSettingsGroup> > childGroups() const;
48 QList<QPointer<DSettingsOption> > childOptions() const;
49 QList<QPointer<DSettingsOption> > options() const;
50
51 static QPointer<DSettingsGroup> fromJson(const QString &prefixKey, const QJsonObject &group);
52
53private:
54 void parseJson(const QString &prefixKey, const QJsonObject &group);
55
56 QScopedPointer<DSettingsGroupPrivate> dd_ptr;
57 Q_DECLARE_PRIVATE_D(qGetPtrHelper(dd_ptr), DSettingsGroup)
58};
59
60typedef QPointer<DSettingsGroup> GroupPtr;
61
62DCORE_END_NAMESPACE
A group of DSettingsOption and DSettingsGroup. DSettingsGroup can contain a lost option and subgroup.
Definition: dsettingsgroup.h:31