11 import com.nokia.meego 1.0
 
   12 import org.kde.edu.marble 0.11
 
   16     id: exploreActivityPage
 
   19     property bool horizontal: width / height > 1.20
 
   21     tools: ToolBarLayout {
 
   23             iconSource: 
main.
icon( 
"actions/go-home", 48 );
 
   29             iconSource: 
main.
icon( 
"actions/show-menu", 48 );
 
   32                     pageMenu.visualParent = menuIcon
 
   44                 onClicked: pageStack.push(authPage)
 
   55             property string authUrl: 
"https://foursquare.com/oauth2/authenticate?response_type=token" 
   56             property string redirectUri: 
"http://edu.kde.org/marble/dummy" 
   57             property string clientId: 
"YPRWSYFW1RVL4PJQ2XS5G14RTOGTHOKZVHC1EP5KCCCYQPZF" 
   59             url: authUrl + 
"&redirect_uri=" + redirectUri + 
"&client_id=" + clientId
 
   61                 if( marbleWidget.renderPlugin( 
"foursquare" ).storeAccessToken( url ) ) {
 
   63                     authButton.checked = 
false 
   68         tools: ToolBarLayout {
 
   70                 iconSource: 
main.
icon( 
"actions/go-previous-view", 48 );
 
   71                 onClicked: pageStack.pop()
 
   81         function embedMarbleWidget() {
 
   82             marbleWidget.parent = mapContainer
 
   83             settings.projection = 
"Mercator" 
   84             var plugins = settings.defaultRenderPlugins
 
   85             plugins.push( 
"foursquare" )
 
   87             settings.activeRenderPlugins =  plugins
 
   88             settings.mapTheme = settings.streetMapTheme
 
   89             settings.gpsTracking = 
true 
   90             settings.showPositionIndicator = 
true 
   91             settings.showTrack = 
false 
   94             marbleWidget.visible = 
true 
   95             marbleWidget.setDataPluginDelegate( 
"foursquare", foursquareDelegate )
 
   98         Component.onDestruction: {
 
   99             marbleWidget.setDataPluginDelegate( 
"foursquare", 0 )
 
  100             if ( marbleWidget.parent === mapContainer ) {
 
  101                 marbleWidget.parent = null
 
  102                 marbleWidget.visible = 
false 
  108         if ( status === PageStatus.Activating ) {
 
  109             mapContainer.embedMarbleWidget()
 
  114         id: foursquareDelegate
 
  118             property int padding: 7
 
  119             width: container.width + padding
 
  120             height: container.height + padding
 
  123             border.color: 
"#39AC39" 
  127             SequentialAnimation {
 
  128                 id: venueAppearAnimation
 
  129                 PauseAnimation { duration: Math.random() * 100 }
 
  131                     target: venueRectangle
 
  138             Component.onCompleted: {
 
  139                 venueAppearAnimation.running = 
true 
  144                 width: 32 + ( focus ? venueName.width + venueName.anchors.leftMargin : 0 )
 
  145                 height: Math.max( 32, venueName.height )
 
  146                 anchors.horizontalCenter: parent.horizontalCenter
 
  147                 anchors.verticalCenter: parent.verticalCenter
 
  156                     border.color: 
"darkgray" 
  161                     source: categoryIconUrl
 
  162                     anchors.verticalCenter: parent.verticalCenter
 
  167                     scale: container.focus ? 1.0 : 0.0
 
  169                     anchors.left: iconFallBack.right
 
  170                     anchors.leftMargin: 5
 
  171                     anchors.verticalCenter: parent.verticalCenter
 
  172                     visible: parent.focus ? 
true : 
false 
  174                     Behavior on scale { NumberAnimation { duration: 150 } }
 
  177                 Behavior on width { NumberAnimation { duration: 150 } }
 
  178                 onFocusChanged: sticky = focus
 
  181             function updateDetails() {
 
  182                 venueDetails.venueId = identifier
 
  183                 venueDetails.name = name
 
  184                 venueDetails.category = category
 
  185                 venueDetails.address = address
 
  186                 venueDetails.city = city
 
  187                 venueDetails.country = country
 
  188                 venueDetails.usersCount = usersCount
 
  189                 venueDetails.largeIcon = categoryLargeIconUrl
 
  195                     if( container.focus == 
true ) {
 
  198                         venueDetails.visible = 
true 
  200                         container.focus = 
true 
  210         anchors.bottom: exploreActivityPage.bottom
 
  211         width: exploreActivityPage.horizontal ?
 
  212             Math.max( exploreActivityPage.width / 4, minWidth() + 14 ) : exploreActivityPage.width
 
  213         height: exploreActivityPage.horizontal ? exploreActivityPage.height : exploreActivityPage.height / 3
 
  218         border.color: 
"darkgray" 
  220         property string venueId
 
  222         property string category
 
  223         property string address
 
  225         property string country
 
  226         property string usersCount
 
  227         property string largeIcon
 
  229         function minWidth() {
 
  230             return Math.max(detailName.width,
 
  231                             detailCategory.width,
 
  239             source: venueDetails.largeIcon
 
  240             anchors.top: venueDetails.top
 
  241             anchors.left: detailName.left
 
  242             anchors.topMargin: 10
 
  247             text: venueDetails.name
 
  248             anchors.top: detailIcon.bottom
 
  249             anchors.left: venueDetails.left
 
  251             anchors.leftMargin: 7
 
  256             text: venueDetails.category
 
  257             anchors.top: detailName.bottom
 
  258             anchors.left: detailName.left
 
  262             id: detailAddressTitle
 
  263             text: qsTr( 
"Address" )
 
  264             anchors.top: detailCategory.bottom
 
  265             anchors.left: detailName.left
 
  272             text: venueDetails.address
 
  273             anchors.top: detailAddressTitle.bottom
 
  274             anchors.left: detailName.left
 
  279             text: venueDetails.city
 
  280             anchors.top: detailAddress.bottom
 
  281             anchors.left: detailName.left
 
  286             text: venueDetails.country
 
  287             anchors.top: detailCity.bottom
 
  288             anchors.left: detailName.left
 
  293             width: exploreActivityPage.horizontal ? venueDetails.width - anchors.margins : 64
 
  295             anchors.top: exploreActivityPage.horizontal ? detailCountry.bottom : venueDetails.top
 
  296             anchors.left: exploreActivityPage.horizontal ? venueDetails.left : venueDetails.horizontalCenter
 
  297             anchors.bottom: venueDetails.bottom
 
  298             anchors.right:venueDetails.right
 
  303             orientation: ListView.Vertical 
 
  308                 width: photoView.width
 
  310                 fillMode: Image.PreserveAspectFit
 
  314                 SequentialAnimation {
 
  315                     id: photoAppearAnimation
 
  316                     PauseAnimation { duration: Math.random() * 100 }
 
  325                 Component.onCompleted: {
 
  326                     photoAppearAnimation.running = 
true 
  333             property string clientId: 
"YPRWSYFW1RVL4PJQ2XS5G14RTOGTHOKZVHC1EP5KCCCYQPZF" 
  334             property string clientSecret: 
"5L2JDCAYQCEJWY5FNDU4A1RWATE4E5FIIXXRM41YBTFSERUH" 
  335             property string source: 
"https://api.foursquare.com/v2/venues/" + venueDetails.venueId + 
"/photos?v=20120617&group=venue&limit=5&client_id=" + clientId + 
"&client_secret=" + clientSecret
 
  339                 property string oldId
 
  341                 function retrieve() {
 
  342                     if( oldId == venueDetails.venueId ) {
 
  346                     var xhr = 
new XMLHttpRequest;
 
  347                     xhr.open( 
"GET", modelData.source );
 
  348                     xhr.onreadystatechange = 
function() {
 
  349                         if( xhr.readyState === XMLHttpRequest.DONE ) {
 
  350                             listModel.oldId = venueDetails.venueId
 
  352                             var data = JSON.parse( xhr.responseText );
 
  353                             for( var item in data.response.photos.items ) {
 
  354                                 var photo = data.response.photos.items[ item ];
 
  356                                     url: photo.prefix + 
"original" + photo.suffix,
 
  369         Behavior on width { NumberAnimation { duration: 150 } }