mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
expanding found machines inside sections
CURA-11003
This commit is contained in:
parent
2249e298ca
commit
56d6325671
1 changed files with 34 additions and 18 deletions
|
@ -15,7 +15,7 @@ import Cura 1.1 as Cura
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
id: base
|
id: base
|
||||||
property bool findingPrinter: false
|
property bool findingPrinters: false
|
||||||
// The currently selected machine item in the local machine list.
|
// The currently selected machine item in the local machine list.
|
||||||
property var currentItem: machineList.currentIndex >= 0 ? machineList.model.getItem(machineList.currentIndex) : null
|
property var currentItem: machineList.currentIndex >= 0 ? machineList.model.getItem(machineList.currentIndex) : null
|
||||||
// The currently active (expanded) section/category, where section/category is the grouping of local machine items.
|
// The currently active (expanded) section/category, where section/category is the grouping of local machine items.
|
||||||
|
@ -63,6 +63,7 @@ Item
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer
|
Timer
|
||||||
{
|
{
|
||||||
id: printerSearchTimer
|
id: printerSearchTimer
|
||||||
|
@ -110,43 +111,53 @@ Item
|
||||||
onTextChanged: printerSearchTimer.restart()
|
onTextChanged: printerSearchTimer.restart()
|
||||||
onEditingFinished:
|
onEditingFinished:
|
||||||
{
|
{
|
||||||
console.log("here")
|
|
||||||
machineDefinitionsModel.filter = {"id" : "*" + text.toLowerCase() + "*", "visible": true}
|
machineDefinitionsModel.filter = {"id" : "*" + text.toLowerCase() + "*", "visible": true}
|
||||||
findingPrinters = (text.length > 0)
|
base.findingPrinters = (text.length > 0)
|
||||||
if (findingPrinters != lastFindingPrinters)
|
if (base.findingPrinters != lastFindingPrinters)
|
||||||
{
|
{
|
||||||
updateDefinitionModel()
|
updateDefinitionModel()
|
||||||
lastFindingPrinters = findingPrinters
|
lastFindingPrinters = base.findingPrinters
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onEscapePressed: filter.text = ""
|
Keys.onEscapePressed: filter.text = ""
|
||||||
function updateDefinitionModel()
|
function updateDefinitionModel()
|
||||||
{
|
{
|
||||||
if (findingPrinters)
|
if (base.findingPrinters)
|
||||||
{
|
{
|
||||||
expandedCategories = machineDefinitionsModel.expanded.slice()
|
base.currentSections.clear()
|
||||||
machineDefinitionsModel.expanded = [""] // keep categories closed while to prevent render while making settings visible one by one
|
for (var i = 0; i < machineDefinitionsModel.count; i++)
|
||||||
machineDefinitionsModel.showAncestors = true
|
{
|
||||||
machineDefinitionsModel.showAll = true
|
var sectionexpanded = machineDefinitionsModel.getItem(i)["section"]
|
||||||
machineDefinitionsModel.expanded = ["*"]
|
if (!base.currentSections.has(sectionexpanded))
|
||||||
|
{
|
||||||
|
base.currentSections.add(sectionexpanded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateCurrentItemUponSectionChange(base.currentSections[0]);
|
||||||
|
// Trigger update on base.currentSections
|
||||||
|
base.currentSections = base.currentSections;
|
||||||
|
// Set the machineName to the first element of the list
|
||||||
|
machineList.currentIndex = 0
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (expandedCategories)
|
const initialSection = "Ultimaker B.V.";
|
||||||
{
|
base.currentSections.clear();
|
||||||
machineDefinitionsModel.expanded = expandedCategories
|
base.currentSections.add(initialSection);
|
||||||
}
|
updateCurrentItemUponSectionChange(initialSection);
|
||||||
machineDefinitionsModel.showAncestors = false
|
// Trigger update on base.currentSections
|
||||||
machineDefinitionsModel.showAll = false
|
base.currentSections = base.currentSections;
|
||||||
|
machineList.currentIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UM.SimpleButton
|
UM.SimpleButton
|
||||||
{
|
{
|
||||||
id: clearFilterButton
|
id: clearFilterButton
|
||||||
iconSource: UM.Theme.getIcon("Cancel")
|
iconSource: UM.Theme.getIcon("Cancel")
|
||||||
visible: findingPrinters
|
visible: base.findingPrinters
|
||||||
|
|
||||||
height: Math.round(filter.height * 0.4)
|
height: Math.round(filter.height * 0.4)
|
||||||
width: visible ? height : 0
|
width: visible ? height : 0
|
||||||
|
@ -230,6 +241,11 @@ Item
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked:
|
onClicked:
|
||||||
|
{
|
||||||
|
changeVisibility()
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeVisibility()
|
||||||
{
|
{
|
||||||
if (base.currentSections.has(section))
|
if (base.currentSections.has(section))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue