mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -05:00
save/restore expanded items when sorting
This commit is contained in:
parent
fdea4febbe
commit
b5cdd0f4f0
@ -126,8 +126,7 @@ FriendList::FriendList(QWidget *parent) :
|
|||||||
#ifdef RS_DIRECT_CHAT
|
#ifdef RS_DIRECT_CHAT
|
||||||
connect(ui->peerTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(chatfriend(QTreeWidgetItem *)));
|
connect(ui->peerTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(chatfriend(QTreeWidgetItem *)));
|
||||||
#else
|
#else
|
||||||
connect( ui->peerTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
|
connect( ui->peerTreeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(expandItem(QTreeWidgetItem *)) );
|
||||||
this, SLOT(expandItem(QTreeWidgetItem *)) );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged()));
|
connect(NotifyQt::getInstance(), SIGNAL(groupsChanged(int)), this, SLOT(groupsChanged()));
|
||||||
|
@ -185,7 +185,7 @@ NewFriendList::NewFriendList(QWidget *parent) : RsAutoUpdatePage(5000,parent), u
|
|||||||
ui->peerTreeWidget->setSortingEnabled(true);
|
ui->peerTreeWidget->setSortingEnabled(true);
|
||||||
|
|
||||||
/* Set sort */
|
/* Set sort */
|
||||||
sortByColumn(RsFriendListModel::COLUMN_THREAD_NAME, Qt::AscendingOrder);
|
sortColumn(RsFriendListModel::COLUMN_THREAD_NAME, Qt::AscendingOrder);
|
||||||
toggleSortByState(false);
|
toggleSortByState(false);
|
||||||
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
// workaround for Qt bug, should be solved in next Qt release 4.7.0
|
||||||
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
// http://bugreports.qt.nokia.com/browse/QTBUG-8270
|
||||||
@ -229,6 +229,11 @@ NewFriendList::NewFriendList(QWidget *parent) : RsAutoUpdatePage(5000,parent), u
|
|||||||
|
|
||||||
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||||
connect(h, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint)));
|
connect(h, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint)));
|
||||||
|
|
||||||
|
// #ifdef RS_DIRECT_CHAT
|
||||||
|
// connect(ui->peerTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(chatNode()));
|
||||||
|
// #endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NewFriendList::~NewFriendList()
|
NewFriendList::~NewFriendList()
|
||||||
@ -238,9 +243,14 @@ NewFriendList::~NewFriendList()
|
|||||||
|
|
||||||
void NewFriendList::sortColumn(int col,Qt::SortOrder so)
|
void NewFriendList::sortColumn(int col,Qt::SortOrder so)
|
||||||
{
|
{
|
||||||
|
std::set<QString> expanded_indexes;
|
||||||
|
std::set<QString> selected_indexes;
|
||||||
|
|
||||||
|
saveExpandedPathsAndSelection(expanded_indexes, selected_indexes);
|
||||||
mProxyModel->setSortingEnabled(true);
|
mProxyModel->setSortingEnabled(true);
|
||||||
mProxyModel->sort(col,so);
|
mProxyModel->sort(col,so);
|
||||||
mProxyModel->setSortingEnabled(false);
|
mProxyModel->setSortingEnabled(false);
|
||||||
|
restoreExpandedPathsAndSelection(expanded_indexes, selected_indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewFriendList::headerContextMenuRequested(QPoint p)
|
void NewFriendList::headerContextMenuRequested(QPoint p)
|
||||||
@ -1538,11 +1548,6 @@ void NewFriendList::toggleColumnVisible()
|
|||||||
ui->peerTreeWidget->setColumnHidden(column, !visible);
|
ui->peerTreeWidget->setColumnHidden(column, !visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewFriendList::sortByColumn(int column, Qt::SortOrder sortOrder)
|
|
||||||
{
|
|
||||||
ui->peerTreeWidget->sortByColumn(column, sortOrder);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NewFriendList::setShowState(bool show)
|
void NewFriendList::setShowState(bool show)
|
||||||
{
|
{
|
||||||
mModel->setDisplayStatusString(show);
|
mModel->setDisplayStatusString(show);
|
||||||
|
@ -64,7 +64,6 @@ public:
|
|||||||
bool isColumnVisible(int col) const;
|
bool isColumnVisible(int col) const;
|
||||||
|
|
||||||
std::string getSelectedGroupId() const;
|
std::string getSelectedGroupId() const;
|
||||||
void sortByColumn(int column, Qt::SortOrder sortOrder);
|
|
||||||
|
|
||||||
void updateDisplay() override;
|
void updateDisplay() override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user