summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-02-12 21:34:40 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-02-12 22:35:31 +0100
commit0365646737a1894ca6de94e8a9ad9dd6f28e0493 (patch)
treea51b0155275b835a56991f16d48021b798fd4d19 /framework
parent1026c329afed70f5ab3b8db32756ea926049dbe9 (diff)
downloadkube-0365646737a1894ca6de94e8a9ad9dd6f28e0493.tar.gz
kube-0365646737a1894ca6de94e8a9ad9dd6f28e0493.zip
A basic but working searchview
Diffstat (limited to 'framework')
-rw-r--r--framework/qml/ConversationView.qml15
-rw-r--r--framework/qml/MailListView.qml32
-rw-r--r--framework/src/domain/maillistmodel.cpp27
3 files changed, 36 insertions, 38 deletions
diff --git a/framework/qml/ConversationView.qml b/framework/qml/ConversationView.qml
index f3011f65..2dab92ba 100644
--- a/framework/qml/ConversationView.qml
+++ b/framework/qml/ConversationView.qml
@@ -32,21 +32,6 @@ FocusScope {
32 property bool hideTrash: true; 32 property bool hideTrash: true;
33 property bool hideNonTrash: false; 33 property bool hideNonTrash: false;
34 34
35 Kube.Listener {
36 filter: Kube.Messages.mailSelection
37 onMessageReceived: {
38 root.mail = message.mail
39 }
40 }
41
42 Kube.Listener {
43 filter: Kube.Messages.folderSelection
44 onMessageReceived: {
45 root.hideTrash = !message.trash
46 root.hideNonTrash = message.trash
47 }
48 }
49
50 Rectangle { 35 Rectangle {
51 anchors.fill: parent 36 anchors.fill: parent
52 color: Kube.Colors.backgroundColor 37 color: Kube.Colors.backgroundColor
diff --git a/framework/qml/MailListView.qml b/framework/qml/MailListView.qml
index 8fed8c9d..69b7d871 100644
--- a/framework/qml/MailListView.qml
+++ b/framework/qml/MailListView.qml
@@ -32,27 +32,18 @@ FocusScope {
32 property bool isTrash : false 32 property bool isTrash : false
33 property bool isUnread : false 33 property bool isUnread : false
34 property variant currentMail: null 34 property variant currentMail: null
35 property bool showFilter: false
36 property string filter: null
35 37
36 onCurrentMailChanged: { 38 onCurrentMailChanged: {
37 Kube.Fabric.postMessage(Kube.Messages.markAsRead, {"mail": currentMail}) 39 Kube.Fabric.postMessage(Kube.Messages.markAsRead, {"mail": currentMail})
38 Kube.Fabric.postMessage(Kube.Messages.mailSelection, {"mail": currentMail})
39 } 40 }
40 41 onParentFolderChanged: {
41 Kube.Listener { 42 currentMail = null
42 filter: Kube.Messages.folderSelection 43 filterField.clearSearch()
43 onMessageReceived: {
44 parentFolder = message.folder
45 currentMail = null
46 filterField.clearSearch()
47 }
48 } 44 }
49 45 onShowFilterChanged: {
50 Kube.Listener { 46 find.forceActiveFocus()
51 filter: Kube.Messages.search
52 onMessageReceived: {
53 filterField.visible = true
54 find.forceActiveFocus()
55 }
56 } 47 }
57 48
58 Shortcut { 49 Shortcut {
@@ -78,12 +69,12 @@ FocusScope {
78 Layout.fillWidth: true 69 Layout.fillWidth: true
79 height: Kube.Units.gridUnit * 2 70 height: Kube.Units.gridUnit * 2
80 color: Kube.Colors.buttonColor 71 color: Kube.Colors.buttonColor
81 visible: false 72 visible: root.showFilter
82 73
83 function clearSearch() { 74 function clearSearch() {
84 filterField.visible = false 75 root.showFilter = false
85 find.text = "" 76 find.text = ""
86 mailListModel.filter = "" 77 root.filter = ""
87 } 78 }
88 79
89 RowLayout { 80 RowLayout {
@@ -104,7 +95,7 @@ FocusScope {
104 id: find 95 id: find
105 Layout.fillWidth: true 96 Layout.fillWidth: true
106 placeholderText: qsTr("Filter...") 97 placeholderText: qsTr("Filter...")
107 onTextChanged: mailListModel.filter = text 98 onTextChanged: root.filter = text
108 activeFocusOnTab: visible 99 activeFocusOnTab: visible
109 focus: visible 100 focus: visible
110 Keys.onEscapePressed: filterField.clearSearch() 101 Keys.onEscapePressed: filterField.clearSearch()
@@ -150,6 +141,7 @@ FocusScope {
150 model: Kube.MailListModel { 141 model: Kube.MailListModel {
151 id: mailListModel 142 id: mailListModel
152 parentFolder: root.parentFolder 143 parentFolder: root.parentFolder
144 filter: root.filter
153 } 145 }
154 146
155 delegate: Kube.ListDelegate { 147 delegate: Kube.ListDelegate {
diff --git a/framework/src/domain/maillistmodel.cpp b/framework/src/domain/maillistmodel.cpp
index e3ef04d6..dcebedbc 100644
--- a/framework/src/domain/maillistmodel.cpp
+++ b/framework/src/domain/maillistmodel.cpp
@@ -48,6 +48,21 @@ void MailListModel::setFilter(const QString &filter)
48 f = "\"" + filter + "\""; 48 f = "\"" + filter + "\"";
49 } 49 }
50 f.append('*'); 50 f.append('*');
51 if (mCurrentQueryItem.isEmpty()) {
52 using namespace Sink::ApplicationDomain;
53 query.request<Mail::Subject>();
54 query.request<Mail::Sender>();
55 query.request<Mail::To>();
56 query.request<Mail::Cc>();
57 query.request<Mail::Bcc>();
58 query.request<Mail::Date>();
59 query.request<Mail::Unread>();
60 query.request<Mail::Important>();
61 query.request<Mail::Draft>();
62 query.request<Mail::Sent>();
63 query.request<Mail::Trash>();
64 query.request<Mail::Folder>();
65 }
51 query.filter<Sink::ApplicationDomain::Mail::Subject>(Sink::QueryBase::Comparator(f, Sink::QueryBase::Comparator::Fulltext)); 66 query.filter<Sink::ApplicationDomain::Mail::Subject>(Sink::QueryBase::Comparator(f, Sink::QueryBase::Comparator::Fulltext));
52 } 67 }
53 runQuery(query); 68 runQuery(query);
@@ -202,9 +217,15 @@ bool MailListModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePar
202 217
203void MailListModel::runQuery(const Sink::Query &query) 218void MailListModel::runQuery(const Sink::Query &query)
204{ 219{
205 mQuery = query; 220 if (query.getBaseFilters().isEmpty() && query.ids().isEmpty()) {
206 m_model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); 221 mQuery = {};
207 setSourceModel(m_model.data()); 222 m_model.clear();
223 setSourceModel(nullptr);
224 } else {
225 mQuery = query;
226 m_model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query);
227 setSourceModel(m_model.data());
228 }
208} 229}
209 230
210bool MailListModel::isThreaded() const 231bool MailListModel::isThreaded() const