~mrqtros/ubuntu-rssreader-app/ubuntu-rssreader-app-to-tabs

« back to all changes in this revision

Viewing changes to shorts/qml/delegates/ArticleOneImgA.qml

  • Committer: Roman Shchekin
  • Date: 2015-07-04 08:38:18 UTC
  • Revision ID: mrqtros@gmail.com-20150704083818-ecojm3nmy5bpkxrb
Merge with the Reboot project.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 2.4
 
2
import Ubuntu.Components 1.2
 
3
import Ubuntu.Components.ListItems 1.0 as ListItem
 
4
 
 
5
import "../utils/dateutils.js" as DateUtils
 
6
 
 
7
//UbuntuShape
 
8
Rectangle
 
9
{
 
10
    id: articleOneImgA
 
11
 
 
12
    property bool invalid: false
 
13
    property var modelItem
 
14
    property var rssModel
 
15
    property int modelIndex
 
16
 
 
17
    // property string secretProp: ""
 
18
 
 
19
    width: units.gu(18)
 
20
    height: units.gu(33) /*content.height + units.gu(1.5)*/
 
21
//    color: invalid ? "black" : modelItem.status == "1" ? "#55cccccc" : "#5533b5e5"
 
22
    color: invalid ? "black" : modelItem.status == "1" ? "#e5e4e5" : "#b0dded"
 
23
 
 
24
    onModelItemChanged: {
 
25
        if (modelItem == null) {
 
26
            invalid = true
 
27
        }
 
28
    }
 
29
 
 
30
    Rectangle {
 
31
        z: -1
 
32
        width: parent.width
 
33
        height: parent.height
 
34
        x: units.gu(0.6)
 
35
        y: units.gu(0.6)
 
36
        color: invalid ? "black" : modelItem.status == "1" ? "#aacccccc" : "#3333b5e5"
 
37
    }
 
38
 
 
39
    Item {
 
40
        id: uPic
 
41
 
 
42
        anchors {
 
43
            left: parent.left
 
44
            right: parent.right
 
45
        }
 
46
        height: pic.height
 
47
        opacity: height
 
48
        Image {
 
49
            id: pic
 
50
            fillMode: Image.PreserveAspectCrop
 
51
            width: (implicitHeight < 50 || implicitWidth < 50) ? 0 : parent.width
 
52
            height:  implicitHeight > (articleOneImgA.height * 0.72) ? (articleOneImgA.height * 0.72) : implicitHeight
 
53
            source: invalid ? "" : modelItem.image
 
54
            sourceSize.width: uPic.width
 
55
        }
 
56
 
 
57
        Behavior on height { UbuntuNumberAnimation{} }
 
58
        Behavior on opacity { NumberAnimation{} }
 
59
    }
 
60
 
 
61
    Column {
 
62
        anchors {
 
63
            top: uPic.bottom
 
64
            bottom: parent.bottom
 
65
            topMargin: units.gu(1)
 
66
            bottomMargin: units.gu(1)
 
67
            left: parent.left
 
68
            leftMargin: units.gu(1)
 
69
            right: parent.right
 
70
            rightMargin: units.gu(1)
 
71
        }
 
72
        spacing: units.gu(1)
 
73
 
 
74
        Row {
 
75
            anchors {
 
76
                left: parent.left
 
77
                right: parent.right
 
78
            }
 
79
            height: labelTime.paintedHeight
 
80
            spacing: units.gu(0.5)
 
81
 
 
82
            Image {
 
83
                id: imgFavourite
 
84
                anchors.verticalCenter: labelTime.verticalCenter
 
85
                fillMode: Image.PreserveAspectCrop
 
86
                source: Qt.resolvedUrl("/img/qml/icons/favorite-selected.svg")
 
87
                sourceSize.height: invalid ? 0 : (modelItem.favourite == "1" ? units.gu(1.5) : 0)
 
88
                visible: invalid ? false : (modelItem.favourite == "1")
 
89
            }
 
90
 
 
91
            Label {
 
92
                id: labelTime
 
93
                text: { invalid ? "" : DateUtils.formatRelativeTime(i18n, modelItem.pubdate) }
 
94
                fontSize: "x-small"
 
95
                width: parent.width - units.gu(2)
 
96
                wrapMode: Text.WrapAtWordBoundaryOrAnywhere
 
97
                elide: Text.ElideRight
 
98
                maximumLineCount: 1
 
99
                opacity: 0.8
 
100
            }
 
101
        }
 
102
 
 
103
        Label {
 
104
            id: labelTitle
 
105
 
 
106
            text: invalid ? "" : modelItem.title
 
107
            anchors {
 
108
                left: parent.left
 
109
                right: parent.right
 
110
            }
 
111
            height: parent.height - parent.spacing * 2 - labelTime.paintedHeight - labelFeedname.paintedHeight
 
112
            wrapMode: Text.WrapAtWordBoundaryOrAnywhere
 
113
            fontSize: "small"
 
114
            textFormat: Text.PlainText
 
115
            font.weight: Font.DemiBold
 
116
            elide: Text.ElideRight
 
117
            opacity: invalid ? 0.4 : modelItem.status == "1" ? 0.8 : 1
 
118
        }
 
119
 
 
120
        Label {
 
121
            id: labelFeedname
 
122
 
 
123
            text: invalid ? "" : modelItem.feed_name
 
124
            fontSize: "x-small"
 
125
            anchors {
 
126
                left: parent.left
 
127
                right: parent.right
 
128
            }
 
129
            wrapMode: Text.WrapAtWordBoundaryOrAnywhere
 
130
            elide: Text.ElideRight
 
131
            maximumLineCount: 1
 
132
            opacity: 0.8
 
133
        }
 
134
    }
 
135
    //    }
 
136
 
 
137
    MouseArea {
 
138
        anchors.fill: parent
 
139
        onClicked: {
 
140
            mainView.showArticle(rssModel, modelIndex)
 
141
        }
 
142
    }
 
143
}