From 7d2fe2b7c6d921bd7628cf1047266e7be9a0f2e4 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 1 Sep 2019 16:38:48 +0200 Subject: 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 --- qt-models/maplocationmodel.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'qt-models') 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 MapLocationModel::roleNames() const { QHash 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; } -- cgit v1.2.3-70-g09d2