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

Forums

OverviewFelgo 3 Support (Qt 5) › calendar.selectedDate Event List from firebase?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #21129

    Edward

    Hello Felgo!

    I have my calendarListModel: [] which I pull from Firebase, now I am having issues creating the events list on the currently selected date in the calendar;

    I either have the entire modelData, or nothing, the result I am looking for would be, for example. That if there are 3 events in the database under the date of 22-2-2019, they will only show in the eventListview when that date is selected, but not any events for other dates stored.

    When I read the data from firebase I push It into an array, code below.

     

    //after read from Firebase, data is pushed into calendarListModel: [] in my main.qml
    for(var i in value)
        calendarListModel.push({date: new Date(value[i].date).getTime(), status: value[i].status, name: value[i].name, details: value[i].details})
    
                ListView {
                    id:eventListView
                    model: calendarListModel
    
                    delegate: Rectangle {
                        Rectangle {
                            width: parent.width
    
                        Column {
                            id: eventItemColumn
                           
                            Label {
                                id: nameLabel
                                text: modelData.name
                            }
                            Label {
                                id: detailsLabel
                                text: modelData.details
                                }
                            }
                        }
                    }
                }

     

    I have tried  a number of things such as (and a hell of a lot of variations of the below);

    model: calendarListModel.date(calendar.SelectedDate)

     

                    model:
                        {
                        for (calendar.selectedDate ; calendarListModel.date === calendar.selectedDate; ) {
                            model.append({name: calendarListModel.name, details: calendarListModel.details})
                        }
                    }

     

                    model: {
                        if (calendar.selectedDate === calendarListModel.date) {
                            modelData = ({name: calendarListModel.name, details: calendarListModel.details})
                        }
                        else {
                        }
    
                    }

     

    model: {
        var eventModel = calendarListModel.find(
            function(obj) {
            return obj.date === calendar.selectedDate;
    	}
        );
        if (eventModel === undefined)
        {eventModel.clear()}
    	else {
    	eventModel.append(calendarListModel)
    	}
    }

     

    calendar.selectedDate(calendarListModel.indexOf(styleData.date.getTime()) > -1)

     

    After exhausting options I can think of, and trawling the web, someonehelp!

     

    Thanks in advance for any advice!

    E

     

    #21131

    Günther
    Felgo Team

    Hi Edward,

    if you do not want to show your full model data, it is required to create an additional filtered version of your big ListModel. You can create an additional filtered listmodel manually, or use the SortFilterProxyModel to apply general sorting or filter settings (in case this suits your use-case).

    This post might be interesting for you: https://felgo.com/apps/avoid-cpp-models-qt

    It holds many insights for working with models in Felgo and also some simple examples for SortFilterProxyModel.

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded