diff --git a/smsapp/conversationmodel.h b/smsapp/conversationmodel.h --- a/smsapp/conversationmodel.h +++ b/smsapp/conversationmodel.h @@ -46,6 +46,8 @@ DateRole, }; + Q_ENUMS(Roles) + QString threadId() const; void setThreadId(const QString &threadId); diff --git a/smsapp/qml/ConversationDisplay.qml b/smsapp/qml/ConversationDisplay.qml --- a/smsapp/qml/ConversationDisplay.qml +++ b/smsapp/qml/ConversationDisplay.qml @@ -39,11 +39,15 @@ title: person && person.name ? i18n("%1: %2", person.name, phoneNumber) : phoneNumber ListView { - model: ConversationModel { - id: model - deviceId: device.id() - threadId: page.conversationId - } + model: QSortFilterProxyModel { + id: model + sortOrder: Qt.AscendingOrder + sortRole: ConversationModel.DateRole + sourceModel: ConversationModel { + deviceId: device.id() + threadId: page.conversationId + } + } delegate: Kirigami.BasicListItem { readonly property real margin: 100 @@ -60,7 +64,7 @@ placeholderText: i18n("Say hi...") onAccepted: { console.log("sending sms", page.phoneNumber) - model.sendReplyToConversation(message.text) + model.sourceModel.sendReplyToConversation(message.text) text = "" } }