diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-09 05:19:09 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-09 05:19:09 (GMT) |
commit | 475abec27948923ae6de74db53b137f19c661601 (patch) | |
tree | 35f572bd7d17390e35164d2b8882c67bb22ff82e /demos/declarative | |
parent | 95ad31adca64f639712fa378d25aa3e552b3dc72 (diff) | |
parent | ce69639de67ae74caedb545c9c94aaae6512243f (diff) | |
download | Qt-475abec27948923ae6de74db53b137f19c661601.zip Qt-475abec27948923ae6de74db53b137f19c661601.tar.gz Qt-475abec27948923ae6de74db53b137f19c661601.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'demos/declarative')
-rw-r--r-- | demos/declarative/twitter/TwitterCore/FatDelegate.qml | 28 | ||||
-rw-r--r-- | demos/declarative/twitter/TwitterCore/HomeTitleBar.qml | 34 | ||||
-rw-r--r-- | demos/declarative/twitter/TwitterCore/TitleBar.qml | 14 | ||||
-rw-r--r-- | demos/declarative/twitter/twitter.qml | 9 |
4 files changed, 39 insertions, 46 deletions
diff --git a/demos/declarative/twitter/TwitterCore/FatDelegate.qml b/demos/declarative/twitter/TwitterCore/FatDelegate.qml index e999bb4..62ee11a 100644 --- a/demos/declarative/twitter/TwitterCore/FatDelegate.qml +++ b/demos/declarative/twitter/TwitterCore/FatDelegate.qml @@ -4,21 +4,19 @@ 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; + function handleLink(link){ + if(link.slice(0,3) == 'app'){ + screen.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 { @@ -35,11 +33,11 @@ Component { 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>"; + + "<br /><b>" + wrapper.addTags(statusText) + "</b></html>"; textFormat: Qt.RichText color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap anchors.left: whiteRect.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6 - onLinkActivated: handleLink(link) + onLinkActivated: wrapper.handleLink(link) } } } diff --git a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml index 55b7e62..992c7e2 100644 --- a/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/HomeTitleBar.qml @@ -11,25 +11,23 @@ Item { id: container width: (parent.width * 2) - 55 ; height: parent.height - Script { - function accept() { - if(rssModel.authName == '' || rssModel.authPass == '') - return false;//Can't login like that + function accept() { + if(rssModel.authName == '' || rssModel.authPass == '') + return false;//Can't login like that - var postData = "status=" + editor.text; - var postman = new XMLHttpRequest(); - postman.open("POST", "http://twitter.com/statuses/update.xml", true, rssModel.authName, rssModel.authPass); - postman.onreadystatechange = function() { - if (postman.readyState == postman.DONE) { - titleBar.update(); - } + var postData = "status=" + editor.text; + var postman = new XMLHttpRequest(); + postman.open("POST", "http://twitter.com/statuses/update.xml", true, rssModel.authName, rssModel.authPass); + postman.onreadystatechange = function() { + if (postman.readyState == postman.DONE) { + titleBar.update(); } - postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); - postman.send(postData); - - editor.text = "" - titleBar.state = "" } + postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); + postman.send(postData); + + editor.text = "" + titleBar.state = "" } Rectangle { @@ -59,7 +57,7 @@ Item { Button { id: tagButton; x: titleBar.width - 90; width: 85; height: 32; text: "New Post..." anchors.verticalCenter: parent.verticalCenter; - onClicked: if (titleBar.state == "Posting") accept(); else titleBar.state = "Posting" + onClicked: if (titleBar.state == "Posting") container.accept(); else titleBar.state = "Posting" } Text { @@ -96,7 +94,7 @@ Item { Keys.forwardTo: [(returnKey), (editor)] Item { id: returnKey - Keys.onReturnPressed: accept() + Keys.onReturnPressed: container.accept() Keys.onEscapePressed: titleBar.state = "" } } diff --git a/demos/declarative/twitter/TwitterCore/TitleBar.qml b/demos/declarative/twitter/TwitterCore/TitleBar.qml index 1125519..87ceec5 100644 --- a/demos/declarative/twitter/TwitterCore/TitleBar.qml +++ b/demos/declarative/twitter/TwitterCore/TitleBar.qml @@ -11,12 +11,10 @@ Item { id: container width: (parent.width * 2) - 55 ; height: parent.height - Script { - function accept() { - titleBar.state = "" - background.state = "" - rssModel.tags = editor.text - } + function accept() { + titleBar.state = "" + background.state = "" + rssModel.tags = editor.text } Text { @@ -33,7 +31,7 @@ Item { Button { id: tagButton; x: titleBar.width - 50; width: 45; height: 32; text: "..." - onClicked: if (titleBar.state == "Tags") accept(); else titleBar.state = "Tags" + onClicked: if (titleBar.state == "Tags") container.accept(); else titleBar.state = "Tags" anchors.verticalCenter: parent.verticalCenter } @@ -58,7 +56,7 @@ Item { Item { id: returnKey - Keys.onReturnPressed: accept() + Keys.onReturnPressed: container.accept() Keys.onEscapePressed: titleBar.state = "" } } diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml index 583bf7f..0e3ec3e 100644 --- a/demos/declarative/twitter/twitter.qml +++ b/demos/declarative/twitter/twitter.qml @@ -15,12 +15,11 @@ Item { toolBar.button2Label = "Return home"; } } + function setUser(str){hack.running = true; tmpStr = str} + function reallySetUser(){rssModel.tags = tmpStr;} + //Workaround for bug 260266 - Timer{ interval: 1; running: false; repeat: false; onTriggered: reallySetUser(); id:hack } - Script { - function setUser(str){hack.running = true; tmpStr = str} - function reallySetUser(){rssModel.tags = tmpStr;} - } + Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack } //TODO: better way to return to the auth screen Keys.onEscapePressed: rssModel.authName='' |