Commit 9e002e01 authored by David Redondo's avatar David Redondo 🏎
Browse files

Correctly look up data in the model

Commit fbd66cdc exposed this preexisting bug.
Before sModel was always a PlasmaCore.SortFilterModel but now that we can hit the
!showHiddenDevices.visible condition in main.qml:546/573 it can also just be
a normal SourceModel or SinkModel that do not have a get() method like the
SortFilterModel. So we have to access the data properly.
BUG:427687
FIXED-IN:5.20.1
parent 9eb8d3d6
......@@ -435,20 +435,20 @@ PlasmaComponents.ListItem {
menuItem.section = true;
contextMenu.addMenuItem(menuItem);
var sModel = type == "sink-input" ? sinkView.model : sourceView.model;
for (var i = 0; i < sModel.count; ++i) {
var data = sModel.get(i);
const modelIndex = sModel.index(i, 0)
const index = sModel.data(modelIndex, sModel.role("Index"))
var menuItem = newMenuItem();
menuItem.text = data.Description;
menuItem.text = sModel.data(modelIndex, sModel.role("Description"));
menuItem.enabled = true;
menuItem.checkable = true;
menuItem.checked = data.Index === PulseObject.deviceIndex;
menuItem.checked = index === PulseObject.deviceIndex;
var setActiveSink = function(sinkIndex) {
return function() {
PulseObject.deviceIndex = sinkIndex;
};
};
menuItem.clicked.connect(setActiveSink(data.Index));
menuItem.clicked.connect(setActiveSink(index));
contextMenu.addMenuItem(menuItem);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment