diff --git a/retroshare-gui/src/gui/common/NewFriendList.cpp b/retroshare-gui/src/gui/common/NewFriendList.cpp index 95e0c844c..a388c9dea 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.cpp +++ b/retroshare-gui/src/gui/common/NewFriendList.cpp @@ -453,6 +453,7 @@ void NewFriendList::processSettings(bool load) if (load) // load settings { + std::cerr <<"Re-loading settings..." << std::endl; // states setShowUnconnected(!Settings->value("hideUnconnected", !mProxyModel->showOfflineNodes()).toBool()); setShowState(Settings->value("showState", mModel->getDisplayStatusString()).toBool()); @@ -1087,24 +1088,29 @@ void NewFriendList::removeGroup() checkInternalData(true); } -void NewFriendList::checkInternalData(bool force) +void NewFriendList::applyWhileKeepingTree(std::function predicate) { std::set expanded_indexes; - std::set selected_indexes; + std::set selected_indexes; - saveExpandedPathsAndSelection(expanded_indexes, selected_indexes); + saveExpandedPathsAndSelection(expanded_indexes, selected_indexes); // This is a hack to avoid crashes on windows while calling endInsertRows(). I'm not sure wether these crashes are // due to a Qt bug, or a misuse of the proxy model on my side. Anyway, this soves them for good. mProxyModel->setSourceModel(nullptr); - mModel->checkInternalData(force); + predicate(); mProxyModel->setSourceModel(mModel); restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes); } +void NewFriendList::checkInternalData(bool force) +{ + applyWhileKeepingTree([force,this]() { mModel->checkInternalData(force) ; }); +} + void NewFriendList::exportFriendlistClicked() { QString fileName; @@ -1490,6 +1496,7 @@ bool NewFriendList::isColumnVisible(int col) const } void NewFriendList::setColumnVisible(int col,bool visible) { + std::cerr << "Setting column " << col << " to be visible: " << visible << std::endl; ui->peerTreeWidget->setColumnHidden(col, !visible); } void NewFriendList::toggleColumnVisible() @@ -1507,12 +1514,12 @@ void NewFriendList::toggleColumnVisible() void NewFriendList::setShowState(bool show) { - mModel->setDisplayStatusString(show); + applyWhileKeepingTree([show,this]() { mModel->setDisplayStatusString(show) ; }); } void NewFriendList::setShowGroups(bool show) { - mModel->setDisplayGroups(show); + applyWhileKeepingTree([show,this]() { mModel->setDisplayGroups(show) ; }); } /** diff --git a/retroshare-gui/src/gui/common/NewFriendList.h b/retroshare-gui/src/gui/common/NewFriendList.h index 2a1955ced..cf026b81b 100644 --- a/retroshare-gui/src/gui/common/NewFriendList.h +++ b/retroshare-gui/src/gui/common/NewFriendList.h @@ -102,7 +102,9 @@ private: RsFriendListModel *mModel; QAction *mActionSortByState; - void expandGroup(const RsNodeGroupId& gid); + void applyWhileKeepingTree(std::function predicate); + + void expandGroup(const RsNodeGroupId& gid); void recursRestoreExpandedItems(const QModelIndex& index, const QString& parent_path, const std::set& exp, const std::set &sel); void recursSaveExpandedItems(const QModelIndex& index,const QString& parent_path,std::set& exp, std::set& sel); void saveExpandedPathsAndSelection(std::set& expanded_indexes, std::set& selected_indexes);