SearchPage.qml Example File

appdemos/qtws/qml/pages/SearchPage.qml
 import Felgo 3.0
 import QtQuick 2.0
 import "../common"
 import QtQuick.Controls 2.0 as QtQuick2

 Page {
   id: page
   title: searchModel.length + " results"
   rightBarItem: ActivityIndicatorBarItem { opacity: dataModel.loading || scheduleItem.loading ? 1 : 0 }

   property var searchModel: []
   readonly property bool dataAvailable: searchModel !== undefined && searchModel.length > 0

   AppText {
     text: "No talks found for search."
     visible: !dataAvailable
     anchors.centerIn: parent
   }

   TimetableDaySchedule {
     id: scheduleItem
     anchors.fill: parent
     scheduleData: page.searchModel ? prepareSearchModel(page.searchModel) : []
     searchAllowed: false
     onItemClicked: {
       //page.navigationStack.popAllExceptFirstAndPush(Qt.resolvedUrl("DetailPage.qml"), { item: item })
       page.navigationStack.popAllExceptFirstAndPush(detailPageComponent, { item: item })
     }
     visible: dataAvailable
   }

   // prepareSearchModel - prepare model data for display
   function prepareSearchModel(events) {
     if(!events)
       return []

     var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];

     // get events and prepare data for sorting and sections
     for(var idx in events) {
       var data = events[idx]
       if(data !== undefined) {
         // prepare event date for sorting
         var date = new Date(data.day+"T00:00.000Z")
         data.dayTime = date.getTime()

         // prepare event section
         var weekday = isNaN(date.getUTCDay()) ? "Unknown" : days[ date.getUTCDay() ]
         data.section = weekday + ", " + (data.start.substring(0, 2) + ":00")

         events[idx] = data
       }
     }

     // sort events
     events = events.sort(function(a, b) {
       if(a.dayTime == b.dayTime)
         return (a.start > b.start) - (a.start < b.start)
       else
         return (a.dayTime > b.dayTime) - (a.dayTime < b.dayTime)
     })

     return events
   }
 }

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