mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-05-11 20:30:27 +02:00
refactor: Add OptionsModel getOption/setOption methods
Easiest to review ignoring whitespace.
This commit is contained in:
parent
0de36941ec
commit
a63b60f02b
@ -335,9 +335,29 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
|||||||
{
|
{
|
||||||
if(role == Qt::EditRole)
|
if(role == Qt::EditRole)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
return getOption(OptionID(index.row()));
|
||||||
switch(index.row())
|
}
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
// write QSettings values
|
||||||
|
bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role)
|
||||||
|
{
|
||||||
|
bool successful = true; /* set to false on parse error */
|
||||||
|
if(role == Qt::EditRole)
|
||||||
{
|
{
|
||||||
|
successful = setOption(OptionID(index.row()), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_EMIT dataChanged(index, index);
|
||||||
|
|
||||||
|
return successful;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant OptionsModel::getOption(OptionID option) const
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
switch (option) {
|
||||||
case StartAtStartup:
|
case StartAtStartup:
|
||||||
return GUIUtil::GetStartOnSystemStartup();
|
return GUIUtil::GetStartOnSystemStartup();
|
||||||
case ShowTrayIcon:
|
case ShowTrayIcon:
|
||||||
@ -410,19 +430,14 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
|||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return QVariant();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// write QSettings values
|
bool OptionsModel::setOption(OptionID option, const QVariant& value)
|
||||||
bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role)
|
|
||||||
{
|
{
|
||||||
bool successful = true; /* set to false on parse error */
|
bool successful = true; /* set to false on parse error */
|
||||||
if(role == Qt::EditRole)
|
|
||||||
{
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
switch(index.row())
|
|
||||||
{
|
switch (option) {
|
||||||
case StartAtStartup:
|
case StartAtStartup:
|
||||||
successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
|
successful = GUIUtil::SetStartOnSystemStartup(value.toBool());
|
||||||
break;
|
break;
|
||||||
@ -585,9 +600,6 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Q_EMIT dataChanged(index, index);
|
|
||||||
|
|
||||||
return successful;
|
return successful;
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,8 @@ public:
|
|||||||
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
|
||||||
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override;
|
bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) override;
|
||||||
|
QVariant getOption(OptionID option) const;
|
||||||
|
bool setOption(OptionID option, const QVariant& value);
|
||||||
/** Updates current unit in memory, settings and emits displayUnitChanged(new_unit) signal */
|
/** Updates current unit in memory, settings and emits displayUnitChanged(new_unit) signal */
|
||||||
void setDisplayUnit(const QVariant& new_unit);
|
void setDisplayUnit(const QVariant& new_unit);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user