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
Posts: 33
Registered: ‎01-02-2012
My Device: 9900
My Carrier: bell

indexPath problem unable to fine the item in the model QListDataItem

I'm having a problem with the code below:

void ProfileBoxManager::editItem(const QVariant &index, const QString &Milestone, const QString &Description,const  QString &Task,const  QString &StartDate,const  QString &EndDate)
{
	
	QVariantMap itemMap = index.toMap();
        int itemDataIndex = mBucket.indexOf(itemMap);
	int itemIndex = m_modlist->indexOf(itemMap);
	itemMap["Milestone"] = Milestone;
	itemMap["Description"] = Description;
	itemMap["Task"] = Task;
	itemMap["StartDate"] = StartDate;
	itemMap["EndDate"] = EndDate;
	mBucket.replace(itemDataIndex, itemMap);
	m_modlist->replace(itemIndex, itemMap);
	saveData();
}

 Essentially this code is supposed edit an item from the datamodel. In order to do this it simply takes in the selected index from the list. Concerts it to QVariantMap. But the problem occurs when we search from the item in the Datamodel. 

 int itemDataIndex = mBucket.indexOf(itemMap);
 int itemIndex = m_modlist->indexOf(itemMap);

 Both of these return -1 which means they have not found the item in the datamodel. Has someone come across this issue please let me know that would be great.

 

Developer
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: indexPath problem unable to fine the item in the model QListDataItem

Could index.toMap() be returning and empty QVariantMap?

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Contributor
Posts: 33
Registered: ‎01-02-2012
My Device: 9900
My Carrier: bell

Re: indexPath problem unable to fine the item in the model QListDataItem

All it is returning is qMap() empty.
Developer
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: indexPath problem unable to fine the item in the model QListDataItem

Is the variant of type Map? If it is, then I'm stumped.

 

QMap<QString, QVariant> QVariant::toMap() const

Returns the variant as a QMap<QString, QVariant> if the variant is of type() Map; otherwise returns an empty array.

 

(taken from the QVariant Cascades Page).

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!