mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-04-19 14:55:54 -04:00
fixed sorting
This commit is contained in:
parent
0bda8eeb8d
commit
756ded0b5d
@ -302,7 +302,8 @@ IdDialog::IdDialog(QWidget *parent)
|
||||
connect(ui->inviteButton, SIGNAL(clicked()), this, SLOT(sendInvite()));
|
||||
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();
|
||||
|
||||
@ -2627,21 +2628,20 @@ void IdDialog::applyWhileKeepingTree(std::function<void()> predicate)
|
||||
ui->idTreeWidget->setColumnWidth(i,col_sizes[i]);
|
||||
}
|
||||
|
||||
mProxyModel->setSortingEnabled(true);
|
||||
mProxyModel->sort(mLastSortColumn,mLastSortOrder);
|
||||
mProxyModel->setSortingEnabled(false);
|
||||
#ifdef SUSPENDED
|
||||
// restore sorting
|
||||
// sortColumn(mLastSortColumn,mLastSortOrder);
|
||||
#ifdef DEBUG_NEW_FRIEND_LIST
|
||||
std::cerr << "Sorting again with sort column: " << mLastSortColumn << " and order " << mLastSortOrder << std::endl;
|
||||
#endif
|
||||
// mProxyModel->setSortingEnabled(true);
|
||||
// mProxyModel->sort(mLastSortColumn,mLastSortOrder);
|
||||
// mProxyModel->setSortingEnabled(false);
|
||||
|
||||
// if(selected_index.isValid())
|
||||
// ui->idTreeWidget->scrollTo(selected_index);
|
||||
#endif
|
||||
}
|
||||
#define DEBUG_ID_DIALOG
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
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 updateCirclesDisplay();
|
||||
void toggleAutoBanIdentities(bool b);
|
||||
void sortColumn(int col,Qt::SortOrder so);
|
||||
|
||||
void acceptCircleSubscription() ;
|
||||
void cancelCircleSubscription() ;
|
||||
@ -149,7 +150,10 @@ private:
|
||||
QTreeWidgetItem *mMyCircleItem;
|
||||
RsGxsUpdateBroadcastBase *mCirclesBroadcastBase ;
|
||||
|
||||
void saveExpandedCircleItems(std::vector<bool> &expanded_root_items, std::set<RsGxsCircleId>& expanded_circle_items) const;
|
||||
int mLastSortColumn;
|
||||
Qt::SortOrder mLastSortOrder;
|
||||
|
||||
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 applyWhileKeepingTree(std::function<void()> predicate);
|
||||
|
@ -495,34 +495,13 @@ QVariant RsIdentityListModel::sortRole(const EntryIndex& entry,int column) const
|
||||
{
|
||||
switch(column)
|
||||
{
|
||||
#warning TODO
|
||||
// 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_REPUTATION: return decorationRole(entry,column);
|
||||
|
||||
case COLUMN_THREAD_ID:
|
||||
case COLUMN_THREAD_OWNER:
|
||||
case COLUMN_THREAD_NAME: [[__fallthrough__]];
|
||||
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_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:
|
||||
return QVariant();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user