|
QtCanpool 3.3.0
|
Thin wrapper around QSettings that keeps call sites free of the usual boilerplate: typed accessors with defaults, group handling and a versioned migration hook for layout changes between releases. 更多...
#include <qxcore/qxsettings.h>

Public 类型 | |
| using | Migration = std::function< void(QxSettings &settings)> |
| A migration step that upgrades the stored layout to a target version. | |
Public 成员函数 | |
| QxSettings (const QString &organization, const QString &application=QString(), QObject *parent=nullptr) | |
| Settings stored in the platform-native location for organization / application. | |
| QxSettings (const QString &fileName, QSettings::Format format, QObject *parent=nullptr) | |
| Settings stored in an explicit file, which keeps tests hermetic. | |
| ~QxSettings () override | |
| QSettings * | settings () const |
| The underlying QSettings instance, never null. | |
| QString | fileName () const |
| Backing file name, empty for platform-native storage. | |
| void | beginGroup (const QString &prefix) |
| void | endGroup () |
| QString | group () const |
| bool | contains (const QString &key) const |
| QVariant | value (const QString &key, const QVariant &defaultValue=QVariant()) const |
| QString | stringValue (const QString &key, const QString &defaultValue=QString()) const |
| int | intValue (const QString &key, int defaultValue=0) const |
| bool | boolValue (const QString &key, bool defaultValue=false) const |
| QStringList | stringListValue (const QString &key, const QStringList &defaultValue=QStringList()) const |
| QStringList | allKeys () const |
| void | setValue (const QString &key, const QVariant &value) |
| void | remove (const QString &key) |
| void | clear () |
| void | sync () |
| void | setVersionKey (const QString &key) |
| Key holding the layout version; "version" by default. | |
| QString | versionKey () const |
| int | version () const |
| void | setVersion (int version) |
| void | addMigration (int version, Migration migration) |
| Registers a migration that upgrades the layout to version. | |
| int | migrate (int targetVersion) |
| Applies every registered step whose version is greater than the stored version and not greater than targetVersion, then stores targetVersion. | |
| void | valueChanged (const QString &key, const QVariant &value) |
| Emitted whenever a value is written or removed. | |
Thin wrapper around QSettings that keeps call sites free of the usual boilerplate: typed accessors with defaults, group handling and a versioned migration hook for layout changes between releases.
A QxSettings object owns its QSettings instance, so an application can keep one instance instead of constructing QSettings everywhere; when a migration step runs it always goes through the same object the application reads from.
在文件 qxsettings.h 第 31 行定义.
| using QxCore::QxSettings::Migration = std::function<void(QxSettings &settings)> |
A migration step that upgrades the stored layout to a target version.
在文件 qxsettings.h 第 36 行定义.
|
explicit |
Settings stored in the platform-native location for organization / application.
在文件 qxsettings.cpp 第 34 行定义.
|
explicit |
Settings stored in an explicit file, which keeps tests hermetic.
在文件 qxsettings.cpp 第 42 行定义.
|
override |
在文件 qxsettings.cpp 第 50 行定义.
| void QxCore::QxSettings::addMigration | ( | int | version, |
| Migration | migration | ||
| ) |
Registers a migration that upgrades the layout to version.
Steps run in ascending version order, so a jump across several versions applies every step in between.
在文件 qxsettings.cpp 第 183 行定义.
| QStringList QxCore::QxSettings::allKeys | ( | ) | const |
在文件 qxsettings.cpp 第 121 行定义.
| void QxCore::QxSettings::beginGroup | ( | const QString & | prefix | ) |
在文件 qxsettings.cpp 第 69 行定义.
| bool QxCore::QxSettings::boolValue | ( | const QString & | key, |
| bool | defaultValue = false |
||
| ) | const |
在文件 qxsettings.cpp 第 111 行定义.
| void QxCore::QxSettings::clear | ( | ) |
在文件 qxsettings.cpp 第 144 行定义.
| bool QxCore::QxSettings::contains | ( | const QString & | key | ) | const |
在文件 qxsettings.cpp 第 89 行定义.
| void QxCore::QxSettings::endGroup | ( | ) |
在文件 qxsettings.cpp 第 75 行定义.
| QString QxCore::QxSettings::fileName | ( | ) | const |
Backing file name, empty for platform-native storage.
在文件 qxsettings.cpp 第 61 行定义.
| QString QxCore::QxSettings::group | ( | ) | const |
在文件 qxsettings.cpp 第 81 行定义.
| int QxCore::QxSettings::intValue | ( | const QString & | key, |
| int | defaultValue = 0 |
||
| ) | const |
在文件 qxsettings.cpp 第 106 行定义.
| int QxCore::QxSettings::migrate | ( | int | targetVersion | ) |
Applies every registered step whose version is greater than the stored version and not greater than targetVersion, then stores targetVersion.
Returns the number of steps that ran, or 0 when the stored version is already at targetVersion or beyond.
在文件 qxsettings.cpp 第 189 行定义.
| void QxCore::QxSettings::remove | ( | const QString & | key | ) |
在文件 qxsettings.cpp 第 136 行定义.
| QSettings * QxCore::QxSettings::settings | ( | ) | const |
The underlying QSettings instance, never null.
在文件 qxsettings.cpp 第 55 行定义.
| void QxCore::QxSettings::setValue | ( | const QString & | key, |
| const QVariant & | value | ||
| ) |
在文件 qxsettings.cpp 第 129 行定义.
| void QxCore::QxSettings::setVersion | ( | int | version | ) |
在文件 qxsettings.cpp 第 177 行定义.
| void QxCore::QxSettings::setVersionKey | ( | const QString & | key | ) |
Key holding the layout version; "version" by default.
在文件 qxsettings.cpp 第 159 行定义.
| QStringList QxCore::QxSettings::stringListValue | ( | const QString & | key, |
| const QStringList & | defaultValue = QStringList() |
||
| ) | const |
在文件 qxsettings.cpp 第 116 行定义.
| QString QxCore::QxSettings::stringValue | ( | const QString & | key, |
| const QString & | defaultValue = QString() |
||
| ) | const |
在文件 qxsettings.cpp 第 101 行定义.
| void QxCore::QxSettings::sync | ( | ) |
在文件 qxsettings.cpp 第 151 行定义.
| QVariant QxCore::QxSettings::value | ( | const QString & | key, |
| const QVariant & | defaultValue = QVariant() |
||
| ) | const |
在文件 qxsettings.cpp 第 95 行定义.
| void QxCore::QxSettings::valueChanged | ( | const QString & | key, |
| const QVariant & | value | ||
| ) |
Emitted whenever a value is written or removed.
key is the group-qualified key, the same one the next read would use.
| int QxCore::QxSettings::version | ( | ) | const |
在文件 qxsettings.cpp 第 171 行定义.
| QString QxCore::QxSettings::versionKey | ( | ) | const |
在文件 qxsettings.cpp 第 165 行定义.