Commit 2863a483 authored by David Edmundson's avatar David Edmundson
Browse files

Avoid caching QModelIndexes

QModelIndexes can go out of date with no change notifications.

What we were seeing in the applications side bar is that the filter of
PIDs would change which effectively removes and replaces every delegate.

Delegates get re-used, if one is re-used at the same row and column the
modelIndex is not updated, however the internalId is completely wrong.
Having valid numbers and parents and wrong internalIds is an absolute
recipe for disaster!
parent 1612127f
......@@ -95,7 +95,7 @@ FocusScope {
ToolTip.hide();
if (delegateUnderMouse) {
var currentIndex = delegateUnderMouse.background.__modelIndex;
var currentIndex = tableView.model.index(delegateUnderMouse.background.row, delegateUnderMouse.background.column)
tableView.selectionModel.setCurrentIndex(currentIndex, ItemSelectionModel.NoUpdate);
} else {
tableView.selectionModel.clearCurrentIndex()
......@@ -134,7 +134,7 @@ FocusScope {
return;
}
var currentIndex = delegateUnderMouse.background.__modelIndex;
var currentIndex = tableView.model.index(delegateUnderMouse.background.row, delegateUnderMouse.background.column)
if (tableView.selectionModel.isSelected(currentIndex) && mouse.button == Qt.RightButton) {
tableView.contextMenuRequested(currentIndex, mapToGlobal(mouse.x, mouse.y))
......
......@@ -20,7 +20,6 @@ Rectangle {
property bool selected: false
property var __selection: view.selectionModel
property var __modelIndex: view.model.index(row, column)
color: (row % 2 == 0) ? Kirigami.Theme.backgroundColor : Kirigami.Theme.alternateBackgroundColor
......@@ -57,6 +56,6 @@ Rectangle {
color: Kirigami.Theme.backgroundColor
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.Selection
opacity: selected ? 1 : (root.__selection.currentIndex.row == root.__modelIndex.row ? 0.3 : 0)
opacity: selected ? 1 : (root.__selection.currentIndex.row == root.row ? 0.3 : 0)
}
}
Supports Markdown
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