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

« back to all changes in this revision

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