NotificationModel QML Type

A proxy model for the NotificationManager singleton. More...

Import Statement: import QtApplicationManager.SystemUI 2.0

Properties

Methods

Detailed Description

The NotificationModel type provides a customizable model that can be used to tailor the NotificationManager model to your needs. The NotificationManager singleton is a model itself, that includes all available notifications. In contrast, the NotificationModel supports filtering and sorting.

Since the NotificationModel is based on the NotificationManager model, the latter is referred to as the source model. The NotificationModel includes the same roles as the NotificationManager model.

Note: If you require a model with all notifications, with no filtering whatsoever, you should use the NotificationManager directly, as it has better performance.

The following code snippet displays the summary of all notifications with a priority greater than 5 in a list:

import QtQuick
import QtApplicationManager.SystemUI

ListView {
    model: NotificationModel {
        filterFunction: function(notification) {
            return notification.priority > 5;
        }
    }

    Text {
        required property string summary
        text: summary
    }
}

Property Documentation

count : int [read-only]

Holds the number of notifications included in this model.


filterFunction : var

A JavaScript function callback that is invoked for each notification in the NotificationManager source model. This function gets one Notification parameter and must return a Boolean. If the notification passed should be included in this model, then the function must return true; false otherwise.

If you need no filtering at all, you should set this property to an undefined (the default) or null value.

Note: Whenever this function is changed, the filter is reevaluated. Changes in the source model are also reflected. To force a complete reevaluation, call invalidate().


sortFunction : var

A JavaScript function callback that is invoked to sort the notifications in this model. This function gets two Notification parameters and must return a Boolean. If the first notification should have a smaller index in this model than the second, the function must return true; false otherwise.

If you need no sorting at all, you should set this property to an undefined (the default) or null value.

Note: Whenever this function is changed, the model is sorted. Changes in the source model are also reflected. To force a complete reevaluation, call invalidate().


Method Documentation

int indexOfNotification(int notificationId)

Maps the notification corresponding to the given notificationId to its position within this model. Returns -1 if the specified notification is invalid, or not part of this model.


int indexOfNotification(object notification)

Maps the notification to its position within this model. Returns -1 if the specified notification is invalid, or not part of this model.


invalidate()

Forces a reevaluation of the model.


int mapFromSource(int index)

Maps a notification's index from the NotificationManager model to the corresponding index in this model. Returns -1 if the specified index is invalid.


int mapToSource(int index)

Maps a notification's index in this model to the corresponding index in the NotificationManager model. Returns -1 if the specified index is invalid.


© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.