Commit be1174c9 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

Add Profile::assignProperties() method that takes a PropertyMap

parent 9bc2211f
......@@ -280,6 +280,11 @@ void Profile::setProperty(Property p, const QVariant &value)
_propertyValues.insert(p, value);
}
void Profile::assignProperties(const PropertyMap &map)
{
_propertyValues.insert(map);
}
bool Profile::isPropertySet(Property p) const
{
return _propertyValues.contains(p);
......
......@@ -426,6 +426,10 @@ public:
/** Sets the value of the specified @p property to @p value. */
virtual void setProperty(Property p, const QVariant &value);
/** Sets the Porperty/value pairs from @p map on this Profile */
void assignProperties(const PropertyMap &map);
/** Returns true if the specified property has been set in this Profile
* instance.
*/
......
......@@ -281,13 +281,15 @@ void ProfileManager::changeProfile(Profile::Ptr profile, Profile::PropertyMap pr
bool isNameChanged = false;
// Insert the changes into the existing Profile instance
profile->assignProperties(propertyMap);
// Check if the name changed
for (auto it = propertyMap.cbegin(); it != propertyMap.cend(); ++it) {
const auto property = it.key();
auto value = it.value();
isNameChanged |= property == Profile::Name || property == Profile::UntranslatedName;
profile->setProperty(property, value);
if (isNameChanged) {
break;
}
}
// when changing a group, iterate through the profiles
......
......@@ -322,11 +322,7 @@ void SessionManager::sessionProfileCommandReceived(Session *session, const QStri
newProfile = _sessionRuntimeProfiles[session];
}
QHashIterator<Profile::Property, QVariant> iter(changes);
while (iter.hasNext()) {
iter.next();
newProfile->setProperty(iter.key(), iter.value());
}
newProfile->assignProperties(changes);
_sessionProfiles[session] = newProfile;
applyProfile(newProfile, true);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment