mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
improved debug output and code in NewFriendList sorting
This commit is contained in:
parent
61a79b296e
commit
e750a3fced
@ -119,7 +119,7 @@ public:
|
|||||||
|
|
||||||
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
|
bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
|
||||||
{
|
{
|
||||||
bool is_group_1 = left.data(RsFriendListModel::TypeRole).toUInt() == (uint)RsFriendListModel::ENTRY_TYPE_GROUP;
|
bool is_group_1 = left.data(RsFriendListModel::TypeRole).toUInt() == (uint)RsFriendListModel::ENTRY_TYPE_GROUP;
|
||||||
bool is_group_2 = right.data(RsFriendListModel::TypeRole).toUInt() == (uint)RsFriendListModel::ENTRY_TYPE_GROUP;
|
bool is_group_2 = right.data(RsFriendListModel::TypeRole).toUInt() == (uint)RsFriendListModel::ENTRY_TYPE_GROUP;
|
||||||
|
|
||||||
if(is_group_1 ^ is_group_2) // if the two are different, put the group first.
|
if(is_group_1 ^ is_group_2) // if the two are different, put the group first.
|
||||||
@ -128,10 +128,10 @@ public:
|
|||||||
bool online1 = (left .data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE);
|
bool online1 = (left .data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE);
|
||||||
bool online2 = (right.data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE);
|
bool online2 = (right.data(RsFriendListModel::OnlineRole).toInt() != RS_STATUS_OFFLINE);
|
||||||
|
|
||||||
if(online1 != online2 && m_sortByState)
|
if((online1 != online2) && m_sortByState)
|
||||||
return (m_header->sortIndicatorOrder()==Qt::AscendingOrder)?online1:online2 ; // always put online nodes first
|
return (m_header->sortIndicatorOrder()==Qt::AscendingOrder)?online1:online2 ; // always put online nodes first
|
||||||
|
|
||||||
return left.data(RsFriendListModel::SortRole) < right.data(RsFriendListModel::SortRole) ;
|
return QSortFilterProxyModel::lessThan(left,right);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
|
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
|
||||||
@ -1123,6 +1123,7 @@ void NewFriendList::applyWhileKeepingTree(std::function<void()> predicate)
|
|||||||
std::cerr << "expanded paths are: " << std::endl;
|
std::cerr << "expanded paths are: " << std::endl;
|
||||||
for(auto path:expanded_indexes)
|
for(auto path:expanded_indexes)
|
||||||
std::cerr << " \"" << path.toStdString() << "\"" << std::endl;
|
std::cerr << " \"" << path.toStdString() << "\"" << std::endl;
|
||||||
|
std::cerr << "Current sort column is: " << mLastSortColumn << " and order is " << mLastSortOrder << std::endl;
|
||||||
#endif
|
#endif
|
||||||
whileBlocking(ui->peerTreeWidget)->clearSelection();
|
whileBlocking(ui->peerTreeWidget)->clearSelection();
|
||||||
|
|
||||||
@ -1140,7 +1141,9 @@ void NewFriendList::applyWhileKeepingTree(std::function<void()> predicate)
|
|||||||
col_sizes[i] = ui->peerTreeWidget->columnWidth(i);
|
col_sizes[i] = ui->peerTreeWidget->columnWidth(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG_NEW_FRIEND_LIST
|
||||||
|
std::cerr << "Applying predicate..." << std::endl;
|
||||||
|
#endif
|
||||||
mProxyModel->setSourceModel(nullptr);
|
mProxyModel->setSourceModel(nullptr);
|
||||||
|
|
||||||
predicate();
|
predicate();
|
||||||
@ -1158,6 +1161,9 @@ void NewFriendList::applyWhileKeepingTree(std::function<void()> predicate)
|
|||||||
|
|
||||||
// restore sorting
|
// restore sorting
|
||||||
// sortColumn(mLastSortColumn,mLastSortOrder);
|
// sortColumn(mLastSortColumn,mLastSortOrder);
|
||||||
|
#ifdef DEBUG_NEW_FRIEND_LIST
|
||||||
|
std::cerr << "Sorting again with sort column: " << mLastSortColumn << " and order " << mLastSortOrder << std::endl;
|
||||||
|
#endif
|
||||||
mProxyModel->sort(mLastSortColumn,mLastSortOrder);
|
mProxyModel->sort(mLastSortColumn,mLastSortOrder);
|
||||||
|
|
||||||
if(selected_index.isValid())
|
if(selected_index.isValid())
|
||||||
@ -1166,6 +1172,9 @@ void NewFriendList::applyWhileKeepingTree(std::function<void()> predicate)
|
|||||||
|
|
||||||
void NewFriendList::sortColumn(int col,Qt::SortOrder so)
|
void NewFriendList::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<QString> expanded_indexes;
|
std::set<QString> expanded_indexes;
|
||||||
QString selected;
|
QString selected;
|
||||||
QModelIndex selected_index;
|
QModelIndex selected_index;
|
||||||
|
Loading…
Reference in New Issue
Block a user