Commit e794670e authored by blam's avatar blam

Merge branch 'jb46437-favorites-ui-update' into 'master'

[nemo-qml-plugin-contacts] Add PeopleModel roles: company, title and role. Contributes to JB#46437

See merge request mer-core/nemo-qml-plugin-contacts!28
parents 8b647778 65ec5ee5
......@@ -83,6 +83,9 @@ const QByteArray phoneDetailsRole("phoneDetails");
const QByteArray emailDetailsRole("emailDetails");
const QByteArray accountDetailsRole("accountDetails");
const QByteArray noteDetailsRole("noteDetails");
const QByteArray companyNameRole("companyName");
const QByteArray titleRole("title");
const QByteArray roleRole("role");
const ML10N::MLocale mLocale;
......@@ -509,6 +512,9 @@ QHash<int, QByteArray> SeasideFilteredModel::roleNames() const
roles.insert(EmailDetailsRole, emailDetailsRole);
roles.insert(AccountDetailsRole, accountDetailsRole);
roles.insert(NoteDetailsRole, noteDetailsRole);
roles.insert(CompanyNameRole, companyNameRole);
roles.insert(TitleRole, titleRole);
roles.insert(RoleRole, roleRole);
return roles;
}
......@@ -768,6 +774,9 @@ QVariantMap SeasideFilteredModel::get(int row) const
m.insert(emailDetailsRole, data(cacheItem, EmailDetailsRole));
m.insert(accountDetailsRole, data(cacheItem, AccountDetailsRole));
m.insert(noteDetailsRole, data(cacheItem, NoteDetailsRole));
m.insert(companyNameRole, data(cacheItem, CompanyNameRole));
m.insert(titleRole, data(cacheItem, TitleRole));
m.insert(roleRole, data(cacheItem, RoleRole));
return m;
}
......@@ -944,6 +953,12 @@ QVariant SeasideFilteredModel::data(SeasideCache::CacheItem *cacheItem, int role
}
}
return rv;
} else if (role == CompanyNameRole) {
return SeasidePerson::companyName(contact);
} else if (role == TitleRole) {
return SeasidePerson::title(contact);
} else if (role == RoleRole) {
return SeasidePerson::role(contact);
} else if (role == Qt::DisplayRole || role == SectionBucketRole) {
if (SeasidePerson *person = static_cast<SeasidePerson *>(cacheItem->itemData)) {
// If we have a person instance, prefer to use that
......
......@@ -108,6 +108,9 @@ public:
EmailDetailsRole,
AccountDetailsRole,
NoteDetailsRole,
CompanyNameRole,
TitleRole,
RoleRole,
};
Q_ENUM(PeopleRoles)
......
......@@ -328,12 +328,17 @@ QString SeasidePerson::sectionBucket() const
return QString();
}
QString SeasidePerson::companyName() const
QString SeasidePerson::companyName(const QContact &contact)
{
QContactOrganization company = mContact->detail<QContactOrganization>();
QContactOrganization company = contact.detail<QContactOrganization>();
return company.name();
}
QString SeasidePerson::companyName() const
{
return companyName(*mContact);
}
void SeasidePerson::setCompanyName(const QString &name)
{
QContactOrganization companyNameDetail = mContact->detail<QContactOrganization>();
......@@ -342,12 +347,17 @@ void SeasidePerson::setCompanyName(const QString &name)
emit companyNameChanged();
}
QString SeasidePerson::title() const
QString SeasidePerson::title(const QContact &contact)
{
QContactOrganization company = mContact->detail<QContactOrganization>();
QContactOrganization company = contact.detail<QContactOrganization>();
return company.title();
}
QString SeasidePerson::title() const
{
return title(*mContact);
}
void SeasidePerson::setTitle(const QString &title)
{
QContactOrganization companyDetail = mContact->detail<QContactOrganization>();
......@@ -356,12 +366,17 @@ void SeasidePerson::setTitle(const QString &title)
emit titleChanged();
}
QString SeasidePerson::role() const
QString SeasidePerson::role(const QContact &contact)
{
QContactOrganization company = mContact->detail<QContactOrganization>();
QContactOrganization company = contact.detail<QContactOrganization>();
return company.role();
}
QString SeasidePerson::role() const
{
return role(*mContact);
}
void SeasidePerson::setRole(const QString &role)
{
QContactOrganization companyDetail = mContact->detail<QContactOrganization>();
......
......@@ -343,6 +343,9 @@ public:
void mergeCandidatesFetched(const QList<int> &ids);
void aggregationOperationCompleted();
static QString companyName(const QContact &contact);
static QString title(const QContact &contact);
static QString role(const QContact &contact);
static QVariantList nicknameDetails(const QContact &contact);
static QVariantList phoneDetails(const QContact &contact);
static QVariantList emailDetails(const QContact &contact);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment