Thu, 09 Mar 2017 12:50:14 +0200
Laid groundwork for library collection support.
|
1204
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
1 | /* |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 - 2017 Teemu Piippo |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
4 | * |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
9 | * |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
14 | * |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
17 | */ |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
18 | |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
19 | #pragma once |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
20 | #include <QObject> |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
21 | #include <QSettings> |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
22 | #include "basics.h" |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
23 | |
|
1206
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
24 | /* |
|
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
25 | * This class encapsulates a simple interface around QSettings. It is derived by a subclass written by a code generator that implements |
|
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
26 | * static, type-safe configuration entries. |
|
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
27 | */ |
|
1204
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
28 | class BaseConfiguration : public QObject |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
29 | { |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
30 | Q_OBJECT |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
31 | |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
32 | public: |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
33 | BaseConfiguration(); |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
34 | |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
35 | bool existsEntry(const QString& name); |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
36 | QVariant defaultValueByName(const QString& name); |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
37 | virtual void initDefaults(); |
|
1206
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
38 | void setValue(const QString& name, const QVariant& value); |
|
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
39 | void setValue(const QString& name, const QVariant& value, const QVariant& defaultValue); |
|
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
40 | void sync(); |
|
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
41 | QVariant value(const QString& name); |
|
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
42 | QVariant value(const QString& name, const QVariant& defaultValue); |
|
1204
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
43 | |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
44 | signals: |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
45 | void configurationChanged(QString, QVariant, QVariant); |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
46 | |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
47 | protected: |
|
1206
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
48 | void registerConfigurationEntry(const QString& name, const QVariant& value); |
|
1204
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
49 | |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
50 | private: |
|
1206
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
51 | QMap<QString, QVariant> m_defaults; |
|
743dc95e0be6
Better encapsulated the BaseConfiguration class.
Teemu Piippo <teemu@hecknology.net>
parents:
1204
diff
changeset
|
52 | QSettings m_settings; |
|
1204
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
53 | bool m_isInitialized = false; |
|
1d25231dd7c9
Split the configuration main interface to a new class, BaseInterface, so that moc can properly deal with it.
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
54 | }; |