2
* Copyright (C) 2013 Canonical, Ltd.
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.
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.
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/>.
18
import Ubuntu.Components 0.1
19
import "../../Components"
21
BaseCarouselDelegate {
24
property var dataModel
25
readonly property real frameHeight: Math.max(height / 3.6, units.gu(5.5))
33
sourceSize { width: item.width; height: item.height }
34
source: dataModel.avatar ? dataModel.avatar : ""
35
fillMode: Image.PreserveAspectCrop
45
// TODO This will go away once we have 'clip: true' in UbuntuShape
46
anchors.centerIn: parent
47
width: parent.width + units.gu(1.5)
48
height: parent.height + units.gu(1.5)
49
visible: labelRemotePost.visible
51
source: "graphics/bottomshape.sci"
54
property bool showRemoteDetails: true
55
// To decide if the remote icon and time should be shown, its once layed out to do so.
56
// Then it's checked if everything fits in the frame size. If not, showRemoteDetails is set false
57
// Using bindings to do so cause a binding loop
58
function checkSizeForRemoteDetails() {
59
showRemoteDetails = true
60
showRemoteDetails = (frame.height - column.minimumHeight) >= labelRemotePostTime.height
64
id: remoteSourceIconContainer
66
// TODO use proper asset and get rid of these dimensions
69
visible: showRemoteDetails
72
anchors.centerIn: parent
73
anchors.horizontalCenterOffset: units.gu(1)
74
source: dataModel.remoteSourceIcon ? dataModel.remoteSourceIcon : ""
75
fillMode: Image.PreserveAspectFit
82
property real minimumHeight: labelName.height + labelRemotePost.height + anchors.topMargin + anchors.bottomMargin
85
left: remoteSourceIconContainer.visible ? remoteSourceIconContainer.right : parent.left
87
top: remoteSourceIconContainer.visible ? parent.top : undefined
88
verticalCenter: remoteSourceIconContainer.visible ? undefined : parent.verticalCenter
96
text: dataModel.name ? dataModel.name : ""
99
elide: Text.ElideRight
100
font.weight: Font.Bold
101
onTextChanged: checkSizeForRemoteDetails()
108
text: dataModel.remotePost ? dataModel.remotePost : ""
112
elide: Text.ElideRight
114
wrapMode: Text.WordWrap
115
onTextChanged: checkSizeForRemoteDetails()
119
id: labelRemotePostTime
122
text: model.remotePostTime ? model.remotePostTime : ""
126
elide: Text.ElideRight
127
visible: showRemoteDetails
128
onTextChanged: checkSizeForRemoteDetails()
132
onHeightChanged: checkSizeForRemoteDetails()
133
onWidthChanged: checkSizeForRemoteDetails()
134
Component.onCompleted: checkSizeForRemoteDetails()
144
bottom: parent.bottom
146
height: item.frameHeight
147
opacity: item.explicitlyScaled ? 1.0 : 0
149
Behavior on opacity {
152
easing.type: Easing.InOutQuad
156
sourceComponent: opacity > 0 ? component_frame : undefined
160
anchors.centerIn: parent
162
source: "../../Components/graphics/non-selected.sci"
163
width: parent.width + units.gu(1.5)
164
height: parent.height + units.gu(1.5)