From 3386238f353c9633a84d9d115fd67da79822b517 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 26 Nov 2016 11:03:31 +0100 Subject: [PATCH] improved preservation of directories when updating, and allow to temporarily disable sorting while an update is received --- libretroshare/src/file_sharing/p3filelists.cc | 2 ++ retroshare-gui/src/gui/SharedFilesDialog.cpp | 30 +++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/file_sharing/p3filelists.cc b/libretroshare/src/file_sharing/p3filelists.cc index 017e6e9d9..ff52d245a 100644 --- a/libretroshare/src/file_sharing/p3filelists.cc +++ b/libretroshare/src/file_sharing/p3filelists.cc @@ -1472,6 +1472,8 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem *sitem) #endif RS_STACK_MUTEX(mFLSMtx) ; + RsServer::notify()->notifyListPreChange(NOTIFY_LIST_DIRLIST_FRIENDS, 0); // notify the GUI if the hierarchy has changed + if(mRemoteDirectories[fi]->deserialiseUpdateDirEntry(entry_index,item->directory_content_data)) { RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_FRIENDS, 0); // notify the GUI if the hierarchy has changed diff --git a/retroshare-gui/src/gui/SharedFilesDialog.cpp b/retroshare-gui/src/gui/SharedFilesDialog.cpp index 78ac47a3f..86b85edaf 100644 --- a/retroshare-gui/src/gui/SharedFilesDialog.cpp +++ b/retroshare-gui/src/gui/SharedFilesDialog.cpp @@ -880,13 +880,23 @@ void LocalSharedFilesDialog::openfolder() void SharedFilesDialog::preModDirectories(bool local) { - if (isRemote() == local) { - return; - } + // (cyril) what is this for?? + // if (isRemote() == local) { + // return; + //} + + std::cerr << "About to modify directories. Local=" << local << ". Temporarily disabling sorting" << std::endl; + + ui.dirTreeView->setSortingEnabled(false); + + std::set expanded_indexes,selected_indexes; + saveExpandedPathsAndSelection(expanded_indexes,selected_indexes) ; /* Notify both models, only one is visible */ tree_model->preMods(); flat_model->preMods(); + + restoreExpandedPathsAndSelection(expanded_indexes,selected_indexes) ; } void SharedFilesDialog::saveExpandedPathsAndSelection(std::set& expanded_indexes, std::set& selected_indexes) @@ -978,9 +988,9 @@ void SharedFilesDialog::recursRestoreExpandedItems(const QModelIndex& index, con void SharedFilesDialog::postModDirectories(bool local) { - if (isRemote() == local) { - return; - } +// if (isRemote() == local) { +// return; +// } std::set expanded_indexes,selected_indexes; saveExpandedPathsAndSelection(expanded_indexes,selected_indexes) ; @@ -993,13 +1003,15 @@ void SharedFilesDialog::postModDirectories(bool local) flat_model->postMods(); ui.dirTreeView->update() ; - restoreExpandedPathsAndSelection(expanded_indexes,selected_indexes) ; - if (ui.filterPatternLineEdit->text().isEmpty() == false) FilterItems(); + ui.dirTreeView->setSortingEnabled(true); + + restoreExpandedPathsAndSelection(expanded_indexes,selected_indexes) ; + #ifdef DEBUG_SHARED_FILES_DIALOG - std::cerr << "****** updated directories! ******" << std::endl; + std::cerr << "****** updated directories! Re-enabling sorting ******" << std::endl; #endif QCoreApplication::flush(); }