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

wilder
Ahmad Samir 4 years ago
parent 9bc2211ffb
commit be1174c971
  1. 5
      src/profile/Profile.cpp
  2. 4
      src/profile/Profile.h
  3. 10
      src/profile/ProfileManager.cpp
  4. 6
      src/session/SessionManager.cpp

@ -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);

Loading…
Cancel
Save