diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-12 21:34:40 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-02-12 22:35:31 +0100 |
commit | 0365646737a1894ca6de94e8a9ad9dd6f28e0493 (patch) | |
tree | a51b0155275b835a56991f16d48021b798fd4d19 | |
parent | 1026c329afed70f5ab3b8db32756ea926049dbe9 (diff) | |
download | kube-0365646737a1894ca6de94e8a9ad9dd6f28e0493.tar.gz kube-0365646737a1894ca6de94e8a9ad9dd6f28e0493.zip |
A basic but working searchview
-rw-r--r-- | framework/qml/ConversationView.qml | 15 | ||||
-rw-r--r-- | framework/qml/MailListView.qml | 32 | ||||
-rw-r--r-- | framework/src/domain/maillistmodel.cpp | 27 | ||||
-rw-r--r-- | views/conversation/qml/View.qml | 27 | ||||
-rw-r--r-- | views/search/metadata.json | 4 | ||||
-rw-r--r-- | views/search/qml/View.qml | 57 |
6 files changed, 116 insertions, 46 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 | ||
203 | void MailListModel::runQuery(const Sink::Query &query) | 218 | void 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 | ||
210 | bool MailListModel::isThreaded() const | 231 | bool MailListModel::isThreaded() const |
diff --git a/views/conversation/qml/View.qml b/views/conversation/qml/View.qml index 7f1c78bb..5f0d362d 100644 --- a/views/conversation/qml/View.qml +++ b/views/conversation/qml/View.qml | |||
@@ -109,6 +109,18 @@ FocusScope { | |||
109 | anchors.fill: parent | 109 | anchors.fill: parent |
110 | activeFocusOnTab: true | 110 | activeFocusOnTab: true |
111 | Layout.minimumWidth: Kube.Units.gridUnit * 10 | 111 | Layout.minimumWidth: Kube.Units.gridUnit * 10 |
112 | Kube.Listener { | ||
113 | filter: Kube.Messages.folderSelection | ||
114 | onMessageReceived: mailListView.parentFolder = message.folder | ||
115 | } | ||
116 | |||
117 | Kube.Listener { | ||
118 | filter: Kube.Messages.search | ||
119 | onMessageReceived: mailListView.showFilter = true | ||
120 | } | ||
121 | onCurrentMailChanged: { | ||
122 | Kube.Fabric.postMessage(Kube.Messages.mailSelection, {"mail": currentMail}) | ||
123 | } | ||
112 | } | 124 | } |
113 | } | 125 | } |
114 | 126 | ||
@@ -118,6 +130,21 @@ FocusScope { | |||
118 | Layout.fillWidth: true | 130 | Layout.fillWidth: true |
119 | Layout.fillHeight: parent.height | 131 | Layout.fillHeight: parent.height |
120 | activeFocusOnTab: true | 132 | activeFocusOnTab: true |
133 | Kube.Listener { | ||
134 | filter: Kube.Messages.mailSelection | ||
135 | onMessageReceived: { | ||
136 | mailView.mail = message.mail | ||
137 | } | ||
138 | } | ||
139 | |||
140 | Kube.Listener { | ||
141 | filter: Kube.Messages.folderSelection | ||
142 | onMessageReceived: { | ||
143 | mailView.hideTrash = !message.trash | ||
144 | mailView.hideNonTrash = message.trash | ||
145 | } | ||
146 | } | ||
147 | |||
121 | } | 148 | } |
122 | } | 149 | } |
123 | } | 150 | } |
diff --git a/views/search/metadata.json b/views/search/metadata.json index 870ff2aa..a3f6d4a5 100644 --- a/views/search/metadata.json +++ b/views/search/metadata.json | |||
@@ -1,4 +1,4 @@ | |||
1 | { | 1 | { |
2 | "icon": "mail-message-inverted", | 2 | "icon": "edit-find-inverted", |
3 | "tooltip": "Follow conversations." | 3 | "tooltip": "Search" |
4 | } | 4 | } |
diff --git a/views/search/qml/View.qml b/views/search/qml/View.qml index d2c8ae65..437b0ba2 100644 --- a/views/search/qml/View.qml +++ b/views/search/qml/View.qml | |||
@@ -26,14 +26,59 @@ import QtQuick.Layouts 1.1 | |||
26 | import org.kube.framework 1.0 as Kube | 26 | import org.kube.framework 1.0 as Kube |
27 | 27 | ||
28 | FocusScope { | 28 | FocusScope { |
29 | Rectangle { | 29 | SplitView { |
30 | anchors.fill: parent | 30 | anchors.fill: parent |
31 | Kube.MailListView { | 31 | ColumnLayout { |
32 | id: mailListView | 32 | width: Kube.Units.gridUnit * 18 |
33 | anchors.fill: parent | ||
34 | activeFocusOnTab: true | ||
35 | Layout.minimumWidth: Kube.Units.gridUnit * 10 | 33 | Layout.minimumWidth: Kube.Units.gridUnit * 10 |
34 | Rectangle { | ||
35 | id: filterField | ||
36 | Layout.fillWidth: true | ||
37 | height: Kube.Units.gridUnit * 2 | ||
38 | color: Kube.Colors.textColor | ||
39 | |||
40 | function clearSearch() { | ||
41 | find.text = "" | ||
42 | mailListView.filter = "" | ||
43 | } | ||
44 | |||
45 | RowLayout { | ||
46 | anchors { | ||
47 | verticalCenter: parent.verticalCenter | ||
48 | } | ||
49 | |||
50 | width: parent.width - Kube.Units.smallSpacing | ||
51 | spacing: 0 | ||
52 | |||
53 | Kube.IconButton { | ||
54 | iconName: Kube.Icons.remove | ||
55 | onClicked: filterField.clearSearch() | ||
56 | } | ||
57 | |||
58 | Kube.TextField { | ||
59 | id: find | ||
60 | Layout.fillWidth: true | ||
61 | placeholderText: qsTr("Search...") | ||
62 | onTextChanged: mailListView.filter = text | ||
63 | focus: true | ||
64 | Keys.onEscapePressed: filterField.clearSearch() | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | Kube.MailListView { | ||
69 | id: mailListView | ||
70 | showFilter: false | ||
71 | Layout.fillWidth: true | ||
72 | Layout.fillHeight: true | ||
73 | } | ||
74 | } | ||
75 | Kube.ConversationView { | ||
76 | id: mailView | ||
77 | objectName: "mailView" | ||
78 | Layout.fillWidth: true | ||
79 | Layout.fillHeight: parent.height | ||
80 | activeFocusOnTab: true | ||
81 | mail: mailListView.currentMail | ||
36 | } | 82 | } |
37 | } | ||
38 | } | 83 | } |
39 | } | 84 | } |