summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-23 12:16:08 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2018-07-23 14:28:15 +0200
commite0604f713649186507db37be54cc3aaadcd99663 (patch)
tree66b796b19b3943f0ecdbb0ff0720a6d0bd36ae0f
parent36b2a1ac66ce66708904870b9458512bbaea4a03 (diff)
downloadkube-e0604f713649186507db37be54cc3aaadcd99663.tar.gz
kube-e0604f713649186507db37be54cc3aaadcd99663.zip
Search view updates
-rw-r--r--components/kube/qml/Kube.qml2
-rw-r--r--framework/qml/ConversationView.qml6
-rw-r--r--framework/src/domain/maillistmodel.cpp42
-rw-r--r--framework/src/domain/maillistmodel.h4
-rw-r--r--views/conversation/qml/View.qml5
-rw-r--r--views/search/qml/View.qml163
6 files changed, 172 insertions, 50 deletions
diff --git a/components/kube/qml/Kube.qml b/components/kube/qml/Kube.qml
index 8cbe8691..afc7c83f 100644
--- a/components/kube/qml/Kube.qml
+++ b/components/kube/qml/Kube.qml
@@ -161,7 +161,7 @@ Controls2.ApplicationWindow {
161 model: Kube.ExtensionModel { 161 model: Kube.ExtensionModel {
162 id: extensionModel 162 id: extensionModel
163 extensionPoint: "views" 163 extensionPoint: "views"
164 sortOrder: ["composer", "conversation", "people"] 164 sortOrder: ["search", "composer", "conversation", "people"]
165 } 165 }
166 Kube.IconButton { 166 Kube.IconButton {
167 id: button 167 id: button
diff --git a/framework/qml/ConversationView.qml b/framework/qml/ConversationView.qml
index e1e93b66..b052caa2 100644
--- a/framework/qml/ConversationView.qml
+++ b/framework/qml/ConversationView.qml
@@ -28,7 +28,7 @@ import QtQml 2.2 as QtQml
28FocusScope { 28FocusScope {
29 id: root 29 id: root
30 30
31 property variant mail; 31 property alias model: listView.model
32 property bool hideTrash: true; 32 property bool hideTrash: true;
33 property bool hideNonTrash: false; 33 property bool hideNonTrash: false;
34 property string searchString: "" 34 property string searchString: ""
@@ -83,10 +83,6 @@ FocusScope {
83 //Shrink the listview if the content doesn't fill the full height, so the email appears on top instead of on the bottom. 83 //Shrink the listview if the content doesn't fill the full height, so the email appears on top instead of on the bottom.
84 height: Math.min(contentHeight, parent.height) 84 height: Math.min(contentHeight, parent.height)
85 85
86 model: Kube.MailListModel {
87 mail: root.mail
88 }
89
90 Keys.onPressed: { 86 Keys.onPressed: {
91 //Not implemented as a shortcut because we want it only to apply if we have the focus 87 //Not implemented as a shortcut because we want it only to apply if we have the focus
92 if (event.text == "d") { 88 if (event.text == "d") {
diff --git a/framework/src/domain/maillistmodel.cpp b/framework/src/domain/maillistmodel.cpp
index 152b4f23..d29e851e 100644
--- a/framework/src/domain/maillistmodel.cpp
+++ b/framework/src/domain/maillistmodel.cpp
@@ -328,6 +328,48 @@ QVariant MailListModel::mail() const
328 return QVariant(); 328 return QVariant();
329} 329}
330 330
331void MailListModel::setSingleMail(const QVariant &variant)
332{
333 using namespace Sink::ApplicationDomain;
334 auto mail = variant.value<Sink::ApplicationDomain::Mail::Ptr>();
335 if (!mail) {
336 mCurrentQueryItem.clear();
337 setSourceModel(nullptr);
338 return;
339 }
340 if (mCurrentQueryItem == mail->identifier()) {
341 return;
342 }
343 mCurrentQueryItem = mail->identifier();
344 Sink::Query query{*mail};
345 query.setFlags(Sink::Query::LiveQuery | Sink::Query::UpdateStatus);
346 query.request<Mail::Subject>();
347 query.request<Mail::Sender>();
348 query.request<Mail::To>();
349 query.request<Mail::Cc>();
350 query.request<Mail::Bcc>();
351 query.request<Mail::Date>();
352 query.request<Mail::Unread>();
353 query.request<Mail::Important>();
354 query.request<Mail::Draft>();
355 query.request<Mail::Folder>();
356 query.request<Mail::Sent>();
357 query.request<Mail::Trash>();
358 query.request<Mail::MimeMessage>();
359 query.request<Mail::FullPayloadAvailable>();
360 mFetchMails = true;
361 mFetchedMails.clear();
362 qDebug() << "Running mail query: " << mail->resourceInstanceIdentifier() << mail->identifier();
363 //Latest mail at the bottom
364 sort(0, Qt::AscendingOrder);
365 runQuery(query);
366}
367
368QVariant MailListModel::singleMail() const
369{
370 return {};
371}
372
331 373
332void MailListModel::setShowDrafts(bool) 374void MailListModel::setShowDrafts(bool)
333{ 375{
diff --git a/framework/src/domain/maillistmodel.h b/framework/src/domain/maillistmodel.h
index 4af13dbd..052e4541 100644
--- a/framework/src/domain/maillistmodel.h
+++ b/framework/src/domain/maillistmodel.h
@@ -31,6 +31,7 @@ class KUBE_EXPORT MailListModel : public QSortFilterProxyModel
31 Q_OBJECT 31 Q_OBJECT
32 Q_PROPERTY (QVariant parentFolder READ parentFolder WRITE setParentFolder) 32 Q_PROPERTY (QVariant parentFolder READ parentFolder WRITE setParentFolder)
33 Q_PROPERTY (QVariant mail READ mail WRITE setMail) 33 Q_PROPERTY (QVariant mail READ mail WRITE setMail)
34 Q_PROPERTY (QVariant singleMail READ singleMail WRITE setSingleMail)
34 Q_PROPERTY (bool showDrafts READ showDrafts WRITE setShowDrafts) 35 Q_PROPERTY (bool showDrafts READ showDrafts WRITE setShowDrafts)
35 Q_PROPERTY (bool showInbox READ showInbox WRITE setShowInbox) 36 Q_PROPERTY (bool showInbox READ showInbox WRITE setShowInbox)
36 Q_PROPERTY (QString entityId READ entityId WRITE setEntityId) 37 Q_PROPERTY (QString entityId READ entityId WRITE setEntityId)
@@ -85,6 +86,9 @@ public:
85 void setMail(const QVariant &mail); 86 void setMail(const QVariant &mail);
86 QVariant mail() const; 87 QVariant mail() const;
87 88
89 void setSingleMail(const QVariant &mail);
90 QVariant singleMail() const;
91
88 void setFilter(const QString &mail); 92 void setFilter(const QString &mail);
89 QString filter() const; 93 QString filter() const;
90 94
diff --git a/views/conversation/qml/View.qml b/views/conversation/qml/View.qml
index 7463d5e2..1ca0348f 100644
--- a/views/conversation/qml/View.qml
+++ b/views/conversation/qml/View.qml
@@ -200,10 +200,13 @@ Kube.View {
200 Layout.fillWidth: true 200 Layout.fillWidth: true
201 Layout.fillHeight: parent.height 201 Layout.fillHeight: parent.height
202 activeFocusOnTab: true 202 activeFocusOnTab: true
203 model: Kube.MailListModel {
204 id: mailViewModel
205 }
203 Kube.Listener { 206 Kube.Listener {
204 filter: Kube.Messages.mailSelection 207 filter: Kube.Messages.mailSelection
205 onMessageReceived: { 208 onMessageReceived: {
206 mailView.mail = message.mail 209 mailViewModel.mail = message.mail
207 } 210 }
208 } 211 }
209 212
diff --git a/views/search/qml/View.qml b/views/search/qml/View.qml
index 74e6cf5b..18098f30 100644
--- a/views/search/qml/View.qml
+++ b/views/search/qml/View.qml
@@ -20,64 +20,141 @@
20 20
21import QtQuick 2.7 21import QtQuick 2.7
22import QtQuick.Controls 1.3 as Controls1 22import QtQuick.Controls 1.3 as Controls1
23import QtQuick.Controls 2.0 as Controls2 23import QtQuick.Controls 2
24import QtQuick.Layouts 1.1 24import QtQuick.Layouts 1.1
25 25
26import org.kube.framework 1.0 as Kube 26import org.kube.framework 1.0 as Kube
27 27
28FocusScope { 28Kube.View {
29 Controls1.SplitView { 29 id: root
30 anchors.fill: parent 30 property string searchTerm: ""
31 ColumnLayout {
32 width: Kube.Units.gridUnit * 18
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.darkBackgroundColor
39 31
40 function clearSearch() {
41 find.text = ""
42 mailListView.filter = ""
43 }
44 32
45 RowLayout { 33 Rectangle {
46 anchors { 34 id: overlay
47 verticalCenter: parent.verticalCenter 35
48 } 36 parent: ApplicationWindow.overlay
37 height: app.height
38 width: app.width - app.sidebarWidth
39 x: app.sidebarWidth
40 y: 0
41
42 visible: root.searchTerm == ""
43
44 Row {
45 anchors.centerIn: parent
46
47 spacing: Kube.Units.smallSpacing
48
49 Kube.TextField {
50 id: searchField
51 anchors.verticalCenter: parent.verticalCenter
52 width: Kube.Units.gridUnit * 30
53 focus: true
54 text: root.searchTerm
55 Keys.onEscapePressed: root.searchTerm = ""
56 onAccepted: root.searchTerm = text
57 }
49 58
50 width: parent.width - Kube.Units.smallSpacing 59 Kube.PositiveButton {
51 spacing: 0 60 anchors.verticalCenter: parent.verticalCenter
61 text: qsTr("Search")
62 enabled: searchField.text != ""
63 onClicked: root.searchTerm = searchField.text
64 }
65 }
66 }
52 67
53 Kube.IconButton { 68 RowLayout {
54 iconName: Kube.Icons.remove 69 spacing: 0
55 onClicked: filterField.clearSearch() 70 Rectangle {
71 Layout.fillHeight: true
72 width: Kube.Units.gridUnit * 10
73 color: Kube.Colors.darkBackgroundColor
74 ColumnLayout {
75 anchors {
76 left: parent.left
77 right: parent.right
78 top: parent.top
79 margins: Kube.Units.smallSpacing
80 }
81 RowLayout {
82 Kube.CheckBox {
83 checked: true
84 }
85 Kube.Label {
86 text: qsTr("Mail")
87 color: Kube.Colors.highlightedTextColor
88 }
89 }
90 RowLayout {
91 Kube.CheckBox {
92 checked: false
56 } 93 }
94 Kube.Label {
95 text: qsTr("Contacts")
96 color: Kube.Colors.highlightedTextColor
97 }
98 }
99 RowLayout {
100 Kube.CheckBox {
101 checked: false
102 }
103 Kube.Label {
104 text: qsTr("Events")
105 color: Kube.Colors.highlightedTextColor
106 }
107 }
108 }
109 }
57 110
111 Item {
112 Layout.fillHeight: true
113 Layout.fillWidth: true
114 ColumnLayout {
115 anchors.fill: parent
116 spacing: 0
117 Rectangle {
118 id: toolbar
119 Layout.fillWidth: true
120 height: searchBar.height + Kube.Units.smallSpacing * 2
121 color: Kube.Colors.backgroundColor
58 Kube.TextField { 122 Kube.TextField {
59 id: find 123 id: searchBar
60 Layout.fillWidth: true 124 anchors.horizontalCenter: parent.horizontalCenter
125 anchors.verticalCenter: parent.verticalCenter
126 text: root.searchTerm
127 width: parent.width * 0.5
61 placeholderText: qsTr("Search...") 128 placeholderText: qsTr("Search...")
62 onTextChanged: mailListView.filter = text 129 Keys.onEscapePressed: root.searchTerm = ""
63 focus: true 130 onTextChanged: {
64 Keys.onEscapePressed: filterField.clearSearch() 131 forceActiveFocus()
132 mailListView.filter = text
133 }
134 }
135 }
136
137 Controls1.SplitView {
138 Layout.fillHeight: true
139 Layout.fillWidth: true
140 Kube.MailListView {
141 id: mailListView
142 width: Kube.Units.gridUnit * 18
143 Layout.minimumWidth: Kube.Units.gridUnit * 10
144 Layout.fillHeight: true
145 }
146 Kube.ConversationView {
147 id: mailView
148 Layout.minimumWidth: Kube.Units.gridUnit * 5
149 Layout.fillWidth: true
150 Layout.fillHeight: true
151 activeFocusOnTab: true
152 model: Kube.MailListModel {
153 singleMail: mailListView.currentMail
154 }
65 } 155 }
66 } 156 }
67 } 157 }
68 Kube.MailListView {
69 id: mailListView
70 Layout.fillWidth: true
71 Layout.fillHeight: true
72 }
73 }
74 Kube.ConversationView {
75 id: mailView
76 objectName: "mailView"
77 Layout.fillWidth: true
78 Layout.fillHeight: parent.height
79 activeFocusOnTab: true
80 mail: mailListView.currentMail
81 } 158 }
82 } 159 }
83} 160}