improved preservation of directories when updating, and allow to temporarily disable sorting while an update is received

This commit is contained in:
csoler 2016-11-26 11:03:31 +01:00
parent 7aaf3306f0
commit 3386238f35
2 changed files with 23 additions and 9 deletions

View File

@ -1472,6 +1472,8 @@ void p3FileDatabase::handleDirSyncResponse(RsFileListsSyncResponseItem *sitem)
#endif #endif
RS_STACK_MUTEX(mFLSMtx) ; 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)) 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 RsServer::notify()->notifyListChange(NOTIFY_LIST_DIRLIST_FRIENDS, 0); // notify the GUI if the hierarchy has changed

View File

@ -880,13 +880,23 @@ void LocalSharedFilesDialog::openfolder()
void SharedFilesDialog::preModDirectories(bool local) void SharedFilesDialog::preModDirectories(bool local)
{ {
if (isRemote() == local) { // (cyril) what is this for??
return; // if (isRemote() == local) {
} // return;
//}
std::cerr << "About to modify directories. Local=" << local << ". Temporarily disabling sorting" << std::endl;
ui.dirTreeView->setSortingEnabled(false);
std::set<std::string> expanded_indexes,selected_indexes;
saveExpandedPathsAndSelection(expanded_indexes,selected_indexes) ;
/* Notify both models, only one is visible */ /* Notify both models, only one is visible */
tree_model->preMods(); tree_model->preMods();
flat_model->preMods(); flat_model->preMods();
restoreExpandedPathsAndSelection(expanded_indexes,selected_indexes) ;
} }
void SharedFilesDialog::saveExpandedPathsAndSelection(std::set<std::string>& expanded_indexes, std::set<std::string>& selected_indexes) void SharedFilesDialog::saveExpandedPathsAndSelection(std::set<std::string>& expanded_indexes, std::set<std::string>& selected_indexes)
@ -978,9 +988,9 @@ void SharedFilesDialog::recursRestoreExpandedItems(const QModelIndex& index, con
void SharedFilesDialog::postModDirectories(bool local) void SharedFilesDialog::postModDirectories(bool local)
{ {
if (isRemote() == local) { // if (isRemote() == local) {
return; // return;
} // }
std::set<std::string> expanded_indexes,selected_indexes; std::set<std::string> expanded_indexes,selected_indexes;
saveExpandedPathsAndSelection(expanded_indexes,selected_indexes) ; saveExpandedPathsAndSelection(expanded_indexes,selected_indexes) ;
@ -993,13 +1003,15 @@ void SharedFilesDialog::postModDirectories(bool local)
flat_model->postMods(); flat_model->postMods();
ui.dirTreeView->update() ; ui.dirTreeView->update() ;
restoreExpandedPathsAndSelection(expanded_indexes,selected_indexes) ;
if (ui.filterPatternLineEdit->text().isEmpty() == false) if (ui.filterPatternLineEdit->text().isEmpty() == false)
FilterItems(); FilterItems();
ui.dirTreeView->setSortingEnabled(true);
restoreExpandedPathsAndSelection(expanded_indexes,selected_indexes) ;
#ifdef DEBUG_SHARED_FILES_DIALOG #ifdef DEBUG_SHARED_FILES_DIALOG
std::cerr << "****** updated directories! ******" << std::endl; std::cerr << "****** updated directories! Re-enabling sorting ******" << std::endl;
#endif #endif
QCoreApplication::flush(); QCoreApplication::flush();
} }