aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlink2xt <link2xt@testrun.org>2021-08-22 11:54:26 +0000
committerlink2xt <link2xt@testrun.org>2021-08-22 11:54:26 +0000
commit6d828b2ba8ad4b0586853cbdf4f1b32b8a2bf753 (patch)
tree15197d8b07b70f512a6d40a05c22539eb1fac7f1
parente225605ff433ba2ebbfcf5d0d6889e1fd45d6d32 (diff)
downloadkdeltachat-6d828b2ba8ad4b0586853cbdf4f1b32b8a2bf753.tar.gz
kdeltachat-6d828b2ba8ad4b0586853cbdf4f1b32b8a2bf753.zip
Add chatlist search
-rw-r--r--context.cpp9
-rw-r--r--context.h2
-rw-r--r--qml/ChatlistPage.qml9
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};
}
diff --git a/context.h b/context.h
index 0ae2eac..4e6409a 100644
--- a/context.h
+++ b/context.h
@@ -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