From 50f87107bdab4940d33c37f91c90ae74473bb4c1 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Thu, 4 Aug 2022 17:31:41 +0200 Subject: [PATCH] Use a type alias for the Profile Property map --- src/profile/Profile.cpp | 4 ++-- src/profile/Profile.h | 6 ++++-- src/profile/ProfileCommandParser.cpp | 4 ++-- src/profile/ProfileCommandParser.h | 2 +- src/profile/ProfileManager.cpp | 2 +- src/profile/ProfileManager.h | 2 +- src/session/SessionManager.cpp | 2 +- src/widgets/EditProfileDialog.cpp | 6 +++--- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/profile/Profile.cpp b/src/profile/Profile.cpp index 2066769e..a89474e9 100644 --- a/src/profile/Profile.cpp +++ b/src/profile/Profile.cpp @@ -220,7 +220,7 @@ void Profile::useBuiltin() } Profile::Profile(const Profile::Ptr &parent) - : _propertyValues(QHash()) + : _propertyValues(PropertyMap()) , _parent(parent) , _hidden(false) { @@ -270,7 +270,7 @@ bool Profile::isEmpty() const return _propertyValues.isEmpty(); } -QHash Profile::setProperties() const +Profile::PropertyMap Profile::setProperties() const { return _propertyValues; } diff --git a/src/profile/Profile.h b/src/profile/Profile.h index 899361cf..3e366aa2 100644 --- a/src/profile/Profile.h +++ b/src/profile/Profile.h @@ -366,6 +366,8 @@ public: Q_ENUM(Property) + using PropertyMap = QHash; + /** * Constructs a new profile * @@ -430,7 +432,7 @@ public: virtual bool isPropertySet(Property p) const; /** Returns a map of the properties set in this Profile instance. */ - virtual QHash setProperties() const; + virtual PropertyMap setProperties() const; /** Returns true if no properties have been set in this Profile instance. */ bool isEmpty() const; @@ -795,7 +797,7 @@ private: // returns true if the property can be inherited static bool canInheritProperty(Property p); - QHash _propertyValues; + PropertyMap _propertyValues; Ptr _parent; bool _hidden; diff --git a/src/profile/ProfileCommandParser.cpp b/src/profile/ProfileCommandParser.cpp index 82a5b435..16e0b23e 100644 --- a/src/profile/ProfileCommandParser.cpp +++ b/src/profile/ProfileCommandParser.cpp @@ -18,9 +18,9 @@ using namespace Konsole; -QHash ProfileCommandParser::parse(const QString &input) +Profile::PropertyMap ProfileCommandParser::parse(const QString &input) { - QHash changes; + Profile::PropertyMap changes; // regular expression to parse profile change requests. // diff --git a/src/profile/ProfileCommandParser.h b/src/profile/ProfileCommandParser.h index a4361bae..27b48477 100644 --- a/src/profile/ProfileCommandParser.h +++ b/src/profile/ProfileCommandParser.h @@ -44,7 +44,7 @@ public: * and assigned values and returns a table of * properties and values. */ - QHash parse(const QString &input); + Profile::PropertyMap parse(const QString &input); }; } diff --git a/src/profile/ProfileManager.cpp b/src/profile/ProfileManager.cpp index 21c19a47..5e4ee5ae 100644 --- a/src/profile/ProfileManager.cpp +++ b/src/profile/ProfileManager.cpp @@ -267,7 +267,7 @@ QString ProfileManager::saveProfile(const Profile::Ptr &profile) return newPath; } -void ProfileManager::changeProfile(Profile::Ptr profile, QHash propertyMap, bool persistent) +void ProfileManager::changeProfile(Profile::Ptr profile, Profile::PropertyMap propertyMap, bool persistent) { Q_ASSERT(profile); diff --git a/src/profile/ProfileManager.h b/src/profile/ProfileManager.h index 2a68baa7..977ff2cf 100644 --- a/src/profile/ProfileManager.h +++ b/src/profile/ProfileManager.h @@ -132,7 +132,7 @@ public: * set this to false if you want to preview possible changes to a profile but do not * wish to make them permanent. */ - void changeProfile(Profile::Ptr profile, QHash propertyMap, bool persistent = true); + void changeProfile(Profile::Ptr profile, Profile::PropertyMap propertyMap, bool persistent = true); /** * Sets the @p profile as the default profile for creating new sessions diff --git a/src/session/SessionManager.cpp b/src/session/SessionManager.cpp index 2c00c8be..c5eb199f 100644 --- a/src/session/SessionManager.cpp +++ b/src/session/SessionManager.cpp @@ -312,7 +312,7 @@ void SessionManager::sessionProfileCommandReceived(Session *session, const QStri } ProfileCommandParser parser; - QHash changes = parser.parse(text); + Profile::PropertyMap changes = parser.parse(text); Profile::Ptr newProfile; if (!_sessionRuntimeProfiles.contains(session)) { diff --git a/src/widgets/EditProfileDialog.cpp b/src/widgets/EditProfileDialog.cpp index 2cec37ea..8164041b 100644 --- a/src/widgets/EditProfileDialog.cpp +++ b/src/widgets/EditProfileDialog.cpp @@ -1043,7 +1043,7 @@ void EditProfileDialog::unpreviewAll() _delayedPreviewTimer->stop(); _delayedPreviewProperties.clear(); - QHash map; + Profile::PropertyMap map; QHashIterator iter(_previewedProperties); while (iter.hasNext()) { iter.next(); @@ -1064,7 +1064,7 @@ void EditProfileDialog::unpreview(int property) return; } - QHash map; + Profile::PropertyMap map; map.insert(static_cast(property), _previewedProperties[property]); ProfileManager::instance()->changeProfile(_profile, map, false); @@ -1092,7 +1092,7 @@ void EditProfileDialog::delayedPreviewActivate() void EditProfileDialog::preview(int property, const QVariant &value) { - QHash map; + Profile::PropertyMap map; map.insert(static_cast(property), value); _delayedPreviewProperties.remove(property);