Qt: ConfigController::getOption now has a default argument

This commit is contained in:
Vicki Pfau 2017-08-03 22:20:32 -07:00
parent 75e609f65c
commit 17fa98fe4e
2 changed files with 10 additions and 6 deletions

View File

@ -158,12 +158,16 @@ void ConfigController::updateOption(const char* key) {
m_optionSet[optionName]->setValue(mCoreConfigGetValue(&m_config, key)); m_optionSet[optionName]->setValue(mCoreConfigGetValue(&m_config, key));
} }
QString ConfigController::getOption(const char* key) const { QString ConfigController::getOption(const char* key, const QVariant& defaultVal) const {
return QString(mCoreConfigGetValue(&m_config, key)); const char* val = mCoreConfigGetValue(&m_config, key);
if (val) {
return QString(val);
}
return defaultVal.toString();
} }
QString ConfigController::getOption(const QString& key) const { QString ConfigController::getOption(const QString& key, const QVariant& defaultVal) const {
return getOption(key.toUtf8().constData()); return getOption(key.toUtf8().constData(), defaultVal);
} }
QVariant ConfigController::getQtOption(const QString& key, const QString& group) const { QVariant ConfigController::getQtOption(const QString& key, const QString& group) const {

View File

@ -70,8 +70,8 @@ public:
ConfigOption* addOption(const char* key); ConfigOption* addOption(const char* key);
void updateOption(const char* key); void updateOption(const char* key);
QString getOption(const char* key) const; QString getOption(const char* key, const QVariant& defaultVal = QVariant()) const;
QString getOption(const QString& key) const; QString getOption(const QString& key, const QVariant& defaultVal = QVariant()) const;
QVariant getQtOption(const QString& key, const QString& group = QString()) const; QVariant getQtOption(const QString& key, const QString& group = QString()) const;