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
Posts: 92
Registered: ‎08-01-2013
My Device: Z10, Q5, Q10
My Carrier: Vodaphone

Re: List View in C++

I know how to perform DB  CRUD i have already done that.

What i need to know is.. like i populate my QListDataModel using the implementation i have provided in my earlier posts,

How I m supposed to populate GroupDataModel so that it consists of the Headers as well as StandardListItems.?

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: List View in C++

Everything I write you say you already know so I obviously have no idea what it is you are struggling to do, I will leave it to someone else to answer you.

All the best.

If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: List View in C++

Is the confusion here, and the reason I'm not being very successful at helping, is that you are trying to group a QListDataModel?

 

If so just use the GroupDataModel directly as I'm not sure conversion from one type to another is easy or even possible.

 

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 92
Registered: ‎08-01-2013
My Device: Z10, Q5, Q10
My Carrier: Vodaphone

Re: List View in C++

I'm unable to use GroupDataModel, thats the problem.

I know how to write a provider for that, as u mentioned earlier using :

 

class GroupListItemManager : public ListItemProvider
{
public:
    VisualNode * createItem(ListView* list, QString type)
    {
        Q_UNUSED(list);
 
        if (type.compare(GroupDataModel::Header) == 0) {
            return new Header();
        } else {
            return new StandardListItem();
        }
    }
 
    void updateItem(ListView* list, VisualNode *control, QString type,
        QVariantList indexPath, QVariant data)
    {
        Q_UNUSED(list);
        Q_UNUSED(indexPath);
 
        if (type.compare(GroupDataModel::Header) == 0) {
            QString caption = data.value<QString>();
            static_cast<Header*>(control)->setTitle(caption);
        } else {
            QVariantMap map = data.value<QVariantMap>();
            static_cast<StandardListItem*>(control)->setTitle(QString("%1, %2").arg(
                map["country"].toString(), map["continent"].toString()));
        }
    }
};

 

but for this to come into play, i do not know how to append/insert data into group data model.

 

GroupDataModel *model = new GroupDataModel(QStringList() << "country" << "continent");
 
QVariantMap map;
map["country"] = "Italy"; map["continent"] = "Europe"; model->insert(map);
map["country"] = "Japan"; map["continent"] = "Asia"; model->insert(map);
map["country"] = "Egypt"; map["continent"] = "Africa"; model->insert(map);
 
ListView *listView = new ListView();
listView->setDataModel(model);

 

This snippet helps me understand how to insert a list item, but how shall i insert the Header into the model, this is my problem.

I might not be the best at explaining my issue, nevertheless i m trying,,!

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: List View in C++

Yeah I'm still finding it hard to understand what you are trying to do.

Do you want to use a GroupDataModel?

Using the example above the header would just be another element in the map, i.e.

map["header"] = "Red";

Don't think of the header as anything different from the other data, it is just another field and in fact you can use any of the data as the header item.

So in the above example under a GroupDataModel continent could be used as the sorting group header by just sorting on that field.

If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: List View in C++

[ Edited ]

Is it the sortingkeys element you are not understanding?

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__groupdatamodel.html#property...

 

http://developer.blackberry.com/native/documentation/cascades/ui/lists/groupdatamodel.html

 

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 92
Registered: ‎08-01-2013
My Device: Z10, Q5, Q10
My Carrier: Vodaphone

Re: List View in C++

what is want to achive is, a list with elements like :

 

TODAY

- had tea

- had went to office

YESTERDAY

- went to mother's place.

- had coffee

MAY 14

- had lunch

-went for a drive

 

where in a web service call would give me  these items

- had tea

- had went to office

- went to mother's place.

- had coffee

and a timestamp.

 

and from this timestamp i'm supposed to calculate the content of the header. ie, TODAY, YESTERDAY, MAY 14 (ie the day before yesterday)

 

i know i can achieve it using the GroupDataModel, (m using c++) but i do not understand how to go about it, for all the docs i found were for QML.

Highlighted
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: List View in C++

There's a section in that earlier link that shows how to do it in C++ the section entitled 'Creating a GroupDataModel in C++'...

 

http://developer.blackberry.com/native/documentation/cascades/ui/lists/groupdatamodel.html

 

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.