mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:53:23 +00:00
Cleanup: remove redundant Roles:: qualifier in maplocationmodel.cpp
"Roles" is a C-style enum (i.e. not C++-style enum class). Since that means that the names spill into the outer namespace, the names themselves are prefixed with "Role". Nevertheless the code qualified the names with "Roles::". This is redundant and unnecessary. Remove this redundancy to show that we understand how the language works. Note: we could also transform the enum into an enum class and remove the "Role" prefix from the names. That would arguably be "cleaner", but then the enum doesn't auto-convert to/from int, but Qt uses int to pass the roles to functions. So let's go the simple way that avoids casting. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
46e120f81a
commit
7d2fe2b7c6
1 changed files with 12 additions and 12 deletions
|
@ -29,19 +29,19 @@ static bool inEditMode()
|
|||
QVariant MapLocation::getRole(int role) const
|
||||
{
|
||||
switch (role) {
|
||||
case Roles::RoleDivesite:
|
||||
case RoleDivesite:
|
||||
return QVariant::fromValue(divesite);
|
||||
case Roles::RoleCoordinate:
|
||||
case RoleCoordinate:
|
||||
return QVariant::fromValue(coordinate);
|
||||
case Roles::RoleName:
|
||||
case RoleName:
|
||||
return QVariant::fromValue(name);
|
||||
case Roles::RolePixmap:
|
||||
case RolePixmap:
|
||||
return selected ? QString("qrc:///dive-location-marker-selected-icon") :
|
||||
inEditMode() ? QString("qrc:///dive-location-marker-inactive-icon") :
|
||||
QString("qrc:///dive-location-marker-icon");
|
||||
case Roles::RoleZ:
|
||||
case RoleZ:
|
||||
return selected ? 1 : 0;
|
||||
case Roles::RoleIsSelected:
|
||||
case RoleIsSelected:
|
||||
return QVariant::fromValue(selected);
|
||||
default:
|
||||
return QVariant();
|
||||
|
@ -69,12 +69,12 @@ QVariant MapLocationModel::data(const QModelIndex & index, int role) const
|
|||
QHash<int, QByteArray> MapLocationModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[MapLocation::Roles::RoleDivesite] = "divesite";
|
||||
roles[MapLocation::Roles::RoleCoordinate] = "coordinate";
|
||||
roles[MapLocation::Roles::RoleName] = "name";
|
||||
roles[MapLocation::Roles::RolePixmap] = "pixmap";
|
||||
roles[MapLocation::Roles::RoleZ] = "z";
|
||||
roles[MapLocation::Roles::RoleIsSelected] = "isSelected";
|
||||
roles[MapLocation::RoleDivesite] = "divesite";
|
||||
roles[MapLocation::RoleCoordinate] = "coordinate";
|
||||
roles[MapLocation::RoleName] = "name";
|
||||
roles[MapLocation::RolePixmap] = "pixmap";
|
||||
roles[MapLocation::RoleZ] = "z";
|
||||
roles[MapLocation::RoleIsSelected] = "isSelected";
|
||||
return roles;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue