Warning, /plasma/plasma-pa/src/qml/PulseObjectFilterModel.qml is written in an unsupported language. File is not indexed.

0001 import org.kde.kitemmodels as KItemModels
0002 
0003 import org.kde.plasma.private.volume
0004 
0005 KItemModels.KSortFilterProxyModel {
0006     property var filters: []
0007     property bool filterOutInactiveDevices: false
0008     property bool filterVirtualDevices: false
0009 
0010     onFilterVirtualDevicesChanged: {
0011         invalidate()
0012     }
0013 
0014     filterRowCallback: function(source_row, source_parent) {
0015         var idx = sourceModel.index(source_row, 0);
0016 
0017         // Don't ever show the dummy output, that's silly
0018         var dummyOutputName = "auto_null"
0019         if (sourceModel.data(idx, sourceModel.KItemModels.KRoleNames.role("Name")) === dummyOutputName) {
0020             return false;
0021         }
0022 
0023         // Optionally run the role-based filters
0024         if (filters.length > 0) {
0025             for (var i = 0; i < filters.length; ++i) {
0026                 var filter = filters[i];
0027                 if (sourceModel.data(idx, sourceModel.KItemModels.KRoleNames.role(filter.role)) !== filter.value) {
0028                     return false;
0029                 }
0030             }
0031         }
0032 
0033         // Optionally exclude inactive devices
0034         if (filterOutInactiveDevices) {
0035             var ports = sourceModel.data(idx, sourceModel.KItemModels.KRoleNames.role("PulseObject")).ports;
0036             if (ports.length === 1 && ports[0].availability === Port.Unavailable) {
0037                 return false;
0038             }
0039         }
0040 
0041         if (filterVirtualDevices && sourceModel.data(idx, sourceModel.KItemModels.KRoleNames.role("PulseObject")).virtualDevice) {
0042             return false;
0043         }
0044 
0045         return true;
0046     }
0047 }