Mercurial > bellaciao
diff contact.cpp @ 7:017925589d4c
Contact (formerly ContactT) now use shared data
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 14 Aug 2011 18:03:54 +0200 |
parents | 48045176d1c6 |
children |
line wrap: on
line diff
--- a/contact.cpp Fri Aug 12 22:08:37 2011 +0200 +++ b/contact.cpp Sun Aug 14 18:03:54 2011 +0200 @@ -17,49 +17,90 @@ */ #include "contact.h" +#include <QDebug> -ContactT::ContactT() +ContactData::ContactData() :m_connected(false), m_presence_to(false), m_presence_from(false), m_presence_ask(false) { } -ContactT::~ContactT() +ContactData::ContactData(const ContactData& other) + :QSharedData(other), jid(other.jid), groups(other.groups), m_connected(other.m_connected), + m_presence_to(other.m_presence_to), m_presence_from(other.m_presence_from), + m_presence_ask(other.m_presence_ask), m_profile(other.m_profile), m_name(other.m_name) { } -void ContactT::setProfile(const QString& profile) { - m_profile = profile; +Contact::Contact() +{ + d = new ContactData; +} + +Contact::Contact(const Contact& other) + : d(other.d) +{ } -const QString& ContactT::getProfile() const { - return m_profile; +Jid& Contact::getJid() { + return d->jid; +} + +const Jid& Contact::getJid() const { + return d->jid; +} + +QList<QString>& Contact::getGroups() { + return d->groups; +} + +const QList<QString>& Contact::getGroups() const { + return d->groups; } -void ContactT::setAttributes(const QHash<QString, QString>& attr) { - m_name = attr.value("name"); - m_presence_to = attr.value("to") == "True"; - m_presence_from = attr.value("from") == "True"; - m_presence_ask = attr.value("ask") == "True"; +void Contact::setProfile(const QString& profile) +{ + d->m_profile = profile; +} + +const QString& Contact::getProfile() const +{ + return d->m_profile; } -QHash<QString, QString> ContactT::getAttributes() const { +void Contact::setAttributes(const QHash<QString, QString>& attr) +{ + d->m_name = attr.value("name"); + d->m_presence_to = attr.value("to") == "True"; + d->m_presence_from = attr.value("from") == "True"; + d->m_presence_ask = attr.value("ask") == "True"; +} + +QHash<QString, QString> Contact::getAttributes() const +{ QHash<QString, QString> attr; - if (jid.isValid()) { - attr["name"] = m_name; - attr["to"] = m_presence_to ? "True" : "False"; - attr["from"] = m_presence_from ? "True" : "False"; - attr["ask"] = m_presence_ask ? "True" : "False"; + if (d->jid.isValid()) { + attr["name"] = d->m_name; + attr["to"] = d->m_presence_to ? "True" : "False"; + attr["from"] = d->m_presence_from ? "True" : "False"; + attr["ask"] = d->m_presence_ask ? "True" : "False"; } return attr; } -const QString& ContactT::getName() const { - return m_name; +const QString& Contact::getName() const +{ + return d->m_name; } -bool ContactT::isConnected() { - return m_connected; +void Contact::setName(const QString& name) +{ + d->m_name = name; } +bool Contact::isConnected() +{ + return d->m_connected; +} +