Dekko
AttachmentDelegate.qml
1 /* Copyright (C) 2016 - 2017 Dan Chapman <dpniel@ubuntu.com>
2 
3  This file is part of Dekko email client for Ubuntu devices
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License as
7  published by the Free Software Foundation; either version 2 of
8  the License or (at your option) version 3
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 import QtQuick 2.4
19 import Lomiri.Components 1.3
20 import Dekko.Components 1.0
21 import Dekko.Mail.API 1.0
22 import Dekko.Lomiri.Constants 1.0
23 import Dekko.Lomiri.Components 1.0
24 
25 ListItemWithActions {
26  id: listItem
27  property Component openItem: Item{}
28  property var attachment: model.qtObject
29  width: parent.width
30  showDivider: true
31  triggerIndex: model.index
32 
33  Item {
34  Connections {
35  target: attachment
36  onReadyToOpen: {
37  if (isRunningOnMir) {
38  ContentActions.exportFile(dekko, url)
39  } else {
40  Qt.openUrlExternally(url)
41  }
42  }
43  }
44  }
45 
46  onItemClicked: {
47  Log.logInfo("AttachmentPanel::openAttachment", "Attachment octet size is: %1".arg(attachment.sizeInBytes))
48  // This really is a crude hack
49  // the attachments object can't directly
50  // access the custom qnam factory. So we pass
51  // it a QObject from the qml context which
52  // the attachment object can access the QQmlEngine from
53  // FIXME: Refactor Client* classes into seperate lib
54  attachment.open(openItem.createObject())
55  }
56 
57  ListItemLayout {
58  id: aLayout
59  height: listItem.height
60  title.text: attachment ? attachment.displayName : ""
61  subtitle.text: attachment ? attachment.mimeType + ", " + attachment.size : ""
62 
63  Icon {
64  source: Paths.mimeIconForMimeType(attachment.mimeType)
65  color: "#888888"
66  height: Style.largeSpacing; width: height
67  SlotsLayout.position: SlotsLayout.Leading
68  }
69 
70  ActivityIndicator {
71  visible: running
72  running: attachment.fetchInProgress
73  }
74  }
75 }
Dekko::Lomiri::Constants::Style::largeSpacing
int largeSpacing
Definition: Style.qml:30
Dekko
Definition: Dekko.qml:30
Dekko::Lomiri::Constants::Style
Definition: Style.qml:23