summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/UserSearch/ContactListModel.cpp')
-rw-r--r--Swift/QtUI/UserSearch/ContactListModel.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/Swift/QtUI/UserSearch/ContactListModel.cpp b/Swift/QtUI/UserSearch/ContactListModel.cpp
index 907142f..ef6383c 100644
--- a/Swift/QtUI/UserSearch/ContactListModel.cpp
+++ b/Swift/QtUI/UserSearch/ContactListModel.cpp
@@ -53,5 +53,5 @@ ContactListModel::ContactListModel(bool editable) : QAbstractItemModel(), editab
}
-void ContactListModel::setList(const std::vector<Contact>& list) {
+void ContactListModel::setList(const std::vector<Contact::ref>& list) {
emit layoutAboutToBeChanged();
contacts_ = list;
@@ -59,8 +59,12 @@ void ContactListModel::setList(const std::vector<Contact>& list) {
}
-const std::vector<Contact>& ContactListModel::getList() const {
+const std::vector<Contact::ref>& ContactListModel::getList() const {
return contacts_;
}
+Contact::ref ContactListModel::getContact(const size_t i) const {
+ return contacts_[i];
+}
+
Qt::ItemFlags ContactListModel::flags(const QModelIndex& index) const {
Qt::ItemFlags flags = QAbstractItemModel::flags(index);
@@ -79,7 +83,7 @@ int ContactListModel::columnCount(const QModelIndex&) const {
QVariant ContactListModel::data(const QModelIndex& index, int role) const {
if (boost::numeric_cast<size_t>(index.row()) < contacts_.size()) {
- const Contact& contact = contacts_[index.row()];
+ const Contact::ref& contact = contacts_[index.row()];
if (role == Qt::EditRole) {
- return P2QSTRING(contact.jid.toString());
+ return P2QSTRING(contact->jid.toString());
}
return dataForContact(contact, role);
@@ -94,5 +98,5 @@ QModelIndex ContactListModel::index(int row, int column, const QModelIndex& pare
}
- return boost::numeric_cast<size_t>(row) < contacts_.size() ? createIndex(row, column, (void*)&(contacts_[row])) : QModelIndex();
+ return boost::numeric_cast<size_t>(row) < contacts_.size() ? createIndex(row, column, contacts_[row].get()) : QModelIndex();
}
@@ -119,9 +123,9 @@ bool ContactListModel::removeRows(int row, int /*count*/, const QModelIndex& /*p
}
-QVariant ContactListModel::dataForContact(const Contact& contact, int role) const {
+QVariant ContactListModel::dataForContact(const Contact::ref& contact, int role) const {
switch (role) {
- case Qt::DisplayRole: return P2QSTRING(contact.name);
- case DetailTextRole: return P2QSTRING(contact.jid.toString());
- case AvatarRole: return QVariant(P2QSTRING(pathToString(contact.avatarPath)));
+ case Qt::DisplayRole: return P2QSTRING(contact->name);
+ case DetailTextRole: return P2QSTRING(contact->jid.toString());
+ case AvatarRole: return QVariant(P2QSTRING(pathToString(contact->avatarPath)));
case PresenceIconRole: return getPresenceIconForContact(contact);
default: return QVariant();
@@ -129,6 +133,6 @@ QVariant ContactListModel::dataForContact(const Contact& contact, int role) cons
}
-QIcon ContactListModel::getPresenceIconForContact(const Contact& contact) const {
- return QIcon(statusShowTypeToIconPath(contact.statusType));
+QIcon ContactListModel::getPresenceIconForContact(const Contact::ref& contact) const {
+ return QIcon(statusShowTypeToIconPath(contact->statusType));
}