#include "roster-item.h"
#include "_gen/roster-item.moc.hpp"
#include <TelepathyQt/Presence>
RosterItem::RosterItem(const ContactPtr &contact, QListWidget *parent)
: QObject(parent),
QListWidgetItem(parent),
mContact(contact)
{
onContactChanged();
connect(contact.data(),
SIGNAL(aliasChanged(QString)),
SLOT(onContactChanged()));
connect(contact.data(),
SLOT(onContactChanged()));
connect(contact.data(),
SLOT(onContactChanged()));
connect(contact.data(),
SLOT(onContactChanged()));
connect(contact.data(),
SIGNAL(blockStatusChanged(bool)),
SLOT(onContactChanged()));
}
RosterItem::~RosterItem()
{
}
void RosterItem::onContactChanged()
{
QString status = mContact->presence().status();
setText(QString(QLatin1String("%1 (%2) (awaiting approval)")).arg(mContact->id()).arg(status));
setText(QString(QLatin1String("%1 (%2) (pending approval)")).arg(mContact->id()).arg(status));
setText(QString(QLatin1String("%1 (unknown)")).arg(mContact->id()));
} else {
setText(QString(QLatin1String("%1 (%2)")).arg(mContact->id()).arg(status));
}
if (mContact->isBlocked()) {
setText(QString(QLatin1String("%1 (blocked)")).arg(text()));
}
emit changed();
}