mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 18:01:15 +02:00
parent
5173774db0
commit
b1378816d5
2 changed files with 23 additions and 12 deletions
|
@ -53,6 +53,7 @@ Rectangle {
|
||||||
console.log("Failed to get inventory", result.message);
|
console.log("Failed to get inventory", result.message);
|
||||||
} else {
|
} else {
|
||||||
inventoryModel.append(result.data.assets);
|
inventoryModel.append(result.data.assets);
|
||||||
|
filteredInventoryModel.append(result.data.assets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,6 +149,24 @@ Rectangle {
|
||||||
property int previousLength: 0;
|
property int previousLength: 0;
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
placeholderText: "Filter";
|
placeholderText: "Filter";
|
||||||
|
|
||||||
|
onTextChanged: {
|
||||||
|
if (filterBar.text.length < previousLength) {
|
||||||
|
filteredInventoryModel.clear();
|
||||||
|
|
||||||
|
for (var i = 0; i < inventoryModel.count; i++) {
|
||||||
|
filteredInventoryModel.append(inventoryModel.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < filteredInventoryModel.count; i++) {
|
||||||
|
if (filteredInventoryModel.get(i).title.toLowerCase().indexOf(filterBar.text.toLowerCase()) === -1) {
|
||||||
|
filteredInventoryModel.remove(i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
previousLength = filterBar.text.length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -157,11 +176,14 @@ Rectangle {
|
||||||
ListModel {
|
ListModel {
|
||||||
id: inventoryModel;
|
id: inventoryModel;
|
||||||
}
|
}
|
||||||
|
ListModel {
|
||||||
|
id: filteredInventoryModel;
|
||||||
|
}
|
||||||
|
|
||||||
ListView {
|
ListView {
|
||||||
id: inventoryContentsList;
|
id: inventoryContentsList;
|
||||||
clip: true;
|
clip: true;
|
||||||
model: inventoryModel;
|
model: filteredInventoryModel;
|
||||||
// Anchors
|
// Anchors
|
||||||
anchors.top: filterBarContainer.bottom;
|
anchors.top: filterBarContainer.bottom;
|
||||||
anchors.topMargin: 12;
|
anchors.topMargin: 12;
|
||||||
|
@ -172,7 +194,6 @@ Rectangle {
|
||||||
itemName: title;
|
itemName: title;
|
||||||
itemId: id;
|
itemId: id;
|
||||||
itemPreviewImageUrl: preview;
|
itemPreviewImageUrl: preview;
|
||||||
filterText: filterBar.text;
|
|
||||||
anchors.topMargin: 12;
|
anchors.topMargin: 12;
|
||||||
anchors.bottomMargin: 12;
|
anchors.bottomMargin: 12;
|
||||||
|
|
||||||
|
|
|
@ -29,18 +29,12 @@ Rectangle {
|
||||||
property string itemId: "";
|
property string itemId: "";
|
||||||
property string itemPreviewImageUrl: "";
|
property string itemPreviewImageUrl: "";
|
||||||
property string itemHref: "";
|
property string itemHref: "";
|
||||||
property string filterText: "";
|
|
||||||
// Style
|
// Style
|
||||||
color: hifi.colors.white;
|
color: hifi.colors.white;
|
||||||
// Size
|
// Size
|
||||||
width: parent.width;
|
width: parent.width;
|
||||||
height: 120;
|
height: 120;
|
||||||
|
|
||||||
visible: passesFilter();
|
|
||||||
onFilterTextChanged: {
|
|
||||||
root.visible = passesFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: itemPreviewImage;
|
id: itemPreviewImage;
|
||||||
source: root.itemPreviewImageUrl;
|
source: root.itemPreviewImageUrl;
|
||||||
|
@ -143,10 +137,6 @@ Rectangle {
|
||||||
// FUNCTION DEFINITIONS START
|
// FUNCTION DEFINITIONS START
|
||||||
//
|
//
|
||||||
signal sendToInventory(var message);
|
signal sendToInventory(var message);
|
||||||
|
|
||||||
function passesFilter() {
|
|
||||||
return root.itemName.toLowerCase().indexOf(root.filterText.toLowerCase()) !== -1;
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
// FUNCTION DEFINITIONS END
|
// FUNCTION DEFINITIONS END
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue