diff options
-rw-r--r-- | context.cpp | 9 | ||||
-rw-r--r-- | context.h | 2 | ||||
-rw-r--r-- | qml/ChatlistPage.qml | 9 |
3 files changed, 16 insertions, 4 deletions
diff --git a/context.cpp b/context.cpp index a4e58db..53cdd82 100644 --- a/context.cpp +++ b/context.cpp @@ -56,9 +56,14 @@ Context::getInfo() } DcChatlist * -Context::getChatlist(int flags) +Context::getChatlist(int flags, QString query) { - dc_chatlist_t *chatlist = dc_get_chatlist(m_context, flags, NULL, 0); + QByteArray utf8Query = query.toUtf8(); + dc_chatlist_t *chatlist = dc_get_chatlist( + m_context, flags, + query.isEmpty() ? nullptr : utf8Query.constData(), + 0 + ); return new DcChatlist{chatlist}; } @@ -26,7 +26,7 @@ public: Q_INVOKABLE void startIo(); Q_INVOKABLE void stopIo(); Q_INVOKABLE void maybeNetwork(); - Q_INVOKABLE DcChatlist *getChatlist(int flags); + Q_INVOKABLE DcChatlist *getChatlist(int flags, QString query); Q_INVOKABLE uint32_t createChatByContactId(uint32_t contactId); Q_INVOKABLE void setChatVisibility(uint32_t chatId, int visibility); Q_INVOKABLE void deleteChat(uint32_t chatId); diff --git a/qml/ChatlistPage.qml b/qml/ChatlistPage.qml index 7a9877b..17b0dc3 100644 --- a/qml/ChatlistPage.qml +++ b/qml/ChatlistPage.qml @@ -36,6 +36,12 @@ Kirigami.ScrollablePage { updateChatlist() } + header: Kirigami.SearchField { + id: searchField + + onTextChanged: chatlistPage.updateChatlist() + } + mainAction: Kirigami.Action { text: "New chat" iconName: "list-add" @@ -91,7 +97,8 @@ Kirigami.ScrollablePage { } function updateChatlist() { - let chatlist = chatlistPage.context.getChatlist(chatlistPage.archivedOnly ? 1 : 0) + let chatlist = chatlistPage.context.getChatlist(chatlistPage.archivedOnly ? 1 : 0, + searchField.text) // Merge new chatlist with existing one. // To preserve selected item, we do not simply clear and fill |