From ff701fb807cf92bef8da54524d9b8a61f22ee53a Mon Sep 17 00:00:00 2001 From: jolavillette Date: Tue, 30 Dec 2025 20:43:15 +0100 Subject: [PATCH] new attempt at fixing search in My files --- .../gui/FileTransfer/SharedFilesDialog.cpp | 7 ++--- retroshare-gui/src/gui/RemoteDirModel.cpp | 29 +++++-------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp index ccd07ae7c..c2e647366 100644 --- a/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/SharedFilesDialog.cpp @@ -1286,10 +1286,8 @@ void SharedFilesDialog::FilterItems() if(text == "") { model->filterItems(std::list(), found) ; - - // MODIFICATION: Ensure the model and its totals are updated + // Ensure UI refresh model->update(); - if (tree_proxyModel) tree_proxyModel->invalidate(); if (flat_proxyModel) flat_proxyModel->invalidate(); return ; @@ -1304,9 +1302,10 @@ void SharedFilesDialog::FilterItems() for(auto it(lst.begin()); it != lst.end(); ++it) keywords.push_back((*it).toStdString()); + // Execute core search model->filterItems(keywords, found) ; - // MODIFICATION: Refresh the model to reflect search results and updated row counts + // MODIFICATION: Force refresh to apply FilterRole changes in the Proxy Model model->update(); if (tree_proxyModel) tree_proxyModel->invalidate(); diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 1979694b4..a151d70d6 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -354,7 +354,6 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const if ((!ref) && RemoteMode) _parentRow.clear(); //Only clear it when asking root child number and in remote mode. - DirDetails details ; if (! requestDirDetails(ref, RemoteMode,details)) @@ -383,8 +382,6 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const { DirDetails childDetails; //Scan all children to know if they are empty. - //And save their real row index - //Prefer do like that than modify requestDirDetails with a new flag (rsFiles->RequestDirDetails) for(uint64_t i = 0; i < details.children.size(); ++i) { if (requestDirDetails(details.children[i].ref, RemoteMode,childDetails) && (childDetails.children.size() > 0)) @@ -393,19 +390,9 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const return _parentRow.size(); } - // MODIFICATION 3: Count filtered children correctly - if (!mFilteredPointers.empty()) - { - int visibleCount = 0; - for(uint32_t i = 0; i < details.children.size(); ++i) - { - // Check if this specific child pointer is in the visible set - if (mFilteredPointers.find(details.children[i].ref) != mFilteredPointers.end()) - visibleCount++; - } - return visibleCount; - } - + // MODIFICATION: Removed the manual mFilteredPointers count logic. + // QSortFilterProxyModel relies on the source model reporting all rows. + // Filtering here creates an index mismatch that results in an empty list. return details.children.size(); } @@ -1502,7 +1489,7 @@ void RetroshareDirModel::filterItems(const std::list& keywords, uin if(keywords.empty()) { mFilteredPointers.clear(); - // MODIFICATION: Call update to refresh the view when the filter is cleared + // MODIFICATION: Refresh the model to show all items again update(); return ; } @@ -1531,7 +1518,7 @@ void RetroshareDirModel::filterItems(const std::list& keywords, uin mFilteredPointers.insert(p) ; ++found ; - // Climb the directory tree to mark all parents as visible + // Climb the directory tree to mark all parents as visible for Tree View while(det.type == DIR_TYPE_FILE || det.type == DIR_TYPE_EXTRA_FILE || det.type == DIR_TYPE_DIR || det.type == DIR_TYPE_PERSON) { @@ -1543,14 +1530,12 @@ void RetroshareDirModel::filterItems(const std::list& keywords, uin mFilteredPointers.insert(p); // Mark parent node as visible - // If we reach the Person node (root of extra list), stop climbing + // If we reach the Person node (root of files), stop climbing if (det.type == DIR_TYPE_PERSON) break; } } - // MODIFICATION: Restore the update call. - // This triggers beginResetModel/endResetModel which notifies the view - // that row counts and visibility have changed. + // MODIFICATION: Restore the update call to notify the UI of search completion update(); }