Changeset View
Changeset View
Standalone View
Standalone View
src/akonadi/akonadistoragesettings.cpp
Show All 33 Lines | |||||
34 | } | 34 | } | ||
35 | 35 | | |||
36 | StorageSettings &StorageSettings::instance() | 36 | StorageSettings &StorageSettings::instance() | ||
37 | { | 37 | { | ||
38 | static StorageSettings i; | 38 | static StorageSettings i; | ||
39 | return i; | 39 | return i; | ||
40 | } | 40 | } | ||
41 | 41 | | |||
42 | Collection::List StorageSettings::activeCollections() | | |||
43 | { | | |||
44 | KConfigGroup config(KSharedConfig::openConfig(), "General"); | | |||
45 | QList<Collection::Id> ids = config.readEntry("activeCollections", QList<Collection::Id>()); | | |||
46 | Collection::List list; | | |||
47 | list.reserve(ids.size()); | | |||
48 | foreach (const auto &id, ids) { | | |||
49 | list << Collection(id); | | |||
50 | } | | |||
51 | return list; | | |||
52 | } | | |||
53 | | ||||
54 | Collection StorageSettings::defaultNoteCollection() | 42 | Collection StorageSettings::defaultNoteCollection() | ||
55 | { | 43 | { | ||
56 | KConfigGroup config(KSharedConfig::openConfig(), "General"); | 44 | KConfigGroup config(KSharedConfig::openConfig(), "General"); | ||
57 | Collection::Id id = config.readEntry("defaultNoteCollection", -1); | 45 | Collection::Id id = config.readEntry("defaultNoteCollection", -1); | ||
58 | return Collection(id); | 46 | return Collection(id); | ||
59 | } | 47 | } | ||
60 | 48 | | |||
61 | Collection StorageSettings::defaultTaskCollection() | 49 | Collection StorageSettings::defaultTaskCollection() | ||
Show All 19 Lines | 68 | { | |||
81 | if (defaultTaskCollection() == collection) | 69 | if (defaultTaskCollection() == collection) | ||
82 | return; | 70 | return; | ||
83 | 71 | | |||
84 | KConfigGroup config(KSharedConfig::openConfig(), "General"); | 72 | KConfigGroup config(KSharedConfig::openConfig(), "General"); | ||
85 | config.writeEntry("defaultCollection", QString::number(collection.id())); | 73 | config.writeEntry("defaultCollection", QString::number(collection.id())); | ||
86 | config.sync(); | 74 | config.sync(); | ||
87 | emit defaultTaskCollectionChanged(collection); | 75 | emit defaultTaskCollectionChanged(collection); | ||
88 | } | 76 | } | ||
89 | | ||||
90 | void StorageSettings::setActiveCollections(const Collection::List &collections) | | |||
91 | { | | |||
92 | if (activeCollections() == collections) | | |||
93 | return; | | |||
94 | | ||||
95 | QList<Collection::Id> ids; | | |||
96 | for (const auto &col : collections) { | | |||
97 | ids << col.id(); | | |||
98 | } | | |||
99 | | ||||
100 | KConfigGroup config(KSharedConfig::openConfig(), "General"); | | |||
101 | config.writeEntry("activeCollections", ids); | | |||
102 | config.sync(); | | |||
103 | emit activeCollectionsChanged(collections); | | |||
104 | } | |