Changeset View
Changeset View
Standalone View
Standalone View
src/personsmodel.cpp
Show First 20 Lines • Show All 117 Lines • ▼ Show 20 Line(s) | |||||
118 | } | 118 | } | ||
119 | 119 | | |||
120 | QHash<int, QByteArray> PersonsModel::roleNames() const | 120 | QHash<int, QByteArray> PersonsModel::roleNames() const | ||
121 | { | 121 | { | ||
122 | QHash<int, QByteArray> roles = QAbstractItemModel::roleNames(); | 122 | QHash<int, QByteArray> roles = QAbstractItemModel::roleNames(); | ||
123 | roles.insert(PersonUriRole, "personUri"); | 123 | roles.insert(PersonUriRole, "personUri"); | ||
124 | roles.insert(PersonVCardRole, "personVCard"); | 124 | roles.insert(PersonVCardRole, "personVCard"); | ||
125 | roles.insert(ContactsVCardRole, "contactsVCard"); | 125 | roles.insert(ContactsVCardRole, "contactsVCard"); | ||
126 | roles.insert(PhoneNumberRole, "phoneNumber"); | ||||
126 | return roles; | 127 | return roles; | ||
127 | } | 128 | } | ||
128 | 129 | | |||
129 | QVariant PersonsModel::data(const QModelIndex &index, int role) const | 130 | QVariant PersonsModel::data(const QModelIndex &index, int role) const | ||
130 | { | 131 | { | ||
131 | Q_D(const PersonsModel); | 132 | Q_D(const PersonsModel); | ||
132 | 133 | | |||
133 | //optimization - if we don't cover this role, ignore it | 134 | //optimization - if we don't cover this role, ignore it | ||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 157 | { | |||
183 | case PersonsModel::PersonUriRole: | 184 | case PersonsModel::PersonUriRole: | ||
184 | return personUri; | 185 | return personUri; | ||
185 | case PersonsModel::PersonVCardRole: | 186 | case PersonsModel::PersonVCardRole: | ||
186 | return QVariant::fromValue<AbstractContact::Ptr>(person); | 187 | return QVariant::fromValue<AbstractContact::Ptr>(person); | ||
187 | case PersonsModel::ContactsVCardRole: | 188 | case PersonsModel::ContactsVCardRole: | ||
188 | return QVariant::fromValue<AbstractContact::List>(metacontacts[personIndex[personUri].row()].contacts()); | 189 | return QVariant::fromValue<AbstractContact::List>(metacontacts[personIndex[personUri].row()].contacts()); | ||
189 | case PersonsModel::GroupsRole: | 190 | case PersonsModel::GroupsRole: | ||
190 | return person->customProperty(QStringLiteral("all-groups")); | 191 | return person->customProperty(QStringLiteral("all-groups")); | ||
192 | case PersonsModel::PhoneNumberRole: | ||||
193 | return person->customProperty(AbstractContact::PhoneNumberProperty); | ||||
191 | } | 194 | } | ||
192 | return QVariant(); | 195 | return QVariant(); | ||
193 | } | 196 | } | ||
194 | 197 | | |||
195 | int PersonsModel::columnCount(const QModelIndex &parent) const | 198 | int PersonsModel::columnCount(const QModelIndex &parent) const | ||
196 | { | 199 | { | ||
197 | Q_UNUSED(parent); | 200 | Q_UNUSED(parent); | ||
198 | 201 | | |||
▲ Show 20 Lines • Show All 300 Lines • Show Last 20 Lines |