One bug down!

This commit is contained in:
Zach Fox 2016-12-29 15:43:42 -08:00
parent f96508e197
commit be4050aa78

View file

@ -182,7 +182,9 @@ Item {
movable: false movable: false
resizable: false resizable: false
} }
model: userModel model: ListModel {
id: userModel
}
// This Rectangle refers to each Row in the table. // This Rectangle refers to each Row in the table.
rowDelegate: Rectangle { // The only way I know to specify a row height. rowDelegate: Rectangle { // The only way I know to specify a row height.
@ -217,7 +219,7 @@ Item {
HifiControls.CheckBox { HifiControls.CheckBox {
visible: isCheckBox visible: isCheckBox
anchors.centerIn: parent anchors.centerIn: parent
checked: model && model[styleData.role] checked: model[styleData.role]
enabled: styleData.role === "personalMute" ? (model["ignore"] === true ? false : true) : true enabled: styleData.role === "personalMute" ? (model["ignore"] === true ? false : true) : true
boxSize: 24 boxSize: 24
onClicked: { onClicked: {
@ -225,12 +227,13 @@ Item {
if (newValue === undefined) { if (newValue === undefined) {
newValue = false newValue = false
} }
var datum = userData[model.userIndex] userModel.setProperty(model.userIndex, styleData.role, newValue)
datum[styleData.role] = model[styleData.role] = newValue userData[model.userIndex][styleData.role] = newValue // Defensive programming
if (styleData.role === "personalMute" || styleData.role === "ignore") { if (styleData.role === "personalMute" || styleData.role === "ignore") {
Users[styleData.role](model.sessionId, newValue) Users[styleData.role](model.sessionId, newValue)
if (styleData.role === "ignore") { if (styleData.role === "ignore") {
datum["personalMute"] = model["personalMute"] = newValue userModel.setProperty(model.userIndex, "personalMute", newValue)
userData[model.userIndex]["personalMute"] = newValue // Defensive programming
} }
} else { } else {
Users[styleData.role](model.sessionId) Users[styleData.role](model.sessionId)
@ -238,6 +241,10 @@ Item {
userData.splice(model.userIndex, 1) userData.splice(model.userIndex, 1)
sortModel() sortModel()
} }
// http://doc.qt.io/qt-5/qtqml-syntax-propertybinding.html#creating-property-bindings-from-javascript
// I'm using an explicit binding here because clicking a checkbox breaks the implicit binding as set by
// "checked: model[stayleData.role]" above.
checked = Qt.binding(function() { return model[styleData.role] })
} }
} }
} }
@ -415,9 +422,6 @@ Item {
console.log('Unrecognized message:', JSON.stringify(message)); console.log('Unrecognized message:', JSON.stringify(message));
} }
} }
ListModel {
id: userModel
}
function sortModel() { function sortModel() {
var sortProperty = table.getColumn(table.sortIndicatorColumn).role; var sortProperty = table.getColumn(table.sortIndicatorColumn).role;
var before = (table.sortIndicatorOrder === Qt.AscendingOrder) ? -1 : 1; var before = (table.sortIndicatorOrder === Qt.AscendingOrder) ? -1 : 1;