Warning, /pim/kube/framework/qml/mailpartview/MailPartModel.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> 0003 0004 This program is free software; you can redistribute it and/or modify 0005 it under the terms of the GNU General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or 0007 (at your option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0012 GNU General Public License for more details. 0013 0014 You should have received a copy of the GNU General Public License along 0015 with this program; if not, write to the Free Software Foundation, Inc., 0016 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0017 */ 0018 0019 import QtQuick 2.4 0020 import QtQml.Models 2.2 0021 import org.kube.framework 1.0 as Kube 0022 0023 DelegateModel { 0024 id: root 0025 0026 property string searchString: "" 0027 property bool autoLoadImages: false 0028 0029 delegate: Item { 0030 id: partColumn 0031 0032 width: parent ? parent.width : 0 0033 height: childrenRect.height 0034 0035 function getColor(securityLevel) 0036 { 0037 if (securityLevel == "good") { 0038 return Kube.Colors.positiveColor 0039 } 0040 if (securityLevel == "bad") { 0041 return Kube.Colors.negativeColor 0042 } 0043 if (securityLevel == "notsogood") { 0044 return Kube.Colors.warningColor 0045 } 0046 return Kube.Colors.lightgrey 0047 } 0048 0049 function getDetails(signatureDetails) 0050 { 0051 var details = ""; 0052 if (signatureDetails.noSignaturesFound) { 0053 details += qsTr("This message has been signed but we failed to validate the signature.") + "\n" 0054 } else if (signatureDetails.keyMissing) { 0055 details += qsTr("This message has been signed using the key %1.").arg(signatureDetails.keyId) + "\n"; 0056 details += qsTr("The key details are not available.") + "\n"; 0057 } else { 0058 details += qsTr("This message has been signed using the key %1 by %2.").arg(signatureDetails.keyId).arg(signatureDetails.signer) + "\n"; 0059 if (signatureDetails.keyRevoked) { 0060 details += qsTr("The key was revoked.") + "\n" 0061 } 0062 if (signatureDetails.keyExpired) { 0063 details += qsTr("The key has expired.") + "\n" 0064 } 0065 if (signatureDetails.keyIsTrusted) { 0066 details += qsTr("You are trusting this key.") + "\n" 0067 } 0068 if (!signatureDetails.signatureIsGood && !signatureDetails.keyRevoked && !signatureDetails.keyExpired && !signatureDetails.keyIsTrusted) { 0069 details += qsTr("The signature is invalid.") + "\n" 0070 } 0071 } 0072 return details 0073 } 0074 0075 Column { 0076 id: buttons 0077 anchors.left: parent.left 0078 anchors.top: parent.top 0079 anchors.rightMargin: Kube.Units.smallSpacing 0080 spacing: Kube.Units.smallSpacing 0081 Kube.IconButton { 0082 id: encryptedButton 0083 width: Kube.Units.gridUnit 0084 height: width 0085 iconName: Kube.Icons.secure 0086 color: getColor(model.encryptionSecurityLevel) 0087 backgroundOpacity: 0.5 0088 visible: model.encrypted 0089 tooltip: model.encryptionDetails.keyId == "" ? qsTr("This message is encrypted but we don't have the key for it.") : qsTr("This message is encrypted to the key: %1").arg(model.encryptionDetails.keyId); 0090 0091 //FIXME make text copyable 0092 // Kube.SelectableItem { 0093 // visualParent: encryptedButton 0094 // text: parent.tooltip 0095 // } 0096 } 0097 Kube.IconButton { 0098 id: signedButton 0099 width: Kube.Units.gridUnit 0100 height: width 0101 iconName: Kube.Icons.signed 0102 color: getColor(model.signatureSecurityLevel) 0103 backgroundOpacity: 0.5 0104 visible: model.signed 0105 tooltip: getDetails(model.signatureDetails) 0106 } 0107 } 0108 Rectangle { 0109 id: border 0110 visible: encryptedButton.hovered || signedButton.hovered 0111 anchors.topMargin: Kube.Units.smallSpacing 0112 anchors.top: buttons.bottom 0113 anchors.bottom: partLoader.bottom 0114 anchors.right: buttons.right 0115 width: Kube.Units.smallSpacing 0116 color: getColor(model.securityLevel) 0117 opacity: 0.5 0118 } 0119 0120 Loader { 0121 id: partLoader 0122 anchors { 0123 top: parent.top 0124 left: buttons.right 0125 leftMargin: Kube.Units.smallSpacing 0126 right: parent.right 0127 } 0128 height: item ? item.contentHeight : 0 0129 width: parent.width 0130 Binding { 0131 target: partLoader.item 0132 property: "searchString" 0133 value: root.searchString 0134 when: partLoader.status == Loader.Ready 0135 } 0136 Binding { 0137 target: partLoader.item 0138 property: "autoLoadImages" 0139 value: root.autoLoadImages 0140 when: partLoader.status == Loader.Ready 0141 } 0142 } 0143 Component.onCompleted: { 0144 switch (model.type) { 0145 case "plain": 0146 partLoader.setSource("TextPart.qml", 0147 {"content": model.content, 0148 "embedded": model.embedded, 0149 "type": model.type 0150 }) 0151 break 0152 case "html": 0153 partLoader.setSource("HtmlPart.qml", 0154 {"content": model.content, 0155 }) 0156 break; 0157 case "error": 0158 partLoader.setSource("ErrorPart.qml", 0159 { 0160 "errorType": model.errorType, 0161 "errorString": model.errorString, 0162 }) 0163 break; 0164 case "encapsulated": 0165 partLoader.setSource("MailPart.qml", 0166 {"rootIndex": root.modelIndex(index), 0167 "model": root.model, 0168 "sender": model.sender, 0169 "date": model.date 0170 }) 0171 break; 0172 case "ical": 0173 partLoader.setSource("ICalPart.qml", 0174 {"content": model.content}) 0175 break; 0176 } 0177 } 0178 } 0179 }