I have an element that is a delegate for a ListView and it is loading this or that component depending on certain properties of the model like so:
Component.onCompleted:
{
...
else if(typeof(modelData.value) === "string" && modelData.optionsList.length === 0)
{
_firstLoader.sourceComponent = _textEntryComponent
_valueContainerItem.objectName = "textbox"
}
else if(modelData.is_boolean)
{
_firstLoader.sourceComponent = _booleanComponent
_valueContainerItem.objectName = "boolean switch"
}
...
}
Component.onCompleted:
{
...
else if(typeof(modelData.value) === "string" && modelData.optionsList.length === 0)
{
_firstLoader.sourceComponent = _textEntryComponent
_valueContainerItem.objectName = "textbox"
}
else if(modelData.is_boolean)
{
_firstLoader.sourceComponent = _booleanComponent
_valueContainerItem.objectName = "boolean switch"
}
...
}
To copy to clipboard, switch view to plain text mode
The model is essentially just various properties defined in the back end. Here is the ListView (wizard):
ListView
{
id: setupList
onCurrentIndexChanged: vehicleSetupTitle.text = model[setupList.currentIndex].label
model: currentSelectedVehicle.propertiesForVehicle
delegate: Item
{
id: buffer
HardwareSettingsDisplay
{
title: modelData.label
onProgressWizard:
{
setupList.incrementCurrentIndex()
currentSelectedImplement.setLastConfigurationResumeStep(setupList.currentIndex)
}
}
}
}
ListView
{
id: setupList
onCurrentIndexChanged: vehicleSetupTitle.text = model[setupList.currentIndex].label
model: currentSelectedVehicle.propertiesForVehicle
delegate: Item
{
id: buffer
HardwareSettingsDisplay
{
title: modelData.label
onProgressWizard:
{
setupList.incrementCurrentIndex()
currentSelectedImplement.setLastConfigurationResumeStep(setupList.currentIndex)
}
}
}
}
To copy to clipboard, switch view to plain text mode
Where ProgressWizard is a signal created in HardwareSettingsDisplay that fires whenever the user makes an acceptable selection for one of the different components:
signal progressWizard
signal progressWizard
To copy to clipboard, switch view to plain text mode
Alright, so I am having trouble with increment/decrement. So when I want to increment the wizard the user makes a selection and that selection fires the progressWizard() function which moves the wizard forward, in theory. However, I am getting odd behavior so I threw in some print statements:
onModelChanged:
{
console.info("Model just changed.")
console.info("Current index: ", setupList.currentIndex)
console.info("Last configuration step: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
}
onCurrentIndexChanged:
{
console.info("Index just changed.")
console.info("Current index: ", setupList.currentIndex)
console.info("Last configuration step: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
visible ? vehicleSetupTitle.text = model[setupList.currentIndex].label : ""
}
onProgressWizard:
{
console.info("Progress wizard called. Current index value: ", setupList.currentIndex)
console.info("Last configuration step: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
setupList.incrementCurrentIndex()
console.info("Progress wizard called. Index was just incremented: ", setupList.currentIndex)
console.info("Last configuration step: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
presentationManager.settingsPresenter.currentSelectedImplement.setLastConfigurationResumeStep(setupList.currentIndex)
console.info("Last configuration step just set too current index: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
}
onModelChanged:
{
console.info("Model just changed.")
console.info("Current index: ", setupList.currentIndex)
console.info("Last configuration step: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
}
onCurrentIndexChanged:
{
console.info("Index just changed.")
console.info("Current index: ", setupList.currentIndex)
console.info("Last configuration step: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
visible ? vehicleSetupTitle.text = model[setupList.currentIndex].label : ""
}
onProgressWizard:
{
console.info("Progress wizard called. Current index value: ", setupList.currentIndex)
console.info("Last configuration step: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
setupList.incrementCurrentIndex()
console.info("Progress wizard called. Index was just incremented: ", setupList.currentIndex)
console.info("Last configuration step: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
presentationManager.settingsPresenter.currentSelectedImplement.setLastConfigurationResumeStep(setupList.currentIndex)
console.info("Last configuration step just set too current index: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
}
To copy to clipboard, switch view to plain text mode
Here is the output:
//First thing I do is create a new item. It seems to print everything twice
qml: Index just changed.
qml: Current index: 0
qml: Last configuration step: 0
qml: Model just changed.
qml: Current index: 0
qml: Last configuration step: 0
qml: Index just changed.
qml: Current index: 0
qml: Last configuration step: 0
qml: Model just changed.
qml: Current index: 0
qml: Last configuration step: 0
//Now I enter in a name. The wizard progresses and all seems well but the last configuration step isn't being set properly for some reason
qml: Progress wizard called. Current index value: 0
qml: Last configuration step: 0
qml: Index just changed.
qml: Current index: 1
qml: Last configuration step: 0
qml: Progress wizard called. Index was just incremented: 1
qml: Last configuration step: 0
qml: Last configuration step just set too current index: 0
//Now I hit the boolean switch and the wizard goes backwards
qml: Current index: 0
qml: Last configuration step: 0
qml: Model just changed.
qml: Current index: 0
qml: Last configuration step: 0
How is this possible it's not calling: setupList.decrementCurrentIndex() it's not even calling progressWizard() the only thing I can think is that changing the model is somehow reloading the entire Item or ListView. If that's the case then maybe I can do something like this:
onModelChanged:
{
setupList.currentIndex = presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep
setupList.positionViewAtIndex(setupList.currentIndex, ListView.Beginning)
}
onModelChanged:
{
setupList.currentIndex = presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep
setupList.positionViewAtIndex(setupList.currentIndex, ListView.Beginning)
}
To copy to clipboard, switch view to plain text mode
but until I can figure out why my setter isn't working... but that might not even be the case or the best solution here. So I wanted to post my problem here in the hopes that you guys could take a look and help me out if you can think of something I am not doing or am doing wrong please let me know.
EDIT:
I figured out why the last configuration step wasn't being set so I tried the onModelChanged idea:
onModelChanged:
{
console.info("Model just changed.")
console.info("Current index: ", setupList.currentIndex)
console.info("Last configuration step: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
setupList.currentIndex = presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep
setupList.positionViewAtIndex(setupList.currentIndex, ListView.Beginning)
}
onModelChanged:
{
console.info("Model just changed.")
console.info("Current index: ", setupList.currentIndex)
console.info("Last configuration step: ", presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep)
setupList.currentIndex = presentationManager.settingsPresenter.currentSelectedVehicle.lastConfigurationStep
setupList.positionViewAtIndex(setupList.currentIndex, ListView.Beginning)
}
To copy to clipboard, switch view to plain text mode
it worked... for the second component. However, the third component is now sending me back to the second component
Output
//First creation nothing changed
qml: Index just changed.
qml: Current index: 0
qml: Last configuration step: 0
qml: Model just changed.
qml: Current index: 0
qml: Last configuration step: 0
qml: Index just changed.
qml: Current index: 0
qml: Last configuration step: 0
qml: Model just changed.
qml: Current index: 0
qml: Last configuration step: 0
//Text element component entry now reports everything correctly and all seems well. wizard progresses:
qml: Progress wizard called. Current index value: 0
qml: Last configuration step: 0
qml: Index just changed.
qml: Current index: 1
qml: Last configuration step: 0
qml: Progress wizard called. Index was just incremented: 1
qml: Last configuration step: 0
qml: Last configuration step just set too current index: 1
//Second boolean component is no longer sending me backwards but the index is definitely being reset for some reason:
qml: Index just changed.
qml: Current index: 0 //index reset
qml: Last configuration step: 1
qml: Model just changed.
qml: Current index: 0
qml: Last configuration step: 1
qml: Index just changed.
qml: Current index: 1 //index set to last configuration onModelChanged
qml: Last configuration step: 1
//So I hit next and come to another component which is a List Selection component but it's sending me backwards
qml: Index just changed.
qml: Current index: 0 //Got reset to zero
qml: Last configuration step: 1
qml: Model just changed.
qml: Current index: 0
qml: Last configuration step: 1
qml: Index just changed.
qml: Current index: 1 //frustrating...
qml: Last configuration step: 1
Bookmarks