File indexing completed on 2025-01-05 04:59:41
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Christian Mollekopf <chrigi_1@fastmail.fm> 0003 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #include "akonadistoragesettings.h" 0007 0008 #include <KConfig> 0009 #include <KConfigGroup> 0010 #include <KSharedConfig> 0011 0012 using namespace Akonadi; 0013 0014 StorageSettings::StorageSettings() 0015 : QObject() 0016 { 0017 } 0018 0019 StorageSettings &StorageSettings::instance() 0020 { 0021 static StorageSettings i; 0022 return i; 0023 } 0024 0025 Collection StorageSettings::defaultCollection() 0026 { 0027 KConfigGroup config(KSharedConfig::openConfig(), "General"); 0028 Collection::Id id = config.readEntry("defaultCollection", -1); 0029 return Collection(id); 0030 } 0031 0032 void StorageSettings::setDefaultCollection(const Collection &collection) 0033 { 0034 if (defaultCollection() == collection) 0035 return; 0036 0037 KConfigGroup config(KSharedConfig::openConfig(), "General"); 0038 config.writeEntry("defaultCollection", QString::number(collection.id())); 0039 config.sync(); 0040 emit defaultCollectionChanged(collection); 0041 } 0042 0043 #include "moc_akonadistoragesettings.cpp"