ComponentListModel¶
- component fbx.ui.controller.ComponentListModel¶
ComponentListModel is an utility component used for handling stack of visual items. Stacked items may be pushed or popped from the stack. When pushing items, new item URLs are handled relative to parent item URLs (if pushed item has a relative URL).
Loading of new components is done asynchronously. As such, item may not be ready immediately after a
push()
. Signalchanged()
is emitted when all the stack is ready.When an item fails to load, is it removed from the stack.
changed()
is also emitted if the stack actually changes.User may not call stack modifiers (
push()
,pop()
,replace()
, etc.) in a raw. Each call must be acknowledged by achanged()
signal first.This object inherits ListModel. All entries contain a
title
attribute.- property count¶
Current count of items in the stack
User may not change this value directly.
- property topCount¶
Count of component that can be instanciated at the same time at top of the stack.
- property cacheSize¶
Count of Component the stack will keep to optimize loading of new components.
- signal updated()¶
Signal emitted when the stack contents are updated.
All components are ready (others have beed removed from the stack) when this signal is emitted, calls to
instanciate()
may not fail.
- method pop()¶
Removes item at top of stack.
- method popTo(index)¶
- Parameters
index (
int
) –
Removes items at top of stack in order to make stack item
index
new stack top.This example will pop to root of page stack:
popTo(0)
- method push(url, defaults)¶
- Parameters
url (
string
) – An URL to add in the component cachedefaults (
object
) – Properties to assign to the new item
Adds an item to the end of the stack.
- method replace(url, defaults)¶
- Parameters
url (
string
) – An URL to add in the component cachedefaults (
object
) – Properties to assign to the new item
- method replaceAt(index, url, defaults)¶
- Parameters
index (
int
) – Index to replaceurl (
string
) – An URL to add in the component cachedefaults (
object
) – Properties to assign to the new item
Does an atomic
popTo()
thenpush()
. Pushed page will replace page at indexindex
.
- method element(index, parent)¶
- Parameters
index (
int
) – Index of the element in the stack. Use negative indexes to get elements from the top of the stack.parent (
Item
) – A visual Item to parent the new object to.
- Returns
A
Deferred.Deferred()
yielding the object when ready.
Create the Item associated to relevant entry in the stack.
- property baseUrl¶
Base URL for relative URL resolution.
- property titleList¶
A list of pages titles. Only defined property in elements is
title
.
- method replaceAll(all)¶
- Parameters
all (
list
) – A list of objects
Atomic equivalent for
popTo(-1); pushMany(all);
.
- method cleanup()¶
Force a garbage collection of dandling items. All items not in
topCount
will be deleted.
- method getProperty(i, name)¶
- Parameters
i (
int
) – Stack element indexname (
string
) – Property name
- Returns
The property value
Retrieves property
name
from component at indexi
in the list model. Property lookup may use cached values if element is not currently alive.
- method pushMany(all)¶
Atomic equivalent for
push(url, defaults, title)
for all objects inall
.Example:
stack.pushMany([{url: "root.qml", title: "/"}, {url: "directory.qml", defaults: {name: "Home"}, title: "home"}, {url: "item.qml", defaults: {name: "myfile.txt"}}])
title
is optional.defaults
defaults to nothing set.