Changeset View
Changeset View
Standalone View
Standalone View
smsapp/qml/ConversationList.qml
- This file was copied from smsapp/qml/ContactList.qml.
Show All 19 Lines | |||||
20 | 20 | | |||
21 | import QtQuick 2.5 | 21 | import QtQuick 2.5 | ||
22 | import QtQuick.Controls 2.1 | 22 | import QtQuick.Controls 2.1 | ||
23 | import QtQuick.Layouts 1.1 | 23 | import QtQuick.Layouts 1.1 | ||
24 | import org.kde.people 1.0 | 24 | import org.kde.people 1.0 | ||
25 | import org.kde.plasma.core 2.0 as Core | 25 | import org.kde.plasma.core 2.0 as Core | ||
26 | import org.kde.kirigami 2.2 as Kirigami | 26 | import org.kde.kirigami 2.2 as Kirigami | ||
27 | import org.kde.kdeconnect 1.0 | 27 | import org.kde.kdeconnect 1.0 | ||
28 | import org.kde.kdeconnect.sms 1.0 | ||||
28 | 29 | | |||
29 | Kirigami.ScrollablePage | 30 | Kirigami.ScrollablePage | ||
30 | { | 31 | { | ||
32 | footer: ComboBox { | ||||
33 | id: devicesCombo | ||||
34 | enabled: count > 0 | ||||
35 | displayText: enabled ? undefined : i18n("No devices available") | ||||
36 | model: DevicesSortProxyModel { | ||||
37 | id: devicesModel | ||||
38 | //TODO: make it possible to sort only if they can do sms | ||||
39 | sourceModel: DevicesModel { displayFilter: DevicesModel.Paired | DevicesModel.Reachable } | ||||
40 | onRowsInserted: if (devicesCombo.currentIndex < 0) { | ||||
41 | devicesCombo.currentIndex = 0 | ||||
42 | } | ||||
43 | } | ||||
44 | textRole: "display" | ||||
45 | } | ||||
46 | | ||||
47 | readonly property QtObject device: devicesCombo.currentIndex >= 0 ? devicesModel.data(devicesModel.index(devicesCombo.currentIndex, 0), DevicesModel.DeviceRole) : null | ||||
48 | | ||||
31 | Component { | 49 | Component { | ||
32 | id: chatView | 50 | id: chatView | ||
33 | ConversationDisplay {} | 51 | ConversationDisplay {} | ||
34 | } | 52 | } | ||
35 | 53 | | |||
36 | ListView { | 54 | ListView { | ||
37 | id: view | 55 | id: view | ||
38 | currentIndex: 0 | 56 | currentIndex: 0 | ||
39 | 57 | | |||
40 | model: PersonsSortFilterProxyModel { | 58 | model: QSortFilterProxyModel { | ||
41 | requiredProperties: ["phoneNumber"] | 59 | sortOrder: Qt.DescendingOrder | ||
42 | sortRole: Qt.DisplayRole | 60 | sortRole: ConversationListModel.DateRole | ||
43 | sortCaseSensitivity: Qt.CaseInsensitive | 61 | sourceModel: ConversationListModel { | ||
44 | sourceModel: PersonsModel {} | 62 | deviceId: device ? device.id() : "" | ||
63 | } | ||||
45 | } | 64 | } | ||
46 | 65 | | |||
47 | header: TextField { | 66 | header: TextField { | ||
48 | id: filter | 67 | id: filter | ||
49 | placeholderText: i18n("Filter...") | 68 | placeholderText: i18n("Filter...") | ||
50 | width: parent.width | 69 | width: parent.width | ||
51 | onTextChanged: { | 70 | onTextChanged: { | ||
52 | view.model.filterRegExp = new RegExp(filter.text) | 71 | view.model.filterRegExp = new RegExp(filter.text) | ||
Show All 9 Lines | 79 | Shortcut { | |||
62 | onActivated: filter.forceActiveFocus() | 81 | onActivated: filter.forceActiveFocus() | ||
63 | } | 82 | } | ||
64 | } | 83 | } | ||
65 | 84 | | |||
66 | delegate: Kirigami.BasicListItem | 85 | delegate: Kirigami.BasicListItem | ||
67 | { | 86 | { | ||
68 | hoverEnabled: true | 87 | hoverEnabled: true | ||
69 | 88 | | |||
70 | readonly property var person: PersonData { | 89 | label: i18n("<b>%1</b> - %2", display, toolTip) | ||
71 | personUri: model.personUri | | |||
72 | } | | |||
73 | | ||||
74 | label: display | | |||
75 | icon: decoration | 90 | icon: decoration | ||
76 | function startChat() { | 91 | function startChat() { | ||
77 | applicationWindow().pageStack.push(chatView, { person: person.person, device: Qt.binding(function() {return devicesCombo.device })}) | 92 | applicationWindow().pageStack.push(chatView, { | ||
93 | personUri: model.personUri, | ||||
94 | phoneNumber: address, | ||||
95 | conversationId: model.conversationId, | ||||
96 | device: device}) | ||||
78 | } | 97 | } | ||
79 | onClicked: { startChat(); } | 98 | onClicked: { startChat(); } | ||
80 | } | 99 | } | ||
81 | 100 | | |||
82 | } | 101 | } | ||
83 | footer: ComboBox { | | |||
84 | id: devicesCombo | | |||
85 | readonly property QtObject device: currentIndex>0 ? model.data(model.index(currentIndex, 0), DevicesModel.DeviceRole) : null | | |||
86 | enabled: count > 0 | | |||
87 | displayText: enabled ? undefined : i18n("No devices available") | | |||
88 | model: DevicesSortProxyModel { | | |||
89 | //TODO: make it possible to sort only if they can do sms | | |||
90 | sourceModel: DevicesModel { displayFilter: DevicesModel.Paired | DevicesModel.Reachable } | | |||
91 | onRowsInserted: if (devicesCombo.currentIndex < 0) { | | |||
92 | devicesCombo.currentIndex = 0 | | |||
93 | } | | |||
94 | } | | |||
95 | textRole: "display" | | |||
96 | } | | |||
97 | } | 102 | } |