Feat: performance improvements for big providers model flick scrolling
This commit is contained in:
parent
fdc0066cab
commit
6e5db3f2db
2 changed files with 35 additions and 1 deletions
|
|
@ -24,10 +24,13 @@ Item {
|
||||||
+ (dark ? "dark" : "light") + "/" + stem + ".svg").toString()
|
+ (dark ? "dark" : "light") + "/" + stem + ".svg").toString()
|
||||||
: ""
|
: ""
|
||||||
readonly property string _alt: stem.length > 0
|
readonly property string _alt: stem.length > 0
|
||||||
|
&& primaryImg.status === Image.Error
|
||||||
? Qt.resolvedUrl("../../resources/icons/"
|
? Qt.resolvedUrl("../../resources/icons/"
|
||||||
+ (dark ? "light" : "dark") + "/" + stem + ".svg").toString()
|
+ (dark ? "light" : "dark") + "/" + stem + ".svg").toString()
|
||||||
: ""
|
: ""
|
||||||
readonly property string _model: stem.length > 0
|
readonly property string _model: stem.length > 0
|
||||||
|
&& primaryImg.status === Image.Error
|
||||||
|
&& altImg.status === Image.Error
|
||||||
? Qt.resolvedUrl("../../resources/icons/models/" + stem + ".svg").toString()
|
? Qt.resolvedUrl("../../resources/icons/models/" + stem + ".svg").toString()
|
||||||
: ""
|
: ""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,34 @@ Rectangle {
|
||||||
return pruned;
|
return pruned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate a dynamic cache during model search that returns
|
||||||
|
// the same array instead of rebuild the list at every keystroke
|
||||||
|
property var _rowsCache: []
|
||||||
|
function rowsFor(filter) {
|
||||||
|
var rows = buildRows(filter);
|
||||||
|
var old = _rowsCache;
|
||||||
|
if (old.length === rows.length) {
|
||||||
|
var same = true;
|
||||||
|
for (var i = 0; i < rows.length; i++) {
|
||||||
|
var a = old[i], b = rows[i];
|
||||||
|
if (!a || !b
|
||||||
|
|| a.kind !== b.kind
|
||||||
|
|| a.model !== b.model
|
||||||
|
|| a.providerId !== b.providerId
|
||||||
|
|| a.type !== b.type
|
||||||
|
|| a.name !== b.name
|
||||||
|
|| a.pid !== b.pid
|
||||||
|
|| a.collapsed !== b.collapsed) {
|
||||||
|
same = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (same) return old;
|
||||||
|
}
|
||||||
|
_rowsCache = rows;
|
||||||
|
return rows;
|
||||||
|
}
|
||||||
|
|
||||||
// Model zone (left): label + chevron. Hover highlights the zone
|
// Model zone (left): label + chevron. Hover highlights the zone
|
||||||
// (not the tune section) and shows the pointing cursor.
|
// (not the tune section) and shows the pointing cursor.
|
||||||
Item {
|
Item {
|
||||||
|
|
@ -252,7 +280,10 @@ Rectangle {
|
||||||
clip: true
|
clip: true
|
||||||
spacing: 2
|
spacing: 2
|
||||||
model: selector.service
|
model: selector.service
|
||||||
? selector.buildRows(manualEntry.text) : []
|
? selector.rowsFor(manualEntry.text) : []
|
||||||
|
// Recycle delegates on scroll instead of destroying
|
||||||
|
// and recreating them (each row is ~30 objects).
|
||||||
|
reuseItems: true
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
id: rowDelegate
|
id: rowDelegate
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue