39 lines
1.1 KiB
C
39 lines
1.1 KiB
C
|
|
#ifndef SETTINGS_H
|
|||
|
|
#define SETTINGS_H
|
|||
|
|
|
|||
|
|
#include <QObject>
|
|||
|
|
#include <QSettings>
|
|||
|
|
|
|||
|
|
#include "global.h"
|
|||
|
|
|
|||
|
|
class Settings
|
|||
|
|
{
|
|||
|
|
public:
|
|||
|
|
//获取单例实例
|
|||
|
|
static Settings& instance();
|
|||
|
|
//基础读写接口
|
|||
|
|
void setValue(const QString& group, const QString& name, const QVariant& value);
|
|||
|
|
QVariant value(const QString& group, const QString& name);
|
|||
|
|
void clearValue(const QString& group, const QString& name);
|
|||
|
|
//数据库配置读写接口
|
|||
|
|
QStringList getConnectionList();
|
|||
|
|
DatabaseConfig loadDatabaseConfig(const QString& configID);
|
|||
|
|
void saveDatabaseConfig(const DatabaseConfig& config);
|
|||
|
|
void removeDatabaseConfig(const QString& configID);
|
|||
|
|
|
|||
|
|
private:
|
|||
|
|
explicit Settings();
|
|||
|
|
~Settings();
|
|||
|
|
// 禁止拷贝
|
|||
|
|
Settings(const Settings&) = delete; //delete关键字表示该函数不可用,包括编译器自动生成的函数
|
|||
|
|
Settings& operator=(const Settings&) = delete;
|
|||
|
|
|
|||
|
|
QVariant getDefaultValue(const QString& group, const QString& name);
|
|||
|
|
|
|||
|
|
QSettings* m_settings;
|
|||
|
|
QString m_settingsFile;
|
|||
|
|
bool m_isVaildSettingsFile;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
#endif // SETTINGS_H
|