profile: use a clone() method, as the copy is not exact

Change-Id: I02667ed57ce68702d8be5cac24614f3b9d713ded
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
hjk
2012-06-28 15:38:23 +02:00
parent 59417df92a
commit 0ba19ff029
3 changed files with 21 additions and 15 deletions

View File

@@ -97,22 +97,24 @@ Profile::Profile() :
setIconPath(QLatin1String(":///DESKTOP///")); setIconPath(QLatin1String(":///DESKTOP///"));
} }
Profile::Profile(const Profile &other) :
d(new Internal::ProfilePrivate)
{
d->m_displayName = QCoreApplication::translate("ProjectExplorer::Profile", "Clone of %1").arg(other.d->m_displayName);
d->m_autodetected = false;
d->m_data = other.d->m_data;
d->m_isValid = other.d->m_isValid;
d->m_icon = other.d->m_icon;
d->m_iconPath = other.d->m_iconPath;
}
Profile::~Profile() Profile::~Profile()
{ {
delete d; delete d;
} }
Profile *Profile::clone() const
{
Profile *p = new Profile;
p->d->m_displayName = QCoreApplication::translate("ProjectExplorer::Profile", "Clone of %1")
.arg(d->m_displayName);
p->d->m_autodetected = false;
p->d->m_data = d->m_data;
p->d->m_isValid = d->m_isValid;
p->d->m_icon = d->m_icon;
p->d->m_iconPath = d->m_iconPath;
return p;
}
bool Profile::isValid() const bool Profile::isValid() const
{ {
return d->m_id.isValid() && d->m_isValid; return d->m_id.isValid() && d->m_isValid;

View File

@@ -59,7 +59,6 @@ class PROJECTEXPLORER_EXPORT Profile
{ {
public: public:
Profile(); Profile();
Profile(const Profile &other);
~Profile(); ~Profile();
bool isValid() const; bool isValid() const;
@@ -85,8 +84,13 @@ public:
void addToEnvironment(Utils::Environment &env) const; void addToEnvironment(Utils::Environment &env) const;
QString toHtml(); QString toHtml();
Profile *clone() const;
private: private:
// Unimplemented.
Profile(const Profile &other);
void operator=(const Profile &other);
void setAutoDetected(bool detected); void setAutoDetected(bool detected);
void setId(const Core::Id &id); void setId(const Core::Id &id);
void setValid(bool valid); void setValid(bool valid);

View File

@@ -189,11 +189,11 @@ void ProfileOptionsPage::addNewProfile()
void ProfileOptionsPage::cloneProfile() void ProfileOptionsPage::cloneProfile()
{ {
Profile *clone = m_model->profile(currentIndex()); Profile *current = m_model->profile(currentIndex());
if (!clone) if (!current)
return; return;
Profile *p = new Profile(*clone); Profile *p = current->clone();
m_model->markForAddition(p); m_model->markForAddition(p);