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