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 of applications. It can be used to tailor the ApplicationManager model to your needs (the ApplicationManager singleton is itself a model that includes all available applications). It supports filtering and sorting. Since this model is based on the ApplicationManager model, the latter will be referred to as the source model. The ApplicationModel includes the same roles as the ApplicationManager model.

Note: If a model with all applications is needed, ApplicationManager should be used directly, since it performs slightly better.

As an example, the following code snippet will show all icons of non-aliased applications in a list:

import QtQuick 2.6
import QtApplicationManager.SystemUI 2.0

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

    delegate: Image {
        source: icon
    }
}

Property Documentation

[read-only] count : int

Holds the number of applications included in this model.


filterFunction : var

A JavaScript function callback that will be invoked for each application in the ApplicationManager source model. It gets one parameter of type ApplicationObject and must return a bool. If the passed application should be included in this model the function must return true and false otherwise.

Note: The filter will be reevaluated when this function is changed. However, dynamic properties (like isRunning) used in this function will not trigger a reevaluation when the property changes. Changes in the source model will be reflected, though. Since the type is derived from QSortFilterProxyModel, the invalidate() slot can be used to force a reevalution.


sortFunction : var

A JavaScript function callback that will be invoked to sort the applications in this model. It gets two parameters of type ApplicationObject and must return a bool. If the first application should have a smaller index in this model than the second, the function must return true and false otherwise.

Note: Sorting will be done whenever this function is changed. However, dynamic properties (like isRunning) used in this function will not trigger sorting when the property changes. Changes in the source model will be reflected, though. Since the type is derived from QSortFilterProxyModel, the invalidate() slot can be used to force a reevalution.


Method Documentation

int indexOfApplication(id)

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


int mapFromSource(sourceIndex)

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(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.


© 2019 Luxoft Sweden AB. 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.