mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-14 00:49:41 -05:00
fixed model internals. Seems to work now.
This commit is contained in:
parent
ca442a7113
commit
951b7f93fb
@ -193,6 +193,8 @@ QModelIndex RsFriendListModel::index(int row, int column, const QModelIndex & pa
|
||||
|
||||
convertInternalIdToIndex(parent.internalId(),parent_index);
|
||||
|
||||
RsDbg() << "Index row=" << row << " col=" << column << " parent=" << parent << std::endl;
|
||||
|
||||
EntryIndex new_index;
|
||||
|
||||
switch(parent_index.type)
|
||||
@ -204,13 +206,14 @@ QModelIndex RsFriendListModel::index(int row, int column, const QModelIndex & pa
|
||||
case ENTRY_TYPE_PROFILE: new_index.type = ENTRY_TYPE_NODE;
|
||||
new_index.ind = mProfiles[parent_index.ind].child_indices[row];
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
return QModelIndex();
|
||||
}
|
||||
quintptr ref ;
|
||||
convertIndexToInternalId(new_index,ref);
|
||||
|
||||
RsDbg() << " returning " << createIndex(row,column,ref) << std::endl;
|
||||
|
||||
return createIndex(row,column,ref);
|
||||
}
|
||||
|
||||
@ -481,6 +484,8 @@ QVariant RsFriendListModel::sortRole(const EntryIndex& fmpe,int column) const
|
||||
|
||||
QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
|
||||
{
|
||||
RsDbg() << " Display role " << e.type << "," << e.ind << " (col="<< col<<") : " << std::endl;
|
||||
|
||||
switch(e.type)
|
||||
{
|
||||
case ENTRY_TYPE_GROUP:
|
||||
@ -714,6 +719,9 @@ void RsFriendListModel::updateInternalData()
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,mGroups.size()-1);
|
||||
endInsertRows();
|
||||
|
||||
mGroups.clear();
|
||||
mLocations.clear();
|
||||
mProfiles.clear();
|
||||
@ -788,9 +796,11 @@ void RsFriendListModel::updateInternalData()
|
||||
if(it5 == ssl_indexes.end())
|
||||
{
|
||||
RsNodeDetails nodedet;
|
||||
|
||||
rsPeers->getPeerDetails(*it4,nodedet);
|
||||
|
||||
if(nodedet.location.empty())
|
||||
nodedet.location = tr("[Unknown]").toStdString();
|
||||
|
||||
ssl_indexes[*it4] = mNodeDetails.size();
|
||||
mNodeDetails.push_back(nodedet);
|
||||
|
||||
@ -815,6 +825,9 @@ void RsFriendListModel::updateInternalData()
|
||||
mGroups.push_back(groupinfo);
|
||||
}
|
||||
|
||||
beginInsertRows(QModelIndex(),0,mGroups.size()-1);
|
||||
endInsertRows();
|
||||
|
||||
postMods();
|
||||
}
|
||||
|
||||
|
@ -839,6 +839,7 @@ void NewFriendList::addToGroup()
|
||||
|
||||
// add to group
|
||||
rsPeers->assignPeerToGroup(groupId, gpgId, true);
|
||||
mModel->updateInternalData();
|
||||
}
|
||||
|
||||
void NewFriendList::moveToGroup()
|
||||
@ -862,6 +863,7 @@ void NewFriendList::moveToGroup()
|
||||
|
||||
// add to group
|
||||
rsPeers->assignPeerToGroup(groupId, gpgId, true);
|
||||
mModel->updateInternalData();
|
||||
}
|
||||
|
||||
void NewFriendList::removeFromGroup()
|
||||
@ -879,6 +881,7 @@ void NewFriendList::removeFromGroup()
|
||||
|
||||
// remove from (all) group(s)
|
||||
rsPeers->assignPeerToGroup(groupId, gpgId, false);
|
||||
mModel->updateInternalData();
|
||||
}
|
||||
|
||||
void NewFriendList::editGroup()
|
||||
@ -895,6 +898,7 @@ void NewFriendList::editGroup()
|
||||
CreateGroup editGrpDialog(groupId, this);
|
||||
editGrpDialog.exec();
|
||||
}
|
||||
mModel->updateInternalData();
|
||||
}
|
||||
|
||||
void NewFriendList::removeGroup()
|
||||
@ -905,6 +909,7 @@ void NewFriendList::removeGroup()
|
||||
return;
|
||||
|
||||
rsPeers->removeGroup(pinfo.id);
|
||||
mModel->updateInternalData();
|
||||
}
|
||||
|
||||
void NewFriendList::exportFriendlistClicked()
|
||||
|
Loading…
Reference in New Issue
Block a user