diff options
author | Michael Bohlender <michael.bohlender@kdemail.net> | 2017-03-19 20:59:33 +0100 |
---|---|---|
committer | Michael Bohlender <michael.bohlender@kdemail.net> | 2017-03-19 20:59:33 +0100 |
commit | dfc0042f5b22bf6aa873b10b25e5b661f1754ecf (patch) | |
tree | 725af4685ecb30a7ab24a7e3a7cf55d8e34351ee | |
parent | 5b25db7bbfaa907e03fa3ec0b2675c17981b69b0 (diff) | |
download | kube-dfc0042f5b22bf6aa873b10b25e5b661f1754ecf.tar.gz kube-dfc0042f5b22bf6aa873b10b25e5b661f1754ecf.zip |
add firstname and lastname roles to peoplemodel, update ui to display them
-rw-r--r-- | components/package/contents/ui/People.qml | 26 | ||||
-rw-r--r-- | framework/domain/peoplemodel.cpp | 8 | ||||
-rw-r--r-- | 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 { | |||
125 | model: KubeFramework.PeopleModel{} | 125 | model: KubeFramework.PeopleModel{} |
126 | 126 | ||
127 | delegate: Rectangle { | 127 | delegate: Rectangle { |
128 | id: delegateRoot | ||
128 | 129 | ||
129 | height: Kirigami.Units.gridUnit * 3 | 130 | height: Kirigami.Units.gridUnit * 3 |
130 | width: Kirigami.Units.gridUnit * 10 | 131 | width: Kirigami.Units.gridUnit * 10 |
@@ -150,16 +151,33 @@ Popup { | |||
150 | color: "lightgrey" | 151 | color: "lightgrey" |
151 | } | 152 | } |
152 | 153 | ||
153 | Text { | 154 | Column { |
155 | |||
156 | width: parent.width | ||
157 | |||
154 | anchors { | 158 | anchors { |
155 | left: avatarPlaceholder.right | 159 | left: avatarPlaceholder.right |
156 | leftMargin: Kirigami.Units.smallSpacing | 160 | margins: Kirigami.Units.smallSpacing |
157 | verticalCenter: parent.verticalCenter | 161 | verticalCenter: parent.verticalCenter |
158 | } | 162 | } |
159 | 163 | ||
160 | color: Kirigami.Theme.textColor | 164 | Text { |
161 | text: model.name | 165 | width: delegateRoot.width - avatarPlaceholder.width - Kirigami.Units.smallSpacing * 2 |
166 | |||
167 | text: model.firstName | ||
168 | elide: Text.ElideRight | ||
169 | color: Kirigami.Theme.textColor | ||
170 | } | ||
171 | |||
172 | Text { | ||
173 | width: delegateRoot.width - avatarPlaceholder.width - Kirigami.Units.smallSpacing * 2 | ||
174 | |||
175 | text: model.lastName | ||
176 | elide: Text.ElideRight | ||
177 | color: Kirigami.Theme.textColor | ||
178 | } | ||
162 | } | 179 | } |
180 | } | ||
163 | } | 181 | } |
164 | } | 182 | } |
165 | } | 183 | } |
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 | |||
50 | {Emails, "emails"}, | 50 | {Emails, "emails"}, |
51 | {Addressbook, "addressbook"}, | 51 | {Addressbook, "addressbook"}, |
52 | {Type, "type"}, | 52 | {Type, "type"}, |
53 | {DomainObject, "domainObject"} | 53 | {DomainObject, "domainObject"}, |
54 | {FirstName, "firstName"}, | ||
55 | {LastName, "lastName"} | ||
54 | }; | 56 | }; |
55 | return roles; | 57 | return roles; |
56 | } | 58 | } |
@@ -70,6 +72,10 @@ QVariant PeopleModel::data(const QModelIndex &idx, int role) const | |||
70 | return "contact"; | 72 | return "contact"; |
71 | case DomainObject: | 73 | case DomainObject: |
72 | return QVariant::fromValue(contact); | 74 | return QVariant::fromValue(contact); |
75 | case FirstName: | ||
76 | return "FIRSTNAME"; | ||
77 | case LastName: | ||
78 | return contact->getFn(); | ||
73 | } | 79 | } |
74 | return QSortFilterProxyModel::data(idx, role); | 80 | return QSortFilterProxyModel::data(idx, role); |
75 | } | 81 | } |
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: | |||
48 | Type, | 48 | Type, |
49 | Emails, | 49 | Emails, |
50 | Addressbook, | 50 | Addressbook, |
51 | DomainObject | 51 | DomainObject, |
52 | FirstName, | ||
53 | LastName | ||
52 | }; | 54 | }; |
53 | 55 | ||
54 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; | 56 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; |