| 1 |
/* |
| 2 |
* Copyright (C) 2012-2015 Canonical, Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
|
| 19 |
import Lomiri.AddressBook.Base 0.1 |
| 20 |
|
| 21 |
ContactDetailBase { |
| 22 |
id: root |
| 23 |
|
| 24 |
property alias typeLabel: view.typeLabel |
| 25 |
property alias lineHeight: view.lineHeight |
| 26 |
readonly property bool isReady: (fields != null) && (detail != null) |
| 27 |
|
| 28 |
signal actionTrigerred(string actionName, QtObject detail) |
| 29 |
|
| 30 |
function populateValues() |
| 31 |
{ |
| 32 |
if (isReady) { |
| 33 |
var values = [] |
| 34 |
for(var i=0; i < fields.length; i++) { |
| 35 |
values.push(detail.value(fields[i])) |
| 36 |
} |
| 37 |
view.values = values |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
implicitHeight: view.implicitHeight |
| 42 |
onIsReadyChanged: populateValues() |
| 43 |
|
| 44 |
Connections { |
| 45 |
target: root.detail |
| 46 |
function onDetailChanged() { populateValues() } |
| 47 |
} |
| 48 |
|
| 49 |
BasicFieldView { |
| 50 |
id: view |
| 51 |
|
| 52 |
parentIndex: root.index |
| 53 |
detail: root.detail |
| 54 |
fields: root.fields |
| 55 |
|
| 56 |
anchors { |
| 57 |
left: parent.left |
| 58 |
top: parent.top |
| 59 |
right: messageActions.left |
| 60 |
bottom: parent.bottom |
| 61 |
leftMargin: units.gu(2) |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
ActionButton { |
| 66 |
id: messageActions |
| 67 |
objectName: "message-contact" |
| 68 |
|
| 69 |
anchors { |
| 70 |
right: callActions.left |
| 71 |
rightMargin: units.gu(1) |
| 72 |
verticalCenter: parent.verticalCenter |
| 73 |
} |
| 74 |
width: units.gu(4) |
| 75 |
height: units.gu(4) |
| 76 |
iconName: "message" |
| 77 |
onClicked: root.actionTrigerred("message", root.detail) |
| 78 |
} |
| 79 |
|
| 80 |
|
| 81 |
ActionButton { |
| 82 |
id: callActions |
| 83 |
objectName: "tel-contact" |
| 84 |
|
| 85 |
anchors { |
| 86 |
right: parent.right |
| 87 |
rightMargin: units.gu(2) |
| 88 |
top: parent.top |
| 89 |
verticalCenter: parent.verticalCenter |
| 90 |
} |
| 91 |
width: units.gu(4) |
| 92 |
height: units.gu(4) |
| 93 |
iconName: "call-start" |
| 94 |
onClicked: root.actionTrigerred("tel", root.detail) |
| 95 |
} |
| 96 |
} |