Warning, /pim/kube/views/search/qml/View.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *  Copyright (C) 2017 Michael Bohlender, <michael.bohlender@kdemail.net>
0003  *  Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
0004  *
0005  *  This program is free software; you can redistribute it and/or modify
0006  *  it under the terms of the GNU General Public License as published by
0007  *  the Free Software Foundation; either version 2 of the License, or
0008  *  (at your option) any later version.
0009  *
0010  *  This program is distributed in the hope that it will be useful,
0011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0013  *  GNU General Public License for more details.
0014  *
0015  *  You should have received a copy of the GNU General Public License along
0016  *  with this program; if not, write to the Free Software Foundation, Inc.,
0017  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0018  */
0019 
0020 
0021 import QtQuick 2.7
0022 import QtQuick.Controls 1.3 as Controls1
0023 import QtQuick.Controls 2
0024 import QtQuick.Layouts 1.1
0025 
0026 import org.kube.framework 1.0 as Kube
0027 
0028 Kube.View {
0029     id: root
0030     property string searchTerm: ""
0031 
0032     //Initial search-box overlay
0033     Rectangle {
0034         parent: ApplicationWindow.overlay
0035         height: overlayArea.height
0036         width: overlayArea.width
0037         x: overlayArea.x
0038         y: overlayArea.y
0039 
0040         visible: root.visible && root.searchTerm == ""
0041 
0042         Row {
0043             anchors.centerIn: parent
0044 
0045             spacing: Kube.Units.smallSpacing
0046 
0047             Kube.TextField {
0048                 id: searchField
0049                 anchors.verticalCenter: parent.verticalCenter
0050                 width: Kube.Units.gridUnit * 30
0051                 focus: true
0052                 text: root.searchTerm
0053                 Keys.onEscapePressed: root.searchTerm = ""
0054                 onAccepted: root.searchTerm = text
0055             }
0056 
0057             Kube.PositiveButton {
0058                 anchors.verticalCenter: parent.verticalCenter
0059                 text: qsTr("Search")
0060                 enabled: searchField.text != ""
0061                 onClicked: root.searchTerm = searchField.text
0062             }
0063         }
0064     }
0065 
0066     RowLayout {
0067         spacing: 0
0068         //Sidebar
0069         Rectangle {
0070             //It contains nothing useful right now
0071             visible: false
0072             Layout.fillHeight: true
0073             width: Kube.Units.gridUnit * 10
0074             color: Kube.Colors.darkBackgroundColor
0075             ColumnLayout {
0076                 anchors {
0077                     fill: parent
0078                     margins: Kube.Units.smallSpacing
0079                 }
0080                 RowLayout {
0081                     Kube.CheckBox {
0082                         checked: false
0083                     }
0084                     Kube.Label {
0085                         text: qsTr("Unread")
0086                         color: Kube.Colors.highlightedTextColor
0087                     }
0088                 }
0089                 RowLayout {
0090                     Kube.CheckBox {
0091                         checked: false
0092                     }
0093                     Kube.Label {
0094                         text: qsTr("Important")
0095                         color: Kube.Colors.highlightedTextColor
0096                     }
0097                 }
0098 
0099                 Kube.Label{
0100                     text: qsTr("Accounts")
0101                     color: Kube.Colors.highlightedTextColor
0102                     font.weight: Font.Bold
0103                 }
0104 
0105                 Kube.ListView {
0106                     id: listView
0107                     activeFocusOnTab: true
0108 
0109                     Layout.fillWidth: true
0110                     Layout.fillHeight: true
0111                     clip: true
0112                     currentIndex: -1
0113                     highlightFollowsCurrentItem: false
0114 
0115                     onCurrentItemChanged: {
0116                         if (currentItem) {
0117                             mailListView.currentAccount = currentItem.currentData.accountId
0118                         }
0119                     }
0120 
0121                     model: Kube.AccountsModel {}
0122 
0123                     delegate: Kube.ListDelegate {
0124                         id: delegateRoot
0125 
0126                         width: listView.availableWidth
0127                         height: Kube.Units.gridUnit * 1.5
0128 
0129                         color: Kube.Colors.darkBackgroundColor
0130                         border.width: 0
0131                         Kube.Label {
0132                             anchors {
0133                                 centerIn: parent
0134                             }
0135                             text: model.name
0136                             color: Kube.Colors.highlightedTextColor
0137                             elide: Text.ElideRight
0138                         }
0139                     }
0140                 }
0141             }
0142         }
0143 
0144         Item {
0145             Layout.fillHeight: true
0146             Layout.fillWidth: true
0147             ColumnLayout {
0148                 anchors.fill: parent
0149                 spacing: 0
0150                 Rectangle {
0151                     id: toolbar
0152                     Layout.fillWidth: true
0153                     height: searchBar.height + Kube.Units.smallSpacing * 2
0154                     color: Kube.Colors.backgroundColor
0155                     Kube.TextField {
0156                         id: searchBar
0157                         anchors.horizontalCenter: parent.horizontalCenter
0158                         anchors.verticalCenter: parent.verticalCenter
0159                         text: root.searchTerm
0160                         width: parent.width * 0.5
0161                         placeholderText: qsTr("Search...")
0162                         Keys.onEscapePressed: root.searchTerm = ""
0163                         onTextChanged: {
0164                             forceActiveFocus()
0165                             mailListView.filter = text
0166                         }
0167                     }
0168                 }
0169 
0170                 Controls1.SplitView {
0171                     Layout.fillHeight: true
0172                     Layout.fillWidth: true
0173                     Kube.MailListView  {
0174                         id: mailListView
0175                         width: Kube.Units.gridUnit * 18
0176                         Layout.minimumWidth: Kube.Units.gridUnit * 10
0177                         Layout.fillHeight: true
0178                     }
0179                     Kube.ConversationView {
0180                         id: mailView
0181                         Layout.minimumWidth: Kube.Units.gridUnit * 5
0182                         Layout.fillWidth: true
0183                         Layout.fillHeight: true
0184                         activeFocusOnTab: true
0185                         model: Kube.MailListModel {
0186                             filter: {
0187                                 "singleMail": mailListView.currentMail,
0188                                 "headersOnly": false,
0189                                 "fetchMails": true
0190                             }
0191                         }
0192                     }
0193                 }
0194             }
0195         }
0196     }
0197 }