summaryrefslogtreecommitdiffstats
path: root/demos/declarative/twitter/content/FatDelegate.qml
blob: 32a921e5780e0ed0e7bc1dafe33aee907b8c29be (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
47
import Qt 4.6
import "../../flickr/common"

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.DesktopServices.openUrl(link);
                }
            }
            function addTags(str){
                ret = str.replace(/@[a-zA-Z0-9_]+/g, '<a href="app://$&">$&</a>');//click to jump to user?
                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: "white"; color: "#cccccc"; style: "Raised"; styleColor: "black"; wrap: true
                anchors.left: whiteRect.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6
                onLinkActivated: handleLink(link)
            }
        }
    }
}