mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:43:24 +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
|
QVariant MapLocation::getRole(int role) const
|
||||||
{
|
{
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case Roles::RoleDivesite:
|
case RoleDivesite:
|
||||||
return QVariant::fromValue(divesite);
|
return QVariant::fromValue(divesite);
|
||||||
case Roles::RoleCoordinate:
|
case RoleCoordinate:
|
||||||
return QVariant::fromValue(coordinate);
|
return QVariant::fromValue(coordinate);
|
||||||
case Roles::RoleName:
|
case RoleName:
|
||||||
return QVariant::fromValue(name);
|
return QVariant::fromValue(name);
|
||||||
case Roles::RolePixmap:
|
case RolePixmap:
|
||||||
return selected ? QString("qrc:///dive-location-marker-selected-icon") :
|
return selected ? QString("qrc:///dive-location-marker-selected-icon") :
|
||||||
inEditMode() ? QString("qrc:///dive-location-marker-inactive-icon") :
|
inEditMode() ? QString("qrc:///dive-location-marker-inactive-icon") :
|
||||||
QString("qrc:///dive-location-marker-icon");
|
QString("qrc:///dive-location-marker-icon");
|
||||||
case Roles::RoleZ:
|
case RoleZ:
|
||||||
return selected ? 1 : 0;
|
return selected ? 1 : 0;
|
||||||
case Roles::RoleIsSelected:
|
case RoleIsSelected:
|
||||||
return QVariant::fromValue(selected);
|
return QVariant::fromValue(selected);
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
@ -69,12 +69,12 @@ QVariant MapLocationModel::data(const QModelIndex & index, int role) const
|
||||||
QHash<int, QByteArray> MapLocationModel::roleNames() const
|
QHash<int, QByteArray> MapLocationModel::roleNames() const
|
||||||
{
|
{
|
||||||
QHash<int, QByteArray> roles;
|
QHash<int, QByteArray> roles;
|
||||||
roles[MapLocation::Roles::RoleDivesite] = "divesite";
|
roles[MapLocation::RoleDivesite] = "divesite";
|
||||||
roles[MapLocation::Roles::RoleCoordinate] = "coordinate";
|
roles[MapLocation::RoleCoordinate] = "coordinate";
|
||||||
roles[MapLocation::Roles::RoleName] = "name";
|
roles[MapLocation::RoleName] = "name";
|
||||||
roles[MapLocation::Roles::RolePixmap] = "pixmap";
|
roles[MapLocation::RolePixmap] = "pixmap";
|
||||||
roles[MapLocation::Roles::RoleZ] = "z";
|
roles[MapLocation::RoleZ] = "z";
|
||||||
roles[MapLocation::Roles::RoleIsSelected] = "isSelected";
|
roles[MapLocation::RoleIsSelected] = "isSelected";
|
||||||
return roles;
|
return roles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue