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

« back to all changes in this revision

Viewing changes to shorts/qml/delegates/ArticleTextB.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
    property bool invalid: false
 
11
    property var modelItem
 
12
    property var rssModel
 
13
    property int modelIndex
 
14
 
 
15
    // property string secretProp: ""
 
16
 
 
17
    width: units.gu(18)
 
18
    height: units.gu(15) /*content.height + units.gu(4)*/
 
19
//    color: invalid ? "black" : modelItem.status == "1" ? "#55cccccc" : "#5533b5e5"
 
20
    color: invalid ? "black" : modelItem.status == "1" ? "#e5e4e5" : "#b0dded"
 
21
 
 
22
    onModelItemChanged: {
 
23
        if (modelItem == null) {
 
24
            invalid = true
 
25
        }
 
26
    }
 
27
 
 
28
    Rectangle {
 
29
        z: -1
 
30
        width: parent.width
 
31
        height: parent.height
 
32
        x: units.gu(0.6)
 
33
        y: units.gu(0.6)
 
34
        color: invalid ? "black" : modelItem.status == "1" ? "#aacccccc" : "#3333b5e5"
 
35
    }
 
36
 
 
37
    Column {
 
38
        id: content
 
39
 
 
40
        anchors {
 
41
            fill: parent; topMargin: units.gu(1); bottomMargin: units.gu(1);
 
42
            leftMargin: units.gu(1); rightMargin: units.gu(1.5)
 
43
        }
 
44
        spacing: units.gu(1)
 
45
 
 
46
        Row {
 
47
            anchors {
 
48
                left: parent.left
 
49
                right: parent.right
 
50
            }
 
51
            height: labelTime.paintedHeight
 
52
            spacing: units.gu(0.5)
 
53
 
 
54
            Image {
 
55
                id: imgFavourite
 
56
                anchors.verticalCenter: labelTime.verticalCenter
 
57
                fillMode: Image.PreserveAspectCrop
 
58
                source: Qt.resolvedUrl("/img/qml/icons/favorite-selected.svg")
 
59
                sourceSize.height: invalid ? 0 : (modelItem.favourite == "1" ? units.gu(1.5) : 0)
 
60
                visible: invalid ? false : (modelItem.favourite == "1")
 
61
            }
 
62
 
 
63
            Label {
 
64
                id: labelTime
 
65
                text: { invalid ? "" : DateUtils.formatRelativeTime(i18n, modelItem.pubdate) }
 
66
                fontSize: "x-small"
 
67
                width: parent.width - units.gu(2)
 
68
                wrapMode: Text.WrapAtWordBoundaryOrAnywhere
 
69
                opacity: 0.8
 
70
            }
 
71
        }
 
72
 
 
73
        Label {
 
74
            id: labelTitle
 
75
 
 
76
            text: invalid ? "" : modelItem.title
 
77
            anchors {
 
78
                left: parent.left
 
79
                right: parent.right
 
80
            }
 
81
            height: parent.height - parent.spacing * 2 - labelTime.paintedHeight - labelFeedname.paintedHeight
 
82
            wrapMode: Text.WrapAtWordBoundaryOrAnywhere
 
83
            fontSize: "small"
 
84
            textFormat: Text.PlainText
 
85
            font.weight: Font.DemiBold
 
86
            elide: Text.ElideRight
 
87
            opacity: invalid ? 0.4 : modelItem.status == "1" ? 0.8 : 1
 
88
        }
 
89
 
 
90
        Label {
 
91
            id: labelFeedname
 
92
 
 
93
            text: invalid ? "" : modelItem.feed_name
 
94
            fontSize: "x-small"
 
95
            anchors {
 
96
                left: parent.left
 
97
                right: parent.right
 
98
            }
 
99
            wrapMode: Text.WrapAtWordBoundaryOrAnywhere
 
100
            opacity: 0.8
 
101
        }
 
102
    }
 
103
 
 
104
    MouseArea {
 
105
        anchors.fill: parent
 
106
        onClicked: {
 
107
            mainView.showArticle(rssModel, modelIndex)
 
108
        }
 
109
    }
 
110
}