summaryrefslogtreecommitdiffstats
path: root/demos/declarative/twitter/TwitterCore/FatDelegate.qml
blob: 0f013e609ace8dfe49035735cd4bf316d031d55d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import Qt 4.6

Component {
    id: listDelegate
    Item {
        id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 58){txt.height+8}else{58}//50+4+4
        Script {
            function handleLink(link){
                if(link.slice(0,3) == 'app'){
                    setUser(link.slice(7));
                    screen.setMode(true);
                }else if(link.slice(0,4) == 'http'){
                    Qt.openUrlExternally(link);
                }
            }
            function addTags(str){
                var ret = str.replace(/@[a-zA-Z0-9_]+/g, '<a href="app://$&">$&</a>');//click to jump to user?
                var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '<a href="$&">$&</a>');//surrounds http links with html link tags
                return ret2;
            }
        }
        Item {
            id: moveMe; height: parent.height
            Rectangle {
                id: blackRect
                color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1
            }
            Rectangle {
                id: whiteRect; x: 6; width: 50; height: 50; color: "white"; smooth: true
                anchors.verticalCenter: parent.verticalCenter

                Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != 1 }
                Image { id: realImage; source: userImage; x: 1; y: 1; width:48; height:48 }
            }
            Text { id:txt; y:4; x: 56
                text: '<html><style type="text/css">a:link {color:"#aaccaa"}; a:visited {color:"#336633"}</style>'
                    + '<a href="app://@'+userScreenName+'"><b>'+userScreenName + "</b></a>  from " +source
                    + "<br /><b>" + addTags(statusText) + "</b></html>";
                textFormat: Qt.RichText
                color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrap: true
                anchors.left: whiteRect.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
                onLinkActivated: handleLink(link)
            }
        }
    }
}