From 210b43dc47b3402147866b9cf5f430362d594bb8 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 9 Apr 2011 19:43:09 +0000 Subject: [PATCH] added temporisation to update of Flat shared files view. Makes it more handy for large lists git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4144 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/RemoteDirModel.cpp | 26 ++++++++++++++++++----- retroshare-gui/src/gui/RemoteDirModel.h | 8 ++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 09daafc1b..b4cb2c2cc 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include "RemoteDirModel.h" #include @@ -1294,18 +1295,28 @@ TreeStyle_RDM::~TreeStyle_RDM() void FlatStyle_RDM::postMods() { _ref_entries.clear() ; + _ref_stack.clear() ; + + _ref_stack.push_back(NULL) ; // init the stack with the topmost parent directory std::cerr << "FlatStyle_RDM::postMods(): cleared ref entries" << std::endl; + updateRefs() ; +} - std::vector stack(1,(void *)NULL) ; +void FlatStyle_RDM::updateRefs() +{ + RetroshareDirModel::preMods() ; - while(!stack.empty()) + static const uint32_t MAX_REFS_PER_SECOND = 2000 ; + uint32_t nb_treated_refs = 0 ; + + while(!_ref_stack.empty()) { - void *ref = stack.back() ; + void *ref = _ref_stack.back() ; #ifdef RDM_DEBUG std::cerr << "FlatStyle_RDM::postMods(): poped ref " << ref << std::endl; #endif - stack.pop_back() ; + _ref_stack.pop_back() ; uint32_t flags = DIR_FLAGS_DETAILS; DirDetails details ; @@ -1317,7 +1328,12 @@ void FlatStyle_RDM::postMods() std::cerr << "FlatStyle_RDM::postMods(): addign ref " << ref << std::endl; #endif for(std::list::iterator it = details.children.begin(); it != details.children.end(); it++) - stack.push_back(it->ref) ; + _ref_stack.push_back(it->ref) ; + } + if(++nb_treated_refs > MAX_REFS_PER_SECOND) // we've done enough, let's give back hand to + { // the user and setup a timer to finish the job later. + QTimer::singleShot(500,this,SLOT(updateRefs())) ; + break ; } } std::cerr << "reference tab contains " << _ref_entries.size() << " files" << std::endl; diff --git a/retroshare-gui/src/gui/RemoteDirModel.h b/retroshare-gui/src/gui/RemoteDirModel.h index 3e21027eb..f77553bc2 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.h +++ b/retroshare-gui/src/gui/RemoteDirModel.h @@ -162,6 +162,8 @@ class TreeStyle_RDM: public RetroshareDirModel // class FlatStyle_RDM: public RetroshareDirModel { + Q_OBJECT + public: FlatStyle_RDM(bool mode) : RetroshareDirModel(mode) @@ -170,6 +172,9 @@ class FlatStyle_RDM: public RetroshareDirModel virtual ~FlatStyle_RDM() ; + protected slots: + void updateRefs() ; + protected: virtual void postMods(); @@ -186,7 +191,8 @@ class FlatStyle_RDM: public RetroshareDirModel QString computeDirectoryPath(const DirDetails& details) const ; - std::vector > _ref_entries ; + std::vector > _ref_entries ;// used to store the refs to display + std::vector _ref_stack ; // used to store the refs to update };