QVariant ContactsModel::data(const QModelIndex& index, int role) const { qWarning() << "Getting contacts data for index " << index.row() << " in role " << role; const KABC::Addressee& contact = m_contacts[index.row()]; switch (role) { case Qt::UserRole: { return index.row(); } case Qt::UserRole+1: { return getName(contact); } case Qt::UserRole+2: { KABC::PhoneNumber::List numbers = contact.phoneNumbers(); if (numbers.empty()) return "-"; return numbers.first().number(); } case Qt::UserRole+3: { QStringList mails = contact.emails(); if (mails.empty()) return "-"; return mails.first(); } case Qt::UserRole+4: { QString skypeUid = contact.custom("KADDRESSBOOK", "skype"); if (skypeUid.isEmpty()) return "-"; return skypeUid; } case Qt::UserRole+5: { return getAvatar(contact); } case Qt::UserRole+6: { return true; } case Qt::UserRole+7: { return contact.uid(); } } if (role == Qt::DisplayRole) return m_contacts[index.row()].formattedName(); return QVariant(); }