From dfc0042f5b22bf6aa873b10b25e5b661f1754ecf Mon Sep 17 00:00:00 2001 From: Michael Bohlender Date: Sun, 19 Mar 2017 20:59:33 +0100 Subject: add firstname and lastname roles to peoplemodel, update ui to display them --- components/package/contents/ui/People.qml | 26 ++++++++++++++++++++++---- framework/domain/peoplemodel.cpp | 8 +++++++- framework/domain/peoplemodel.h | 4 +++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/components/package/contents/ui/People.qml b/components/package/contents/ui/People.qml index 9f76aebf..444e2430 100644 --- a/components/package/contents/ui/People.qml +++ b/components/package/contents/ui/People.qml @@ -125,6 +125,7 @@ Popup { model: KubeFramework.PeopleModel{} delegate: Rectangle { + id: delegateRoot height: Kirigami.Units.gridUnit * 3 width: Kirigami.Units.gridUnit * 10 @@ -150,16 +151,33 @@ Popup { color: "lightgrey" } - Text { + Column { + + width: parent.width + anchors { left: avatarPlaceholder.right - leftMargin: Kirigami.Units.smallSpacing + margins: Kirigami.Units.smallSpacing verticalCenter: parent.verticalCenter } - color: Kirigami.Theme.textColor - text: model.name + Text { + width: delegateRoot.width - avatarPlaceholder.width - Kirigami.Units.smallSpacing * 2 + + text: model.firstName + elide: Text.ElideRight + color: Kirigami.Theme.textColor + } + + Text { + width: delegateRoot.width - avatarPlaceholder.width - Kirigami.Units.smallSpacing * 2 + + text: model.lastName + elide: Text.ElideRight + color: Kirigami.Theme.textColor + } } + } } } } diff --git a/framework/domain/peoplemodel.cpp b/framework/domain/peoplemodel.cpp index 7cc2f3fa..d33c6703 100644 --- a/framework/domain/peoplemodel.cpp +++ b/framework/domain/peoplemodel.cpp @@ -50,7 +50,9 @@ QHash< int, QByteArray > PeopleModel::roleNames() const {Emails, "emails"}, {Addressbook, "addressbook"}, {Type, "type"}, - {DomainObject, "domainObject"} + {DomainObject, "domainObject"}, + {FirstName, "firstName"}, + {LastName, "lastName"} }; return roles; } @@ -70,6 +72,10 @@ QVariant PeopleModel::data(const QModelIndex &idx, int role) const return "contact"; case DomainObject: return QVariant::fromValue(contact); + case FirstName: + return "FIRSTNAME"; + case LastName: + return contact->getFn(); } return QSortFilterProxyModel::data(idx, role); } diff --git a/framework/domain/peoplemodel.h b/framework/domain/peoplemodel.h index 419d59a6..1e9d2d01 100644 --- a/framework/domain/peoplemodel.h +++ b/framework/domain/peoplemodel.h @@ -48,7 +48,9 @@ public: Type, Emails, Addressbook, - DomainObject + DomainObject, + FirstName, + LastName }; QHash roleNames() const Q_DECL_OVERRIDE; -- cgit v1.2.3