Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
lvandyk
Posts: 19
Registered: ‎07-17-2012
My Device: BB 10 Alpha Device
Accepted Solution

Structure a QVariantList for GroupDataModel and proper tree hierarachy

I have two QVariantLists that contain QVariantMaps.

 

How do I structure the overall QVariantList container to be compatible with a GroupDataModel? I am trying to achieve the same tree hierachy at http://developer.blackberry.com/cascades/reference/index_paths.html .Then I can use indexPaths correctly.

 

So for example:

 

QVariantList -- header1 -- listItems

     |

     ------------ header 2 --- listitems

 

What I tried to do in C++:

//Should be 'branch' 0
QVariantList beforeList;
beforeList.append(beforeMap);


//Should be 'branch' 1
QVariantList afterList;
afterList.append(afterMap);


QVariantList mainList;
mainList.append(beforeList);
mainList.append(afterList);

 This excludes the headers. The ListView does display but all index paths are 0,x. 

 

Could someone show me in C++ how to create the two branches with their headers?

 

 

Thanks!

Developer
ekke
Posts: 1,571
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Structure a QVariantList for GroupDataModel and proper tree hierarachy

you should use sort fields to sort the list and group by a property of your data

then you'll get headers automatically and you can decide if Header contains complete value or only first character

the order of your List doesn't matter - GroupDataModel will sort and group it for you and provide Header and Items.

 

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Contributor
lvandyk
Posts: 19
Registered: ‎07-17-2012
My Device: BB 10 Alpha Device

Re: Structure a QVariantList for GroupDataModel and proper tree hierarachy

[ Edited ]

So if I understand correctly I should go the route of: groupDataModel(QStringList() << "header" << "item").

But then how do I do that in code? Thats where I'm struggling.

Developer
ekke
Posts: 1,571
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: Structure a QVariantList for GroupDataModel and proper tree hierarachy

I'm defining this in QML

only providing and managing the data of this GroupDataModel from C++

 

perhaps Simon will jump in - if I understand right he is doing these things from C++ ;-)

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner