Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

GameNetworkExample

 import QtQuick 2.0
 import Felgo 3.0 // for SimpleButton for closing temporarily

 Item {
   id: levelDelegate

   property alias levels: levelRepeater.model

   signal levelClicked(int levelId)

   onLevelsChanged: {
     console.debug("LevelDelegate.levels changed to", JSON.stringify(levels))
   }

   anchors.fill: parent

   Rectangle {
     anchors.fill: parent
     color: "grey"
     //opacity: 0.7
   }

   Flickable {
     id: flickable
     width: parent.width
     height: parent.height

     contentWidth: levelListColumn.width
     contentHeight: levelListColumn.height

     // otherwise it would scroll over the timeFrameRow
     clip: true

     flickableDirection: Flickable.VerticalFlick

     Column {
       id: levelListColumn
       width: parent.width

       spacing: 5

       Repeater {
         id: levelRepeater

         // the delegate must be modifiable by the user, by default show a grid with 2 columns, or just a list at first
         delegate: Rectangle {
           width: levelDelegate.width
           height: col.height
           color: "white"

           Component.onCompleted: {
             console.debug("model in level object:", JSON.stringify(modelData))
           }

           Column {
             id: col
             width: parent.width

             Text {
               text: "LevelId: " + modelData.id +
                     "\nLevelName: " + modelData.name +
                     "\nDescription: " + modelData.description +
                     "\nAuthor: " + modelData.user.name +
                     "\nQuality: " + modelData.average_quality + ", Difficulty:" + modelData.average_difficulty +
                     "\n#Favored: " + modelData.times_favored + ", #Played: " + modelData.times_played + ", #Downloaded: " + modelData.times_downloaded +
                     "\nUserRating: " + JSON.stringify(modelData.rating) +
                     "\nData: " + JSON.stringify(modelData.data)
               width: parent.width
               wrapMode: Text.Wrap
             }

           }// Column

           MouseArea {
             anchors.fill: parent
             onClicked: {
               console.debug("clicked level model with id:", modelData.id, ", complete model:", JSON.stringify(modelData))
               levelClicked(modelData.id)
             }
           }

         }//delegate
       }//Repeater
     }//Column

   }//Flickable

   // just temporariy to allow making the whole switcher invisible
   SimpleButton {
     text: "Close"
     anchors.right: parent.right
     onClicked: parent.visible = false
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded