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
Developer
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers
Accepted Solution

get a custom object back out of a GroupDataModel

hey gang,

 

I have a GroupDataModel which I populate like this:

 

m_model->insert(new Task(lineList.at(3), lineList.at(0), 11223344, lineList.at(2), true));

 in a loop.  there will be several "Task" objects int he GroupDataModel.

 

What I'm not clear no is how to get a specific "Task" out of the GroupDataModel.

 

I've been trying to use toListOfObjects(), but I'm not sure how to use it.

 

I can't find any good examples, though there are some for toGroupOfMaps().

 

anyone able to help?

 

thx,

 

J

bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.
Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: get a custom object back out of a GroupDataModel

[ Edited ]

Try this 

toListOfMaps

QList<QVariantMap> list = m_model->toListOfMaps();

foreach(QVariantMap item, list){
    // here is logic for compare/find the item by the any value
    if (item["your key"] == your condition){
        //here is your find item
    }
}

 Same logic you can use for toListOfObjects, but instead of QVariantMap use your Task object.

QList<Task*> list = m_model->toListOfObjects();

foreach(Task *item, list){
    // here is logic for compare/find the item by the any value
    if (item->youkey == your condition){
        //here is your find item
    }
}

 

Maybe is a better solution, but hope this will works :Innocent:

 



If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Please use plain text.
Developer
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

Re: get a custom object back out of a GroupDataModel

Works! Thanks!
bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Please use plain text.
Developer
Benecore
Posts: 540
Registered: ‎08-31-2013
My Device: Q10, Z10LE, Nokia N950, DAB....
My Carrier: Telekom Slovakia

Re: get a custom object back out of a GroupDataModel

I'm glad I helped


If helped give a like. If your problem was solved mark the post as "Solution"
Portfolio: BlackBerry Nokia
Social: Twitter | Facebook
About Me / Blog DevPDA | Blog
Please use plain text.