mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cleanup: return directly in ExtraDataModel::data()
Instead of assigning to a ret variable and returning at the end of the function, return directly from the various switch branches. This is more idiomatic and consistent with the other models. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
6790e07a4c
commit
2ff459c356
1 changed files with 7 additions and 12 deletions
|
@ -20,33 +20,28 @@ void ExtraDataModel::clear()
|
||||||
|
|
||||||
QVariant ExtraDataModel::data(const QModelIndex &index, int role) const
|
QVariant ExtraDataModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
QVariant ret;
|
|
||||||
struct extra_data *ed = get_dive_dc(&displayed_dive, dc_number)->extra_data;
|
struct extra_data *ed = get_dive_dc(&displayed_dive, dc_number)->extra_data;
|
||||||
int i = -1;
|
int i = -1;
|
||||||
while (ed && ++i < index.row())
|
while (ed && ++i < index.row())
|
||||||
ed = ed->next;
|
ed = ed->next;
|
||||||
if (!ed)
|
if (!ed)
|
||||||
return ret;
|
return QVariant();
|
||||||
|
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::FontRole:
|
case Qt::FontRole:
|
||||||
ret = defaultModelFont();
|
return defaultModelFont();
|
||||||
break;
|
|
||||||
case Qt::TextAlignmentRole:
|
case Qt::TextAlignmentRole:
|
||||||
ret = int(Qt::AlignLeft | Qt::AlignVCenter);
|
return static_cast<int>(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
break;
|
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
switch (index.column()) {
|
switch (index.column()) {
|
||||||
case KEY:
|
case KEY:
|
||||||
ret = QString(ed->key);
|
return ed->key;
|
||||||
break;
|
|
||||||
case VALUE:
|
case VALUE:
|
||||||
ret = QString(ed->value);
|
return ed->value;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
break;
|
return QVariant();
|
||||||
}
|
}
|
||||||
return ret;
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
int ExtraDataModel::rowCount(const QModelIndex&) const
|
int ExtraDataModel::rowCount(const QModelIndex&) const
|
||||||
|
|
Loading…
Add table
Reference in a new issue