ApplicationModel QML Type

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

Import Statement: import QtApplicationManager.SystemUI 2.0

Properties

Methods

Detailed Description

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

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

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

The following code snippet displays all the icons of non-aliased applications in a list:

import QtQuick
import QtApplicationManager.SystemUI

ListView {
    model: ApplicationModel {
        filterFunction: function(application) {
            return !application.alias;
        }
    }

    delegate: Image {
        required property string icon
        source: icon
    }
}

Property Documentation

count : int [read-only]

Holds the number of applications included in this model.


filterFunction : var

A JavaScript function callback that is invoked for each application in the ApplicationManager source model. This function gets one ApplicationObject parameter and must return a Boolean. If the application 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. However, dynamic properties used in this function, like isRunning, don't trigger a reevaluation when those properties change. Changes in the source model are reflected. To force a complete reevaluation, call invalidate().


sortFunction : var

A JavaScript function callback that is invoked to sort the applications in this model. This function gets two ApplicationObject parameters and must return a Boolean. If the first application 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. However, dynamic properties used in this function, like isRunning, don't trigge a sort when when those properties change. Changes in the source model are reflected. To force a complete reevaluation, call invalidate().


Method Documentation

int indexOfApplication(ApplicationObject application)

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


int indexOfApplication(string id)

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


invalidate()

Forces a reevaluation of the model.


int mapFromSource(int index)

Maps an application's index from the ApplicationManager model to the corresponding index in this model. Returns -1 if the specified index is invalid.


int mapToSource(int index)

Maps an application's index in this model to the corresponding index in the ApplicationManager model. Returns -1 if the specified index is invalid.


© 2024 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.