diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-09-01 16:38:48 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-09-06 11:48:47 -0700 |
commit | 7d2fe2b7c6d921bd7628cf1047266e7be9a0f2e4 (patch) | |
tree | 09bec7e432612969b99db5381b9eeef3e4c719f7 /qt-models | |
parent | 46e120f81a4631e8425839f7b47e1e9a8aaf2a2c (diff) | |
download | subsurface-7d2fe2b7c6d921bd7628cf1047266e7be9a0f2e4.tar.gz |
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>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/maplocationmodel.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp index 189244db6..9b21f7142 100644 --- a/qt-models/maplocationmodel.cpp +++ b/qt-models/maplocationmodel.cpp @@ -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; } |