From 951b7f93fb6d9cf24fd6f04063270afd90a4f985 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 28 Jul 2019 09:12:55 +0200 Subject: [PATCH] fixed model internals. Seems to work now. --- .../src/gui/common/FriendListModel.cpp | 17 +++++++++++++++-- retroshare-gui/src/gui/common/NewFriendList.cpp | 5 +++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendListModel.cpp b/retroshare-gui/src/gui/common/FriendListModel.cpp index 055fb47c5..760e7c29b 100644 --- a/retroshare-gui/src/gui/common/FriendListModel.cpp +++ b/retroshare-gui/src/gui/common/FriendListModel.cpp @@ -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(); } diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index e017e1263..636280c11 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -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()