touch-packages team mailing list archive
-
touch-packages team
-
Mailing list archive
-
Message #36300
[Bug 1242531] Re: ItemSelector is hard to use with generic models
** Changed in: ubuntu-ui-toolkit (Ubuntu)
Importance: Undecided => Low
** Changed in: ubuntu-ui-toolkit (Ubuntu)
Status: New => Triaged
--
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to ubuntu-ui-toolkit in
Ubuntu.
https://bugs.launchpad.net/bugs/1242531
Title:
ItemSelector is hard to use with generic models
Status in Ubuntu UI Toolkit:
Triaged
Status in “ubuntu-ui-toolkit” package in Ubuntu:
Triaged
Bug description:
Hi!
The default delegate of ItemSelector, OptionSelectorDelegate, expects the text to be displayed to be in the "modelData" context variable. However, this variable is normally only available for ListModel or QStringList models. It's not clear how one should use ItemSelector with another model (defined from C++, for instance) which defines other role names but not "modelData".
I tried replacing the delegate of ItemSelector with a custom delegate,
but nothing was displayed. I guess some documentation needs to be
added to explain how to replace the delegate.
I ended up with this solution, which seems to be working well:
===============
ListItem.ItemSelector {
anchors.left: parent.left
anchors.right: parent.right
text: "Account"
model: root.model
delegate: OptionSelectorDelegate {
property string modelData: model.displayName
}
}
===============
However, I wonder if this will be supported in the future or if I run the risk of seeing my code break when a new version of the UI toolkit is released.
So, I'd recommend to add documentation on how to address this case; also, the OptionSelectorDelegate is currently not displayed in the documentation, but I think it should be.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242531/+subscriptions