I just tried this:
QList<RosterContact*> contacts;
if(index.isValid()) {
if(index.data(RosterItem::TypeRole) == RosterItem::Contact) {
RosterContact *cnt = static_cast<RosterContact*>(index.internalPointer());
if(cnt) {
contacts.append(cnt);
}
}
}
}
foreach(RosterContact *cnt, contacts) {
itemModel->moveToGroup(cnt, group);
}
QList<RosterContact*> contacts;
foreach(QModelIndex in, list) {
QModelIndex index = proxy->mapToSource(in);
if(index.isValid()) {
if(index.data(RosterItem::TypeRole) == RosterItem::Contact) {
RosterContact *cnt = static_cast<RosterContact*>(index.internalPointer());
if(cnt) {
contacts.append(cnt);
}
}
}
}
foreach(RosterContact *cnt, contacts) {
itemModel->moveToGroup(cnt, group);
}
To copy to clipboard, switch view to plain text mode
And it works great, no crashes and all items are moved. I know looping through contacts twice is not very efficient but I guess I don't have much choice.
What do you think of this solution?
Bookmarks