mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
cleanup: directly return from DivePictureModel::data()
Instead of assigning to a QVariant ret and returning at the end, return directly in the various switch-cases. This makes the code more readable, and is more idiomatic C++, as it avoids unnecessary copies. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3f3869ff65
commit
1fd8ea9d49
1 changed files with 10 additions and 18 deletions
|
@ -79,42 +79,34 @@ int DivePictureModel::columnCount(const QModelIndex&) const
|
||||||
|
|
||||||
QVariant DivePictureModel::data(const QModelIndex &index, int role) const
|
QVariant DivePictureModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
QVariant ret;
|
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return ret;
|
return QVariant();
|
||||||
|
|
||||||
const PictureEntry &entry = pictures.at(index.row());
|
const PictureEntry &entry = pictures.at(index.row());
|
||||||
if (index.column() == 0) {
|
if (index.column() == 0) {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
ret = entry.filename;
|
return entry.filename;
|
||||||
break;
|
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
ret = entry.image.scaled(size, size, Qt::KeepAspectRatio);
|
return entry.image.scaled(size, size, Qt::KeepAspectRatio);
|
||||||
break;
|
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
ret = QFileInfo(entry.filename).fileName();
|
return QFileInfo(entry.filename).fileName();
|
||||||
break;
|
|
||||||
case Qt::DisplayPropertyRole:
|
case Qt::DisplayPropertyRole:
|
||||||
ret = QFileInfo(entry.filename).filePath();
|
return QFileInfo(entry.filename).filePath();
|
||||||
break;
|
|
||||||
case Qt::UserRole:
|
case Qt::UserRole:
|
||||||
ret = entry.diveId;
|
return entry.diveId;
|
||||||
break;
|
|
||||||
case Qt::UserRole + 1:
|
case Qt::UserRole + 1:
|
||||||
ret = entry.offsetSeconds;
|
return entry.offsetSeconds;
|
||||||
break;
|
|
||||||
case Qt::UserRole + 2:
|
case Qt::UserRole + 2:
|
||||||
ret = entry.length.seconds;
|
return entry.length.seconds;
|
||||||
}
|
}
|
||||||
} else if (index.column() == 1) {
|
} else if (index.column() == 1) {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Qt::DisplayRole:
|
case Qt::DisplayRole:
|
||||||
ret = entry.filename;
|
return entry.filename;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true if we actually removed a picture
|
// Return true if we actually removed a picture
|
||||||
|
|
Loading…
Reference in a new issue