mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-03 11:54:30 -04:00
fixed sorting
This commit is contained in:
parent
0bda8eeb8d
commit
756ded0b5d
3 changed files with 41 additions and 33 deletions
|
@ -303,6 +303,7 @@ IdDialog::IdDialog(QWidget *parent)
|
||||||
connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editIdentity()));
|
connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editIdentity()));
|
||||||
|
|
||||||
connect(ui->idTreeWidget, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(chatIdentityItem(QModelIndex&)) );
|
connect(ui->idTreeWidget, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(chatIdentityItem(QModelIndex&)) );
|
||||||
|
connect(ui->idTreeWidget->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumn(int,Qt::SortOrder)));
|
||||||
|
|
||||||
ui->editButton->hide();
|
ui->editButton->hide();
|
||||||
|
|
||||||
|
@ -2627,21 +2628,20 @@ void IdDialog::applyWhileKeepingTree(std::function<void()> predicate)
|
||||||
ui->idTreeWidget->setColumnWidth(i,col_sizes[i]);
|
ui->idTreeWidget->setColumnWidth(i,col_sizes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mProxyModel->setSortingEnabled(true);
|
||||||
|
mProxyModel->sort(mLastSortColumn,mLastSortOrder);
|
||||||
|
mProxyModel->setSortingEnabled(false);
|
||||||
#ifdef SUSPENDED
|
#ifdef SUSPENDED
|
||||||
// restore sorting
|
// restore sorting
|
||||||
// sortColumn(mLastSortColumn,mLastSortOrder);
|
// sortColumn(mLastSortColumn,mLastSortOrder);
|
||||||
#ifdef DEBUG_NEW_FRIEND_LIST
|
#ifdef DEBUG_NEW_FRIEND_LIST
|
||||||
std::cerr << "Sorting again with sort column: " << mLastSortColumn << " and order " << mLastSortOrder << std::endl;
|
std::cerr << "Sorting again with sort column: " << mLastSortColumn << " and order " << mLastSortOrder << std::endl;
|
||||||
#endif
|
#endif
|
||||||
// mProxyModel->setSortingEnabled(true);
|
|
||||||
// mProxyModel->sort(mLastSortColumn,mLastSortOrder);
|
|
||||||
// mProxyModel->setSortingEnabled(false);
|
|
||||||
|
|
||||||
// if(selected_index.isValid())
|
// if(selected_index.isValid())
|
||||||
// ui->idTreeWidget->scrollTo(selected_index);
|
// ui->idTreeWidget->scrollTo(selected_index);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#define DEBUG_ID_DIALOG
|
|
||||||
|
|
||||||
void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set<QStringList>& expanded, std::set<QStringList>& selected)
|
void IdDialog::saveExpandedPathsAndSelection_idTreeView(std::set<QStringList>& expanded, std::set<QStringList>& selected)
|
||||||
{
|
{
|
||||||
|
@ -2720,3 +2720,25 @@ void IdDialog::recursRestoreExpandedItems_idTreeView(const QModelIndex& index,co
|
||||||
ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
ui->idTreeWidget->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void IdDialog::sortColumn(int col,Qt::SortOrder so)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_NEW_FRIEND_LIST
|
||||||
|
std::cerr << "Sorting with column=" << col << " and order=" << so << std::endl;
|
||||||
|
#endif
|
||||||
|
std::set<QStringList> expanded_indexes,selected_indexes;
|
||||||
|
|
||||||
|
saveExpandedPathsAndSelection_idTreeView(expanded_indexes, selected_indexes);
|
||||||
|
whileBlocking(ui->idTreeWidget)->clearSelection();
|
||||||
|
|
||||||
|
mProxyModel->setSortingEnabled(true);
|
||||||
|
mProxyModel->sort(col,so);
|
||||||
|
mProxyModel->setSortingEnabled(false);
|
||||||
|
|
||||||
|
restoreExpandedPathsAndSelection_idTreeView(expanded_indexes,selected_indexes);
|
||||||
|
|
||||||
|
//if(selected_index.isValid())
|
||||||
|
// ui->peerTreeWidget->scrollTo(selected_index);
|
||||||
|
|
||||||
|
mLastSortColumn = col;
|
||||||
|
mLastSortOrder = so;
|
||||||
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ private slots:
|
||||||
void showEditExistingCircle();
|
void showEditExistingCircle();
|
||||||
void updateCirclesDisplay();
|
void updateCirclesDisplay();
|
||||||
void toggleAutoBanIdentities(bool b);
|
void toggleAutoBanIdentities(bool b);
|
||||||
|
void sortColumn(int col,Qt::SortOrder so);
|
||||||
|
|
||||||
void acceptCircleSubscription() ;
|
void acceptCircleSubscription() ;
|
||||||
void cancelCircleSubscription() ;
|
void cancelCircleSubscription() ;
|
||||||
|
@ -149,6 +150,9 @@ private:
|
||||||
QTreeWidgetItem *mMyCircleItem;
|
QTreeWidgetItem *mMyCircleItem;
|
||||||
RsGxsUpdateBroadcastBase *mCirclesBroadcastBase ;
|
RsGxsUpdateBroadcastBase *mCirclesBroadcastBase ;
|
||||||
|
|
||||||
|
int mLastSortColumn;
|
||||||
|
Qt::SortOrder mLastSortOrder;
|
||||||
|
|
||||||
void saveExpandedCircleItems(std::vector<bool> &expanded_root_items, std::set<RsGxsCircleId>& expanded_circle_items) const;
|
void saveExpandedCircleItems(std::vector<bool> &expanded_root_items, std::set<RsGxsCircleId>& expanded_circle_items) const;
|
||||||
void restoreExpandedCircleItems(const std::vector<bool>& expanded_root_items,const std::set<RsGxsCircleId>& expanded_circle_items);
|
void restoreExpandedCircleItems(const std::vector<bool>& expanded_root_items,const std::set<RsGxsCircleId>& expanded_circle_items);
|
||||||
|
|
||||||
|
|
|
@ -495,32 +495,11 @@ QVariant RsIdentityListModel::sortRole(const EntryIndex& entry,int column) const
|
||||||
{
|
{
|
||||||
switch(column)
|
switch(column)
|
||||||
{
|
{
|
||||||
#warning TODO
|
case COLUMN_THREAD_REPUTATION: return decorationRole(entry,column);
|
||||||
// case COLUMN_THREAD_LAST_CONTACT:
|
|
||||||
// {
|
|
||||||
// switch(entry.type)
|
|
||||||
// {
|
|
||||||
// case ENTRY_TYPE_PROFILE:
|
|
||||||
// {
|
|
||||||
// const HierarchicalProfileInformation *prof = getProfileInfo(entry);
|
|
||||||
//
|
|
||||||
// if(!prof)
|
|
||||||
// return QVariant();
|
|
||||||
//
|
|
||||||
// uint32_t last_contact = 0;
|
|
||||||
//
|
|
||||||
// for(uint32_t i=0;i<prof->child_node_indices.size();++i)
|
|
||||||
// last_contact = std::max(last_contact, mLocations[prof->child_node_indices[i]].node_info.lastConnect);
|
|
||||||
//
|
|
||||||
// return QVariant(last_contact);
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// return QVariant();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
|
|
||||||
|
case COLUMN_THREAD_ID:
|
||||||
|
case COLUMN_THREAD_OWNER:
|
||||||
|
case COLUMN_THREAD_NAME: [[__fallthrough__]];
|
||||||
default:
|
default:
|
||||||
return displayRole(entry,column);
|
return displayRole(entry,column);
|
||||||
}
|
}
|
||||||
|
@ -653,7 +632,10 @@ QVariant RsIdentityListModel::displayRole(const EntryIndex& e, int col) const
|
||||||
{
|
{
|
||||||
case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(det.mNickname.c_str()));
|
case COLUMN_THREAD_NAME: return QVariant(QString::fromUtf8(det.mNickname.c_str()));
|
||||||
case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(det.mId.toStdString()) );
|
case COLUMN_THREAD_ID: return QVariant(QString::fromStdString(det.mId.toStdString()) );
|
||||||
case COLUMN_THREAD_OWNER: return QVariant(QString::fromStdString(det.mPgpId.toStdString()) );
|
case COLUMN_THREAD_OWNER: if(det.mPgpId.isNull())
|
||||||
|
return QVariant();
|
||||||
|
else
|
||||||
|
return QVariant(QString::fromStdString(det.mPgpId.toStdString()) );
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue