LevelDelegate.qml Example File

examples/gamenetwork/GameNetworkTest/qml/LevelDelegate.qml
 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
     //visible: achievementView.debugMode
   }
 }

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support