File indexing completed on 2024-05-19 04:55:56
0001 /** 0002 * \file isettings.h 0003 * Interface for application settings. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 07 Apr 2013 0008 * 0009 * Copyright (C) 2013-2018 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include <QVariant> 0030 #include "kid3api.h" 0031 0032 class QString; 0033 0034 /** 0035 * Interface for application settings. 0036 */ 0037 class KID3_CORE_EXPORT ISettings { 0038 public: 0039 /** 0040 * Destructor. 0041 */ 0042 virtual ~ISettings(); 0043 0044 /** 0045 * Use settings subgroup. 0046 * @param prefix group name 0047 * @param forState true if this group stores state information 0048 */ 0049 virtual void beginGroup(const QString& prefix, bool forState = false) = 0; 0050 0051 /** 0052 * Finnish using settings subgroup. 0053 */ 0054 virtual void endGroup() = 0; 0055 0056 /** 0057 * Set value for setting. 0058 * @param key name of setting 0059 * @param value value for setting 0060 */ 0061 virtual void setValue(const QString& key, const QVariant& value) = 0; 0062 0063 /** 0064 * Get value for setting. 0065 * @param key name of setting 0066 * @param defaultValue default value 0067 * @return value of setting as variant. 0068 */ 0069 virtual QVariant value(const QString& key, 0070 const QVariant& defaultValue) const = 0; 0071 0072 /** 0073 * Remove setting. 0074 * @param key name of setting 0075 */ 0076 virtual void remove(const QString& key) = 0; 0077 0078 /** 0079 * Check if setting exists. 0080 * @param key name of setting 0081 * @return true if setting exists. 0082 */ 0083 virtual bool contains(const QString& key) const = 0; 0084 0085 /** 0086 * Write unsaved changes to permanent storage. 0087 */ 0088 virtual void sync() = 0; 0089 0090 protected: 0091 /** 0092 * Migrate from an old settings version. 0093 * Can be called from the constructor of derived classes to automatically 0094 * convert old settings. 0095 */ 0096 void migrateOldSettings(); 0097 };