mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
keep expand state when showing/hiding IPs and last connection state
This commit is contained in:
parent
335cd9a7c2
commit
da21a40eda
@ -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<void()> predicate)
|
||||
{
|
||||
std::set<QString> expanded_indexes;
|
||||
std::set<QString> selected_indexes;
|
||||
std::set<QString> 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) ; });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,7 +102,9 @@ private:
|
||||
RsFriendListModel *mModel;
|
||||
QAction *mActionSortByState;
|
||||
|
||||
void expandGroup(const RsNodeGroupId& gid);
|
||||
void applyWhileKeepingTree(std::function<void()> predicate);
|
||||
|
||||
void expandGroup(const RsNodeGroupId& gid);
|
||||
void recursRestoreExpandedItems(const QModelIndex& index, const QString& parent_path, const std::set<QString>& exp, const std::set<QString> &sel);
|
||||
void recursSaveExpandedItems(const QModelIndex& index,const QString& parent_path,std::set<QString>& exp, std::set<QString>& sel);
|
||||
void saveExpandedPathsAndSelection(std::set<QString>& expanded_indexes, std::set<QString>& selected_indexes);
|
||||
|
Loading…
Reference in New Issue
Block a user