diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-08 16:48:41 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-07-08 16:48:41 +0200 |
commit | 3fe20509c29c40305d0362adbc787edfc29e96d4 (patch) | |
tree | f11f9e2604c56ccaa8606023e89b495928d990b3 /common/resourceconfig.cpp | |
parent | c0a8d67cde03e33bf21e0f186f85d4c89c7ff572 (diff) | |
download | sink-3fe20509c29c40305d0362adbc787edfc29e96d4.tar.gz sink-3fe20509c29c40305d0362adbc787edfc29e96d4.zip |
Filter queries by available resources, and filter resources by
resource-types
Diffstat (limited to 'common/resourceconfig.cpp')
-rw-r--r-- | common/resourceconfig.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/common/resourceconfig.cpp b/common/resourceconfig.cpp index 1f8fcda..ec72fb9 100644 --- a/common/resourceconfig.cpp +++ b/common/resourceconfig.cpp | |||
@@ -30,33 +30,38 @@ static QSharedPointer<QSettings> getSettings() | |||
30 | void ResourceConfig::addResource(const QByteArray &identifier, const QByteArray &type) | 30 | void ResourceConfig::addResource(const QByteArray &identifier, const QByteArray &type) |
31 | { | 31 | { |
32 | auto settings = getSettings(); | 32 | auto settings = getSettings(); |
33 | settings->beginGroup("resources"); | 33 | settings->beginGroup(QString::fromLatin1(identifier)); |
34 | settings->setValue(QString::fromLatin1(identifier), type); | 34 | settings->setValue("type", type); |
35 | settings->setValue("enabled", true); | ||
35 | settings->endGroup(); | 36 | settings->endGroup(); |
36 | // settings->beginGroup(identifier); | ||
37 | // //Add some settings? | ||
38 | // settings->endGroup(); | ||
39 | settings->sync(); | 37 | settings->sync(); |
40 | } | 38 | } |
41 | 39 | ||
42 | void ResourceConfig::removeResource(const QByteArray &identifier) | 40 | void ResourceConfig::removeResource(const QByteArray &identifier) |
43 | { | 41 | { |
44 | auto settings = getSettings(); | 42 | auto settings = getSettings(); |
45 | settings->beginGroup("resources"); | 43 | settings->beginGroup(QString::fromLatin1(identifier)); |
46 | settings->remove(QString::fromLatin1(identifier)); | 44 | settings->remove(""); |
47 | settings->endGroup(); | 45 | settings->endGroup(); |
48 | settings->sync(); | 46 | settings->sync(); |
49 | } | 47 | } |
50 | 48 | ||
51 | QList<QPair<QByteArray, QByteArray> > ResourceConfig::getResources() | 49 | QMap<QByteArray, QByteArray> ResourceConfig::getResources() |
52 | { | 50 | { |
53 | QList<QPair<QByteArray, QByteArray> > resources; | 51 | QMap<QByteArray, QByteArray> resources; |
54 | auto settings = getSettings(); | 52 | auto settings = getSettings(); |
55 | settings->beginGroup("resources"); | 53 | for (const auto &identifier : settings->childGroups()) { |
56 | for (const auto &identifier : settings->childKeys()) { | 54 | settings->beginGroup(identifier); |
57 | const auto type = settings->value(identifier).toByteArray(); | 55 | const auto type = settings->value("type").toByteArray(); |
58 | resources << qMakePair<QByteArray, QByteArray>(identifier.toLatin1(), type); | 56 | resources.insert(identifier.toLatin1(), type); |
57 | settings->endGroup(); | ||
59 | } | 58 | } |
60 | settings->endGroup(); | ||
61 | return resources; | 59 | return resources; |
62 | } | 60 | } |
61 | |||
62 | void ResourceConfig::clear() | ||
63 | { | ||
64 | auto settings = getSettings(); | ||
65 | settings->clear(); | ||
66 | settings->sync(); | ||
67 | } | ||